mirror of
https://github.com/postgres/postgres.git
synced 2025-11-10 17:42:29 +03:00
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:
@@ -803,10 +803,6 @@ libpqrcv_processTuples(PGresult *pgres, WalRcvExecResult *walres,
|
|||||||
MemoryContext rowcontext;
|
MemoryContext rowcontext;
|
||||||
MemoryContext oldcontext;
|
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. */
|
/* Make sure we got expected number of fields. */
|
||||||
if (nfields != nRetTypes)
|
if (nfields != nRetTypes)
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
@@ -824,6 +820,10 @@ libpqrcv_processTuples(PGresult *pgres, WalRcvExecResult *walres,
|
|||||||
PQfname(pgres, coln), retTypes[coln], -1, 0);
|
PQfname(pgres, coln), retTypes[coln], -1, 0);
|
||||||
attinmeta = TupleDescGetAttInMetadata(walres->tupledesc);
|
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. */
|
/* Create temporary context for local allocations. */
|
||||||
rowcontext = AllocSetContextCreate(CurrentMemoryContext,
|
rowcontext = AllocSetContextCreate(CurrentMemoryContext,
|
||||||
"libpqrcv query result context",
|
"libpqrcv query result context",
|
||||||
|
|||||||
Reference in New Issue
Block a user