Skip to content

Commit 6d3c085

Browse files
committed
Fix up commit 4b3347, where I failed to notice that the initial
problem was really about the OID being interpreted as an integer literal upon input, and overflowing its integer space before even making it into pg_try_advisory_lock(). (We do still need to add -2147483648 to make the result fit into an integer, as 4b3347 does.) Hopefully fixes issue #30, for real this time.
1 parent 4b33474 commit 6d3c085

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

bin/pg_repack.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1359,7 +1359,8 @@ repack_one_table(const repack_table *table, const char *orderby)
13591359
/* Release advisory lock on table. */
13601360
params[0] = REPACK_LOCK_PREFIX_STR;
13611361
params[1] = buffer;
1362-
res = pgut_execute(connection, "SELECT pg_advisory_unlock($1, -2147483648 + $2)",
1362+
1363+
res = pgut_execute(connection, "SELECT pg_advisory_unlock($1, CAST(-2147483648 + $2::bigint AS integer))",
13631364
2, params);
13641365
ret = true;
13651366

@@ -1530,7 +1531,7 @@ static bool advisory_lock(PGconn *conn, const char *relid)
15301531
* *unsigned* 4-byte integer. Add -2147483648 to that OID to make
15311532
* it fit reliably into signed int space.
15321533
*/
1533-
res = pgut_execute(conn, "SELECT pg_try_advisory_lock($1, -2147483648 + $2)",
1534+
res = pgut_execute(conn, "SELECT pg_try_advisory_lock($1, CAST(-2147483648 + $2::bigint AS integer))",
15341535
2, params);
15351536

15361537
if (PQresultStatus(res) != PGRES_TUPLES_OK) {

0 commit comments

Comments
 (0)