aboutsummaryrefslogtreecommitdiff
path: root/src/backend/nodes/makefuncs.c
blob: a461524e7adf5972d444a89eb4d8b3c21e9feb13 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*
 * makefuncs.c--
 *    creator functions for primitive nodes. The functions here are for
 *    the most frequently created nodes.
 *
 * Copyright (c) 1994, Regents of the University of California
 *
 *
 * IDENTIFICATION
 *    $Header: /cvsroot/pgsql/src/backend/nodes/makefuncs.c,v 1.1.1.1 1996/07/09 06:21:32 scrappy Exp $
 *
 * NOTES
 *    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.
 *
 * HISTORY
 *    AUTHOR		DATE		MAJOR EVENT
 *    Andrew Yu		Oct 20, 1994	file creation
 */
#include "postgres.h"
#include "nodes/pg_list.h"
#include "nodes/primnodes.h"
#include "nodes/makefuncs.h"

/*
 * makeOper -
 *    creates an Oper node
 */
Oper *
makeOper(Oid opno,
	 Oid opid,
	 Oid opresulttype,
	 int opsize,
	 FunctionCachePtr op_fcache)
{
    Oper *oper = makeNode(Oper);

    oper->opno = opno;
    oper->opid = opid;
    oper->opresulttype = opresulttype;
    oper->opsize = opsize;
    oper->op_fcache = op_fcache;
    return oper;
}

/*
 * makeVar -
 *    creates a Var node
 *
 */
Var *
makeVar(Index varno, 
	AttrNumber varattno,
	Oid vartype,
	Index varnoold,
	AttrNumber varoattno)
{
    Var *var = makeNode(Var);

    var->varno =  varno;
    var->varattno = varattno;
    var->vartype = vartype;
    var->varnoold =  varnoold;
    var->varoattno = varoattno;

    return var;
}

/*
 * makeResdom -
 *    creates a Resdom (Result Domain) node
 */
Resdom *
makeResdom(AttrNumber resno,
	   Oid restype,
	   int reslen,
	   char *resname,
	   Index reskey,
	   Oid reskeyop,
	   int resjunk)
{
    Resdom *resdom = makeNode(Resdom);

    resdom->resno = resno; 
    resdom->restype = restype;
    resdom->reslen = reslen;
    resdom->resname = resname;
    resdom->reskey = reskey;
    resdom->reskeyop = reskeyop;
    resdom->resjunk = resjunk;
    return resdom;
}

/*
 * makeConst -
 *    creates a Const node
 */
Const *
makeConst(Oid consttype,
	  Size constlen,
	  Datum constvalue,
	  bool constisnull,
	  bool constbyval,
	  bool constisset)
{
    Const *cnst = makeNode(Const);

    cnst->consttype = consttype;
    cnst->constlen = constlen;
    cnst->constvalue = constvalue;
    cnst->constisnull = constisnull;
    cnst->constbyval = constbyval;
    cnst->constisset = constisset;
    return cnst;
}