PostgreSQL Source Code  git master
makefuncs.c File Reference
#include "postgres.h"
#include "catalog/pg_class.h"
#include "catalog/pg_type.h"
#include "nodes/makefuncs.h"
#include "nodes/nodeFuncs.h"
#include "utils/errcodes.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 (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)
 
DefElemmakeDefElem (char *name, Node *arg, int location)
 
DefElemmakeDefElemExtended (char *nameSpace, char *name, Node *arg, DefElemAction defaction, int location)
 
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, bool summarizing)
 
GroupingSetmakeGroupingSet (GroupingSetKind kind, List *content, int location)
 
VacuumRelationmakeVacuumRelation (RangeVar *relation, Oid oid, List *va_cols)
 
JsonFormatmakeJsonFormat (JsonFormatType type, JsonEncoding encoding, int location)
 
JsonValueExprmakeJsonValueExpr (Expr *raw_expr, Expr *formatted_expr, JsonFormat *format)
 
JsonEncoding makeJsonEncoding (char *name)
 
NodemakeJsonKeyValue (Node *key, Node *value)
 
NodemakeJsonIsPredicate (Node *expr, JsonFormat *format, JsonValueType item_type, bool unique_keys, int location)
 

Function Documentation

◆ flatCopyTargetEntry()

TargetEntry* flatCopyTargetEntry ( TargetEntry src_tle)

Definition at line 274 of file makefuncs.c.

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

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 692 of file makefuncs.c.

693 {
694  if (qual1 == NULL)
695  return qual2;
696  if (qual2 == NULL)
697  return qual1;
698  return (Node *) make_andclause(list_make2(qual1, qual2));
699 }
Expr * make_andclause(List *andclauses)
Definition: makefuncs.c:639
#define list_make2(x1, x2)
Definition: pg_list.h:214
Definition: nodes.h:129

References list_make2, and make_andclause().

Referenced by AddQual(), and subquery_push_qual().

◆ make_andclause()

Expr* make_andclause ( List andclauses)

Definition at line 639 of file makefuncs.c.

640 {
641  BoolExpr *expr = makeNode(BoolExpr);
642 
643  expr->boolop = AND_EXPR;
644  expr->args = andclauses;
645  expr->location = -1;
646  return (Expr *) expr;
647 }
@ AND_EXPR
Definition: primnodes.h:858
int location
Definition: primnodes.h:868
BoolExprType boolop
Definition: primnodes.h:866
List * args
Definition: primnodes.h:867

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 711 of file makefuncs.c.

712 {
713  if (andclauses == NIL)
714  return (Expr *) makeBoolConst(true, false);
715  else if (list_length(andclauses) == 1)
716  return (Expr *) linitial(andclauses);
717  else
718  return make_andclause(andclauses);
719 }
Node * makeBoolConst(bool value, bool isnull)
Definition: makefuncs.c:360
static int list_length(const List *l)
Definition: pg_list.h:152
#define NIL
Definition: pg_list.h:68
#define linitial(l)
Definition: pg_list.h:178

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 722 of file makefuncs.c.

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

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 671 of file makefuncs.c.

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

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 613 of file makefuncs.c.

616 {
617  OpExpr *expr = makeNode(OpExpr);
618 
619  expr->opno = opno;
620  expr->opfuncid = InvalidOid;
621  expr->opresulttype = opresulttype;
622  expr->opretset = opretset;
623  expr->opcollid = opcollid;
624  expr->inputcollid = inputcollid;
625  if (rightop)
626  expr->args = list_make2(leftop, rightop);
627  else
628  expr->args = list_make1(leftop);
629  expr->location = -1;
630  return (Expr *) expr;
631 }
#define InvalidOid
Definition: postgres_ext.h:36
int location
Definition: primnodes.h:766
Oid opno
Definition: primnodes.h:745
List * args
Definition: primnodes.h:763

References OpExpr::args, InvalidOid, list_make1, list_make2, OpExpr::location, makeNode, and OpExpr::opno.

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

References a, makeNode, and name.

◆ makeAlias()

◆ makeBoolConst()

Node* makeBoolConst ( bool  value,
bool  isnull 
)

Definition at line 360 of file makefuncs.c.

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

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(), process_duplicate_ors(), and reconsider_outer_join_clauses().

◆ makeBoolExpr()

◆ makeColumnDef()

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

Definition at line 493 of file makefuncs.c.

494 {
496 
497  n->colname = pstrdup(colname);
498  n->typeName = makeTypeNameFromOid(typeOid, typmod);
499  n->inhcount = 0;
500  n->is_local = true;
501  n->is_not_null = false;
502  n->is_from_type = false;
503  n->storage = 0;
504  n->raw_default = NULL;
505  n->cooked_default = NULL;
506  n->collClause = NULL;
507  n->collOid = collOid;
508  n->constraints = NIL;
509  n->fdwoptions = NIL;
510  n->location = -1;
511 
512  return n;
513 }
TypeName * makeTypeNameFromOid(Oid typeOid, int32 typmod)
Definition: makefuncs.c:475
bool is_not_null
Definition: parsenodes.h:725
CollateClause * collClause
Definition: parsenodes.h:735
int location
Definition: parsenodes.h:739
List * constraints
Definition: parsenodes.h:737
Node * cooked_default
Definition: parsenodes.h:730
int inhcount
Definition: parsenodes.h:723
char * colname
Definition: parsenodes.h:720
TypeName * typeName
Definition: parsenodes.h:721
bool is_from_type
Definition: parsenodes.h:726
List * fdwoptions
Definition: parsenodes.h:738
Node * raw_default
Definition: parsenodes.h:729
char storage
Definition: parsenodes.h:727
Oid collOid
Definition: parsenodes.h:736
bool is_local
Definition: parsenodes.h:724

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(), DefineSequence(), DefineVirtualRelation(), intorel_startup(), MergeAttributes(), transformOfType(), and transformTableLikeClause().

◆ makeConst()

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

Definition at line 302 of file makefuncs.c.

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

References Const::consttype, 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(), create_final_distinct_paths(), 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(), 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 549 of file makefuncs.c.

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

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

Referenced by buildDefItem(), copy_table(), 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 567 of file makefuncs.c.

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

References arg, makeNode, name, and res.

◆ makeFromExpr()

◆ makeFuncCall()

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

Definition at line 588 of file makefuncs.c.

589 {
590  FuncCall *n = makeNode(FuncCall);
591 
592  n->funcname = name;
593  n->args = args;
594  n->agg_order = NIL;
595  n->agg_filter = NULL;
596  n->over = NULL;
597  n->agg_within_group = false;
598  n->agg_star = false;
599  n->agg_distinct = false;
600  n->func_variadic = false;
601  n->funcformat = funcformat;
602  n->location = location;
603  return n;
604 }
bool agg_within_group
Definition: parsenodes.h:428
int location
Definition: parsenodes.h:433
CoercionForm funcformat
Definition: parsenodes.h:432
Node * agg_filter
Definition: parsenodes.h:426
List * agg_order
Definition: parsenodes.h:425
List * funcname
Definition: parsenodes.h:423
List * args
Definition: parsenodes.h:424
bool agg_star
Definition: parsenodes.h:429
bool agg_distinct
Definition: parsenodes.h:430
bool func_variadic
Definition: parsenodes.h:431
struct WindowDef * over
Definition: parsenodes.h:427

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 522 of file makefuncs.c.

524 {
525  FuncExpr *funcexpr;
526 
527  funcexpr = makeNode(FuncExpr);
528  funcexpr->funcid = funcid;
529  funcexpr->funcresulttype = rettype;
530  funcexpr->funcretset = false; /* only allowed case here */
531  funcexpr->funcvariadic = false; /* only allowed case here */
532  funcexpr->funcformat = fformat;
533  funcexpr->funccollid = funccollid;
534  funcexpr->inputcollid = inputcollid;
535  funcexpr->args = args;
536  funcexpr->location = -1;
537 
538  return funcexpr;
539 }
Oid funcid
Definition: primnodes.h:677
List * args
Definition: primnodes.h:695
int location
Definition: primnodes.h:697

References generate_unaccent_rules::args, FuncExpr::args, FuncExpr::funcid, 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 transformJsonValueExpr().

◆ makeGroupingSet()

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

Definition at line 805 of file makefuncs.c.

806 {
808 
809  n->kind = kind;
810  n->content = content;
811  n->location = location;
812  return n;
813 }
List * content
Definition: parsenodes.h:1463

References GroupingSet::content, 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,
bool  summarizing 
)

Definition at line 746 of file makefuncs.c.

749 {
751 
752  n->ii_NumIndexAttrs = numattrs;
753  n->ii_NumIndexKeyAttrs = numkeyattrs;
754  Assert(n->ii_NumIndexKeyAttrs != 0);
756  n->ii_Unique = unique;
757  n->ii_NullsNotDistinct = nulls_not_distinct;
758  n->ii_ReadyForInserts = isready;
759  n->ii_CheckedUnchanged = false;
760  n->ii_IndexUnchanged = false;
761  n->ii_Concurrent = concurrent;
762  n->ii_Summarizing = summarizing;
763 
764  /* summarizing indexes cannot contain non-key attributes */
765  Assert(!summarizing || (numkeyattrs == numattrs));
766 
767  /* expressions */
768  n->ii_Expressions = expressions;
770 
771  /* predicates */
772  n->ii_Predicate = predicates;
773  n->ii_PredicateState = NULL;
774 
775  /* exclusion constraints */
776  n->ii_ExclusionOps = NULL;
777  n->ii_ExclusionProcs = NULL;
778  n->ii_ExclusionStrats = NULL;
779 
780  /* opclass options */
781  n->ii_OpclassOptions = NULL;
782 
783  /* speculative inserts */
784  n->ii_UniqueOps = NULL;
785  n->ii_UniqueProcs = NULL;
786  n->ii_UniqueStrats = NULL;
787 
788  /* initialize index-build state to default */
789  n->ii_BrokenHotChain = false;
790  n->ii_ParallelWorkers = 0;
791 
792  /* set up for possible use by index AM */
793  n->ii_Am = amoid;
794  n->ii_AmCache = NULL;
796 
797  return n;
798 }
MemoryContext CurrentMemoryContext
Definition: mcxt.c:135
bool ii_Unique
Definition: execnodes.h:191
uint16 * ii_ExclusionStrats
Definition: execnodes.h:186
bool ii_BrokenHotChain
Definition: execnodes.h:197
int ii_NumIndexAttrs
Definition: execnodes.h:177
void * ii_AmCache
Definition: execnodes.h:201
bool ii_CheckedUnchanged
Definition: execnodes.h:194
Datum * ii_OpclassOptions
Definition: execnodes.h:190
Oid * ii_UniqueOps
Definition: execnodes.h:187
ExprState * ii_PredicateState
Definition: execnodes.h:183
Oid * ii_ExclusionOps
Definition: execnodes.h:184
bool ii_NullsNotDistinct
Definition: execnodes.h:192
int ii_ParallelWorkers
Definition: execnodes.h:199
bool ii_Concurrent
Definition: execnodes.h:196
uint16 * ii_UniqueStrats
Definition: execnodes.h:189
int ii_NumIndexKeyAttrs
Definition: execnodes.h:178
List * ii_ExpressionsState
Definition: execnodes.h:181
List * ii_Expressions
Definition: execnodes.h:180
bool ii_IndexUnchanged
Definition: execnodes.h:195
Oid * ii_ExclusionProcs
Definition: execnodes.h:185
Oid ii_Am
Definition: execnodes.h:200
bool ii_Summarizing
Definition: execnodes.h:198
Oid * ii_UniqueProcs
Definition: execnodes.h:188
MemoryContext ii_Context
Definition: execnodes.h:202
bool ii_ReadyForInserts
Definition: execnodes.h:193
List * ii_Predicate
Definition: execnodes.h:182

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_Summarizing, 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().

◆ makeJsonEncoding()

JsonEncoding makeJsonEncoding ( char *  name)

Definition at line 868 of file makefuncs.c.

869 {
870  if (!pg_strcasecmp(name, "utf8"))
871  return JS_ENC_UTF8;
872  if (!pg_strcasecmp(name, "utf16"))
873  return JS_ENC_UTF16;
874  if (!pg_strcasecmp(name, "utf32"))
875  return JS_ENC_UTF32;
876 
877  ereport(ERROR,
878  errcode(ERRCODE_INVALID_PARAMETER_VALUE),
879  errmsg("unrecognized JSON encoding: %s", name));
880 
881  return JS_ENC_DEFAULT;
882 }
int errcode(int sqlerrcode)
Definition: elog.c:858
int errmsg(const char *fmt,...)
Definition: elog.c:1069
#define ERROR
Definition: elog.h:39
#define ereport(elevel,...)
Definition: elog.h:149
int pg_strcasecmp(const char *s1, const char *s2)
Definition: pgstrcasecmp.c:36
@ JS_ENC_DEFAULT
Definition: primnodes.h:1553
@ JS_ENC_UTF32
Definition: primnodes.h:1556
@ JS_ENC_UTF8
Definition: primnodes.h:1554
@ JS_ENC_UTF16
Definition: primnodes.h:1555

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 835 of file makefuncs.c.

836 {
838 
839  jf->format_type = type;
840  jf->encoding = encoding;
841  jf->location = location;
842 
843  return jf;
844 }
int32 encoding
Definition: pg_database.h:41
int location
Definition: primnodes.h:1580
JsonEncoding encoding
Definition: primnodes.h:1579
JsonFormatType format_type
Definition: primnodes.h:1578
const char * type

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

Referenced by transformJsonOutput(), transformJsonReturning(), and transformJsonSerializeExpr().

◆ makeJsonIsPredicate()

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

Definition at line 904 of file makefuncs.c.

906 {
908 
909  n->expr = expr;
910  n->format = format;
911  n->item_type = item_type;
912  n->unique_keys = unique_keys;
913  n->location = location;
914 
915  return (Node *) n;
916 }
static char format
JsonFormat * format
Definition: primnodes.h:1659
JsonValueType item_type
Definition: primnodes.h:1660

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 889 of file makefuncs.c.

890 {
892 
893  n->key = (Expr *) key;
895 
896  return (Node *) n;
897 }
#define castNode(_type_, nodeptr)
Definition: nodes.h:197
JsonValueExpr * value
Definition: parsenodes.h:1739

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

◆ makeJsonValueExpr()

JsonValueExpr* makeJsonValueExpr ( Expr raw_expr,
Expr formatted_expr,
JsonFormat format 
)

Definition at line 851 of file makefuncs.c.

853 {
855 
856  jve->raw_expr = raw_expr;
857  jve->formatted_expr = formatted_expr;
858  jve->format = format;
859 
860  return jve;
861 }
Expr * formatted_expr
Definition: primnodes.h:1607
JsonFormat * format
Definition: primnodes.h:1608
Expr * raw_expr
Definition: primnodes.h:1606

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

Referenced by transformJsonArrayQueryConstructor(), and transformJsonParseArg().

◆ makeNullConst()

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

Definition at line 340 of file makefuncs.c.

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

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(), remove_unused_subquery_outputs(), ReplaceVarsFromTargetList_callback(), rewriteValuesRTE(), rewriteValuesRTEToNulls(), 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 405 of file makefuncs.c.

407 {
409 
410  r->arg = arg;
411  r->resulttype = rtype;
412  r->resulttypmod = rtypmod;
413  r->resultcollid = rcollid;
414  r->relabelformat = rformat;
415  r->location = -1;
416 
417  return r;
418 }
Oid resulttype
Definition: primnodes.h:1112
Expr * arg
Definition: primnodes.h:1111

References arg, RelabelType::arg, RelabelType::location, makeNode, and RelabelType::resulttype.

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 241 of file makefuncs.c.

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

References TargetEntry::expr, InvalidOid, makeNode, TargetEntry::resno, 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 447 of file makefuncs.c.

448 {
450 }
TypeName * makeTypeNameFromNameList(List *names)
Definition: makefuncs.c:459

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 475 of file makefuncs.c.

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

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

Referenced by generateSerialExtraStmts(), makeColumnDef(), and transformAlterTableStmt().

◆ makeVacuumRelation()

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

Definition at line 820 of file makefuncs.c.

821 {
823 
824  v->relation = relation;
825  v->oid = oid;
826  v->va_cols = va_cols;
827  return v;
828 }
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 non-null varnullingrels,
85  * or with varnosyn/varattnosyn different from varno/varattno. We don't
86  * provide separate arguments for them, but just initialize them to NULL
87  * and the given varno/varattno. This reduces code clutter and chance of
88  * error for most callers.
89  */
90  var->varnullingrels = NULL;
91  var->varnosyn = (Index) varno;
92  var->varattnosyn = varattno;
93 
94  /* Likewise, we just set location to "unknown" here */
95  var->location = -1;
96 
97  return var;
98 }
unsigned int Index
Definition: c.h:603
Definition: primnodes.h:226
AttrNumber varattno
Definition: primnodes.h:238
int varno
Definition: primnodes.h:233
Index varlevelsup
Definition: primnodes.h:258
int location
Definition: primnodes.h:271

References Var::location, makeNode, Var::varattno, Var::varlevelsup, and Var::varno.

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 106 of file makefuncs.c.

108 {
109  return makeVar(varno,
110  tle->resno,
111  exprType((Node *) tle->expr),
112  exprTypmod((Node *) tle->expr),
113  exprCollation((Node *) tle->expr),
114  0);
115 }
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:43
int32 exprTypmod(const Node *expr)
Definition: nodeFuncs.c:282
Oid exprCollation(const Node *expr)
Definition: nodeFuncs.c:786

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_phv(), search_indexed_tlist_for_sortgroupref(), and transformInsertStmt().

◆ makeWholeRowVar()

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

Definition at line 136 of file makefuncs.c.

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

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().