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

Function PQmakeEmptyPGresult

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

* PQmakeEmptyPGresult * returns a newly allocated, initialized PGresult with given status. * If conn is not NULL and status indicates an error, the conn's * errorMessage is copied. Also, any PGEvents are copied from the conn. */

Source from the content-addressed store, hash-verified

156 * errorMessage is copied. Also, any PGEvents are copied from the conn.
157 */
158PGresult *
159PQmakeEmptyPGresult(PGconn *conn, ExecStatusType status)
160{
161 PGresult *result;
162
163 result = (PGresult *) malloc(sizeof(PGresult));
164 if (!result)
165 return NULL;
166
167 result->ntups = 0;
168 result->numAttributes = 0;
169 result->attDescs = NULL;
170 result->tuples = NULL;
171 result->tupArrSize = 0;
172 result->numParameters = 0;
173 result->paramDescs = NULL;
174 result->resultStatus = status;
175 result->cmdStatus[0] = '\0';
176 result->binary = 0;
177 result->events = NULL;
178 result->nEvents = 0;
179 result->errMsg = NULL;
180 result->errFields = NULL;
181 result->errQuery = NULL;
182 result->null_field[0] = '\0';
183 result->curBlock = NULL;
184 result->curOffset = 0;
185 result->spaceLeft = 0;
186 result->memorySize = sizeof(PGresult);
187
188 result->cdbstats = NULL; /*CDB*/
189
190 result->extras = NULL;
191 result->extraslen = 0;
192 result->extraType = PGExtraTypeNone;
193
194 result->numRejected = 0;
195 result->numCompleted = 0;
196 result->nWaits = 0;
197 result->waitGxids = NULL;
198
199 if (conn)
200 {
201 /* copy connection data we might need for operations on PGresult */
202 result->noticeHooks = conn->noticeHooks;
203 result->client_encoding = conn->client_encoding;
204
205 /* consider copying conn's errorMessage */
206 switch (status)
207 {
208 case PGRES_EMPTY_QUERY:
209 case PGRES_COMMAND_OK:
210 case PGRES_TUPLES_OK:
211 case PGRES_COPY_OUT:
212 case PGRES_COPY_IN:
213 case PGRES_COPY_BOTH:
214 case PGRES_SINGLE_TUPLE:
215 /* non-error cases */

Callers 14

ECPGallocate_descFunction · 0.85
pqParseInput3Function · 0.85
getRowDescriptionsFunction · 0.85
getParamDescriptionsFunction · 0.85
pqGetErrorNotice3Function · 0.85
getCopyStartFunction · 0.85
pqFunctionCall3Function · 0.85
PQcopyResultFunction · 0.85
pqSaveErrorResultFunction · 0.85
pqPrepareAsyncResultFunction · 0.85
pqInternalNoticeFunction · 0.85
PQgetResultFunction · 0.85

Calls 3

pqSetResultErrorFunction · 0.85
dupEventsFunction · 0.85
PQclearFunction · 0.85

Tested by

no test coverage detected