#include "postgres.h"
#include "nodes/params.h"
#include "utils/datum.h"
#include "utils/lsyscache.h"
Go to the source code of this file.
Functions | |
ParamListInfo | copyParamList (ParamListInfo from) |
ParamListInfo copyParamList | ( | ParamListInfo | from | ) |
Definition at line 34 of file params.c.
References datumCopy(), get_typlenbyval(), i, ParamExternData::isnull, NULL, ParamListInfoData::numParams, OidIsValid, palloc(), ParamListInfoData::paramFetch, ParamListInfoData::paramFetchArg, ParamListInfoData::params, ParamListInfoData::parserSetup, ParamListInfoData::parserSetupArg, ParamExternData::ptype, and ParamExternData::value.
Referenced by PerformCursorOpen(), and SPI_cursor_open_internal().
{ ParamListInfo retval; Size size; int i; if (from == NULL || from->numParams <= 0) return NULL; /* sizeof(ParamListInfoData) includes the first array element */ size = sizeof(ParamListInfoData) + (from->numParams - 1) * sizeof(ParamExternData); retval = (ParamListInfo) palloc(size); retval->paramFetch = NULL; retval->paramFetchArg = NULL; retval->parserSetup = NULL; retval->parserSetupArg = NULL; retval->numParams = from->numParams; for (i = 0; i < from->numParams; i++) { ParamExternData *oprm = &from->params[i]; ParamExternData *nprm = &retval->params[i]; int16 typLen; bool typByVal; /* give hook a chance in case parameter is dynamic */ if (!OidIsValid(oprm->ptype) && from->paramFetch != NULL) (*from->paramFetch) (from, i + 1); /* flat-copy the parameter info */ *nprm = *oprm; /* need datumCopy in case it's a pass-by-reference datatype */ if (nprm->isnull || !OidIsValid(nprm->ptype)) continue; get_typlenbyval(nprm->ptype, &typLen, &typByVal); nprm->value = datumCopy(nprm->value, typByVal, typLen); } return retval; }