Skip to content

Commit 1d6033b

Browse files
committed
Import libpq-batch patch.
1 parent 3a788db commit 1d6033b

File tree

10 files changed

+1186
-44
lines changed

10 files changed

+1186
-44
lines changed

doc/src/sgml/libpq.sgml

Lines changed: 502 additions & 0 deletions
Large diffs are not rendered by default.

doc/src/sgml/lobj.sgml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@
130130
<application>libpq</application> library.
131131
</para>
132132

133+
<para>
134+
Client applications cannot use these functions while libpq connection is in batch mode.
135+
</para>
136+
133137
<sect2 id="lo-create">
134138
<title>Creating a Large Object</title>
135139

src/backend/replication/libpqwalreceiver/libpqwalreceiver.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,6 +1022,9 @@ libpqrcv_exec(WalReceiverConn *conn, const char *query,
10221022
walres->status = WALRCV_ERROR;
10231023
walres->err = pchomp(PQerrorMessage(conn->streamConn));
10241024
break;
1025+
default:
1026+
/* This is just to keep compiler quiet */
1027+
break;
10251028
}
10261029

10271030
PQclear(pgres);

src/interfaces/libpq/exports.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,3 +179,8 @@ PQgetgssctx 176
179179
PQsetSSLKeyPassHook_OpenSSL 177
180180
PQgetSSLKeyPassHook_OpenSSL 178
181181
PQdefaultSSLKeyPassHook_OpenSSL 179
182+
PQenterBatchMode 180
183+
PQexitBatchMode 181
184+
PQbatchSendQueue 182
185+
PQbatchProcessQueue 183
186+
PQbatchStatus 184

src/interfaces/libpq/fe-connect.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,24 @@ pqDropConnection(PGconn *conn, bool flushInput)
535535
}
536536
}
537537

538+
/*
539+
* PQfreeCommandQueue
540+
* Free all the entries of PGcommandQueueEntry queue passed.
541+
*/
542+
static void
543+
PQfreeCommandQueue(PGcommandQueueEntry *queue)
544+
{
545+
546+
while (queue != NULL)
547+
{
548+
PGcommandQueueEntry *prev = queue;
549+
550+
queue = queue->next;
551+
if (prev->query)
552+
free(prev->query);
553+
free(prev);
554+
}
555+
}
538556

539557
/*
540558
* pqDropServerData
@@ -554,6 +572,7 @@ pqDropServerData(PGconn *conn)
554572
{
555573
PGnotify *notify;
556574
pgParameterStatus *pstatus;
575+
PGcommandQueueEntry *queue;
557576

558577
/* Forget pending notifies */
559578
notify = conn->notifyHead;
@@ -566,6 +585,14 @@ pqDropServerData(PGconn *conn)
566585
}
567586
conn->notifyHead = conn->notifyTail = NULL;
568587

588+
queue = conn->cmd_queue_head;
589+
PQfreeCommandQueue(queue);
590+
conn->cmd_queue_head = conn->cmd_queue_tail = NULL;
591+
592+
queue = conn->cmd_queue_recycle;
593+
PQfreeCommandQueue(queue);
594+
conn->cmd_queue_recycle = NULL;
595+
569596
/* Reset ParameterStatus data, as well as variables deduced from it */
570597
pstatus = conn->pstatus;
571598
while (pstatus != NULL)

0 commit comments

Comments
 (0)