Skip to content

Commit 8398c83

Browse files
committed
Handle empty result set in libpqrcv_exec
Always return tupleslot and tupledesc from libpqrcv_exec. This avoids requiring callers to handle that separately. Author: Petr Jelinek <petr.jelinek@2ndquadrant.com> Reported-by: Michael Banck <michael.banck@credativ.de>
1 parent 7ac955b commit 8398c83

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/backend/replication/libpqwalreceiver/libpqwalreceiver.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -803,10 +803,6 @@ libpqrcv_processTuples(PGresult *pgres, WalRcvExecResult *walres,
803803
MemoryContext rowcontext;
804804
MemoryContext oldcontext;
805805

806-
/* No point in doing anything here if there were no tuples returned. */
807-
if (PQntuples(pgres) == 0)
808-
return;
809-
810806
/* Make sure we got expected number of fields. */
811807
if (nfields != nRetTypes)
812808
ereport(ERROR,
@@ -824,6 +820,10 @@ libpqrcv_processTuples(PGresult *pgres, WalRcvExecResult *walres,
824820
PQfname(pgres, coln), retTypes[coln], -1, 0);
825821
attinmeta = TupleDescGetAttInMetadata(walres->tupledesc);
826822

823+
/* No point in doing more here if there were no tuples returned. */
824+
if (PQntuples(pgres) == 0)
825+
return;
826+
827827
/* Create temporary context for local allocations. */
828828
rowcontext = AllocSetContextCreate(CurrentMemoryContext,
829829
"libpqrcv query result context",

0 commit comments

Comments
 (0)