MCPcopy Create free account
hub / github.com/apache/cloudberry / PQclear

Function PQclear

src/interfaces/libpq/fe-exec.c:717–776  ·  view source on GitHub ↗

* PQclear - * free's the memory associated with a PGresult */

Source from the content-addressed store, hash-verified

715 * free's the memory associated with a PGresult
716 */
717void
718PQclear(PGresult *res)
719{
720 PGresult_data *block;
721 int i;
722
723 if (!res)
724 return;
725
726 for (i = 0; i < res->nEvents; i++)
727 {
728 /* only send DESTROY to successfully-initialized event procs */
729 if (res->events[i].resultInitialized)
730 {
731 PGEventResultDestroy evt;
732
733 evt.result = res;
734 (void) res->events[i].proc(PGEVT_RESULTDESTROY, &evt,
735 res->events[i].passThrough);
736 }
737 free(res->events[i].name);
738 }
739
740 if (res->events)
741 free(res->events);
742
743 /* Free all the subsidiary blocks */
744 while ((block = res->curBlock) != NULL)
745 {
746 res->curBlock = block->next;
747 free(block);
748 }
749
750 /* Free the top-level tuple pointer array */
751 if (res->tuples)
752 free(res->tuples);
753
754 /* zero out the pointer fields to catch programming errors */
755 res->attDescs = NULL;
756 res->tuples = NULL;
757 res->paramDescs = NULL;
758 res->errFields = NULL;
759 res->events = NULL;
760 res->nEvents = 0;
761 /* res->curBlock was zeroed out earlier */
762
763 if (res->extras)
764 free(res->extras);
765 res->extraslen = 0;
766 res->extras = NULL;
767 res->extraType = PGExtraTypeNone;
768
769 if (res->waitGxids)
770 free(res->waitGxids);
771 res->waitGxids = NULL;
772 res->nWaits = 0;
773
774 /* Free the PGresult structure itself */

Callers 15

do_sql_commandFunction · 0.85
pgfdw_get_resultFunction · 0.85
pgfdw_report_errorFunction · 0.85
pgfdw_xact_callbackFunction · 0.85
pgfdw_cancel_queryFunction · 0.85
pgfdw_exec_cleanup_queryFunction · 0.85
pgfdw_get_cleanup_resultFunction · 0.85
postgresEndDirectModifyFunction · 0.85
get_remote_estimateFunction · 0.85
create_cursorFunction · 0.85
fetch_more_dataFunction · 0.85

Calls

no outgoing calls

Tested by 15

mainFunction · 0.68
run_permutationFunction · 0.68
try_complete_stepFunction · 0.68
test_multi_pipelinesFunction · 0.68
test_nosyncFunction · 0.68
test_pipeline_abortFunction · 0.68
test_pipelined_insertFunction · 0.68
test_preparedFunction · 0.68
test_simple_pipelineFunction · 0.68
test_singlerowmodeFunction · 0.68
test_transactionFunction · 0.68
process_resultFunction · 0.68