1
/*-------------------------------------------------------------------------
4
* Support functions for plan parameter lists.
6
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
7
* Portions Copyright (c) 1994, Regents of the University of California
10
* $PostgreSQL: pgsql/src/backend/nodes/params.c,v 1.4 2004-12-31 21:59:55 pgsql Exp $
12
*-------------------------------------------------------------------------
17
#include "nodes/params.h"
18
#include "utils/datum.h"
19
#include "utils/lsyscache.h"
25
* The result is allocated in CurrentMemoryContext.
28
copyParamList(ParamListInfo from)
38
while (from[size].kind != PARAM_INVALID)
41
retval = (ParamListInfo) palloc0((size + 1) * sizeof(ParamListInfoData));
43
for (i = 0; i < size; i++)
46
retval[i].kind = from[i].kind;
47
if (from[i].kind == PARAM_NAMED)
48
retval[i].name = pstrdup(from[i].name);
49
retval[i].id = from[i].id;
50
retval[i].ptype = from[i].ptype;
53
retval[i].isnull = from[i].isnull;
56
retval[i].value = from[i].value; /* nulls just copy */
63
get_typlenbyval(from[i].ptype, &typLen, &typByVal);
64
retval[i].value = datumCopy(from[i].value, typByVal, typLen);
68
retval[size].kind = PARAM_INVALID;
74
* Search a ParamList for a given parameter.
76
* On success, returns a pointer to the parameter's entry.
77
* On failure, returns NULL if noError is true, else ereports the error.
80
lookupParam(ParamListInfo paramList, int thisParamKind,
81
const char *thisParamName, AttrNumber thisParamId,
84
if (paramList != NULL)
86
while (paramList->kind != PARAM_INVALID)
88
if (thisParamKind == paramList->kind)
90
switch (thisParamKind)
93
if (strcmp(paramList->name, thisParamName) == 0)
97
if (paramList->id == thisParamId)
101
elog(ERROR, "unrecognized paramkind: %d",
111
if (thisParamKind == PARAM_NAMED)
113
(errcode(ERRCODE_UNDEFINED_OBJECT),
114
errmsg("no value found for parameter \"%s\"",
118
(errcode(ERRCODE_UNDEFINED_OBJECT),
119
errmsg("no value found for parameter %d",