makefuncs.c 2.42 KB
Newer Older
1 2
/*
 * makefuncs.c--
3 4
 *	  creator functions for primitive nodes. The functions here are for
 *	  the most frequently created nodes.
5 6 7 8 9
 *
 * Copyright (c) 1994, Regents of the University of California
 *
 *
 * IDENTIFICATION
10
 *	  $Header: /cvsroot/pgsql/src/backend/nodes/makefuncs.c,v 1.8 1998/02/21 16:58:22 momjian Exp $
11 12
 *
 * NOTES
13 14 15
 *	  Creator functions in POSTGRES 4.2 are generated automatically. Most of
 *	  them are rarely used. Now we don't generate them any more. If you want
 *	  one, you have to write it yourself.
16 17
 *
 * HISTORY
18 19
 *	  AUTHOR			DATE			MAJOR EVENT
 *	  Andrew Yu			Oct 20, 1994	file creation
20 21 22 23 24 25 26 27
 */
#include "postgres.h"
#include "nodes/pg_list.h"
#include "nodes/primnodes.h"
#include "nodes/makefuncs.h"

/*
 * makeOper -
28
 *	  creates an Oper node
29
 */
30
Oper	   *
31
makeOper(Oid opno,
32 33 34 35
		 Oid opid,
		 Oid opresulttype,
		 int opsize,
		 FunctionCachePtr op_fcache)
36
{
37
	Oper	   *oper = makeNode(Oper);
38

39 40 41 42 43 44
	oper->opno = opno;
	oper->opid = opid;
	oper->opresulttype = opresulttype;
	oper->opsize = opsize;
	oper->op_fcache = op_fcache;
	return oper;
45 46 47 48
}

/*
 * makeVar -
49
 *	  creates a Var node
50 51
 *
 */
52
Var		   *
53 54 55
makeVar(Index varno,
		AttrNumber varattno,
		Oid vartype,
Bruce Momjian's avatar
Bruce Momjian committed
56
		int16 vartypmod,
57
		Index varlevelsup,
58 59
		Index varnoold,
		AttrNumber varoattno)
60
{
61
	Var		   *var = makeNode(Var);
62

63 64 65
	var->varno = varno;
	var->varattno = varattno;
	var->vartype = vartype;
66
	var->vartypmod = vartypmod;
67
	var->varlevelsup = varlevelsup;
68 69
	var->varnoold = varnoold;
	var->varoattno = varoattno;
70

71
	return var;
72 73 74 75
}

/*
 * makeResdom -
76
 *	  creates a Resdom (Result Domain) node
77
 */
78
Resdom	   *
79
makeResdom(AttrNumber resno,
80
		   Oid restype,
Bruce Momjian's avatar
Bruce Momjian committed
81
		   int16 restypmod,
82 83 84 85
		   char *resname,
		   Index reskey,
		   Oid reskeyop,
		   int resjunk)
86
{
87
	Resdom	   *resdom = makeNode(Resdom);
88

89 90
	resdom->resno = resno;
	resdom->restype = restype;
91
	resdom->restypmod = restypmod;
92 93 94 95 96
	resdom->resname = resname;
	resdom->reskey = reskey;
	resdom->reskeyop = reskeyop;
	resdom->resjunk = resjunk;
	return resdom;
97 98 99 100
}

/*
 * makeConst -
101
 *	  creates a Const node
102
 */
103
Const	   *
104
makeConst(Oid consttype,
105
		  int constlen,
106 107 108 109 110
		  Datum constvalue,
		  bool constisnull,
		  bool constbyval,
		  bool constisset,
		  bool constiscast)
111
{
112
	Const	   *cnst = makeNode(Const);
113

114 115 116 117 118 119 120 121
	cnst->consttype = consttype;
	cnst->constlen = constlen;
	cnst->constvalue = constvalue;
	cnst->constisnull = constisnull;
	cnst->constbyval = constbyval;
	cnst->constisset = constisset;
	cnst->constiscast = constiscast;
	return cnst;
122
}