PostgreSQL Source Code  git master
makefuncs.h File Reference
#include "nodes/execnodes.h"
#include "nodes/parsenodes.h"
Include dependency graph for makefuncs.h:
This graph shows which files directly or indirectly include this file:

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 (int varno, AttrNumber varattno, Oid vartype, int32 vartypmod, Oid varcollid, Index varlevelsup)
 
VarmakeVarFromTargetEntry (int varno, TargetEntry *tle)
 
VarmakeWholeRowVar (RangeTblEntry *rte, int 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)
 
FuncCallmakeFuncCall (List *name, List *args, CoercionForm funcformat, int location)
 
Exprmake_opclause (Oid opno, Oid opresulttype, bool opretset, Expr *leftop, Expr *rightop, Oid opcollid, Oid inputcollid)
 
Exprmake_andclause (List *andclauses)
 
Exprmake_orclause (List *orclauses)
 
Exprmake_notclause (Expr *notclause)
 
Nodemake_and_qual (Node *qual1, Node *qual2)
 
Exprmake_ands_explicit (List *andclauses)
 
Listmake_ands_implicit (Expr *clause)
 
IndexInfomakeIndexInfo (int numattrs, int numkeyattrs, Oid amoid, List *expressions, List *predicates, bool unique, bool nulls_not_distinct, bool isready, bool concurrent)
 
DefElemmakeDefElem (char *name, Node *arg, int location)
 
DefElemmakeDefElemExtended (char *nameSpace, char *name, Node *arg, DefElemAction defaction, int location)
 
GroupingSetmakeGroupingSet (GroupingSetKind kind, List *content, int location)
 
VacuumRelationmakeVacuumRelation (RangeVar *relation, Oid oid, List *va_cols)
 
JsonFormatmakeJsonFormat (JsonFormatType type, JsonEncoding encoding, int location)
 
JsonValueExprmakeJsonValueExpr (Expr *expr, JsonFormat *format)
 
JsonBehaviormakeJsonBehavior (JsonBehaviorType type, Node *expr)
 
NodemakeJsonTableJoinedPlan (JsonTablePlanJoinType type, Node *plan1, Node *plan2, int location)
 
NodemakeJsonKeyValue (Node *key, Node *value)
 
NodemakeJsonIsPredicate (Node *expr, JsonFormat *format, JsonValueType item_type, bool unique_keys, int location)
 
JsonEncoding makeJsonEncoding (char *name)
 

Function Documentation

◆ flatCopyTargetEntry()

TargetEntry* flatCopyTargetEntry ( TargetEntry src_tle)

Definition at line 272 of file makefuncs.c.

273 {
275 
276  Assert(IsA(src_tle, TargetEntry));
277  memcpy(tle, src_tle, sizeof(TargetEntry));
278  return tle;
279 }
Assert(fmt[strlen(fmt) - 1] !='\n')
#define IsA(nodeptr, _type_)
Definition: nodes.h:624
#define makeNode(_type_)
Definition: nodes.h:621

References Assert(), IsA, and makeNode.

Referenced by expand_insert_targetlist(), process_matched_tle(), rewriteTargetListIU(), set_dummy_tlist_references(), and set_upper_references().

◆ make_and_qual()

Node* make_and_qual ( Node qual1,
Node qual2 
)

Definition at line 690 of file makefuncs.c.

691 {
692  if (qual1 == NULL)
693  return qual2;
694  if (qual2 == NULL)
695  return qual1;
696  return (Node *) make_andclause(list_make2(qual1, qual2));
697 }
Expr * make_andclause(List *andclauses)
Definition: makefuncs.c:637
#define list_make2(x1, x2)
Definition: pg_list.h:208
Definition: nodes.h:574

References list_make2, and make_andclause().

Referenced by AddQual(), and subquery_push_qual().

◆ make_andclause()

Expr* make_andclause ( List andclauses)

Definition at line 637 of file makefuncs.c.

638 {
639  BoolExpr *expr = makeNode(BoolExpr);
640 
641  expr->boolop = AND_EXPR;
642  expr->args = andclauses;
643  expr->location = -1;
644  return (Expr *) expr;
645 }
@ AND_EXPR
Definition: primnodes.h:628
int location
Definition: primnodes.h:636
BoolExprType boolop
Definition: primnodes.h:634
List * args
Definition: primnodes.h:635

References AND_EXPR, BoolExpr::args, BoolExpr::boolop, BoolExpr::location, and makeNode.

Referenced by eval_const_expressions_mutator(), ExplainNode(), find_duplicate_ors(), make_and_qual(), make_ands_explicit(), make_sub_restrictinfos(), negate_clause(), process_duplicate_ors(), process_sublinks_mutator(), and pull_up_sublinks_qual_recurse().

◆ make_ands_explicit()

Expr* make_ands_explicit ( List andclauses)

Definition at line 709 of file makefuncs.c.

710 {
711  if (andclauses == NIL)
712  return (Expr *) makeBoolConst(true, false);
713  else if (list_length(andclauses) == 1)
714  return (Expr *) linitial(andclauses);
715  else
716  return make_andclause(andclauses);
717 }
Node * makeBoolConst(bool value, bool isnull)
Definition: makefuncs.c:358
static int list_length(const List *l)
Definition: pg_list.h:149
#define NIL
Definition: pg_list.h:65
#define linitial(l)
Definition: pg_list.h:174

References linitial, list_length(), make_andclause(), makeBoolConst(), and NIL.

Referenced by ATExecAttachPartition(), check_default_partition_contents(), convert_EXISTS_to_ANY(), create_bitmap_subplan(), DetachAddConstraintIfNeeded(), ExecInitCheck(), extract_or_clause(), get_proposed_default_constraint(), get_qual_for_list(), show_qual(), and UpdateIndexRelation().

◆ make_ands_implicit()

List* make_ands_implicit ( Expr clause)

Definition at line 720 of file makefuncs.c.

721 {
722  /*
723  * NB: because the parser sets the qual field to NULL in a query that has
724  * no WHERE clause, we must consider a NULL input clause as TRUE, even
725  * though one might more reasonably think it FALSE.
726  */
727  if (clause == NULL)
728  return NIL; /* NULL -> NIL list == TRUE */
729  else if (is_andclause(clause))
730  return ((BoolExpr *) clause)->args;
731  else if (IsA(clause, Const) &&
732  !((Const *) clause)->constisnull &&
733  DatumGetBool(((Const *) clause)->constvalue))
734  return NIL; /* constant TRUE input -> NIL list */
735  else
736  return list_make1(clause);
737 }
static bool is_andclause(const void *clause)
Definition: nodeFuncs.h:95
#define list_make1(x1)
Definition: pg_list.h:206
#define DatumGetBool(X)
Definition: postgres.h:437

References DatumGetBool, is_andclause(), IsA, list_make1, and NIL.

Referenced by apply_child_basequals(), ConstraintImpliedByRelConstraint(), convert_EXISTS_to_ANY(), cost_subplan(), DefineIndex(), DoCopy(), get_proposed_default_constraint(), get_relation_constraints(), index_concurrently_create_copy(), preprocess_expression(), RelationGetIndexPredicate(), test_predtest(), and TriggerEnabled().

◆ make_notclause()

Expr* make_notclause ( Expr notclause)

Definition at line 669 of file makefuncs.c.

670 {
671  BoolExpr *expr = makeNode(BoolExpr);
672 
673  expr->boolop = NOT_EXPR;
674  expr->args = list_make1(notclause);
675  expr->location = -1;
676  return (Expr *) expr;
677 }
@ NOT_EXPR
Definition: primnodes.h:628

References BoolExpr::args, BoolExpr::boolop, list_make1, BoolExpr::location, makeNode, and NOT_EXPR.

Referenced by negate_clause().

◆ make_opclause()

Expr* make_opclause ( Oid  opno,
Oid  opresulttype,
bool  opretset,
Expr leftop,
Expr rightop,
Oid  opcollid,
Oid  inputcollid 
)

Definition at line 611 of file makefuncs.c.

614 {
615  OpExpr *expr = makeNode(OpExpr);
616 
617  expr->opno = opno;
618  expr->opfuncid = InvalidOid;
619  expr->opresulttype = opresulttype;
620  expr->opretset = opretset;
621  expr->opcollid = opcollid;
622  expr->inputcollid = inputcollid;
623  if (rightop)
624  expr->args = list_make2(leftop, rightop);
625  else
626  expr->args = list_make1(leftop);
627  expr->location = -1;
628  return (Expr *) expr;
629 }
#define InvalidOid
Definition: postgres_ext.h:36
bool opretset
Definition: primnodes.h:554
int location
Definition: primnodes.h:558
Oid opno
Definition: primnodes.h:551
Oid opcollid
Definition: primnodes.h:555
List * args
Definition: primnodes.h:557
Oid opfuncid
Definition: primnodes.h:552
Oid inputcollid
Definition: primnodes.h:556
Oid opresulttype
Definition: primnodes.h:553

References OpExpr::args, OpExpr::inputcollid, InvalidOid, list_make1, list_make2, OpExpr::location, makeNode, OpExpr::opcollid, OpExpr::opfuncid, OpExpr::opno, OpExpr::opresulttype, and OpExpr::opretset.

Referenced by build_implied_join_equality(), convert_EXISTS_to_ANY(), expand_indexqual_rowcompare(), find_window_run_conditions(), make_partition_op_expr(), match_boolean_index_clause(), match_clause_to_partition_key(), match_network_subset(), match_pattern_prefix(), operator_predicate_proof(), process_implied_equality(), and rewriteSearchAndCycle().

◆ make_orclause()

Expr* make_orclause ( List orclauses)

◆ makeA_Expr()

A_Expr* makeA_Expr ( A_Expr_Kind  kind,
List name,
Node lexpr,
Node rexpr,
int  location 
)

Definition at line 31 of file makefuncs.c.

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 }
const char * name
Definition: encode.c:561
int a
Definition: isn.c:69

References a, makeNode, and name.

◆ makeAlias()

◆ makeBoolConst()

Node* makeBoolConst ( bool  value,
bool  isnull 
)

Definition at line 358 of file makefuncs.c.

359 {
360  /* note that pg_type.h hardwires size of bool as 1 ... duplicate it */
361  return (Node *) makeConst(BOOLOID, -1, InvalidOid, 1,
362  BoolGetDatum(value), isnull, true);
363 }
static struct @151 value
Const * makeConst(Oid consttype, int32 consttypmod, Oid constcollid, int constlen, Datum constvalue, bool constisnull, bool constbyval)
Definition: makefuncs.c:300
#define BoolGetDatum(X)
Definition: postgres.h:446

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

Referenced by create_append_plan(), eval_const_expressions_mutator(), find_duplicate_ors(), get_qual_for_range(), make_ands_explicit(), make_row_distinct_op(), match_boolean_index_clause(), match_boolean_partition_clause(), negate_clause(), and process_duplicate_ors().

◆ makeBoolExpr()

◆ makeColumnDef()

ColumnDef* makeColumnDef ( const char *  colname,
Oid  typeOid,
int32  typmod,
Oid  collOid 
)

Definition at line 491 of file makefuncs.c.

492 {
494 
495  n->colname = pstrdup(colname);
496  n->typeName = makeTypeNameFromOid(typeOid, typmod);
497  n->inhcount = 0;
498  n->is_local = true;
499  n->is_not_null = false;
500  n->is_from_type = false;
501  n->storage = 0;
502  n->raw_default = NULL;
503  n->cooked_default = NULL;
504  n->collClause = NULL;
505  n->collOid = collOid;
506  n->constraints = NIL;
507  n->fdwoptions = NIL;
508  n->location = -1;
509 
510  return n;
511 }
TypeName * makeTypeNameFromOid(Oid typeOid, int32 typmod)
Definition: makefuncs.c:473
bool is_not_null
Definition: parsenodes.h:682
CollateClause * collClause
Definition: parsenodes.h:691
int location
Definition: parsenodes.h:695
List * constraints
Definition: parsenodes.h:693
Node * cooked_default
Definition: parsenodes.h:686
int inhcount
Definition: parsenodes.h:680
char * colname
Definition: parsenodes.h:677
TypeName * typeName
Definition: parsenodes.h:678
bool is_from_type
Definition: parsenodes.h:683
List * fdwoptions
Definition: parsenodes.h:694
Node * raw_default
Definition: parsenodes.h:685
char storage
Definition: parsenodes.h:684
Oid collOid
Definition: parsenodes.h:692
bool is_local
Definition: parsenodes.h:681

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

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

◆ makeConst()

Const* makeConst ( Oid  consttype,
int32  consttypmod,
Oid  constcollid,
int  constlen,
Datum  constvalue,
bool  constisnull,
bool  constbyval 
)

Definition at line 300 of file makefuncs.c.

307 {
308  Const *cnst = makeNode(Const);
309 
310  /*
311  * If it's a varlena value, force it to be in non-expanded (non-toasted)
312  * format; this avoids any possible dependency on external values and
313  * improves consistency of representation, which is important for equal().
314  */
315  if (!constisnull && constlen == -1)
316  constvalue = PointerGetDatum(PG_DETOAST_DATUM(constvalue));
317 
318  cnst->consttype = consttype;
319  cnst->consttypmod = consttypmod;
320  cnst->constcollid = constcollid;
321  cnst->constlen = constlen;
322  cnst->constvalue = constvalue;
323  cnst->constisnull = constisnull;
324  cnst->constbyval = constbyval;
325  cnst->location = -1; /* "unknown" */
326 
327  return cnst;
328 }
#define PG_DETOAST_DATUM(datum)
Definition: fmgr.h:240
#define PointerGetDatum(X)
Definition: postgres.h:600
Oid constcollid
Definition: primnodes.h:226
Oid consttype
Definition: primnodes.h:224
int constlen
Definition: primnodes.h:227
Datum constvalue
Definition: primnodes.h:228
bool constisnull
Definition: primnodes.h:229
bool constbyval
Definition: primnodes.h:231
int32 consttypmod
Definition: primnodes.h:225
int location
Definition: primnodes.h:235

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(), array_subscript_transform(), build_coercion_expression(), build_minmax_path(), check_sql_fn_retval(), eval_const_expressions_mutator(), evaluate_expr(), expand_insert_targetlist(), generate_setop_tlist(), get_qual_for_hash(), get_qual_for_list(), get_typdefault(), getJsonEncodingConst(), make_const(), makeBoolConst(), makeNullConst(), makeParentJsonTableNode(), match_clause_to_partition_key(), match_network_subset(), pattern_fixed_prefix(), RelationGetDummyIndexExpressions(), rewriteSearchAndCycle(), rewriteTargetListIU(), rewriteValuesRTE(), scalararraysel(), set_fn_opclass_options(), string_to_bytea_const(), and string_to_const().

◆ makeDefElem()

DefElem* makeDefElem ( char *  name,
Node arg,
int  location 
)

Definition at line 547 of file makefuncs.c.

548 {
550 
551  res->defnamespace = NULL;
552  res->defname = name;
553  res->arg = arg;
554  res->defaction = DEFELEM_UNSPEC;
555  res->location = location;
556 
557  return res;
558 }
@ DEFELEM_UNSPEC
Definition: parsenodes.h:755
void * arg

References arg, DEFELEM_UNSPEC, makeNode, name, and res.

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

◆ makeDefElemExtended()

DefElem* makeDefElemExtended ( char *  nameSpace,
char *  name,
Node arg,
DefElemAction  defaction,
int  location 
)

Definition at line 565 of file makefuncs.c.

567 {
569 
570  res->defnamespace = nameSpace;
571  res->defname = name;
572  res->arg = arg;
573  res->defaction = defaction;
574  res->location = location;
575 
576  return res;
577 }

References arg, makeNode, name, and res.

◆ makeFromExpr()

◆ makeFuncCall()

FuncCall* makeFuncCall ( List name,
List args,
CoercionForm  funcformat,
int  location 
)

Definition at line 586 of file makefuncs.c.

587 {
588  FuncCall *n = makeNode(FuncCall);
589 
590  n->funcname = name;
591  n->args = args;
592  n->agg_order = NIL;
593  n->agg_filter = NULL;
594  n->over = NULL;
595  n->agg_within_group = false;
596  n->agg_star = false;
597  n->agg_distinct = false;
598  n->func_variadic = false;
599  n->funcformat = funcformat;
600  n->location = location;
601  return n;
602 }
bool agg_within_group
Definition: parsenodes.h:385
int location
Definition: parsenodes.h:390
CoercionForm funcformat
Definition: parsenodes.h:389
Node * agg_filter
Definition: parsenodes.h:383
List * agg_order
Definition: parsenodes.h:382
List * funcname
Definition: parsenodes.h:380
List * args
Definition: parsenodes.h:381
bool agg_star
Definition: parsenodes.h:386
bool agg_distinct
Definition: parsenodes.h:387
bool func_variadic
Definition: parsenodes.h:388
struct WindowDef * over
Definition: parsenodes.h:384

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::funcformat, FuncCall::funcname, FuncCall::location, makeNode, name, NIL, and FuncCall::over.

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

◆ makeFuncExpr()

FuncExpr* makeFuncExpr ( Oid  funcid,
Oid  rettype,
List args,
Oid  funccollid,
Oid  inputcollid,
CoercionForm  fformat 
)

Definition at line 520 of file makefuncs.c.

522 {
523  FuncExpr *funcexpr;
524 
525  funcexpr = makeNode(FuncExpr);
526  funcexpr->funcid = funcid;
527  funcexpr->funcresulttype = rettype;
528  funcexpr->funcretset = false; /* only allowed case here */
529  funcexpr->funcvariadic = false; /* only allowed case here */
530  funcexpr->funcformat = fformat;
531  funcexpr->funccollid = funccollid;
532  funcexpr->inputcollid = inputcollid;
533  funcexpr->args = args;
534  funcexpr->location = -1;
535 
536  return funcexpr;
537 }
Oid funccollid
Definition: primnodes.h:510
bool funcretset
Definition: primnodes.h:506
Oid funcid
Definition: primnodes.h:504
bool funcvariadic
Definition: primnodes.h:507
List * args
Definition: primnodes.h:512
CoercionForm funcformat
Definition: primnodes.h:509
Oid inputcollid
Definition: primnodes.h:511
int location
Definition: primnodes.h:513
Oid funcresulttype
Definition: primnodes.h:505

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_deserialfn_expr(), build_aggregate_finalfn_expr(), build_aggregate_serialfn_expr(), build_aggregate_transfn_expr(), build_coercion_expression(), coerceJsonFuncExpr(), get_qual_for_hash(), make_path_cat_expr(), makeJsonByteaToTextConversion(), rewriteSearchAndCycle(), and transformJsonValueExprExt().

◆ makeGroupingSet()

GroupingSet* makeGroupingSet ( GroupingSetKind  kind,
List content,
int  location 
)

Definition at line 798 of file makefuncs.c.

799 {
801 
802  n->kind = kind;
803  n->content = content;
804  n->location = location;
805  return n;
806 }
GroupingSetKind kind
Definition: parsenodes.h:1374
List * content
Definition: parsenodes.h:1375

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

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

◆ makeIndexInfo()

IndexInfo* makeIndexInfo ( int  numattrs,
int  numkeyattrs,
Oid  amoid,
List expressions,
List predicates,
bool  unique,
bool  nulls_not_distinct,
bool  isready,
bool  concurrent 
)

Definition at line 744 of file makefuncs.c.

746 {
748 
749  n->ii_NumIndexAttrs = numattrs;
750  n->ii_NumIndexKeyAttrs = numkeyattrs;
751  Assert(n->ii_NumIndexKeyAttrs != 0);
753  n->ii_Unique = unique;
754  n->ii_NullsNotDistinct = nulls_not_distinct;
755  n->ii_ReadyForInserts = isready;
756  n->ii_CheckedUnchanged = false;
757  n->ii_IndexUnchanged = false;
758  n->ii_Concurrent = concurrent;
759 
760  /* expressions */
761  n->ii_Expressions = expressions;
763 
764  /* predicates */
765  n->ii_Predicate = predicates;
766  n->ii_PredicateState = NULL;
767 
768  /* exclusion constraints */
769  n->ii_ExclusionOps = NULL;
770  n->ii_ExclusionProcs = NULL;
771  n->ii_ExclusionStrats = NULL;
772 
773  /* opclass options */
774  n->ii_OpclassOptions = NULL;
775 
776  /* speculative inserts */
777  n->ii_UniqueOps = NULL;
778  n->ii_UniqueProcs = NULL;
779  n->ii_UniqueStrats = NULL;
780 
781  /* initialize index-build state to default */
782  n->ii_BrokenHotChain = false;
783  n->ii_ParallelWorkers = 0;
784 
785  /* set up for possible use by index AM */
786  n->ii_Am = amoid;
787  n->ii_AmCache = NULL;
789 
790  return n;
791 }
MemoryContext CurrentMemoryContext
Definition: mcxt.c:42
bool ii_Unique
Definition: execnodes.h:175
uint16 * ii_ExclusionStrats
Definition: execnodes.h:170
bool ii_BrokenHotChain
Definition: execnodes.h:181
int ii_NumIndexAttrs
Definition: execnodes.h:161
void * ii_AmCache
Definition: execnodes.h:184
bool ii_CheckedUnchanged
Definition: execnodes.h:178
Datum * ii_OpclassOptions
Definition: execnodes.h:174
Oid * ii_UniqueOps
Definition: execnodes.h:171
ExprState * ii_PredicateState
Definition: execnodes.h:167
Oid * ii_ExclusionOps
Definition: execnodes.h:168
bool ii_NullsNotDistinct
Definition: execnodes.h:176
int ii_ParallelWorkers
Definition: execnodes.h:182
bool ii_Concurrent
Definition: execnodes.h:180
uint16 * ii_UniqueStrats
Definition: execnodes.h:173
int ii_NumIndexKeyAttrs
Definition: execnodes.h:162
List * ii_ExpressionsState
Definition: execnodes.h:165
List * ii_Expressions
Definition: execnodes.h:164
bool ii_IndexUnchanged
Definition: execnodes.h:179
Oid * ii_ExclusionProcs
Definition: execnodes.h:169
Oid ii_Am
Definition: execnodes.h:183
Oid * ii_UniqueProcs
Definition: execnodes.h:172
MemoryContext ii_Context
Definition: execnodes.h:185
bool ii_ReadyForInserts
Definition: execnodes.h:177
List * ii_Predicate
Definition: execnodes.h:166

References Assert(), CurrentMemoryContext, IndexInfo::ii_Am, IndexInfo::ii_AmCache, IndexInfo::ii_BrokenHotChain, IndexInfo::ii_CheckedUnchanged, IndexInfo::ii_Concurrent, IndexInfo::ii_Context, IndexInfo::ii_ExclusionOps, IndexInfo::ii_ExclusionProcs, IndexInfo::ii_ExclusionStrats, IndexInfo::ii_Expressions, IndexInfo::ii_ExpressionsState, IndexInfo::ii_IndexUnchanged, IndexInfo::ii_NullsNotDistinct, IndexInfo::ii_NumIndexAttrs, IndexInfo::ii_NumIndexKeyAttrs, IndexInfo::ii_OpclassOptions, IndexInfo::ii_ParallelWorkers, IndexInfo::ii_Predicate, IndexInfo::ii_PredicateState, IndexInfo::ii_ReadyForInserts, IndexInfo::ii_Unique, IndexInfo::ii_UniqueOps, IndexInfo::ii_UniqueProcs, IndexInfo::ii_UniqueStrats, makeNode, and NIL.

Referenced by BuildDummyIndexInfo(), BuildIndexInfo(), CheckIndexCompatible(), DefineIndex(), and index_concurrently_create_copy().

◆ makeJsonBehavior()

JsonBehavior* makeJsonBehavior ( JsonBehaviorType  type,
Node expr 
)

Definition at line 860 of file makefuncs.c.

861 {
862  JsonBehavior *behavior = makeNode(JsonBehavior);
863 
864  behavior->btype = type;
865  behavior->default_expr = default_expr;
866 
867  return behavior;
868 }
JsonBehaviorType btype
Definition: primnodes.h:1409
Node * default_expr
Definition: primnodes.h:1410

References JsonBehavior::btype, JsonBehavior::default_expr, makeNode, and generate_unaccent_rules::type.

Referenced by transformJsonBehavior(), and transformJsonTableColumn().

◆ makeJsonEncoding()

JsonEncoding makeJsonEncoding ( char *  name)

Definition at line 894 of file makefuncs.c.

895 {
896  if (!pg_strcasecmp(name, "utf8"))
897  return JS_ENC_UTF8;
898  if (!pg_strcasecmp(name, "utf16"))
899  return JS_ENC_UTF16;
900  if (!pg_strcasecmp(name, "utf32"))
901  return JS_ENC_UTF32;
902 
903  ereport(ERROR,
904  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
905  errmsg("unrecognized JSON encoding: %s", name)));
906 
907  return JS_ENC_DEFAULT;
908 }
int errcode(int sqlerrcode)
Definition: elog.c:693
int errmsg(const char *fmt,...)
Definition: elog.c:904
#define ERROR
Definition: elog.h:33
#define ereport(elevel,...)
Definition: elog.h:143
int pg_strcasecmp(const char *s1, const char *s2)
Definition: pgstrcasecmp.c:36
@ JS_ENC_DEFAULT
Definition: primnodes.h:1263
@ JS_ENC_UTF32
Definition: primnodes.h:1266
@ JS_ENC_UTF8
Definition: primnodes.h:1264
@ JS_ENC_UTF16
Definition: primnodes.h:1265

References ereport, errcode(), errmsg(), ERROR, JS_ENC_DEFAULT, JS_ENC_UTF16, JS_ENC_UTF32, JS_ENC_UTF8, name, and pg_strcasecmp().

◆ makeJsonFormat()

JsonFormat* makeJsonFormat ( JsonFormatType  type,
JsonEncoding  encoding,
int  location 
)

Definition at line 828 of file makefuncs.c.

829 {
831 
832  jf->format_type = type;
833  jf->encoding = encoding;
834  jf->location = location;
835 
836  return jf;
837 }
int32 encoding
Definition: pg_database.h:41
int location
Definition: primnodes.h:1321
JsonEncoding encoding
Definition: primnodes.h:1320
JsonFormatType format_type
Definition: primnodes.h:1319

References encoding, JsonFormat::encoding, JsonFormat::format_type, JsonFormat::location, makeNode, and generate_unaccent_rules::type.

Referenced by transformJsonConstructorRet(), transformJsonFuncExpr(), transformJsonOutput(), transformJsonSerializeExpr(), and transformJsonTableColumn().

◆ makeJsonIsPredicate()

Node* makeJsonIsPredicate ( Node expr,
JsonFormat format,
JsonValueType  item_type,
bool  unique_keys,
int  location 
)

Definition at line 930 of file makefuncs.c.

932 {
934 
935  n->expr = expr;
936  n->format = format;
937  n->item_type = item_type;
938  n->unique_keys = unique_keys;
939  n->location = location;
940 
941  return (Node *) n;
942 }
static char format
JsonFormat * format
Definition: primnodes.h:1396
JsonValueType item_type
Definition: primnodes.h:1397

References JsonIsPredicate::expr, format, JsonIsPredicate::format, JsonIsPredicate::item_type, JsonIsPredicate::location, makeNode, and JsonIsPredicate::unique_keys.

Referenced by transformJsonIsPredicate().

◆ makeJsonKeyValue()

Node* makeJsonKeyValue ( Node key,
Node value 
)

Definition at line 915 of file makefuncs.c.

916 {
918 
919  n->key = (Expr *) key;
921 
922  return (Node *) n;
923 }
#define castNode(_type_, nodeptr)
Definition: nodes.h:642
JsonValueExpr * value
Definition: parsenodes.h:1762

References castNode, JsonKeyValue::key, sort-test::key, makeNode, JsonKeyValue::value, and value.

◆ makeJsonTableJoinedPlan()

Node* makeJsonTableJoinedPlan ( JsonTablePlanJoinType  type,
Node plan1,
Node plan2,
int  location 
)

Definition at line 875 of file makefuncs.c.

877 {
879 
880  n->plan_type = JSTP_JOINED;
881  n->join_type = type;
882  n->plan1 = castNode(JsonTablePlan, plan1);
883  n->plan2 = castNode(JsonTablePlan, plan2);
884  n->location = location;
885 
886  return (Node *) n;
887 }
@ JSTP_JOINED
Definition: parsenodes.h:1705
JsonTablePlanJoinType join_type
Definition: parsenodes.h:1730
JsonTablePlan * plan1
Definition: parsenodes.h:1731
JsonTablePlan * plan2
Definition: parsenodes.h:1732
JsonTablePlanType plan_type
Definition: parsenodes.h:1729

References castNode, JsonTablePlan::join_type, JSTP_JOINED, JsonTablePlan::location, makeNode, JsonTablePlan::plan1, JsonTablePlan::plan2, JsonTablePlan::plan_type, and generate_unaccent_rules::type.

Referenced by transformJsonTable().

◆ makeJsonValueExpr()

JsonValueExpr* makeJsonValueExpr ( Expr expr,
JsonFormat format 
)

Definition at line 844 of file makefuncs.c.

845 {
847 
848  jve->raw_expr = expr;
849  jve->formatted_expr = NULL;
850  jve->format = format;
851 
852  return jve;
853 }
Expr * formatted_expr
Definition: primnodes.h:1344
JsonFormat * format
Definition: primnodes.h:1345
Expr * raw_expr
Definition: primnodes.h:1343

References format, JsonValueExpr::format, JsonValueExpr::formatted_expr, makeNode, and JsonValueExpr::raw_expr.

Referenced by transformJsonArrayQueryConstructor(), transformJsonParseArg(), and transformJsonTableColumn().

◆ makeNullConst()

Const* makeNullConst ( Oid  consttype,
int32  consttypmod,
Oid  constcollid 
)

Definition at line 338 of file makefuncs.c.

339 {
340  int16 typLen;
341  bool typByVal;
342 
343  get_typlenbyval(consttype, &typLen, &typByVal);
344  return makeConst(consttype,
345  consttypmod,
346  constcollid,
347  (int) typLen,
348  (Datum) 0,
349  true,
350  typByVal);
351 }
signed short int16
Definition: c.h:428
void get_typlenbyval(Oid typid, int16 *typlen, bool *typbyval)
Definition: lsyscache.c:2208
uintptr_t Datum
Definition: postgres.h:411

References get_typlenbyval(), and makeConst().

Referenced by adjust_appendrel_attrs_mutator(), ATExecAddColumn(), build_subplan(), BuildOnConflictExcludedTargetlist(), coerce_record_to_complex(), eval_const_expressions_mutator(), evaluate_function(), ExecInitExprRec(), expandRTE(), expandTupleDesc(), initJsonItemCoercion(), remove_unused_subquery_outputs(), ReplaceVarsFromTargetList_callback(), rewriteValuesRTE(), set_plan_refs(), and transformAssignedExpr().

◆ makeRangeVar()

RangeVar* makeRangeVar ( char *  schemaname,
char *  relname,
int  location 
)

◆ makeRelabelType()

RelabelType* makeRelabelType ( Expr arg,
Oid  rtype,
int32  rtypmod,
Oid  rcollid,
CoercionForm  rformat 
)

Definition at line 403 of file makefuncs.c.

405 {
407 
408  r->arg = arg;
409  r->resulttype = rtype;
410  r->resulttypmod = rtypmod;
411  r->resultcollid = rcollid;
412  r->relabelformat = rformat;
413  r->location = -1;
414 
415  return r;
416 }
int location
Definition: primnodes.h:874
Oid resultcollid
Definition: primnodes.h:872
int32 resulttypmod
Definition: primnodes.h:871
CoercionForm relabelformat
Definition: primnodes.h:873
Oid resulttype
Definition: primnodes.h:870
Expr * arg
Definition: primnodes.h:869

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

Referenced by assign_hypothetical_collations(), buildMergedJoinVar(), coerce_type(), and make_partition_op_expr().

◆ makeSimpleA_Expr()

A_Expr* makeSimpleA_Expr ( A_Expr_Kind  kind,
char *  name,
Node lexpr,
Node rexpr,
int  location 
)

Definition at line 49 of file makefuncs.c.

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 }
String * makeString(char *str)
Definition: value.c:63

References a, list_make1, makeNode, makeString(), and name.

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

◆ makeTargetEntry()

TargetEntry* makeTargetEntry ( Expr expr,
AttrNumber  resno,
char *  resname,
bool  resjunk 
)

Definition at line 239 of file makefuncs.c.

243 {
245 
246  tle->expr = expr;
247  tle->resno = resno;
248  tle->resname = resname;
249 
250  /*
251  * We always set these fields to 0. If the caller wants to change them he
252  * must do so explicitly. Few callers do that, so omitting these
253  * arguments reduces the chance of error.
254  */
255  tle->ressortgroupref = 0;
256  tle->resorigtbl = InvalidOid;
257  tle->resorigcol = 0;
258 
259  tle->resjunk = resjunk;
260 
261  return tle;
262 }
Expr * expr
Definition: primnodes.h:1716
char * resname
Definition: primnodes.h:1718
Oid resorigtbl
Definition: primnodes.h:1721
AttrNumber resno
Definition: primnodes.h:1717
bool resjunk
Definition: primnodes.h:1723
Index ressortgroupref
Definition: primnodes.h:1719
AttrNumber resorigcol
Definition: primnodes.h:1722

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

Referenced by add_row_identity_var(), add_to_flat_tlist(), ApplyRetrieveRule(), build_index_tlist(), build_minmax_path(), build_path_tlist(), build_physical_tlist(), build_remote_returning(), BuildOnConflictExcludedTargetlist(), check_sql_fn_retval(), coerce_fn_result_column(), convert_combining_aggrefs(), convert_EXISTS_to_ANY(), create_unique_plan(), determineRecursiveColTypes(), ExecInitSubPlan(), expand_inherited_rtentry(), expand_insert_targetlist(), expandNSItemAttrs(), ExpandRowReference(), foreign_grouping_ok(), generate_append_tlist(), generate_setop_tlist(), make_tlist_from_pathtarget(), prepare_sort_from_pathkeys(), preprocess_targetlist(), pull_up_constant_function(), pull_up_simple_values(), rebuild_fdw_scan_tlist(), rewriteSearchAndCycle(), rewriteTargetListIU(), transformAggregateCall(), transformMergeStmt(), transformMultiAssignRef(), transformReturnStmt(), transformSetOperationStmt(), transformSetOperationTree(), and transformTargetEntry().

◆ makeTypeName()

TypeName* makeTypeName ( char *  typnam)

Definition at line 445 of file makefuncs.c.

446 {
448 }
TypeName * makeTypeNameFromNameList(List *names)
Definition: makefuncs.c:457

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

Referenced by plpgsql_parse_wordrowtype(), and plpgsql_parse_wordtype().

◆ makeTypeNameFromNameList()

◆ makeTypeNameFromOid()

TypeName* makeTypeNameFromOid ( Oid  typeOid,
int32  typmod 
)

Definition at line 473 of file makefuncs.c.

474 {
475  TypeName *n = makeNode(TypeName);
476 
477  n->typeOid = typeOid;
478  n->typemod = typmod;
479  n->location = -1;
480  return n;
481 }
Oid typeOid
Definition: parsenodes.h:227

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

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

◆ makeVacuumRelation()

VacuumRelation* makeVacuumRelation ( RangeVar relation,
Oid  oid,
List va_cols 
)

Definition at line 813 of file makefuncs.c.

814 {
816 
817  v->relation = relation;
818  v->oid = oid;
819  v->va_cols = va_cols;
820  return v;
821 }
RangeVar * relation
Definition: parsenodes.h:3728

References makeNode, VacuumRelation::oid, VacuumRelation::relation, and VacuumRelation::va_cols.

Referenced by autovacuum_do_vac_analyze(), expand_vacuum_rel(), and get_all_vacuum_rels().

◆ makeVar()

Var* makeVar ( int  varno,
AttrNumber  varattno,
Oid  vartype,
int32  vartypmod,
Oid  varcollid,
Index  varlevelsup 
)

Definition at line 67 of file makefuncs.c.

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  * Only a few callers need to make Var nodes with varnosyn/varattnosyn
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->varnosyn = (Index) varno;
90  var->varattnosyn = varattno;
91 
92  /* Likewise, we just set location to "unknown" here */
93  var->location = -1;
94 
95  return var;
96 }
unsigned int Index
Definition: c.h:549
Definition: primnodes.h:196
Oid vartype
Definition: primnodes.h:202
AttrNumber varattno
Definition: primnodes.h:200
AttrNumber varattnosyn
Definition: primnodes.h:209
Oid varcollid
Definition: primnodes.h:204
int varno
Definition: primnodes.h:198
int32 vartypmod
Definition: primnodes.h:203
Index varlevelsup
Definition: primnodes.h:205
int location
Definition: primnodes.h:210
Index varnosyn
Definition: primnodes.h:208

References Var::location, makeNode, Var::varattno, Var::varattnosyn, Var::varcollid, Var::varlevelsup, Var::varno, Var::varnosyn, Var::vartype, and Var::vartypmod.

Referenced by add_row_identity_columns(), ATPrepAlterColumnType(), build_index_tlist(), build_physical_tlist(), build_remote_returning(), BuildOnConflictExcludedTargetlist(), buildVarFromNSColumn(), eval_const_expressions_mutator(), expand_inherited_rtentry(), expand_single_inheritance_child(), expandNSItemVars(), expandRTE(), expandTupleDesc(), fix_indexqual_operand(), generate_append_tlist(), generate_setop_tlist(), get_qual_for_hash(), get_qual_for_list(), get_range_key_properties(), get_range_nulltest(), get_relation_constraints(), make_inh_translation_list(), make_path_cat_expr(), make_path_rowexpr(), makeVarFromTargetEntry(), makeWholeRowVar(), NotNullImpliedByRelConstraints(), PartConstraintImpliedByRelConstraint(), postgresAddForeignUpdateTargets(), preprocess_targetlist(), rewriteSearchAndCycle(), scanNSItemForColumn(), set_baserel_partition_key_exprs(), set_dummy_tlist_references(), transformAssignedExpr(), and transformSetOperationStmt().

◆ makeVarFromTargetEntry()

Var* makeVarFromTargetEntry ( int  varno,
TargetEntry tle 
)

Definition at line 104 of file makefuncs.c.

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 }
Var * makeVar(int varno, AttrNumber varattno, Oid vartype, int32 vartypmod, Oid varcollid, Index varlevelsup)
Definition: makefuncs.c:67
Oid exprType(const Node *expr)
Definition: nodeFuncs.c:41
int32 exprTypmod(const Node *expr)
Definition: nodeFuncs.c:286
Oid exprCollation(const Node *expr)
Definition: nodeFuncs.c:788

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

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

◆ makeWholeRowVar()

Var* makeWholeRowVar ( RangeTblEntry rte,
int  varno,
Index  varlevelsup,
bool  allowScalar 
)

Definition at line 134 of file makefuncs.c.

138 {
139  Var *result;
140  Oid toid;
141  Node *fexpr;
142 
143  switch (rte->rtekind)
144  {
145  case RTE_RELATION:
146  /* relation: the rowtype is a named composite type */
147  toid = get_rel_type_id(rte->relid);
148  if (!OidIsValid(toid))
149  ereport(ERROR,
150  (errcode(ERRCODE_WRONG_OBJECT_TYPE),
151  errmsg("relation \"%s\" does not have a composite type",
152  get_rel_name(rte->relid))));
153  result = makeVar(varno,
155  toid,
156  -1,
157  InvalidOid,
158  varlevelsup);
159  break;
160 
161  case RTE_FUNCTION:
162 
163  /*
164  * If there's more than one function, or ordinality is requested,
165  * force a RECORD result, since there's certainly more than one
166  * column involved and it can't be a known named type.
167  */
168  if (rte->funcordinality || list_length(rte->functions) != 1)
169  {
170  /* always produces an anonymous RECORD result */
171  result = makeVar(varno,
173  RECORDOID,
174  -1,
175  InvalidOid,
176  varlevelsup);
177  break;
178  }
179 
180  fexpr = ((RangeTblFunction *) linitial(rte->functions))->funcexpr;
181  toid = exprType(fexpr);
182  if (type_is_rowtype(toid))
183  {
184  /* func returns composite; same as relation case */
185  result = makeVar(varno,
187  toid,
188  -1,
189  InvalidOid,
190  varlevelsup);
191  }
192  else if (allowScalar)
193  {
194  /* func returns scalar; just return its output as-is */
195  result = makeVar(varno,
196  1,
197  toid,
198  -1,
199  exprCollation(fexpr),
200  varlevelsup);
201  }
202  else
203  {
204  /* func returns scalar, but we want a composite result */
205  result = makeVar(varno,
207  RECORDOID,
208  -1,
209  InvalidOid,
210  varlevelsup);
211  }
212  break;
213 
214  default:
215 
216  /*
217  * RTE is a join, subselect, tablefunc, or VALUES. We represent
218  * this as a whole-row Var of RECORD type. (Note that in most
219  * cases the Var will be expanded to a RowExpr during planning,
220  * but that is not our concern here.)
221  */
222  result = makeVar(varno,
224  RECORDOID,
225  -1,
226  InvalidOid,
227  varlevelsup);
228  break;
229  }
230 
231  return result;
232 }
#define InvalidAttrNumber
Definition: attnum.h:23
#define OidIsValid(objectId)
Definition: c.h:710
bool type_is_rowtype(Oid typid)
Definition: lsyscache.c:2612
Oid get_rel_type_id(Oid relid)
Definition: lsyscache.c:1960
char * get_rel_name(Oid relid)
Definition: lsyscache.c:1909
@ RTE_FUNCTION
Definition: parsenodes.h:1001
@ RTE_RELATION
Definition: parsenodes.h:998
unsigned int Oid
Definition: postgres_ext.h:31
bool funcordinality
Definition: parsenodes.h:1110
List * functions
Definition: parsenodes.h:1109
RTEKind rtekind
Definition: parsenodes.h:1015

References ereport, errcode(), errmsg(), ERROR, exprCollation(), exprType(), RangeTblEntry::funcordinality, RangeTblEntry::functions, get_rel_name(), get_rel_type_id(), InvalidAttrNumber, InvalidOid, linitial, list_length(), makeVar(), OidIsValid, RangeTblEntry::relid, RTE_FUNCTION, RTE_RELATION, RangeTblEntry::rtekind, and type_is_rowtype().

Referenced by ApplyRetrieveRule(), expand_inherited_rtentry(), preprocess_targetlist(), and transformWholeRowRef().