Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions src/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -2236,18 +2236,16 @@ def _table_checksum__use_cn(
assert cursor is not None

try:
cursor.execute("SELECT t::text FROM {} as t".format(
cursor.execute("SELECT SUM(hashtext(t::text)) FROM {} as t".format(
__class__._delim_sql_ident(table)
))

while True:
row = cursor.fetchone()
if row is None:
break
assert type(row) in [list, tuple] # noqa: E721
assert len(row) == 1
sum += hash(row[0])
continue
row = cursor.fetchone()
assert row is not None
assert type(row) in [list, tuple] # noqa: E721
assert len(row) == 1
v = row[0]
sum += int(v if v is not None else 0)
finally:
cursor.close()

Expand Down
8 changes: 4 additions & 4 deletions tests/test_testgres_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2102,7 +2102,7 @@ def test_node__table_checksum(

with cn.connection.cursor() as cursor:
assert cursor is not None
cursor.execute("SELECT t::text FROM \"t\" as t;")
cursor.execute("SELECT hashtext(t::text) FROM \"t\" as t;")

checksum1 = 0
record_count = 0
Expand All @@ -2113,7 +2113,7 @@ def test_node__table_checksum(
assert type(row) in [list, tuple] # noqa: E721
assert len(row) == 1
record_count += 1
checksum1 += hash(row[0])
checksum1 += int(row[0])
pass

assert record_count == table_checksum_test_data.record_count
Expand Down Expand Up @@ -2162,7 +2162,7 @@ def test_node__pgbench_table_checksums__one_table(

with cn.connection.cursor() as cursor:
assert cursor is not None
cursor.execute("SELECT t::text FROM \"t\" as t;")
cursor.execute("SELECT hashtext(t::text) FROM \"t\" as t;")

checksum1 = 0
record_count = 0
Expand All @@ -2173,7 +2173,7 @@ def test_node__pgbench_table_checksums__one_table(
assert type(row) in [list, tuple] # noqa: E721
assert len(row) == 1
record_count += 1
checksum1 += hash(row[0])
checksum1 += int(row[0])
pass

assert record_count == table_checksum_test_data.record_count
Expand Down