PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
makefuncs.c File Reference
#include "postgres.h"
#include "catalog/pg_class.h"
#include "catalog/pg_type.h"
#include "fmgr.h"
#include "nodes/makefuncs.h"
#include "nodes/nodeFuncs.h"
#include "utils/lsyscache.h"
Include dependency graph for makefuncs.c:

Go to the source code of this file.

Functions

A_ExprmakeA_Expr (A_Expr_Kind kind, List *name, Node *lexpr, Node *rexpr, int location)
 
A_ExprmakeSimpleA_Expr (A_Expr_Kind kind, char *name, Node *lexpr, Node *rexpr, int location)
 
VarmakeVar (Index varno, AttrNumber varattno, Oid vartype, int32 vartypmod, Oid varcollid, Index varlevelsup)
 
VarmakeVarFromTargetEntry (Index varno, TargetEntry *tle)
 
VarmakeWholeRowVar (RangeTblEntry *rte, Index varno, Index varlevelsup, bool allowScalar)
 
TargetEntrymakeTargetEntry (Expr *expr, AttrNumber resno, char *resname, bool resjunk)
 
TargetEntryflatCopyTargetEntry (TargetEntry *src_tle)
 
FromExprmakeFromExpr (List *fromlist, Node *quals)
 
ConstmakeConst (Oid consttype, int32 consttypmod, Oid constcollid, int constlen, Datum constvalue, bool constisnull, bool constbyval)
 
ConstmakeNullConst (Oid consttype, int32 consttypmod, Oid constcollid)
 
NodemakeBoolConst (bool value, bool isnull)
 
ExprmakeBoolExpr (BoolExprType boolop, List *args, int location)
 
AliasmakeAlias (const char *aliasname, List *colnames)
 
RelabelTypemakeRelabelType (Expr *arg, Oid rtype, int32 rtypmod, Oid rcollid, CoercionForm rformat)
 
RangeVarmakeRangeVar (char *schemaname, char *relname, int location)
 
TypeNamemakeTypeName (char *typnam)
 
TypeNamemakeTypeNameFromNameList (List *names)
 
TypeNamemakeTypeNameFromOid (Oid typeOid, int32 typmod)
 
ColumnDefmakeColumnDef (const char *colname, Oid typeOid, int32 typmod, Oid collOid)
 
FuncExprmakeFuncExpr (Oid funcid, Oid rettype, List *args, Oid funccollid, Oid inputcollid, CoercionForm fformat)
 
DefElemmakeDefElem (char *name, Node *arg, int location)
 
DefElemmakeDefElemExtended (char *nameSpace, char *name, Node *arg, DefElemAction defaction, int location)
 
FuncCallmakeFuncCall (List *name, List *args, int location)
 
GroupingSetmakeGroupingSet (GroupingSetKind kind, List *content, int location)
 

Function Documentation

TargetEntry* flatCopyTargetEntry ( TargetEntry src_tle)

Definition at line 268 of file makefuncs.c.

References Assert, IsA, and makeNode.

Referenced by ExecInitAgg(), expand_targetlist(), process_matched_tle(), rewriteTargetListIU(), set_dummy_tlist_references(), and set_upper_references().

269 {
271 
272  Assert(IsA(src_tle, TargetEntry));
273  memcpy(tle, src_tle, sizeof(TargetEntry));
274  return tle;
275 }
#define IsA(nodeptr, _type_)
Definition: nodes.h:560
#define makeNode(_type_)
Definition: nodes.h:557
#define Assert(condition)
Definition: c.h:675
A_Expr* makeA_Expr ( A_Expr_Kind  kind,
List name,
Node lexpr,
Node rexpr,
int  location 
)

Definition at line 31 of file makefuncs.c.

References A_Expr::kind, A_Expr::lexpr, A_Expr::location, makeNode, A_Expr::name, name, and A_Expr::rexpr.

Referenced by transformAExprBetween().

33 {
34  A_Expr *a = makeNode(A_Expr);
35 
36  a->kind = kind;
37  a->name = name;
38  a->lexpr = lexpr;
39  a->rexpr = rexpr;
40  a->location = location;
41  return a;
42 }
A_Expr_Kind kind
Definition: parsenodes.h:274
Node * rexpr
Definition: parsenodes.h:277
int location
Definition: parsenodes.h:278
Node * lexpr
Definition: parsenodes.h:276
#define makeNode(_type_)
Definition: nodes.h:557
List * name
Definition: parsenodes.h:275
const char * name
Definition: encode.c:521
Node* makeBoolConst ( bool  value,
bool  isnull 
)

Definition at line 354 of file makefuncs.c.

References BoolGetDatum, BOOLOID, InvalidOid, and makeConst().

Referenced by create_append_plan(), eval_const_expressions_mutator(), expand_boolean_index_clause(), find_duplicate_ors(), get_qual_for_range(), make_ands_explicit(), make_row_distinct_op(), negate_clause(), process_duplicate_ors(), and transformAExprOf().

355 {
356  /* note that pg_type.h hardwires size of bool as 1 ... duplicate it */
357  return (Node *) makeConst(BOOLOID, -1, InvalidOid, 1,
358  BoolGetDatum(value), isnull, true);
359 }
Definition: nodes.h:509
Const * makeConst(Oid consttype, int32 consttypmod, Oid constcollid, int constlen, Datum constvalue, bool constisnull, bool constbyval)
Definition: makefuncs.c:296
static struct @121 value
#define BoolGetDatum(X)
Definition: postgres.h:408
#define InvalidOid
Definition: postgres_ext.h:36
#define BOOLOID
Definition: pg_type.h:288
Expr* makeBoolExpr ( BoolExprType  boolop,
List args,
int  location 
)
ColumnDef* makeColumnDef ( const char *  colname,
Oid  typeOid,
int32  typmod,
Oid  collOid 
)

Definition at line 487 of file makefuncs.c.

References ColumnDef::collClause, ColumnDef::collOid, ColumnDef::colname, ColumnDef::constraints, ColumnDef::cooked_default, ColumnDef::fdwoptions, ColumnDef::inhcount, ColumnDef::is_from_parent, ColumnDef::is_from_type, ColumnDef::is_local, ColumnDef::is_not_null, ColumnDef::location, makeNode, makeTypeNameFromOid(), NIL, NULL, pstrdup(), ColumnDef::raw_default, ColumnDef::storage, and ColumnDef::typeName.

Referenced by create_ctas_nodata(), DefineVirtualRelation(), and intorel_startup().

488 {
490 
491  n->colname = pstrdup(colname);
492  n->typeName = makeTypeNameFromOid(typeOid, typmod);
493  n->inhcount = 0;
494  n->is_local = true;
495  n->is_not_null = false;
496  n->is_from_type = false;
497  n->is_from_parent = false;
498  n->storage = 0;
499  n->raw_default = NULL;
500  n->cooked_default = NULL;
501  n->collClause = NULL;
502  n->collOid = collOid;
503  n->constraints = NIL;
504  n->fdwoptions = NIL;
505  n->location = -1;
506 
507  return n;
508 }
#define NIL
Definition: pg_list.h:69
char storage
Definition: parsenodes.h:646
bool is_local
Definition: parsenodes.h:642
List * constraints
Definition: parsenodes.h:652
char * pstrdup(const char *in)
Definition: mcxt.c:1077
bool is_from_parent
Definition: parsenodes.h:645
bool is_not_null
Definition: parsenodes.h:643
Node * cooked_default
Definition: parsenodes.h:648
Oid collOid
Definition: parsenodes.h:651
List * fdwoptions
Definition: parsenodes.h:653
int location
Definition: parsenodes.h:654
Node * raw_default
Definition: parsenodes.h:647
TypeName * makeTypeNameFromOid(Oid typeOid, int32 typmod)
Definition: makefuncs.c:469
bool is_from_type
Definition: parsenodes.h:644
#define makeNode(_type_)
Definition: nodes.h:557
#define NULL
Definition: c.h:229
TypeName * typeName
Definition: parsenodes.h:640
CollateClause * collClause
Definition: parsenodes.h:650
int inhcount
Definition: parsenodes.h:641
char * colname
Definition: parsenodes.h:639
Const* makeConst ( Oid  consttype,
int32  consttypmod,
Oid  constcollid,
int  constlen,
Datum  constvalue,
bool  constisnull,
bool  constbyval 
)

Definition at line 296 of file makefuncs.c.

References Const::constbyval, Const::constcollid, Const::constisnull, Const::constlen, Const::consttype, Const::consttypmod, Const::constvalue, Const::location, makeNode, PG_DETOAST_DATUM, and PointerGetDatum.

Referenced by add_security_quals(), add_with_check_options(), build_coercion_expression(), build_minmax_path(), check_sql_fn_retval(), eval_const_expressions_mutator(), evaluate_expr(), expand_targetlist(), generate_setop_tlist(), get_typdefault(), make_const(), makeBoolConst(), makeNullConst(), network_prefix_quals(), rewriteTargetListIU(), rewriteValuesRTE(), scalararraysel(), string_to_bytea_const(), string_to_const(), and transformArraySubscripts().

303 {
304  Const *cnst = makeNode(Const);
305 
306  /*
307  * If it's a varlena value, force it to be in non-expanded (non-toasted)
308  * format; this avoids any possible dependency on external values and
309  * improves consistency of representation, which is important for equal().
310  */
311  if (!constisnull && constlen == -1)
312  constvalue = PointerGetDatum(PG_DETOAST_DATUM(constvalue));
313 
314  cnst->consttype = consttype;
315  cnst->consttypmod = consttypmod;
316  cnst->constcollid = constcollid;
317  cnst->constlen = constlen;
318  cnst->constvalue = constvalue;
319  cnst->constisnull = constisnull;
320  cnst->constbyval = constbyval;
321  cnst->location = -1; /* "unknown" */
322 
323  return cnst;
324 }
Datum constvalue
Definition: primnodes.h:196
bool constbyval
Definition: primnodes.h:199
#define PointerGetDatum(X)
Definition: postgres.h:562
int constlen
Definition: primnodes.h:195
Oid consttype
Definition: primnodes.h:192
Oid constcollid
Definition: primnodes.h:194
int location
Definition: primnodes.h:203
#define makeNode(_type_)
Definition: nodes.h:557
int32 consttypmod
Definition: primnodes.h:193
#define PG_DETOAST_DATUM(datum)
Definition: fmgr.h:205
bool constisnull
Definition: primnodes.h:197
DefElem* makeDefElem ( char *  name,
Node arg,
int  location 
)

Definition at line 544 of file makefuncs.c.

References arg, DefElem::arg, DefElem::defaction, DEFELEM_UNSPEC, DefElem::defname, DefElem::defnamespace, DefElem::location, makeNode, name, and NULL.

Referenced by DefineView(), deserialize_deflist(), fileGetForeignPaths(), generateSerialExtraStmts(), get_file_fdw_attribute_options(), pg_logical_slot_get_changes_guts(), sequence_options(), transformAlterTableStmt(), transformCreateStmt(), and untransformRelOptions().

545 {
546  DefElem *res = makeNode(DefElem);
547 
548  res->defnamespace = NULL;
549  res->defname = name;
550  res->arg = arg;
551  res->defaction = DEFELEM_UNSPEC;
552  res->location = location;
553 
554  return res;
555 }
char * defnamespace
Definition: parsenodes.h:718
DefElemAction defaction
Definition: parsenodes.h:721
int location
Definition: parsenodes.h:722
Node * arg
Definition: parsenodes.h:720
#define makeNode(_type_)
Definition: nodes.h:557
#define NULL
Definition: c.h:229
const char * name
Definition: encode.c:521
void * arg
char * defname
Definition: parsenodes.h:719
DefElem* makeDefElemExtended ( char *  nameSpace,
char *  name,
Node arg,
DefElemAction  defaction,
int  location 
)

Definition at line 562 of file makefuncs.c.

References arg, DefElem::arg, DefElem::defaction, DefElem::defname, DefElem::defnamespace, DefElem::location, makeNode, and name.

564 {
565  DefElem *res = makeNode(DefElem);
566 
567  res->defnamespace = nameSpace;
568  res->defname = name;
569  res->arg = arg;
570  res->defaction = defaction;
571  res->location = location;
572 
573  return res;
574 }
char * defnamespace
Definition: parsenodes.h:718
DefElemAction defaction
Definition: parsenodes.h:721
int location
Definition: parsenodes.h:722
Node * arg
Definition: parsenodes.h:720
#define makeNode(_type_)
Definition: nodes.h:557
const char * name
Definition: encode.c:521
void * arg
char * defname
Definition: parsenodes.h:719
FromExpr* makeFromExpr ( List fromlist,
Node quals 
)

Definition at line 282 of file makefuncs.c.

References FromExpr::fromlist, makeNode, and FromExpr::quals.

Referenced by pull_up_sublinks(), pull_up_sublinks_jointree_recurse(), pull_up_subqueries_cleanup(), transformDeleteStmt(), transformRuleStmt(), transformSelectStmt(), transformSetOperationStmt(), transformUpdateStmt(), and transformValuesClause().

283 {
284  FromExpr *f = makeNode(FromExpr);
285 
286  f->fromlist = fromlist;
287  f->quals = quals;
288  return f;
289 }
List * fromlist
Definition: primnodes.h:1471
Node * quals
Definition: primnodes.h:1472
#define makeNode(_type_)
Definition: nodes.h:557
FuncCall* makeFuncCall ( List name,
List args,
int  location 
)

Definition at line 583 of file makefuncs.c.

References FuncCall::agg_distinct, FuncCall::agg_filter, FuncCall::agg_order, FuncCall::agg_star, FuncCall::agg_within_group, generate_unaccent_rules::args, FuncCall::args, FuncCall::func_variadic, FuncCall::funcname, FuncCall::location, makeNode, name, NIL, NULL, and FuncCall::over.

Referenced by test_rls_hooks_permissive(), test_rls_hooks_restrictive(), transformColumnDefinition(), and transformRangeFunction().

584 {
585  FuncCall *n = makeNode(FuncCall);
586 
587  n->funcname = name;
588  n->args = args;
589  n->agg_order = NIL;
590  n->agg_filter = NULL;
591  n->agg_within_group = false;
592  n->agg_star = false;
593  n->agg_distinct = false;
594  n->func_variadic = false;
595  n->over = NULL;
596  n->location = location;
597  return n;
598 }
#define NIL
Definition: pg_list.h:69
Node * agg_filter
Definition: parsenodes.h:352
int location
Definition: parsenodes.h:358
List * agg_order
Definition: parsenodes.h:351
struct WindowDef * over
Definition: parsenodes.h:357
bool func_variadic
Definition: parsenodes.h:356
#define makeNode(_type_)
Definition: nodes.h:557
#define NULL
Definition: c.h:229
List * args
Definition: parsenodes.h:350
const char * name
Definition: encode.c:521
List * funcname
Definition: parsenodes.h:349
bool agg_within_group
Definition: parsenodes.h:353
bool agg_distinct
Definition: parsenodes.h:355
bool agg_star
Definition: parsenodes.h:354
FuncExpr* makeFuncExpr ( Oid  funcid,
Oid  rettype,
List args,
Oid  funccollid,
Oid  inputcollid,
CoercionForm  fformat 
)

Definition at line 517 of file makefuncs.c.

References generate_unaccent_rules::args, FuncExpr::args, FuncExpr::funccollid, FuncExpr::funcformat, FuncExpr::funcid, FuncExpr::funcresulttype, FuncExpr::funcretset, FuncExpr::funcvariadic, FuncExpr::inputcollid, FuncExpr::location, and makeNode.

Referenced by build_aggregate_combinefn_expr(), build_aggregate_deserialfn_expr(), build_aggregate_finalfn_expr(), build_aggregate_serialfn_expr(), build_aggregate_transfn_expr(), and build_coercion_expression().

519 {
520  FuncExpr *funcexpr;
521 
522  funcexpr = makeNode(FuncExpr);
523  funcexpr->funcid = funcid;
524  funcexpr->funcresulttype = rettype;
525  funcexpr->funcretset = false; /* only allowed case here */
526  funcexpr->funcvariadic = false; /* only allowed case here */
527  funcexpr->funcformat = fformat;
528  funcexpr->funccollid = funccollid;
529  funcexpr->inputcollid = inputcollid;
530  funcexpr->args = args;
531  funcexpr->location = -1;
532 
533  return funcexpr;
534 }
Oid funcresulttype
Definition: primnodes.h:450
List * args
Definition: primnodes.h:457
Oid funccollid
Definition: primnodes.h:455
bool funcretset
Definition: primnodes.h:451
CoercionForm funcformat
Definition: primnodes.h:454
Oid funcid
Definition: primnodes.h:449
#define makeNode(_type_)
Definition: nodes.h:557
Oid inputcollid
Definition: primnodes.h:456
int location
Definition: primnodes.h:458
bool funcvariadic
Definition: primnodes.h:452
GroupingSet* makeGroupingSet ( GroupingSetKind  kind,
List content,
int  location 
)

Definition at line 605 of file makefuncs.c.

References GroupingSet::content, GroupingSet::kind, GroupingSet::location, and makeNode.

Referenced by flatten_grouping_sets(), transformGroupClause(), and transformGroupingSet().

606 {
608 
609  n->kind = kind;
610  n->content = content;
611  n->location = location;
612  return n;
613 }
List * content
Definition: parsenodes.h:1246
GroupingSetKind kind
Definition: parsenodes.h:1245
#define makeNode(_type_)
Definition: nodes.h:557
Const* makeNullConst ( Oid  consttype,
int32  consttypmod,
Oid  constcollid 
)

Definition at line 334 of file makefuncs.c.

References get_typlenbyval(), and makeConst().

Referenced by ATExecAddColumn(), build_subplan(), coerce_record_to_complex(), eval_const_expressions_mutator(), evaluate_function(), ExecInitExprRec(), expandRTE(), expandTupleDesc(), remove_unused_subquery_outputs(), ReplaceVarsFromTargetList_callback(), transformAssignedExpr(), and transformOnConflictClause().

335 {
336  int16 typLen;
337  bool typByVal;
338 
339  get_typlenbyval(consttype, &typLen, &typByVal);
340  return makeConst(consttype,
341  consttypmod,
342  constcollid,
343  (int) typLen,
344  (Datum) 0,
345  true,
346  typByVal);
347 }
signed short int16
Definition: c.h:255
Const * makeConst(Oid consttype, int32 consttypmod, Oid constcollid, int constlen, Datum constvalue, bool constisnull, bool constbyval)
Definition: makefuncs.c:296
uintptr_t Datum
Definition: postgres.h:372
void get_typlenbyval(Oid typid, int16 *typlen, bool *typbyval)
Definition: lsyscache.c:2001
RangeVar* makeRangeVar ( char *  schemaname,
char *  relname,
int  location 
)

Definition at line 419 of file makefuncs.c.

References RangeVar::alias, RangeVar::catalogname, RangeVar::inh, RangeVar::location, makeNode, NULL, RangeVar::relname, RangeVar::relpersistence, RELPERSISTENCE_PERMANENT, and RangeVar::schemaname.

Referenced by AlterTableNamespace(), boot_openrel(), BootstrapToastTable(), ConvertTriggerToFK(), DoCopy(), ExpandColumnRefStar(), fetch_table_list(), generateSerialExtraStmts(), logicalrep_rel_open(), LookupTypeName(), makeRangeVarFromNameList(), plpgsql_parse_cwordrowtype(), plpgsql_parse_cwordtype(), transformAlterTableStmt(), and transformColumnRef().

420 {
421  RangeVar *r = makeNode(RangeVar);
422 
423  r->catalogname = NULL;
424  r->schemaname = schemaname;
425  r->relname = relname;
426  r->inh = true;
428  r->alias = NULL;
429  r->location = location;
430 
431  return r;
432 }
char * schemaname
Definition: primnodes.h:67
#define RELPERSISTENCE_PERMANENT
Definition: pg_class.h:170
int location
Definition: primnodes.h:73
char * relname
Definition: primnodes.h:68
bool inh
Definition: primnodes.h:69
#define makeNode(_type_)
Definition: nodes.h:557
#define NULL
Definition: c.h:229
char relpersistence
Definition: primnodes.h:71
Alias * alias
Definition: primnodes.h:72
char * catalogname
Definition: primnodes.h:66
RelabelType* makeRelabelType ( Expr arg,
Oid  rtype,
int32  rtypmod,
Oid  rcollid,
CoercionForm  rformat 
)

Definition at line 399 of file makefuncs.c.

References arg, RelabelType::arg, RelabelType::location, makeNode, RelabelType::relabelformat, RelabelType::resultcollid, RelabelType::resulttype, and RelabelType::resulttypmod.

Referenced by assign_hypothetical_collations(), buildMergedJoinVar(), canonicalize_ec_expression(), check_sql_fn_retval(), coerce_type(), generate_setop_tlist(), make_partition_op_expr(), and relabel_to_typmod().

401 {
403 
404  r->arg = arg;
405  r->resulttype = rtype;
406  r->resulttypmod = rtypmod;
407  r->resultcollid = rcollid;
408  r->relabelformat = rformat;
409  r->location = -1;
410 
411  return r;
412 }
Expr * arg
Definition: primnodes.h:791
Oid resulttype
Definition: primnodes.h:792
Oid resultcollid
Definition: primnodes.h:794
#define makeNode(_type_)
Definition: nodes.h:557
void * arg
int32 resulttypmod
Definition: primnodes.h:793
CoercionForm relabelformat
Definition: primnodes.h:795
int location
Definition: primnodes.h:796
A_Expr* makeSimpleA_Expr ( A_Expr_Kind  kind,
char *  name,
Node lexpr,
Node rexpr,
int  location 
)

Definition at line 49 of file makefuncs.c.

References A_Expr::kind, A_Expr::lexpr, list_make1, A_Expr::location, makeNode, makeString(), A_Expr::name, and A_Expr::rexpr.

Referenced by test_rls_hooks_permissive(), test_rls_hooks_restrictive(), transformAExprBetween(), transformCaseExpr(), and transformJoinUsingClause().

51 {
52  A_Expr *a = makeNode(A_Expr);
53 
54  a->kind = kind;
55  a->name = list_make1(makeString((char *) name));
56  a->lexpr = lexpr;
57  a->rexpr = rexpr;
58  a->location = location;
59  return a;
60 }
Value * makeString(char *str)
Definition: value.c:53
A_Expr_Kind kind
Definition: parsenodes.h:274
#define list_make1(x1)
Definition: pg_list.h:139
Node * rexpr
Definition: parsenodes.h:277
int location
Definition: parsenodes.h:278
Node * lexpr
Definition: parsenodes.h:276
#define makeNode(_type_)
Definition: nodes.h:557
List * name
Definition: parsenodes.h:275
const char * name
Definition: encode.c:521
TargetEntry* makeTargetEntry ( Expr expr,
AttrNumber  resno,
char *  resname,
bool  resjunk 
)

Definition at line 235 of file makefuncs.c.

References TargetEntry::expr, InvalidOid, makeNode, TargetEntry::resjunk, TargetEntry::resname, TargetEntry::resno, TargetEntry::resorigcol, TargetEntry::resorigtbl, and TargetEntry::ressortgroupref.

Referenced by add_to_flat_tlist(), build_index_tlist(), build_minmax_path(), build_path_tlist(), build_physical_tlist(), check_sql_fn_retval(), convert_combining_aggrefs(), convert_EXISTS_to_ANY(), create_unique_plan(), determineRecursiveColTypes(), ExecInitSubPlan(), expand_targetlist(), expandRelAttrs(), ExpandRowReference(), generate_append_tlist(), generate_setop_tlist(), make_tlist_from_pathtarget(), postgresAddForeignUpdateTargets(), prepare_sort_from_pathkeys(), preprocess_targetlist(), pull_up_simple_values(), rewriteTargetListIU(), rewriteTargetListUD(), transformAggregateCall(), transformMultiAssignRef(), transformOnConflictClause(), transformSetOperationStmt(), transformSetOperationTree(), and transformTargetEntry().

239 {
241 
242  tle->expr = expr;
243  tle->resno = resno;
244  tle->resname = resname;
245 
246  /*
247  * We always set these fields to 0. If the caller wants to change them he
248  * must do so explicitly. Few callers do that, so omitting these
249  * arguments reduces the chance of error.
250  */
251  tle->ressortgroupref = 0;
252  tle->resorigtbl = InvalidOid;
253  tle->resorigcol = 0;
254 
255  tle->resjunk = resjunk;
256 
257  return tle;
258 }
Oid resorigtbl
Definition: primnodes.h:1373
char * resname
Definition: primnodes.h:1370
bool resjunk
Definition: primnodes.h:1375
AttrNumber resno
Definition: primnodes.h:1369
#define InvalidOid
Definition: postgres_ext.h:36
#define makeNode(_type_)
Definition: nodes.h:557
Expr * expr
Definition: primnodes.h:1368
AttrNumber resorigcol
Definition: primnodes.h:1374
Index ressortgroupref
Definition: primnodes.h:1371
TypeName* makeTypeName ( char *  typnam)

Definition at line 441 of file makefuncs.c.

References list_make1, makeString(), and makeTypeNameFromNameList().

Referenced by plpgsql_parse_wordtype().

442 {
444 }
Value * makeString(char *str)
Definition: value.c:53
#define list_make1(x1)
Definition: pg_list.h:139
TypeName * makeTypeNameFromNameList(List *names)
Definition: makefuncs.c:453
TypeName* makeTypeNameFromNameList ( List names)
TypeName* makeTypeNameFromOid ( Oid  typeOid,
int32  typmod 
)

Definition at line 469 of file makefuncs.c.

References TypeName::location, makeNode, TypeName::typemod, and TypeName::typeOid.

Referenced by ATPrepAddOids(), DefineSequence(), generateSerialExtraStmts(), makeColumnDef(), MergeAttributes(), transformAlterTableStmt(), transformOfType(), and transformTableLikeClause().

470 {
471  TypeName *n = makeNode(TypeName);
472 
473  n->typeOid = typeOid;
474  n->typemod = typmod;
475  n->location = -1;
476  return n;
477 }
Oid typeOid
Definition: parsenodes.h:209
#define makeNode(_type_)
Definition: nodes.h:557
int location
Definition: parsenodes.h:215
int32 typemod
Definition: parsenodes.h:213
Var* makeVar ( Index  varno,
AttrNumber  varattno,
Oid  vartype,
int32  vartypmod,
Oid  varcollid,
Index  varlevelsup 
)

Definition at line 67 of file makefuncs.c.

References Var::location, makeNode, Var::varattno, Var::varcollid, Var::varlevelsup, Var::varno, Var::varnoold, Var::varoattno, Var::vartype, and Var::vartypmod.

Referenced by ATExecAttachPartition(), ATPrepAlterColumnType(), build_index_tlist(), build_physical_tlist(), eval_const_expressions_mutator(), expand_targetlist(), expandRTE(), expandTupleDesc(), fix_indexqual_operand(), generate_append_tlist(), generate_setop_tlist(), get_qual_for_list(), get_qual_for_range(), get_range_key_properties(), get_relation_constraints(), make_inh_translation_list(), make_var(), makeVarFromTargetEntry(), makeWholeRowVar(), postgresAddForeignUpdateTargets(), preprocess_targetlist(), rewriteTargetListIU(), rewriteTargetListUD(), set_dummy_tlist_references(), transformOnConflictClause(), and transformSetOperationStmt().

73 {
74  Var *var = makeNode(Var);
75 
76  var->varno = varno;
77  var->varattno = varattno;
78  var->vartype = vartype;
79  var->vartypmod = vartypmod;
80  var->varcollid = varcollid;
81  var->varlevelsup = varlevelsup;
82 
83  /*
84  * Since few if any routines ever create Var nodes with varnoold/varoattno
85  * different from varno/varattno, we don't provide separate arguments for
86  * them, but just initialize them to the given varno/varattno. This
87  * reduces code clutter and chance of error for most callers.
88  */
89  var->varnoold = varno;
90  var->varoattno = varattno;
91 
92  /* Likewise, we just set location to "unknown" here */
93  var->location = -1;
94 
95  return var;
96 }
Index varlevelsup
Definition: primnodes.h:173
AttrNumber varattno
Definition: primnodes.h:168
Definition: primnodes.h:163
Index varnoold
Definition: primnodes.h:176
Oid vartype
Definition: primnodes.h:170
int location
Definition: primnodes.h:178
Index varno
Definition: primnodes.h:166
#define makeNode(_type_)
Definition: nodes.h:557
AttrNumber varoattno
Definition: primnodes.h:177
Oid varcollid
Definition: primnodes.h:172
int32 vartypmod
Definition: primnodes.h:171
Var* makeVarFromTargetEntry ( Index  varno,
TargetEntry tle 
)

Definition at line 104 of file makefuncs.c.

References TargetEntry::expr, exprCollation(), exprType(), exprTypmod(), makeVar(), and TargetEntry::resno.

Referenced by build_physical_tlist(), convert_subquery_pathkeys(), generate_subquery_vars(), make_setop_translation_list(), search_indexed_tlist_for_non_var(), search_indexed_tlist_for_sortgroupref(), and transformInsertStmt().

106 {
107  return makeVar(varno,
108  tle->resno,
109  exprType((Node *) tle->expr),
110  exprTypmod((Node *) tle->expr),
111  exprCollation((Node *) tle->expr),
112  0);
113 }
int32 exprTypmod(const Node *expr)
Definition: nodeFuncs.c:276
Definition: nodes.h:509
AttrNumber resno
Definition: primnodes.h:1369
Var * makeVar(Index varno, AttrNumber varattno, Oid vartype, int32 vartypmod, Oid varcollid, Index varlevelsup)
Definition: makefuncs.c:67
Expr * expr
Definition: primnodes.h:1368
Oid exprType(const Node *expr)
Definition: nodeFuncs.c:42
Oid exprCollation(const Node *expr)
Definition: nodeFuncs.c:720
Var* makeWholeRowVar ( RangeTblEntry rte,
Index  varno,
Index  varlevelsup,
bool  allowScalar 
)

Definition at line 132 of file makefuncs.c.

References elog, ERROR, exprCollation(), exprType(), RangeTblEntry::funcordinality, RangeTblEntry::functions, get_rel_type_id(), InvalidAttrNumber, InvalidOid, linitial, list_length(), makeVar(), OidIsValid, RECORDOID, RangeTblEntry::relid, result, RTE_FUNCTION, RTE_RELATION, RangeTblEntry::rtekind, and type_is_rowtype().

Referenced by preprocess_targetlist(), rewriteTargetListUD(), and transformWholeRowRef().

136 {
137  Var *result;
138  Oid toid;
139  Node *fexpr;
140 
141  switch (rte->rtekind)
142  {
143  case RTE_RELATION:
144  /* relation: the rowtype is a named composite type */
145  toid = get_rel_type_id(rte->relid);
146  if (!OidIsValid(toid))
147  elog(ERROR, "could not find type OID for relation %u",
148  rte->relid);
149  result = makeVar(varno,
151  toid,
152  -1,
153  InvalidOid,
154  varlevelsup);
155  break;
156 
157  case RTE_FUNCTION:
158 
159  /*
160  * If there's more than one function, or ordinality is requested,
161  * force a RECORD result, since there's certainly more than one
162  * column involved and it can't be a known named type.
163  */
164  if (rte->funcordinality || list_length(rte->functions) != 1)
165  {
166  /* always produces an anonymous RECORD result */
167  result = makeVar(varno,
169  RECORDOID,
170  -1,
171  InvalidOid,
172  varlevelsup);
173  break;
174  }
175 
176  fexpr = ((RangeTblFunction *) linitial(rte->functions))->funcexpr;
177  toid = exprType(fexpr);
178  if (type_is_rowtype(toid))
179  {
180  /* func returns composite; same as relation case */
181  result = makeVar(varno,
183  toid,
184  -1,
185  InvalidOid,
186  varlevelsup);
187  }
188  else if (allowScalar)
189  {
190  /* func returns scalar; just return its output as-is */
191  result = makeVar(varno,
192  1,
193  toid,
194  -1,
195  exprCollation(fexpr),
196  varlevelsup);
197  }
198  else
199  {
200  /* func returns scalar, but we want a composite result */
201  result = makeVar(varno,
203  RECORDOID,
204  -1,
205  InvalidOid,
206  varlevelsup);
207  }
208  break;
209 
210  default:
211 
212  /*
213  * RTE is a join, subselect, tablefunc, or VALUES. We represent
214  * this as a whole-row Var of RECORD type. (Note that in most
215  * cases the Var will be expanded to a RowExpr during planning,
216  * but that is not our concern here.)
217  */
218  result = makeVar(varno,
220  RECORDOID,
221  -1,
222  InvalidOid,
223  varlevelsup);
224  break;
225  }
226 
227  return result;
228 }
Definition: nodes.h:509
return result
Definition: formatting.c:1633
bool funcordinality
Definition: parsenodes.h:991
unsigned int Oid
Definition: postgres_ext.h:31
Definition: primnodes.h:163
#define OidIsValid(objectId)
Definition: c.h:538
#define linitial(l)
Definition: pg_list.h:111
#define ERROR
Definition: elog.h:43
#define RECORDOID
Definition: pg_type.h:680
bool type_is_rowtype(Oid typid)
Definition: lsyscache.c:2404
Var * makeVar(Index varno, AttrNumber varattno, Oid vartype, int32 vartypmod, Oid varcollid, Index varlevelsup)
Definition: makefuncs.c:67
Oid get_rel_type_id(Oid relid)
Definition: lsyscache.c:1777
#define InvalidOid
Definition: postgres_ext.h:36
List * functions
Definition: parsenodes.h:990
Oid exprType(const Node *expr)
Definition: nodeFuncs.c:42
static int list_length(const List *l)
Definition: pg_list.h:89
Oid exprCollation(const Node *expr)
Definition: nodeFuncs.c:720
#define InvalidAttrNumber
Definition: attnum.h:23
RTEKind rtekind
Definition: parsenodes.h:936
#define elog
Definition: elog.h:219