diff --git a/src/node.py b/src/node.py index a1ed137c..57cf20c3 100644 --- a/src/node.py +++ b/src/node.py @@ -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() diff --git a/tests/test_testgres_common.py b/tests/test_testgres_common.py index 8c338db0..e8d1f322 100644 --- a/tests/test_testgres_common.py +++ b/tests/test_testgres_common.py @@ -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 @@ -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 @@ -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 @@ -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