Avoid useless memory allocation in gp_create_restore_point()
Function `gp_create_restore_point()` allocates memory for
`context->cdb_pgresults.pg_results` before passing it to the
`CdbDispatchCommand()`. This is unnecessary, as `CdbDispatchCommand()`
would eventually call into `cdbdisp_returnResults()` to allocate
memory for `pg_results`. So the memory allocated by
`gp_create_restore_point()` is unused and wasted.
@@ -70,8 +70,8 @@ gp_create_restore_point(PG_FUNCTION_ARGS)
funcctx->tuple_desc = BlessTupleDesc(tupdesc);
context = (Context *) palloc(sizeof(Context));
- context->cdb_pgresults.pg_results =
- (struct pg_result **) palloc(getgpsegmentCount() * sizeof(struct pg_result *));
+ context->cdb_pgresults.pg_results = NULL;
+ context->cdb_pgresults.numResults = 0;
context->index = 0;
funcctx->user_fctx = (void *) context;
