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

Function ProcessQuery

src/backend/tcop/pquery.c:171–299  ·  view source on GitHub ↗

* ProcessQuery * Execute a single plannable query within a PORTAL_MULTI_QUERY, * PORTAL_ONE_RETURNING, or PORTAL_ONE_MOD_WITH portal * * portal: the portal * plan: the plan tree for the query * sourceText: the source text of the query * params: any parameters needed * dest: where to send results * qc: where to store the command completion status data. * * qc may be NULL if caller does

Source from the content-addressed store, hash-verified

169 * error; otherwise the executor's memory usage will be leaked.
170 */
171static void
172ProcessQuery(Portal portal,
173 PlannedStmt *stmt,
174 const char *sourceText,
175 ParamListInfo params,
176 QueryEnvironment *queryEnv,
177 DestReceiver *dest,
178 QueryCompletion *qc)
179{
180 QueryDesc *queryDesc;
181 int eflag = 0;
182
183 /* auto-stats related */
184 Oid relationOid = InvalidOid; /* relation that is modified */
185 AutoStatsCmdType cmdType = AUTOSTATS_CMDTYPE_SENTINEL; /* command type */
186
187 /*
188 * Create the QueryDesc object
189 */
190 Assert(portal);
191
192 if (portal->sourceTag == T_SelectStmt && gp_select_invisible)
193 queryDesc = CreateQueryDesc(stmt, portal->sourceText,
194 SnapshotAny, InvalidSnapshot,
195 dest, params, queryEnv,
196 GP_INSTRUMENT_OPTS);
197 else
198 queryDesc = CreateQueryDesc(stmt, portal->sourceText,
199 GetActiveSnapshot(), InvalidSnapshot,
200 dest, params, queryEnv,
201 GP_INSTRUMENT_OPTS);
202 queryDesc->ddesc = portal->ddesc;
203
204 /* GPDB hook for collecting query info */
205 if (query_info_collect_hook)
206 (*query_info_collect_hook)(METRICS_QUERY_SUBMIT, queryDesc);
207
208 check_and_unassign_from_resgroup(queryDesc->plannedstmt);
209 queryDesc->plannedstmt->query_mem = ResourceManagerGetQueryMemoryLimit(queryDesc->plannedstmt);
210
211 if (Gp_role == GP_ROLE_DISPATCH || IS_SINGLENODE())
212 {
213 /*
214 * If resource scheduling is enabled and we are locking non SELECT
215 * queries, or this is a SELECT INTO then lock the portal here. Skip
216 * if this query is added by the rewriter or we are superuser.
217 */
218 if (IsResQueueEnabled() && !superuser() && !IsResQueueLockedForPortal(portal))
219 {
220 if ((!ResourceSelectOnly || portal->sourceTag == T_SelectStmt) &&
221 stmt->canSetTag)
222 {
223 ResLockPortal(portal, queryDesc);
224 }
225 else
226 {
227 /* we will not track this query, so reset the query_mem*/
228 queryDesc->plannedstmt->query_mem = 0;

Callers 1

PortalRunMultiFunction · 0.85

Calls 15

CreateQueryDescFunction · 0.85
GetActiveSnapshotFunction · 0.85
superuserFunction · 0.85
ResLockPortalFunction · 0.85
GetIntoRelEFlagsFunction · 0.85
ExecutorStartFunction · 0.85
ExecutorRunFunction · 0.85
autostats_get_cmdtypeFunction · 0.85
ExecutorFinishFunction · 0.85

Tested by

no test coverage detected