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

Function fetch_cursor_param_value

src/backend/executor/execCurrent.c:532–569  ·  view source on GitHub ↗

* fetch_cursor_param_value * * Fetch the string value of a param, verifying it is of type REFCURSOR. */

Source from the content-addressed store, hash-verified

530 * Fetch the string value of a param, verifying it is of type REFCURSOR.
531 */
532static char *
533fetch_cursor_param_value(ExprContext *econtext, int paramId)
534{
535 ParamListInfo paramInfo = econtext->ecxt_param_list_info;
536
537 if (paramInfo &&
538 paramId > 0 && paramId <= paramInfo->numParams)
539 {
540 ParamExternData *prm;
541 ParamExternData prmdata;
542
543 /* give hook a chance in case parameter is dynamic */
544 if (paramInfo->paramFetch != NULL)
545 prm = paramInfo->paramFetch(paramInfo, paramId, false, &prmdata);
546 else
547 prm = &paramInfo->params[paramId - 1];
548
549 if (OidIsValid(prm->ptype) && !prm->isnull)
550 {
551 /* safety check in case hook did something unexpected */
552 if (prm->ptype != REFCURSOROID)
553 ereport(ERROR,
554 (errcode(ERRCODE_DATATYPE_MISMATCH),
555 errmsg("type of parameter %d (%s) does not match that when preparing the plan (%s)",
556 paramId,
557 format_type_be(prm->ptype),
558 format_type_be(REFCURSOROID))));
559
560 /* We know that refcursor uses text's I/O routines */
561 return TextDatumGetCString(prm->value);
562 }
563 }
564
565 ereport(ERROR,
566 (errcode(ERRCODE_UNDEFINED_OBJECT),
567 errmsg("no value found for parameter %d", paramId)));
568 return NULL;
569}
570
571/*
572 * search_plan_tree

Callers 2

execCurrentOfFunction · 0.85
getCurrentOfFunction · 0.85

Calls 3

format_type_beFunction · 0.85
errcodeFunction · 0.50
errmsgFunction · 0.50

Tested by

no test coverage detected