Skip to content

Commit

Permalink
Switch to using pgut_command() and pgut_execute() for conn2.
Browse files Browse the repository at this point in the history
  • Loading branch information
schmiddy committed Oct 28, 2012
1 parent b1cb82f commit 48d911b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions bin/pg_reorg.c
Original file line number Diff line number Diff line change
Expand Up @@ -434,13 +434,13 @@ reorg_one_table(const reorg_table *table, const char *orderby)
command(sql.data, 0, NULL);
command("COMMIT", 0, NULL);

PQclear(PQexec(conn2, "BEGIN ISOLATION LEVEL READ COMMITTED"));
pgut_command(conn2, "BEGIN ISOLATION LEVEL READ COMMITTED", 0, NULL);
elog(DEBUG2, "Obtaining ACCESS SHARE lock for %s", table->target_name);

/* XXX: table name escaping? */
printfStringInfo(&sql, "LOCK TABLE %s IN ACCESS SHARE MODE",
table->target_name);
res = PQexec(conn2, sql.data);
res = pgut_execute(conn2, sql.data, 0, NULL);
if (PQresultStatus(res) != PGRES_COMMAND_OK)
{
printf("%s", PQerrorMessage(conn2));
Expand All @@ -454,7 +454,7 @@ reorg_one_table(const reorg_table *table, const char *orderby)
/* store the backend PID of our connection keeping an ACCESS SHARE
lock on the target table.
*/
res = PQexec(conn2, "SELECT pg_backend_pid()");
res = pgut_execute(conn2, "SELECT pg_backend_pid()", 0, NULL);
if (PQresultStatus(res) != PGRES_TUPLES_OK)
{
printf("%s", PQerrorMessage(conn2));
Expand Down Expand Up @@ -676,7 +676,7 @@ lock_exclusive(const char *relid, const char *lock_query, bool release_conn2)
* lock.
*/
if (release_conn2)
PQclear(PQexec(conn2, "COMMIT"));
pgut_command(conn2, "COMMIT", 0, NULL);

/* wait for a while to lock the table. */
wait_msec = Min(1000, i * 100);
Expand Down Expand Up @@ -728,7 +728,7 @@ reorg_cleanup(bool fatal, void *userdata)

/* Rollback current transaction */
if (conn2)
PQclear(PQexec(conn2, "ROLLBACK"));
pgut_command(conn2, "ROLLBACK", 0, NULL);

if (connection)
command("ROLLBACK", 0, NULL);
Expand Down

0 comments on commit 48d911b

Please sign in to comment.