readfuncs.c

来自「关系型数据库 Postgresql 6.5.2」· C语言 代码 · 共 2,191 行 · 第 1/4 页

C
2,191
字号
	return local_node;}/* ---------------- *		_readNoname * *	Noname is a subclass of Plan * ---------------- */static Noname *_readNoname(){	Noname	   *local_node;	char	   *token;	int			length;	local_node = makeNode(Noname);	_getPlan((Plan *) local_node);	token = lsptok(NULL, &length);		/* eat :nonameid */	token = lsptok(NULL, &length);		/* get nonameid */	local_node->nonameid = atol(token);	token = lsptok(NULL, &length);		/* eat :keycount */	token = lsptok(NULL, &length);		/* get keycount */	local_node->keycount = atoi(token);	return local_node;}/* ---------------- *		_readSort * *	Sort is a subclass of Noname * ---------------- */static Sort *_readSort(){	Sort	   *local_node;	char	   *token;	int			length;	local_node = makeNode(Sort);	_getPlan((Plan *) local_node);	token = lsptok(NULL, &length);		/* eat :nonameid */	token = lsptok(NULL, &length);		/* get nonameid */	local_node->nonameid = atol(token);	token = lsptok(NULL, &length);		/* eat :keycount */	token = lsptok(NULL, &length);		/* get keycount */	local_node->keycount = atoi(token);	return local_node;}static Agg *_readAgg(){	Agg		   *local_node;	char	   *token;	int			length;	local_node = makeNode(Agg);	_getPlan((Plan *) local_node);	token = lsptok(NULL, &length);		/* eat :agg */	local_node->aggs = nodeRead(true);	/* now read it */	return local_node;}/* ---------------- *		_readUnique * * For some reason, unique is a subclass of Noname. */static Unique *_readUnique(){	Unique	   *local_node;	char	   *token;	int			length;	local_node = makeNode(Unique);	_getPlan((Plan *) local_node);	token = lsptok(NULL, &length);		/* eat :nonameid */	token = lsptok(NULL, &length);		/* get :nonameid */	local_node->nonameid = atol(token);	token = lsptok(NULL, &length);		/* eat :keycount */	token = lsptok(NULL, &length);		/* get :keycount */	local_node->keycount = atoi(token);	return local_node;}/* ---------------- *		_readHash * *	Hash is a subclass of Noname * ---------------- */static Hash *_readHash(){	Hash	   *local_node;	char	   *token;	int			length;	local_node = makeNode(Hash);	_getPlan((Plan *) local_node);	token = lsptok(NULL, &length);		/* eat :hashkey */	local_node->hashkey = (Var *) nodeRead(true);	return local_node;}/* *	Stuff from primnodes.h. *//* ---------------- *		_readResdom * *	Resdom is a subclass of Node * ---------------- */static Resdom *_readResdom(){	Resdom	   *local_node;	char	   *token;	int			length;	local_node = makeNode(Resdom);	token = lsptok(NULL, &length);		/* eat :resno */	token = lsptok(NULL, &length);		/* get resno */	local_node->resno = atoi(token);	token = lsptok(NULL, &length);		/* eat :restype */	token = lsptok(NULL, &length);		/* get restype */	local_node->restype = atol(token);	token = lsptok(NULL, &length);		/* eat :restypmod */	token = lsptok(NULL, &length);		/* get restypmod */	local_node->restypmod = atoi(token);	token = lsptok(NULL, &length);		/* eat :resname */	token = lsptok(NULL, &length);		/* get the name */	if (length == 0)		local_node->resname = NULL;	else	{		local_node->resname = (char *) palloc(length + 1);		StrNCpy(local_node->resname, token + 1, length + 1 - 2);		/* strip quotes */	}	token = lsptok(NULL, &length);		/* eat :reskey */	token = lsptok(NULL, &length);		/* get reskey */	local_node->reskey = strtoul(token, NULL, 10);	token = lsptok(NULL, &length);		/* eat :reskeyop */	token = lsptok(NULL, &length);		/* get reskeyop */	local_node->reskeyop = (Oid) atol(token);	token = lsptok(NULL, &length);		/* eat :resgroupref */	token = lsptok(NULL, &length);		/* get resgroupref */	local_node->resgroupref = strtoul(token, NULL, 10);	token = lsptok(NULL, &length);		/* eat :resjunk */	token = lsptok(NULL, &length);		/* get resjunk */	local_node->resjunk = (token[0] == 't') ? true : false;	return local_node;}/* ---------------- *		_readExpr * *	Expr is a subclass of Node * ---------------- */static Expr *_readExpr(){	Expr	   *local_node;	char	   *token;	int			length;	local_node = makeNode(Expr);	token = lsptok(NULL, &length);		/* eat :typeOid */	token = lsptok(NULL, &length);		/* get typeOid */	local_node->typeOid = (Oid) atol(token);	token = lsptok(NULL, &length);		/* eat :opType */	token = lsptok(NULL, &length);		/* get opType */	if (!strncmp(token, "op", 2))		local_node->opType = OP_EXPR;	else if (!strncmp(token, "func", 4))		local_node->opType = FUNC_EXPR;	else if (!strncmp(token, "or", 2))		local_node->opType = OR_EXPR;	else if (!strncmp(token, "and", 3))		local_node->opType = AND_EXPR;	else if (!strncmp(token, "not", 3))		local_node->opType = NOT_EXPR;	else if (!strncmp(token, "subp", 4))		local_node->opType = SUBPLAN_EXPR;	token = lsptok(NULL, &length);		/* eat :oper */	local_node->oper = nodeRead(true);	token = lsptok(NULL, &length);		/* eat :args */	local_node->args = nodeRead(true);	/* now read it */	return local_node;}/* ---------------- *		_readCaseExpr * *	CaseExpr is a subclass of Node * ---------------- */static CaseExpr *_readCaseExpr(){	CaseExpr   *local_node;	char	   *token;	int			length;	local_node = makeNode(CaseExpr);	local_node->args = nodeRead(true);	token = lsptok(NULL, &length);		/* eat :default */	local_node->defresult = nodeRead(true);	return local_node;}/* ---------------- *		_readCaseWhen * *	CaseWhen is a subclass of Node * ---------------- */static CaseWhen *_readCaseWhen(){	CaseWhen   *local_node;	char	   *token;	int			length;	local_node = makeNode(CaseWhen);	local_node->expr = nodeRead(true);	token = lsptok(NULL, &length);		/* eat :then */	local_node->result = nodeRead(true);	return local_node;}/* ---------------- *		_readVar * *	Var is a subclass of Expr * ---------------- */static Var *_readVar(){	Var		   *local_node;	char	   *token;	int			length;	local_node = makeNode(Var);	token = lsptok(NULL, &length);		/* eat :varno */	token = lsptok(NULL, &length);		/* get varno */	local_node->varno = strtoul(token, NULL, 10);	token = lsptok(NULL, &length);		/* eat :varattno */	token = lsptok(NULL, &length);		/* get varattno */	local_node->varattno = atoi(token);	token = lsptok(NULL, &length);		/* eat :vartype */	token = lsptok(NULL, &length);		/* get vartype */	local_node->vartype = (Oid) atol(token);	token = lsptok(NULL, &length);		/* eat :vartypmod */	token = lsptok(NULL, &length);		/* get vartypmod */	local_node->vartypmod = atoi(token);	token = lsptok(NULL, &length);		/* eat :varlevelsup */	token = lsptok(NULL, &length);		/* get varlevelsup */	local_node->varlevelsup = (Oid) atol(token);	token = lsptok(NULL, &length);		/* eat :varnoold */	token = lsptok(NULL, &length);		/* get varnoold */	local_node->varnoold = (Oid) atol(token);	token = lsptok(NULL, &length);		/* eat :varoattno */	token = lsptok(NULL, &length);		/* eat :varoattno */	local_node->varoattno = (int) atol(token);	return local_node;}/* ---------------- * _readArray * * Array is a subclass of Expr * ---------------- */static Array *_readArray(){	Array	   *local_node;	char	   *token;	int			length;	local_node = makeNode(Array);	token = lsptok(NULL, &length);		/* eat :arrayelemtype */	token = lsptok(NULL, &length);		/* get arrayelemtype */	local_node->arrayelemtype = strtoul(token, NULL, 10);	token = lsptok(NULL, &length);		/* eat :arrayelemlength */	token = lsptok(NULL, &length);		/* get arrayelemlength */	local_node->arrayelemlength = atoi(token);	token = lsptok(NULL, &length);		/* eat :arrayelembyval */	token = lsptok(NULL, &length);		/* get arrayelembyval */	local_node->arrayelembyval = (token[0] == 't') ? true : false;	token = lsptok(NULL, &length);		/* eat :arraylow */	token = lsptok(NULL, &length);		/* get arraylow */	local_node->arraylow.indx[0] = atoi(token);	token = lsptok(NULL, &length);		/* eat :arrayhigh */	token = lsptok(NULL, &length);		/* get arrayhigh */	local_node->arrayhigh.indx[0] = atoi(token);	token = lsptok(NULL, &length);		/* eat :arraylen */	token = lsptok(NULL, &length);		/* get arraylen */	local_node->arraylen = atoi(token);	return local_node;}/* ---------------- * _readArrayRef * * ArrayRef is a subclass of Expr * ---------------- */static ArrayRef *_readArrayRef(){	ArrayRef   *local_node;	char	   *token;	int			length;	local_node = makeNode(ArrayRef);	token = lsptok(NULL, &length);		/* eat :refelemtype */	token = lsptok(NULL, &length);		/* get refelemtype */	local_node->refelemtype = strtoul(token, NULL, 10);	token = lsptok(NULL, &length);		/* eat :refattrlength */	token = lsptok(NULL, &length);		/* get refattrlength */	local_node->refattrlength = atoi(token);	token = lsptok(NULL, &length);		/* eat :refelemlength */	token = lsptok(NULL, &length);		/* get refelemlength */	local_node->refelemlength = atoi(token);	token = lsptok(NULL, &length);		/* eat :refelembyval */	token = lsptok(NULL, &length);		/* get refelembyval */	local_node->refelembyval = (token[0] == 't') ? true : false;	token = lsptok(NULL, &length);		/* eat :refupperindex */	local_node->refupperindexpr = nodeRead(true);	token = lsptok(NULL, &length);		/* eat :reflowerindex */	local_node->reflowerindexpr = nodeRead(true);	token = lsptok(NULL, &length);		/* eat :refexpr */	local_node->refexpr = nodeRead(true);	token = lsptok(NULL, &length);		/* eat :refassgnexpr */	local_node->refassgnexpr = nodeRead(true);	return local_node;}/* ---------------- *		_readConst * *	Const is a subclass of Expr * ---------------- */static Const *_readConst(){	Const	   *local_node;	char	   *token;	int			length;	local_node = makeNode(Const);	token = lsptok(NULL, &length);		/* get :consttype */	token = lsptok(NULL, &length);		/* now read it */	local_node->consttype = atol(token);	token = lsptok(NULL, &length);		/* get :constlen */	token = lsptok(NULL, &length);		/* now read it */	local_node->constlen = strtol(token, NULL, 10);	token = lsptok(NULL, &length);		/* get :constisnull */	token = lsptok(NULL, &length);		/* now read it */	if (!strncmp(token, "true", 4))		local_node->constisnull = true;	else		local_node->constisnull = false;	token = lsptok(NULL, &length);		/* get :constvalue */	if (local_node->constisnull)	{		token = lsptok(NULL, &length);	/* skip "NIL" */	}	else	{		/*		 * read the value		 */		local_node->constvalue = readDatum(local_node->consttype);	}	token = lsptok(NULL, &length);		/* get :constbyval */	token = lsptok(NULL, &length);		/* now read it */	if (!strncmp(token, "true", 4))		local_node->constbyval = true;	else		local_node->constbyval = false;	return local_node;}/* ---------------- *		_readFunc * *	Func is a subclass of Expr * ---------------- */static Func *_readFunc(){	Func	   *local_node;	char	   *token;	int			length;	local_node = makeNode(Func);	token = lsptok(NULL, &length);		/* get :funcid */	token = lsptok(NULL, &length);		/* now read it */	local_node->funcid = atol(token);	token = lsptok(NULL, &length);		/* get :functype */	token = lsptok(NULL, &length);		/* now read it */	local_node->functype = atol(token);	token = lsptok(NULL, &length);		/* get :funcisindex */	token = lsptok(NULL, &length);		/* now read it */	if (!strncmp(token, "true", 4))		local_node->funcisindex = true;	else		local_node->funcisindex = false;	token = lsptok(NULL, &length);		/* get :funcsize */	token = lsptok(NULL, &length);		/* now read it */	local_node->funcsize = atol(token);	token = lsptok(NULL, &length);		/* get :func_fcache */	token = lsptok(NULL, &length);		/* get @ */	token = lsptok(NULL, &length);		/* now read it */	local_node->func_fcache = (FunctionCache *) NULL;	token = lsptok(NULL, &length);		/* get :func_tlist */	local_node->func_tlist = nodeRead(true);	/* now read it */	token = lsptok(NULL, &length);		/* get :func_planlist */	local_node->func_planlist = nodeRead(true); /* now read it */	return local_node;}/* ---------------- *		_readOper * *	Oper is a subclass of Expr * ---------------- */static Oper *_readOper(){	Oper	   *local_node;	char	   *token;	int			length;	local_node = makeNode(Oper);	token = lsptok(NULL, &length);		/* get :opno */	token = lsptok(NULL, &length);		/* now read it */	local_node->opno = atol(token);	token = lsptok(NULL, &length);		/* get :opid */	token = lsptok(NULL, &length);		/* now read it */	local_node->opid = atol(token);	token = lsptok(NULL, &length);		/* get :opresulttype */	token = lsptok(NULL, &length);		/* now read it */	local_node->opresulttype = atol(token);	/*	 * NOTE: Alternatively we can call 'replace_opid' which initializes	 * both 'opid' and 'op_fcache'.	 */	local_node->op_fcache = (FunctionCache *) NULL;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?