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>
This commit is contained in:
Peter Eisentraut 2017-03-24 08:41:32 -04:00
parent 7ac955b347
commit 8398c83689
1 changed files with 4 additions and 4 deletions

View File

@ -803,10 +803,6 @@ libpqrcv_processTuples(PGresult *pgres, WalRcvExecResult *walres,
MemoryContext rowcontext;
MemoryContext oldcontext;
/* No point in doing anything here if there were no tuples returned. */
if (PQntuples(pgres) == 0)
return;
/* Make sure we got expected number of fields. */
if (nfields != nRetTypes)
ereport(ERROR,
@ -824,6 +820,10 @@ libpqrcv_processTuples(PGresult *pgres, WalRcvExecResult *walres,
PQfname(pgres, coln), retTypes[coln], -1, 0);
attinmeta = TupleDescGetAttInMetadata(walres->tupledesc);
/* No point in doing more here if there were no tuples returned. */
if (PQntuples(pgres) == 0)
return;
/* Create temporary context for local allocations. */
rowcontext = AllocSetContextCreate(CurrentMemoryContext,
"libpqrcv query result context",