should be it
This commit is contained in:
102
external/duckdb/third_party/libpg_query/include/nodes/bitmapset.hpp
vendored
Executable file
102
external/duckdb/third_party/libpg_query/include/nodes/bitmapset.hpp
vendored
Executable file
@@ -0,0 +1,102 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* bitmapset.h
|
||||
* PostgreSQL generic bitmap set package
|
||||
*
|
||||
* A bitmap set can represent any set of nonnegative integers, although
|
||||
* it is mainly intended for sets where the maximum value is not large,
|
||||
* say at most a few hundred. By convention, a NULL pointer is always
|
||||
* accepted by all operations to represent the empty set. (But beware
|
||||
* that this is not the only representation of the empty set. Use
|
||||
* bms_is_empty() in preference to testing for NULL.)
|
||||
*
|
||||
*
|
||||
* Copyright (c) 2003-2017, PostgreSQL Global Development PGGroup
|
||||
*
|
||||
* src/include/nodes/bitmapset.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace duckdb_libpgquery {
|
||||
|
||||
/*
|
||||
* Forward decl to save including pg_list.h
|
||||
*/
|
||||
struct PGList;
|
||||
|
||||
/*
|
||||
* Data representation
|
||||
*/
|
||||
|
||||
/* The unit size can be adjusted by changing these three declarations: */
|
||||
#define BITS_PER_BITMAPWORD 32
|
||||
typedef uint32_t bitmapword; /* must be an unsigned type */
|
||||
typedef int32_t signedbitmapword; /* must be the matching signed type */
|
||||
|
||||
typedef struct PGBitmapset {
|
||||
int nwords; /* number of words in array */
|
||||
bitmapword words[1]; /* really [nwords] */
|
||||
} PGBitmapset;
|
||||
|
||||
/* result of bms_subset_compare */
|
||||
typedef enum PG_BMS_Comparison {
|
||||
PG_BMS_EQUAL, /* sets are equal */
|
||||
PG_BMS_SUBSET1, /* first set is a subset of the second */
|
||||
PG_BMS_SUBSET2, /* second set is a subset of the first */
|
||||
BMS_DIFFERENT /* neither set is a subset of the other */
|
||||
} PG_BMS_Comparison;
|
||||
|
||||
/* result of bms_membership */
|
||||
typedef enum PG_BMS_Membership {
|
||||
PG_BMS_EMPTY_SET, /* 0 members */
|
||||
PG_BMS_SINGLETON, /* 1 member */
|
||||
BMS_MULTIPLE /* >1 member */
|
||||
} PG_BMS_Membership;
|
||||
|
||||
/*
|
||||
* function prototypes in nodes/bitmapset.c
|
||||
*/
|
||||
|
||||
PGBitmapset *bms_copy(const PGBitmapset *a);
|
||||
bool bms_equal(const PGBitmapset *a, const PGBitmapset *b);
|
||||
PGBitmapset *bms_make_singleton(int x);
|
||||
void bms_free(PGBitmapset *a);
|
||||
|
||||
PGBitmapset *bms_union(const PGBitmapset *a, const PGBitmapset *b);
|
||||
PGBitmapset *bms_intersect(const PGBitmapset *a, const PGBitmapset *b);
|
||||
PGBitmapset *bms_difference(const PGBitmapset *a, const PGBitmapset *b);
|
||||
bool bms_is_subset(const PGBitmapset *a, const PGBitmapset *b);
|
||||
PG_BMS_Comparison bms_subset_compare(const PGBitmapset *a, const PGBitmapset *b);
|
||||
bool bms_is_member(int x, const PGBitmapset *a);
|
||||
bool bms_overlap(const PGBitmapset *a, const PGBitmapset *b);
|
||||
bool bms_overlap_list(const PGBitmapset *a, const struct PGList *b);
|
||||
bool bms_nonempty_difference(const PGBitmapset *a, const PGBitmapset *b);
|
||||
int bms_singleton_member(const PGBitmapset *a);
|
||||
bool bms_get_singleton_member(const PGBitmapset *a, int *member);
|
||||
int bms_num_members(const PGBitmapset *a);
|
||||
|
||||
/* optimized tests when we don't need to know exact membership count: */
|
||||
PG_BMS_Membership bms_membership(const PGBitmapset *a);
|
||||
bool bms_is_empty(const PGBitmapset *a);
|
||||
|
||||
/* these routines recycle (modify or free) their non-const inputs: */
|
||||
|
||||
PGBitmapset *bms_add_member(PGBitmapset *a, int x);
|
||||
PGBitmapset *bms_del_member(PGBitmapset *a, int x);
|
||||
PGBitmapset *bms_add_members(PGBitmapset *a, const PGBitmapset *b);
|
||||
PGBitmapset *bms_int_members(PGBitmapset *a, const PGBitmapset *b);
|
||||
PGBitmapset *bms_del_members(PGBitmapset *a, const PGBitmapset *b);
|
||||
PGBitmapset *bms_join(PGBitmapset *a, PGBitmapset *b);
|
||||
|
||||
/* support for iterating through the integer elements of a set: */
|
||||
int bms_first_member(PGBitmapset *a);
|
||||
int bms_next_member(const PGBitmapset *a, int prevbit);
|
||||
|
||||
/* support for hashtables using Bitmapsets as keys: */
|
||||
uint32_t bms_hash_value(const PGBitmapset *a);
|
||||
|
||||
}
|
||||
44
external/duckdb/third_party/libpg_query/include/nodes/lockoptions.hpp
vendored
Executable file
44
external/duckdb/third_party/libpg_query/include/nodes/lockoptions.hpp
vendored
Executable file
@@ -0,0 +1,44 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* lockoptions.h
|
||||
* Common header for some locking-related declarations.
|
||||
*
|
||||
*
|
||||
* Copyright (c) 2014-2017, PostgreSQL Global Development PGGroup
|
||||
*
|
||||
* src/include/nodes/lockoptions.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#pragma once
|
||||
namespace duckdb_libpgquery {
|
||||
|
||||
/*
|
||||
* This enum represents the different strengths of FOR UPDATE/SHARE clauses.
|
||||
* The ordering here is important, because the highest numerical value takes
|
||||
* precedence when a RTE is specified multiple ways. See applyLockingClause.
|
||||
*/
|
||||
typedef enum PGLockClauseStrength {
|
||||
PG_LCS_NONE, /* no such clause - only used in PGPlanRowMark */
|
||||
PG_LCS_FORKEYSHARE, /* FOR KEY SHARE */
|
||||
PG_LCS_FORSHARE, /* FOR SHARE */
|
||||
PG_LCS_FORNOKEYUPDATE, /* FOR NO KEY UPDATE */
|
||||
LCS_FORUPDATE /* FOR UPDATE */
|
||||
} PGLockClauseStrength;
|
||||
|
||||
/*
|
||||
* This enum controls how to deal with rows being locked by FOR UPDATE/SHARE
|
||||
* clauses (i.e., it represents the NOWAIT and SKIP LOCKED options).
|
||||
* The ordering here is important, because the highest numerical value takes
|
||||
* precedence when a RTE is specified multiple ways. See applyLockingClause.
|
||||
*/
|
||||
typedef enum PGLockWaitPolicy {
|
||||
/* Wait for the lock to become available (default behavior) */
|
||||
PGLockWaitBlock,
|
||||
/* Skip rows that can't be locked (SKIP LOCKED) */
|
||||
PGLockWaitSkip,
|
||||
/* Raise an error if a row cannot be locked (NOWAIT) */
|
||||
LockWaitError
|
||||
} PGLockWaitPolicy;
|
||||
|
||||
}
|
||||
69
external/duckdb/third_party/libpg_query/include/nodes/makefuncs.hpp
vendored
Executable file
69
external/duckdb/third_party/libpg_query/include/nodes/makefuncs.hpp
vendored
Executable file
@@ -0,0 +1,69 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* makefuncs.h
|
||||
* prototypes for the creator functions (for primitive nodes)
|
||||
*
|
||||
*
|
||||
* Portions Copyright (c) 1996-2017, PostgreSQL Global Development PGGroup
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/nodes/makefuncs.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "nodes/parsenodes.hpp"
|
||||
|
||||
namespace duckdb_libpgquery {
|
||||
|
||||
PGAExpr *makeAExpr(PGAExpr_Kind kind, PGList *name, PGNode *lexpr, PGNode *rexpr, int location);
|
||||
|
||||
PGAExpr *makeSimpleAExpr(PGAExpr_Kind kind, const char *name, PGNode *lexpr, PGNode *rexpr, int location);
|
||||
|
||||
PGVar *makeVar(PGIndex varno, PGAttrNumber varattno, PGOid vartype, int32_t vartypmod, PGOid varcollid,
|
||||
PGIndex varlevelsup);
|
||||
|
||||
PGVar *makeVarFromTargetEntry(PGIndex varno, PGTargetEntry *tle);
|
||||
|
||||
PGVar *makeWholeRowVar(PGRangeTblEntry *rte, PGIndex varno, PGIndex varlevelsup, bool allowScalar);
|
||||
|
||||
PGTargetEntry *makeTargetEntry(PGExpr *expr, PGAttrNumber resno, char *resname, bool resjunk);
|
||||
|
||||
PGTargetEntry *flatCopyTargetEntry(PGTargetEntry *src_tle);
|
||||
|
||||
PGFromExpr *makeFromExpr(PGList *fromlist, PGNode *quals);
|
||||
|
||||
PGConst *makeConst(PGOid consttype, int32_t consttypmod, PGOid constcollid, int constlen, PGDatum constvalue,
|
||||
bool constisnull, bool constbyval);
|
||||
|
||||
PGConst *makeNullConst(PGOid consttype, int32_t consttypmod, PGOid constcollid);
|
||||
|
||||
PGNode *makeBoolConst(bool value, bool isnull);
|
||||
|
||||
PGExpr *makeBoolExpr(PGBoolExprType boolop, PGList *args, int location);
|
||||
|
||||
PGAlias *makeAlias(const char *aliasname, PGList *colnames);
|
||||
|
||||
PGRelabelType *makeRelabelType(PGExpr *arg, PGOid rtype, int32_t rtypmod, PGOid rcollid, PGCoercionForm rformat);
|
||||
|
||||
PGRangeVar *makeRangeVar(char *schemaname, char *relname, int location);
|
||||
|
||||
PGTypeName *makeTypeName(char *typnam);
|
||||
PGTypeName *makeTypeNameFromNameList(PGList *names);
|
||||
PGTypeName *makeTypeNameFromOid(PGOid typeOid, int32_t typmod);
|
||||
|
||||
PGColumnDef *makeColumnDef(const char *colname, PGOid typeOid, int32_t typmod, PGOid collOid);
|
||||
|
||||
PGFuncExpr *makeFuncExpr(PGOid funcid, PGOid rettype, PGList *args, PGOid funccollid, PGOid inputcollid,
|
||||
PGCoercionForm fformat);
|
||||
|
||||
PGFuncCall *makeFuncCall(PGList *name, PGList *args, int location);
|
||||
|
||||
PGDefElem *makeDefElem(const char *name, PGNode *arg, int location);
|
||||
PGDefElem *makeDefElemExtended(const char *nameSpace, const char *name, PGNode *arg, PGDefElemAction defaction,
|
||||
int location);
|
||||
|
||||
PGGroupingSet *makeGroupingSet(GroupingSetKind kind, PGList *content, int location);
|
||||
|
||||
}
|
||||
68
external/duckdb/third_party/libpg_query/include/nodes/nodeFuncs.hpp
vendored
Executable file
68
external/duckdb/third_party/libpg_query/include/nodes/nodeFuncs.hpp
vendored
Executable file
@@ -0,0 +1,68 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* nodeFuncs.h
|
||||
* Various general-purpose manipulations of PGNode trees
|
||||
*
|
||||
* Portions Copyright (c) 1996-2017, PostgreSQL Global Development PGGroup
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/nodes/nodeFuncs.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "nodes/parsenodes.hpp"
|
||||
|
||||
namespace duckdb_libpgquery {
|
||||
|
||||
/* flags bits for query_tree_walker and query_tree_mutator */
|
||||
#define QTW_IGNORE_RT_SUBQUERIES 0x01 /* subqueries in rtable */
|
||||
#define QTW_IGNORE_CTE_SUBQUERIES 0x02 /* subqueries in cteList */
|
||||
#define QTW_IGNORE_RC_SUBQUERIES 0x03 /* both of above */
|
||||
#define QTW_IGNORE_JOINALIASES 0x04 /* JOIN alias var lists */
|
||||
#define QTW_IGNORE_RANGE_TABLE 0x08 /* skip rangetable entirely */
|
||||
#define QTW_EXAMINE_RTES 0x10 /* examine RTEs */
|
||||
#define QTW_DONT_COPY_QUERY 0x20 /* do not copy top PGQuery */
|
||||
|
||||
/* callback function for check_functions_in_node */
|
||||
typedef bool (*check_function_callback)(PGOid func_id, void *context);
|
||||
|
||||
PGOid exprType(const PGNode *expr);
|
||||
int32_t exprTypmod(const PGNode *expr);
|
||||
bool exprIsLengthCoercion(const PGNode *expr, int32_t *coercedTypmod);
|
||||
PGNode *relabel_to_typmod(PGNode *expr, int32_t typmod);
|
||||
PGNode *strip_implicit_coercions(PGNode *node);
|
||||
bool expression_returns_set(PGNode *clause);
|
||||
|
||||
PGOid exprCollation(const PGNode *expr);
|
||||
PGOid exprInputCollation(const PGNode *expr);
|
||||
void exprSetCollation(PGNode *expr, PGOid collation);
|
||||
void exprSetInputCollation(PGNode *expr, PGOid inputcollation);
|
||||
|
||||
int exprLocation(const PGNode *expr);
|
||||
|
||||
void fix_opfuncids(PGNode *node);
|
||||
void set_opfuncid(PGOpExpr *opexpr);
|
||||
void set_sa_opfuncid(PGScalarArrayOpExpr *opexpr);
|
||||
|
||||
bool check_functions_in_node(PGNode *node, check_function_callback checker, void *context);
|
||||
|
||||
bool expression_tree_walker(PGNode *node, bool (*walker)(), void *context);
|
||||
PGNode *expression_tree_mutator(PGNode *node, PGNode *(*mutator)(), void *context);
|
||||
|
||||
bool query_tree_walker(PGQuery *query, bool (*walker)(), void *context, int flags);
|
||||
PGQuery *query_tree_mutator(PGQuery *query, PGNode *(*mutator)(), void *context, int flags);
|
||||
|
||||
bool range_table_walker(PGList *rtable, bool (*walker)(), void *context, int flags);
|
||||
PGList *range_table_mutator(PGList *rtable, PGNode *(*mutator)(), void *context, int flags);
|
||||
|
||||
bool query_or_expression_tree_walker(PGNode *node, bool (*walker)(), void *context, int flags);
|
||||
PGNode *query_or_expression_tree_mutator(PGNode *node, PGNode *(*mutator)(), void *context, int flags);
|
||||
|
||||
bool raw_expression_tree_walker(PGNode *node, bool (*walker)(), void *context);
|
||||
|
||||
struct PlanState;
|
||||
bool planstate_tree_walker(struct PlanState *planstate, bool (*walker)(), void *context);
|
||||
|
||||
}
|
||||
836
external/duckdb/third_party/libpg_query/include/nodes/nodes.hpp
vendored
Executable file
836
external/duckdb/third_party/libpg_query/include/nodes/nodes.hpp
vendored
Executable file
@@ -0,0 +1,836 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* nodes.h
|
||||
* Definitions for tagged nodes.
|
||||
*
|
||||
*
|
||||
* Portions Copyright (c) 1996-2017, PostgreSQL Global Development PGGroup
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/nodes/nodes.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "pg_definitions.hpp"
|
||||
|
||||
namespace duckdb_libpgquery {
|
||||
|
||||
/*
|
||||
* The first field of every node is NodeTag. Each node created (with makeNode)
|
||||
* will have one of the following tags as the value of its first field.
|
||||
*
|
||||
* Note that inserting or deleting node types changes the numbers of other
|
||||
* node types later in the list. This is no problem during development, since
|
||||
* the node numbers are never stored on disk. But don't do it in a released
|
||||
* branch, because that would represent an ABI break for extensions.
|
||||
*/
|
||||
typedef enum PGNodeTag {
|
||||
T_PGInvalid = 0,
|
||||
|
||||
/*
|
||||
* TAGS FOR EXECUTOR NODES (execnodes.h)
|
||||
*/
|
||||
T_PGIndexInfo,
|
||||
T_PGExprContext,
|
||||
T_PGProjectionInfo,
|
||||
T_PGJunkFilter,
|
||||
T_PGResultRelInfo,
|
||||
T_PGEState,
|
||||
T_PGTupleTableSlot,
|
||||
|
||||
/*
|
||||
* TAGS FOR PLAN NODES (plannodes.h)
|
||||
*/
|
||||
T_PGPlan,
|
||||
T_PGResult,
|
||||
T_PGProjectSet,
|
||||
T_PGModifyTable,
|
||||
T_PGAppend,
|
||||
T_PGMergeAppend,
|
||||
T_PGRecursiveUnion,
|
||||
T_PGBitmapAnd,
|
||||
T_PGBitmapOr,
|
||||
T_PGScan,
|
||||
T_PGSeqScan,
|
||||
T_PGSampleScan,
|
||||
T_PGIndexScan,
|
||||
T_PGIndexOnlyScan,
|
||||
T_PGBitmapIndexScan,
|
||||
T_PGBitmapHeapScan,
|
||||
T_PGTidScan,
|
||||
T_PGSubqueryScan,
|
||||
T_PGFunctionScan,
|
||||
T_PGValuesScan,
|
||||
T_PGTableFuncScan,
|
||||
T_PGCteScan,
|
||||
T_PGNamedTuplestoreScan,
|
||||
T_PGWorkTableScan,
|
||||
T_PGForeignScan,
|
||||
T_PGCustomScan,
|
||||
T_PGJoin,
|
||||
T_PGNestLoop,
|
||||
T_PGMergeJoin,
|
||||
T_PGHashJoin,
|
||||
T_PGMaterial,
|
||||
T_PGSort,
|
||||
T_PGGroup,
|
||||
T_PGAgg,
|
||||
T_PGWindowAgg,
|
||||
T_PGUnique,
|
||||
T_PGGather,
|
||||
T_PGGatherMerge,
|
||||
T_PGHash,
|
||||
T_PGSetOp,
|
||||
T_PGLockRows,
|
||||
T_PGLimit,
|
||||
/* these aren't subclasses of PGPlan: */
|
||||
T_PGNestLoopParam,
|
||||
T_PGPlanRowMark,
|
||||
T_PGPlanInvalItem,
|
||||
|
||||
/*
|
||||
* TAGS FOR PLAN STATE NODES (execnodes.h)
|
||||
*
|
||||
* These should correspond one-to-one with PGPlan node types.
|
||||
*/
|
||||
T_PGPlanState,
|
||||
T_PGResultState,
|
||||
T_PGProjectSetState,
|
||||
T_PGModifyTableState,
|
||||
T_PGAppendState,
|
||||
T_PGMergeAppendState,
|
||||
T_PGRecursiveUnionState,
|
||||
T_PGBitmapAndState,
|
||||
T_PGBitmapOrState,
|
||||
T_PGScanState,
|
||||
T_PGSeqScanState,
|
||||
T_PGSampleScanState,
|
||||
T_PGIndexScanState,
|
||||
T_PGIndexOnlyScanState,
|
||||
T_PGBitmapIndexScanState,
|
||||
T_PGBitmapHeapScanState,
|
||||
T_PGTidScanState,
|
||||
T_PGSubqueryScanState,
|
||||
T_PGFunctionScanState,
|
||||
T_PGTableFuncScanState,
|
||||
T_PGValuesScanState,
|
||||
T_PGCteScanState,
|
||||
T_PGNamedTuplestoreScanState,
|
||||
T_PGWorkTableScanState,
|
||||
T_PGForeignScanState,
|
||||
T_PGCustomScanState,
|
||||
T_PGJoinState,
|
||||
T_PGNestLoopState,
|
||||
T_PGMergeJoinState,
|
||||
T_PGHashJoinState,
|
||||
T_PGMaterialState,
|
||||
T_PGSortState,
|
||||
T_PGGroupState,
|
||||
T_PGAggState,
|
||||
T_PGWindowAggState,
|
||||
T_PGUniqueState,
|
||||
T_PGGatherState,
|
||||
T_PGGatherMergeState,
|
||||
T_PGHashState,
|
||||
T_PGSetOpState,
|
||||
T_PGLockRowsState,
|
||||
T_PGLimitState,
|
||||
|
||||
/*
|
||||
* TAGS FOR PRIMITIVE NODES (primnodes.h)
|
||||
*/
|
||||
T_PGAlias,
|
||||
T_PGRangeVar,
|
||||
T_PGTableFunc,
|
||||
T_PGExpr,
|
||||
T_PGVar,
|
||||
T_PGConst,
|
||||
T_PGParam,
|
||||
T_PGAggref,
|
||||
T_PGGroupingFunc,
|
||||
T_PGWindowFunc,
|
||||
T_PGArrayRef,
|
||||
T_PGFuncExpr,
|
||||
T_PGNamedArgExpr,
|
||||
T_PGOpExpr,
|
||||
T_PGDistinctExpr,
|
||||
T_PGNullIfExpr,
|
||||
T_PGScalarArrayOpExpr,
|
||||
T_PGBoolExpr,
|
||||
T_PGSubLink,
|
||||
T_PGSubPlan,
|
||||
T_PGAlternativeSubPlan,
|
||||
T_PGFieldSelect,
|
||||
T_PGFieldStore,
|
||||
T_PGRelabelType,
|
||||
T_PGCoerceViaIO,
|
||||
T_PGArrayCoerceExpr,
|
||||
T_PGConvertRowtypeExpr,
|
||||
T_PGCollateExpr,
|
||||
T_PGCaseExpr,
|
||||
T_PGCaseWhen,
|
||||
T_PGCaseTestExpr,
|
||||
T_PGArrayExpr,
|
||||
T_PGRowExpr,
|
||||
T_PGRowCompareExpr,
|
||||
T_PGCoalesceExpr,
|
||||
T_PGMinMaxExpr,
|
||||
T_PGSQLValueFunction,
|
||||
T_PGXmlExpr,
|
||||
T_PGNullTest,
|
||||
T_PGBooleanTest,
|
||||
T_PGCoerceToDomain,
|
||||
T_PGCoerceToDomainValue,
|
||||
T_PGSetToDefault,
|
||||
T_PGCurrentOfExpr,
|
||||
T_PGNextValueExpr,
|
||||
T_PGInferenceElem,
|
||||
T_PGTargetEntry,
|
||||
T_PGRangeTblRef,
|
||||
T_PGJoinExpr,
|
||||
T_PGFromExpr,
|
||||
T_PGOnConflictExpr,
|
||||
T_PGIntoClause,
|
||||
T_PGLambdaFunction,
|
||||
T_PGPivotExpr,
|
||||
T_PGPivot,
|
||||
T_PGPivotStmt,
|
||||
T_PGAtClause,
|
||||
T_PGSingleArrowFunction,
|
||||
|
||||
/*
|
||||
* TAGS FOR EXPRESSION STATE NODES (execnodes.h)
|
||||
*
|
||||
* ExprState represents the evaluation state for a whole expression tree.
|
||||
* Most Expr-based plan nodes do not have a corresponding expression state
|
||||
* node, they're fully handled within execExpr* - but sometimes the state
|
||||
* needs to be shared with other parts of the executor, as for example
|
||||
* with AggrefExprState, which nodeAgg.c has to modify.
|
||||
*/
|
||||
T_PGExprState,
|
||||
T_PGAggrefExprState,
|
||||
T_PGWindowFuncExprState,
|
||||
T_PGSetExprState,
|
||||
T_PGSubPlanState,
|
||||
T_PGAlternativeSubPlanState,
|
||||
T_PGDomainConstraintState,
|
||||
|
||||
/*
|
||||
* TAGS FOR PLANNER NODES (relation.h)
|
||||
*/
|
||||
T_PGPlannerInfo,
|
||||
T_PGPlannerGlobal,
|
||||
T_PGRelOptInfo,
|
||||
T_PGIndexOptInfo,
|
||||
T_PGForeignKeyOptInfo,
|
||||
T_PGParamPathInfo,
|
||||
T_PGPath,
|
||||
T_PGIndexPath,
|
||||
T_PGBitmapHeapPath,
|
||||
T_PGBitmapAndPath,
|
||||
T_PGBitmapOrPath,
|
||||
T_PGTidPath,
|
||||
T_PGSubqueryScanPath,
|
||||
T_PGForeignPath,
|
||||
T_PGCustomPath,
|
||||
T_PGNestPath,
|
||||
T_PGMergePath,
|
||||
T_PGHashPath,
|
||||
T_PGAppendPath,
|
||||
T_PGMergeAppendPath,
|
||||
T_PGResultPath,
|
||||
T_PGMaterialPath,
|
||||
T_PGUniquePath,
|
||||
T_PGGatherPath,
|
||||
T_PGGatherMergePath,
|
||||
T_PGProjectionPath,
|
||||
T_PGProjectSetPath,
|
||||
T_PGSortPath,
|
||||
T_PGGroupPath,
|
||||
T_PGUpperUniquePath,
|
||||
T_PGAggPath,
|
||||
T_PGGroupingSetsPath,
|
||||
T_PGMinMaxAggPath,
|
||||
T_PGWindowAggPath,
|
||||
T_PGSetOpPath,
|
||||
T_PGRecursiveUnionPath,
|
||||
T_PGLockRowsPath,
|
||||
T_PGModifyTablePath,
|
||||
T_PGLimitPath,
|
||||
/* these aren't subclasses of Path: */
|
||||
T_PGEquivalenceClass,
|
||||
T_PGEquivalenceMember,
|
||||
T_PGPathKey,
|
||||
T_PGPathTarget,
|
||||
T_PGRestrictInfo,
|
||||
T_PGPlaceHolderVar,
|
||||
T_PGSpecialJoinInfo,
|
||||
T_PGAppendRelInfo,
|
||||
T_PGPartitionedChildRelInfo,
|
||||
T_PGPlaceHolderInfo,
|
||||
T_PGMinMaxAggInfo,
|
||||
T_PGPlannerParamItem,
|
||||
T_PGRollupData,
|
||||
T_PGGroupingSetData,
|
||||
T_PGStatisticExtInfo,
|
||||
|
||||
/*
|
||||
* TAGS FOR MEMORY NODES (memnodes.h)
|
||||
*/
|
||||
T_PGMemoryContext,
|
||||
T_PGAllocSetContext,
|
||||
T_PGSlabContext,
|
||||
|
||||
/*
|
||||
* TAGS FOR VALUE NODES (value.h)
|
||||
*/
|
||||
T_PGValue,
|
||||
T_PGInteger,
|
||||
T_PGFloat,
|
||||
T_PGString,
|
||||
T_PGBitString,
|
||||
T_PGNull,
|
||||
|
||||
/*
|
||||
* TAGS FOR LIST NODES (pg_list.h)
|
||||
*/
|
||||
T_PGList,
|
||||
T_PGIntList,
|
||||
T_PGOidList,
|
||||
|
||||
/*
|
||||
* TAGS FOR EXTENSIBLE NODES (extensible.h)
|
||||
*/
|
||||
T_PGExtensibleNode,
|
||||
|
||||
/*
|
||||
* TAGS FOR STATEMENT NODES (mostly in parsenodes.h)
|
||||
*/
|
||||
T_PGRawStmt,
|
||||
T_PGQuery,
|
||||
T_PGPlannedStmt,
|
||||
T_PGInsertStmt,
|
||||
T_PGDeleteStmt,
|
||||
T_PGUpdateStmt,
|
||||
T_PGUpdateExtensionsStmt,
|
||||
T_PGSelectStmt,
|
||||
T_PGAlterTableStmt,
|
||||
T_PGAlterTableCmd,
|
||||
T_PGAlterDomainStmt,
|
||||
T_PGSetOperationStmt,
|
||||
T_PGGrantStmt,
|
||||
T_PGGrantRoleStmt,
|
||||
T_PGAlterDefaultPrivilegesStmt,
|
||||
T_PGClosePortalStmt,
|
||||
T_PGClusterStmt,
|
||||
T_PGCopyStmt,
|
||||
T_PGCopyDatabaseStmt,
|
||||
T_PGCreateStmt,
|
||||
T_PGDefineStmt,
|
||||
T_PGDropStmt,
|
||||
T_PGTruncateStmt,
|
||||
T_PGCommentStmt,
|
||||
T_PGCommentOnStmt,
|
||||
T_PGMergeIntoStmt,
|
||||
T_PGFetchStmt,
|
||||
T_PGIndexStmt,
|
||||
T_PGFunctionDefinition,
|
||||
T_PGCreateFunctionStmt,
|
||||
T_PGAlterFunctionStmt,
|
||||
T_PGDoStmt,
|
||||
T_PGRenameStmt,
|
||||
T_PGRuleStmt,
|
||||
T_PGNotifyStmt,
|
||||
T_PGListenStmt,
|
||||
T_PGUnlistenStmt,
|
||||
T_PGTransactionStmt,
|
||||
T_PGViewStmt,
|
||||
T_PGLoadStmt,
|
||||
T_PGCreateDomainStmt,
|
||||
T_PGCreatedbStmt,
|
||||
T_PGDropdbStmt,
|
||||
T_PGVacuumStmt,
|
||||
T_PGExplainStmt,
|
||||
T_PGCreateTableAsStmt,
|
||||
T_PGCreateSeqStmt,
|
||||
T_PGAlterSeqStmt,
|
||||
T_PGVariableSetStmt,
|
||||
T_PGVariableShowStmt,
|
||||
T_PGVariableShowSelectStmt,
|
||||
T_PGDiscardStmt,
|
||||
T_PGCreateTrigStmt,
|
||||
T_PGCreatePLangStmt,
|
||||
T_PGCreateRoleStmt,
|
||||
T_PGAlterRoleStmt,
|
||||
T_PGDropRoleStmt,
|
||||
T_PGLockStmt,
|
||||
T_PGConstraintsSetStmt,
|
||||
T_PGReindexStmt,
|
||||
T_PGCheckPointStmt,
|
||||
T_PGCreateSchemaStmt,
|
||||
T_PGCreateSecretStmt,
|
||||
T_PGAlterDatabaseStmt,
|
||||
T_PGAlterDatabaseSetStmt,
|
||||
T_PGAlterRoleSetStmt,
|
||||
T_PGCreateConversionStmt,
|
||||
T_PGCreateCastStmt,
|
||||
T_PGCreateOpClassStmt,
|
||||
T_PGCreateOpFamilyStmt,
|
||||
T_PGAlterOpFamilyStmt,
|
||||
T_PGPrepareStmt,
|
||||
T_PGExecuteStmt,
|
||||
T_PGCallStmt,
|
||||
T_PGDeallocateStmt,
|
||||
T_PGDeclareCursorStmt,
|
||||
T_PGCreateTableSpaceStmt,
|
||||
T_PGDropSecretStmt,
|
||||
T_PGDropTableSpaceStmt,
|
||||
T_PGAlterObjectDependsStmt,
|
||||
T_PGAlterObjectSchemaStmt,
|
||||
T_PGAlterOwnerStmt,
|
||||
T_PGAlterOperatorStmt,
|
||||
T_PGDropOwnedStmt,
|
||||
T_PGReassignOwnedStmt,
|
||||
T_PGCompositeTypeStmt,
|
||||
T_PGCreateTypeStmt,
|
||||
T_PGCreateRangeStmt,
|
||||
T_PGAlterEnumStmt,
|
||||
T_PGAlterTSDictionaryStmt,
|
||||
T_PGAlterTSConfigurationStmt,
|
||||
T_PGCreateFdwStmt,
|
||||
T_PGAlterFdwStmt,
|
||||
T_PGCreateForeignServerStmt,
|
||||
T_PGAlterForeignServerStmt,
|
||||
T_PGCreateUserMappingStmt,
|
||||
T_PGAlterUserMappingStmt,
|
||||
T_PGDropUserMappingStmt,
|
||||
T_PGAlterTableSpaceOptionsStmt,
|
||||
T_PGAlterTableMoveAllStmt,
|
||||
T_PGSecLabelStmt,
|
||||
T_PGCreateForeignTableStmt,
|
||||
T_PGImportForeignSchemaStmt,
|
||||
T_PGCreateExtensionStmt,
|
||||
T_PGAlterExtensionStmt,
|
||||
T_PGAlterExtensionContentsStmt,
|
||||
T_PGCreateEventTrigStmt,
|
||||
T_PGAlterEventTrigStmt,
|
||||
T_PGRefreshMatViewStmt,
|
||||
T_PGReplicaIdentityStmt,
|
||||
T_PGAlterSystemStmt,
|
||||
T_PGCreatePolicyStmt,
|
||||
T_PGAlterPolicyStmt,
|
||||
T_PGCreateTransformStmt,
|
||||
T_PGCreateAmStmt,
|
||||
T_PGCreatePublicationStmt,
|
||||
T_PGAlterPublicationStmt,
|
||||
T_PGCreateSubscriptionStmt,
|
||||
T_PGAlterSubscriptionStmt,
|
||||
T_PGDropSubscriptionStmt,
|
||||
T_PGCreateStatsStmt,
|
||||
T_PGAlterCollationStmt,
|
||||
T_PGPragmaStmt,
|
||||
T_PGExportStmt,
|
||||
T_PGImportStmt,
|
||||
T_PGAttachStmt,
|
||||
T_PGDetachStmt,
|
||||
T_PGUseStmt,
|
||||
|
||||
/*
|
||||
* TAGS FOR PARSE TREE NODES (parsenodes.h)
|
||||
*/
|
||||
T_PGAExpr,
|
||||
T_PGColumnRef,
|
||||
T_PGParamRef,
|
||||
T_PGAConst,
|
||||
T_PGFuncCall,
|
||||
T_PGAStar,
|
||||
T_PGAIndices,
|
||||
T_PGAIndirection,
|
||||
T_PGAArrayExpr,
|
||||
T_PGResTarget,
|
||||
T_PGMultiAssignRef,
|
||||
T_PGTypeCast,
|
||||
T_PGCollateClause,
|
||||
T_PGSortBy,
|
||||
T_PGWindowDef,
|
||||
T_PGRangeSubselect,
|
||||
T_PGRangeFunction,
|
||||
T_PGRangeTableSample,
|
||||
T_PGRangeTableFunc,
|
||||
T_PGRangeTableFuncCol,
|
||||
T_PGTypeName,
|
||||
T_PGColumnDef,
|
||||
T_PGIndexElem,
|
||||
T_PGConstraint,
|
||||
T_PGDefElem,
|
||||
T_PGRangeTblEntry,
|
||||
T_PGRangeTblFunction,
|
||||
T_PGTableSampleClause,
|
||||
T_PGWithCheckOption,
|
||||
T_PGSortGroupClause,
|
||||
T_PGGroupingSet,
|
||||
T_PGWindowClause,
|
||||
T_PGObjectWithArgs,
|
||||
T_PGAccessPriv,
|
||||
T_PGCreateOpClassItem,
|
||||
T_PGTableLikeClause,
|
||||
T_PGFunctionParameter,
|
||||
T_PGLockingClause,
|
||||
T_PGRowMarkClause,
|
||||
T_PGXmlSerialize,
|
||||
T_PGWithClause,
|
||||
T_PGInferClause,
|
||||
T_PGOnConflictClause,
|
||||
T_PGCommonTableExpr,
|
||||
T_PGRoleSpec,
|
||||
T_PGTriggerTransition,
|
||||
T_PGPartitionElem,
|
||||
T_PGPartitionSpec,
|
||||
T_PGPartitionBoundSpec,
|
||||
T_PGPartitionRangeDatum,
|
||||
T_PGPartitionCmd,
|
||||
T_PGIntervalConstant,
|
||||
T_PGSampleSize,
|
||||
T_PGSampleOptions,
|
||||
T_PGLimitPercent,
|
||||
T_PGPositionalReference,
|
||||
T_PGMatchEntry,
|
||||
T_PGMatchAction,
|
||||
|
||||
/*
|
||||
* TAGS FOR REPLICATION GRAMMAR PARSE NODES (replnodes.h)
|
||||
*/
|
||||
T_PGIdentifySystemCmd,
|
||||
T_PGBaseBackupCmd,
|
||||
T_PGCreateReplicationSlotCmd,
|
||||
T_PGDropReplicationSlotCmd,
|
||||
T_PGStartReplicationCmd,
|
||||
T_PGTimeLineHistoryCmd,
|
||||
T_PGSQLCmd,
|
||||
|
||||
/*
|
||||
* TAGS FOR RANDOM OTHER STUFF
|
||||
*
|
||||
* These are objects that aren't part of parse/plan/execute node tree
|
||||
* structures, but we give them NodeTags anyway for identification
|
||||
* purposes (usually because they are involved in APIs where we want to
|
||||
* pass multiple object types through the same pointer).
|
||||
*/
|
||||
T_PGTriggerData, /* in commands/trigger.h */
|
||||
T_PGEventTriggerData, /* in commands/event_trigger.h */
|
||||
T_PGReturnSetInfo, /* in nodes/execnodes.h */
|
||||
T_PGWindowObjectData, /* private in nodeWindowAgg.c */
|
||||
T_PGTIDBitmap, /* in nodes/tidbitmap.h */
|
||||
T_PGInlineCodeBlock, /* in nodes/parsenodes.h */
|
||||
T_PGFdwRoutine, /* in foreign/fdwapi.h */
|
||||
T_PGIndexAmRoutine, /* in access/amapi.h */
|
||||
T_PGTsmRoutine, /* in access/tsmapi.h */
|
||||
T_PGForeignKeyCacheInfo /* in utils/rel.h */
|
||||
} PGNodeTag;
|
||||
|
||||
/*
|
||||
* The first field of a node of any type is guaranteed to be the NodeTag.
|
||||
* Hence the type of any node can be gotten by casting it to Node. Declaring
|
||||
* a variable to be of PGNode * (instead of void *) can also facilitate
|
||||
* debugging.
|
||||
*/
|
||||
typedef struct PGNode {
|
||||
PGNodeTag type;
|
||||
} PGNode;
|
||||
|
||||
#define nodeTag(nodeptr) (((const PGNode *)(nodeptr))->type)
|
||||
|
||||
#define makeNode(_type_) ((_type_ *)newNode(sizeof(_type_), T_##_type_))
|
||||
|
||||
#define NodeSetTag(nodeptr, t) (((PGNode *)(nodeptr))->type = (t))
|
||||
|
||||
#define IsA(nodeptr, _type_) (nodeTag(nodeptr) == T_##_type_)
|
||||
|
||||
/*
|
||||
* castNode(type, ptr) casts ptr to "type *", and if assertions are enabled,
|
||||
* verifies that the node has the appropriate type (using its nodeTag()).
|
||||
*
|
||||
* Use an inline function when assertions are enabled, to avoid multiple
|
||||
* evaluations of the ptr argument (which could e.g. be a function call).
|
||||
*/
|
||||
#ifdef USE_ASSERT_CHECKING
|
||||
static inline PGNode *castNodeImpl(PGNodeTag type, void *ptr) {
|
||||
Assert(ptr == NULL || nodeTag(ptr) == type);
|
||||
return (PGNode *)ptr;
|
||||
}
|
||||
#define castNode(_type_, nodeptr) ((_type_ *)castNodeImpl(T_##_type_, nodeptr))
|
||||
#else
|
||||
#define castNode(_type_, nodeptr) ((_type_ *)(nodeptr))
|
||||
#endif /* USE_ASSERT_CHECKING */
|
||||
|
||||
/* ----------------------------------------------------------------
|
||||
* extern declarations follow
|
||||
* ----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
* nodes/{outfuncs.c,print.c}
|
||||
*/
|
||||
struct PGBitmapset; /* not to include bitmapset.h here */
|
||||
struct PGStringInfoData; /* not to include stringinfo.h here */
|
||||
|
||||
PGNode* newNode(size_t size, PGNodeTag type);
|
||||
|
||||
void outNode(struct PGStringInfoData *str, const void *obj);
|
||||
void outToken(struct PGStringInfoData *str, const char *s);
|
||||
void outBitmapset(struct PGStringInfoData *str, const struct PGBitmapset *bms);
|
||||
void outDatum(struct PGStringInfoData *str, uintptr_t value, int typlen, bool typbyval);
|
||||
char *nodeToString(const void *obj);
|
||||
char *bmsToString(const struct PGBitmapset *bms);
|
||||
|
||||
/*
|
||||
* nodes/{readfuncs.c,read.c}
|
||||
*/
|
||||
void *stringToNode(char *str);
|
||||
struct PGBitmapset *readBitmapset(void);
|
||||
uintptr_t readDatum(bool typbyval);
|
||||
bool *readBoolCols(int numCols);
|
||||
int *readIntCols(int numCols);
|
||||
PGOid *readOidCols(int numCols);
|
||||
int16_t *readAttrNumberCols(int numCols);
|
||||
|
||||
/*
|
||||
* nodes/copyfuncs.c
|
||||
*/
|
||||
void *copyObjectImpl(const void *obj);
|
||||
|
||||
/* cast result back to argument type, if supported by compiler */
|
||||
//#ifdef HAVE_TYPEOF
|
||||
//#define copyObject(obj) ((typeof(obj)) copyObjectImpl(obj))
|
||||
//#else
|
||||
//#define copyObject(obj) copyObjectImpl(obj)
|
||||
//#endif
|
||||
|
||||
/*
|
||||
* nodes/equalfuncs.c
|
||||
*/
|
||||
// extern bool equal(const void *a, const void *b);
|
||||
|
||||
/*
|
||||
* Typedefs for identifying qualifier selectivities and plan costs as such.
|
||||
* These are just plain "double"s, but declaring a variable as Selectivity
|
||||
* or Cost makes the intent more obvious.
|
||||
*
|
||||
* These could have gone into plannodes.h or some such, but many files
|
||||
* depend on them...
|
||||
*/
|
||||
typedef double Selectivity; /* fraction of tuples a qualifier will pass */
|
||||
typedef double Cost; /* execution cost (in page-access units) */
|
||||
|
||||
/*
|
||||
* PGCmdType -
|
||||
* enums for type of operation represented by a PGQuery or PGPlannedStmt
|
||||
*
|
||||
* This is needed in both parsenodes.h and plannodes.h, so put it here...
|
||||
*/
|
||||
typedef enum PGCmdType {
|
||||
PG_CMD_UNKNOWN,
|
||||
PG_CMD_SELECT, /* select stmt */
|
||||
PG_CMD_UPDATE, /* update stmt */
|
||||
PG_CMD_INSERT, /* insert stmt */
|
||||
PG_CMD_DELETE,
|
||||
PG_CMD_UTILITY, /* cmds like create, destroy, copy, vacuum,
|
||||
* etc. */
|
||||
PG_CMD_NOTHING /* dummy command for instead nothing rules
|
||||
* with qual */
|
||||
} PGCmdType;
|
||||
|
||||
/*
|
||||
* PGJoinType -
|
||||
* enums for types of relation joins
|
||||
*
|
||||
* PGJoinType determines the exact semantics of joining two relations using
|
||||
* a matching qualification. For example, it tells what to do with a tuple
|
||||
* that has no match in the other relation.
|
||||
*
|
||||
* This is needed in both parsenodes.h and plannodes.h, so put it here...
|
||||
*/
|
||||
typedef enum PGJoinType {
|
||||
/*
|
||||
* The canonical kinds of joins according to the SQL JOIN syntax. Only
|
||||
* these codes can appear in parser output (e.g., PGJoinExpr nodes).
|
||||
*/
|
||||
PG_JOIN_INNER, /* matching tuple pairs only */
|
||||
PG_JOIN_LEFT, /* pairs + unmatched LHS tuples */
|
||||
PG_JOIN_FULL, /* pairs + unmatched LHS + unmatched RHS */
|
||||
PG_JOIN_RIGHT, /* pairs + unmatched RHS tuples */
|
||||
|
||||
/*
|
||||
* Semijoins and anti-semijoins (as defined in relational theory) do not
|
||||
* appear in the SQL JOIN syntax, but there are standard idioms for
|
||||
* representing them (e.g., using EXISTS). The planner recognizes these
|
||||
* cases and converts them to joins. So the planner and executor must
|
||||
* support these codes. NOTE: in PG_JOIN_SEMI output, it is unspecified
|
||||
* which matching RHS row is joined to. In PG_JOIN_ANTI output, the row is
|
||||
* guaranteed to be null-extended.
|
||||
*/
|
||||
PG_JOIN_SEMI, /* 1 copy of each LHS row that has match(es) */
|
||||
PG_JOIN_ANTI, /* 1 copy of each LHS row that has no match */
|
||||
|
||||
/*
|
||||
* These codes are used internally in the planner, but are not supported
|
||||
* by the executor (nor, indeed, by most of the planner).
|
||||
*/
|
||||
PG_JOIN_UNIQUE_OUTER, /* LHS path must be made unique */
|
||||
PG_JOIN_UNIQUE_INNER, /* RHS path must be made unique */
|
||||
|
||||
/*
|
||||
* Positional joins are essentially parallel table scans.
|
||||
*/
|
||||
PG_JOIN_POSITION /* Two tables of the same length */
|
||||
|
||||
/*
|
||||
* We might need additional join types someday.
|
||||
*/
|
||||
} PGJoinType;
|
||||
|
||||
/*
|
||||
* PGJoinRefType -
|
||||
* enums for the types of implied conditions
|
||||
*
|
||||
* PGJoinRefType specifies the semantics of interpreting the join conditions.
|
||||
* These can be explicit (e.g., REGULAR) implied (e.g., NATURAL)
|
||||
* or interpreted in a particular manner (e.g., ASOF)
|
||||
*
|
||||
* This is a generalisation of the old Postgres isNatural flag.
|
||||
*/
|
||||
typedef enum PGJoinRefType {
|
||||
PG_JOIN_REGULAR, /* Join conditions are interpreted as is */
|
||||
PG_JOIN_NATURAL, /* Join conditions are inferred from the column names */
|
||||
|
||||
/*
|
||||
* ASOF joins are joins with a single inequality predicate
|
||||
* and optional equality predicates.
|
||||
* The semantics are equivalent to the following window join:
|
||||
* times t
|
||||
* <jointype> JOIN (
|
||||
* SELECT *,
|
||||
* LEAD(begin, 1, 'infinity') OVER ([PARTITION BY key] ORDER BY begin) AS end)
|
||||
* FROM events) e
|
||||
* ON t.ts >= e.begin AND t.ts < e.end [AND t.key = e.key]
|
||||
*/
|
||||
PG_JOIN_ASOF
|
||||
|
||||
/*
|
||||
* Positional join is a candidate to move here
|
||||
*/
|
||||
} PGJoinRefType;
|
||||
|
||||
/*
|
||||
* OUTER joins are those for which pushed-down quals must behave differently
|
||||
* from the join's own quals. This is in fact everything except INNER and
|
||||
* SEMI joins. However, this macro must also exclude the JOIN_UNIQUE symbols
|
||||
* since those are temporary proxies for what will eventually be an INNER
|
||||
* join.
|
||||
*
|
||||
* Note: semijoins are a hybrid case, but we choose to treat them as not
|
||||
* being outer joins. This is okay principally because the SQL syntax makes
|
||||
* it impossible to have a pushed-down qual that refers to the inner relation
|
||||
* of a semijoin; so there is no strong need to distinguish join quals from
|
||||
* pushed-down quals. This is convenient because for almost all purposes,
|
||||
* quals attached to a semijoin can be treated the same as innerjoin quals.
|
||||
*/
|
||||
#define IS_OUTER_JOIN(jointype) \
|
||||
(((1 << (jointype)) & ((1 << PG_JOIN_LEFT) | (1 << PG_JOIN_FULL) | (1 << PG_JOIN_RIGHT) | (1 << PG_JOIN_ANTI))) != 0)
|
||||
|
||||
/*
|
||||
* PGAggStrategy -
|
||||
* overall execution strategies for PGAgg plan nodes
|
||||
*
|
||||
* This is needed in both plannodes.h and relation.h, so put it here...
|
||||
*/
|
||||
typedef enum PGAggStrategy {
|
||||
PG_AGG_PLAIN, /* simple agg across all input rows */
|
||||
PG_AGG_SORTED, /* grouped agg, input must be sorted */
|
||||
PG_AGG_HASHED, /* grouped agg, use internal hashtable */
|
||||
AGG_MIXED /* grouped agg, hash and sort both used */
|
||||
} PGAggStrategy;
|
||||
|
||||
/*
|
||||
* PGAggSplit -
|
||||
* splitting (partial aggregation) modes for PGAgg plan nodes
|
||||
*
|
||||
* This is needed in both plannodes.h and relation.h, so put it here...
|
||||
*/
|
||||
|
||||
/* Primitive options supported by nodeAgg.c: */
|
||||
#define AGGSPLITOP_COMBINE 0x01 /* substitute combinefn for transfn */
|
||||
#define AGGSPLITOP_SKIPFINAL 0x02 /* skip finalfn, return state as-is */
|
||||
#define AGGSPLITOP_SERIALIZE 0x04 /* apply serializefn to output */
|
||||
#define AGGSPLITOP_DESERIALIZE 0x08 /* apply deserializefn to input */
|
||||
|
||||
/* Supported operating modes (i.e., useful combinations of these options): */
|
||||
typedef enum PGAggSplit {
|
||||
/* Basic, non-split aggregation: */
|
||||
PG_AGGSPLIT_SIMPLE = 0,
|
||||
/* Initial phase of partial aggregation, with serialization: */
|
||||
PG_AGGSPLIT_INITIAL_SERIAL = AGGSPLITOP_SKIPFINAL | AGGSPLITOP_SERIALIZE,
|
||||
/* Final phase of partial aggregation, with deserialization: */
|
||||
PG_AGGSPLIT_FINAL_DESERIAL = AGGSPLITOP_COMBINE | AGGSPLITOP_DESERIALIZE
|
||||
} PGAggSplit;
|
||||
|
||||
/* Test whether an PGAggSplit value selects each primitive option: */
|
||||
#define DO_AGGSPLIT_COMBINE(as) (((as)&AGGSPLITOP_COMBINE) != 0)
|
||||
#define DO_AGGSPLIT_SKIPFINAL(as) (((as)&AGGSPLITOP_SKIPFINAL) != 0)
|
||||
#define DO_AGGSPLIT_SERIALIZE(as) (((as)&AGGSPLITOP_SERIALIZE) != 0)
|
||||
#define DO_AGGSPLIT_DESERIALIZE(as) (((as)&AGGSPLITOP_DESERIALIZE) != 0)
|
||||
|
||||
/*
|
||||
* PGSetOpCmd and PGSetOpStrategy -
|
||||
* overall semantics and execution strategies for PGSetOp plan nodes
|
||||
*
|
||||
* This is needed in both plannodes.h and relation.h, so put it here...
|
||||
*/
|
||||
typedef enum PGSetOpCmd {
|
||||
PG_SETOPCMD_INTERSECT,
|
||||
PG_SETOPCMD_INTERSECT_ALL,
|
||||
PG_SETOPCMD_EXCEPT,
|
||||
PG_SETOPCMD_EXCEPT_ALL
|
||||
} PGSetOpCmd;
|
||||
|
||||
typedef enum PGSetOpStrategy {
|
||||
PG_SETOP_SORTED, /* input must be sorted */
|
||||
PG_SETOP_HASHED /* use internal hashtable */
|
||||
} PGSetOpStrategy;
|
||||
|
||||
/*
|
||||
* PGOnConflictAction -
|
||||
* "ON CONFLICT" clause type of query
|
||||
*
|
||||
* This is needed in both parsenodes.h and plannodes.h, so put it here...
|
||||
*/
|
||||
typedef enum PGOnConflictAction {
|
||||
PG_ONCONFLICT_NONE, /* No "ON CONFLICT" clause */
|
||||
PG_ONCONFLICT_NOTHING, /* ON CONFLICT ... DO NOTHING */
|
||||
PG_ONCONFLICT_UPDATE /* ON CONFLICT ... DO UPDATE */
|
||||
} PGOnConflictAction;
|
||||
|
||||
/*
|
||||
* PGOnConflictActionAlias -
|
||||
* "INSERT OR [REPLACE|IGNORE]" aliases for OnConflictAction
|
||||
*
|
||||
* This is needed in both parsenodes.h and plannodes.h, so put it here...
|
||||
*/
|
||||
typedef enum PGOnConflictActionAlias {
|
||||
PG_ONCONFLICT_ALIAS_NONE, /* No "OR [IGNORE|REPLACE]" clause */
|
||||
PG_ONCONFLICT_ALIAS_REPLACE, /* INSERT OR REPLACE */
|
||||
PG_ONCONFLICT_ALIAS_IGNORE /* INSERT OR IGNORE */
|
||||
} PGOnConflictActionAlias;
|
||||
|
||||
/*
|
||||
* PGInsertByNameOrPosition
|
||||
* "INSERT BY [POSITION|NAME]
|
||||
*/
|
||||
typedef enum PGInsertColumnOrder {
|
||||
PG_INSERT_BY_POSITION, /* INSERT BY POSITION (default behavior) */
|
||||
PG_INSERT_BY_NAME, /* INSERT BY NAME */
|
||||
} PGInsertColumnOrder;
|
||||
|
||||
}
|
||||
2326
external/duckdb/third_party/libpg_query/include/nodes/parsenodes.hpp
vendored
Executable file
2326
external/duckdb/third_party/libpg_query/include/nodes/parsenodes.hpp
vendored
Executable file
File diff suppressed because it is too large
Load Diff
339
external/duckdb/third_party/libpg_query/include/nodes/pg_list.hpp
vendored
Executable file
339
external/duckdb/third_party/libpg_query/include/nodes/pg_list.hpp
vendored
Executable file
@@ -0,0 +1,339 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* pg_list.h
|
||||
* interface for PostgreSQL generic linked list package
|
||||
*
|
||||
* This package implements singly-linked homogeneous lists.
|
||||
*
|
||||
* It is important to have constant-time length, append, and prepend
|
||||
* operations. To achieve this, we deal with two distinct data
|
||||
* structures:
|
||||
*
|
||||
* 1. A set of "list cells": each cell contains a data field and
|
||||
* a link to the next cell in the list or NULL.
|
||||
* 2. A single structure containing metadata about the list: the
|
||||
* type of the list, pointers to the head and tail cells, and
|
||||
* the length of the list.
|
||||
*
|
||||
* We support three types of lists:
|
||||
*
|
||||
* duckdb_libpgquery::T_PGList: lists of pointers
|
||||
* (in practice usually pointers to Nodes, but not always;
|
||||
* declared as "void *" to minimize casting annoyances)
|
||||
* duckdb_libpgquery::T_PGIntList: lists of integers
|
||||
* duckdb_libpgquery::T_PGOidList: lists of Oids
|
||||
*
|
||||
* (At the moment, ints and Oids are the same size, but they may not
|
||||
* always be so; try to be careful to maintain the distinction.)
|
||||
*
|
||||
*
|
||||
* Portions Copyright (c) 1996-2017, PostgreSQL Global Development PGGroup
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/nodes/pg_list.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "nodes/nodes.hpp"
|
||||
|
||||
namespace duckdb_libpgquery {
|
||||
|
||||
typedef struct PGListCell ListCell;
|
||||
|
||||
typedef struct PGList {
|
||||
PGNodeTag type; /* duckdb_libpgquery::T_PGList, duckdb_libpgquery::T_PGIntList, or duckdb_libpgquery::T_PGOidList */
|
||||
int length;
|
||||
PGListCell *head;
|
||||
PGListCell *tail;
|
||||
} PGList;
|
||||
|
||||
struct PGListCell {
|
||||
union
|
||||
{
|
||||
void *ptr_value;
|
||||
int int_value;
|
||||
PGOid oid_value;
|
||||
} data;
|
||||
PGListCell *next;
|
||||
};
|
||||
|
||||
/*
|
||||
* The *only* valid representation of an empty list is NIL; in other
|
||||
* words, a non-NIL list is guaranteed to have length >= 1 and
|
||||
* head/tail != NULL
|
||||
*/
|
||||
#define NIL ((PGList *) NULL)
|
||||
|
||||
/*
|
||||
* These routines are used frequently. However, we can't implement
|
||||
* them as macros, since we want to avoid double-evaluation of macro
|
||||
* arguments.
|
||||
*/
|
||||
static inline PGListCell *
|
||||
list_head(const PGList *l)
|
||||
{
|
||||
return l ? l->head : NULL;
|
||||
}
|
||||
|
||||
static inline PGListCell *
|
||||
list_tail(PGList *l)
|
||||
{
|
||||
return l ? l->tail : NULL;
|
||||
}
|
||||
|
||||
static inline int
|
||||
list_length(const PGList *l)
|
||||
{
|
||||
return l ? l->length : 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* NB: There is an unfortunate legacy from a previous incarnation of
|
||||
* the PGList API: the macro lfirst() was used to mean "the data in this
|
||||
* cons cell". To avoid changing every usage of lfirst(), that meaning
|
||||
* has been kept. As a result, lfirst() takes a PGListCell and returns
|
||||
* the data it contains; to get the data in the first cell of a
|
||||
* PGList, use linitial(). Worse, lsecond() is more closely related to
|
||||
* linitial() than lfirst(): given a PGList, lsecond() returns the data
|
||||
* in the second cons cell.
|
||||
*/
|
||||
|
||||
#define lnext(lc) ((lc)->next)
|
||||
#define lfirst(lc) ((lc)->data.ptr_value)
|
||||
#define lfirst_int(lc) ((lc)->data.int_value)
|
||||
#define lfirst_oid(lc) ((lc)->data.oid_value)
|
||||
#define lfirst_node(type,lc) castNode(type, lfirst(lc))
|
||||
|
||||
#define linitial(l) lfirst(list_head(l))
|
||||
#define linitial_int(l) lfirst_int(list_head(l))
|
||||
#define linitial_oid(l) lfirst_oid(list_head(l))
|
||||
#define linitial_node(type,l) castNode(type, linitial(l))
|
||||
|
||||
#define lsecond(l) lfirst(lnext(list_head(l)))
|
||||
#define lsecond_int(l) lfirst_int(lnext(list_head(l)))
|
||||
#define lsecond_oid(l) lfirst_oid(lnext(list_head(l)))
|
||||
#define lsecond_node(type,l) castNode(type, lsecond(l))
|
||||
|
||||
#define lthird(l) lfirst(lnext(lnext(list_head(l))))
|
||||
#define lthird_int(l) lfirst_int(lnext(lnext(list_head(l))))
|
||||
#define lthird_oid(l) lfirst_oid(lnext(lnext(list_head(l))))
|
||||
#define lthird_node(type,l) castNode(type, lthird(l))
|
||||
|
||||
#define lfourth(l) lfirst(lnext(lnext(lnext(list_head(l)))))
|
||||
#define lfourth_int(l) lfirst_int(lnext(lnext(lnext(list_head(l)))))
|
||||
#define lfourth_oid(l) lfirst_oid(lnext(lnext(lnext(list_head(l)))))
|
||||
#define lfourth_node(type,l) castNode(type, lfourth(l))
|
||||
|
||||
#define llast(l) lfirst(list_tail(l))
|
||||
#define llast_int(l) lfirst_int(list_tail(l))
|
||||
#define llast_oid(l) lfirst_oid(list_tail(l))
|
||||
#define llast_node(type,l) castNode(type, llast(l))
|
||||
|
||||
/*
|
||||
* Convenience macros for building fixed-length lists
|
||||
*/
|
||||
#define list_make1(x1) lcons(x1, NIL)
|
||||
#define list_make2(x1,x2) lcons(x1, list_make1(x2))
|
||||
#define list_make3(x1,x2,x3) lcons(x1, list_make2(x2, x3))
|
||||
#define list_make4(x1,x2,x3,x4) lcons(x1, list_make3(x2, x3, x4))
|
||||
#define list_make5(x1,x2,x3,x4,x5) lcons(x1, list_make4(x2, x3, x4, x5))
|
||||
|
||||
#define list_make1_int(x1) lcons_int(x1, NIL)
|
||||
#define list_make2_int(x1,x2) lcons_int(x1, list_make1_int(x2))
|
||||
#define list_make3_int(x1,x2,x3) lcons_int(x1, list_make2_int(x2, x3))
|
||||
#define list_make4_int(x1,x2,x3,x4) lcons_int(x1, list_make3_int(x2, x3, x4))
|
||||
#define list_make5_int(x1,x2,x3,x4,x5) lcons_int(x1, list_make4_int(x2, x3, x4, x5))
|
||||
|
||||
#define list_make1_oid(x1) lcons_oid(x1, NIL)
|
||||
#define list_make2_oid(x1,x2) lcons_oid(x1, list_make1_oid(x2))
|
||||
#define list_make3_oid(x1,x2,x3) lcons_oid(x1, list_make2_oid(x2, x3))
|
||||
#define list_make4_oid(x1,x2,x3,x4) lcons_oid(x1, list_make3_oid(x2, x3, x4))
|
||||
#define list_make5_oid(x1,x2,x3,x4,x5) lcons_oid(x1, list_make4_oid(x2, x3, x4, x5))
|
||||
|
||||
/*
|
||||
* foreach -
|
||||
* a convenience macro which loops through the list
|
||||
*/
|
||||
#define foreach(cell, l) \
|
||||
for ((cell) = list_head(l); (cell) != NULL; (cell) = lnext(cell))
|
||||
|
||||
/*
|
||||
* for_each_cell -
|
||||
* a convenience macro which loops through a list starting from a
|
||||
* specified cell
|
||||
*/
|
||||
#define for_each_cell(cell, initcell) \
|
||||
for ((cell) = (initcell); (cell) != NULL; (cell) = lnext(cell))
|
||||
|
||||
/*
|
||||
* forboth -
|
||||
* a convenience macro for advancing through two linked lists
|
||||
* simultaneously. This macro loops through both lists at the same
|
||||
* time, stopping when either list runs out of elements. Depending
|
||||
* on the requirements of the call site, it may also be wise to
|
||||
* assert that the lengths of the two lists are equal.
|
||||
*/
|
||||
#define forboth(cell1, list1, cell2, list2) \
|
||||
for ((cell1) = list_head(list1), (cell2) = list_head(list2); \
|
||||
(cell1) != NULL && (cell2) != NULL; \
|
||||
(cell1) = lnext(cell1), (cell2) = lnext(cell2))
|
||||
|
||||
/*
|
||||
* for_both_cell -
|
||||
* a convenience macro which loops through two lists starting from the
|
||||
* specified cells of each. This macro loops through both lists at the same
|
||||
* time, stopping when either list runs out of elements. Depending on the
|
||||
* requirements of the call site, it may also be wise to assert that the
|
||||
* lengths of the two lists are equal, and initcell1 and initcell2 are at
|
||||
* the same position in the respective lists.
|
||||
*/
|
||||
#define for_both_cell(cell1, initcell1, cell2, initcell2) \
|
||||
for ((cell1) = (initcell1), (cell2) = (initcell2); \
|
||||
(cell1) != NULL && (cell2) != NULL; \
|
||||
(cell1) = lnext(cell1), (cell2) = lnext(cell2))
|
||||
|
||||
/*
|
||||
* forthree -
|
||||
* the same for three lists
|
||||
*/
|
||||
#define forthree(cell1, list1, cell2, list2, cell3, list3) \
|
||||
for ((cell1) = list_head(list1), (cell2) = list_head(list2), (cell3) = list_head(list3); \
|
||||
(cell1) != NULL && (cell2) != NULL && (cell3) != NULL; \
|
||||
(cell1) = lnext(cell1), (cell2) = lnext(cell2), (cell3) = lnext(cell3))
|
||||
|
||||
PGList *lappend(PGList *list, void *datum);
|
||||
PGList *lappend_int(PGList *list, int datum);
|
||||
PGList *lappend_oid(PGList *list, PGOid datum);
|
||||
|
||||
PGListCell *lappend_cell(PGList *list, PGListCell *prev, void *datum);
|
||||
PGListCell *lappend_cell_int(PGList *list, PGListCell *prev, int datum);
|
||||
PGListCell *lappend_cell_oid(PGList *list, PGListCell *prev, PGOid datum);
|
||||
|
||||
PGList *lcons(void *datum, PGList *list);
|
||||
PGList *lcons_int(int datum, PGList *list);
|
||||
PGList *lcons_oid(PGOid datum, PGList *list);
|
||||
|
||||
PGList *list_concat(PGList *list1, PGList *list2);
|
||||
PGList *list_truncate(PGList *list, int new_size);
|
||||
|
||||
PGListCell *list_nth_cell(const PGList *list, int n);
|
||||
void *list_nth(const PGList *list, int n);
|
||||
int list_nth_int(const PGList *list, int n);
|
||||
PGOid list_nth_oid(const PGList *list, int n);
|
||||
#define list_nth_node(type,list,n) castNode(type, list_nth(list, n))
|
||||
|
||||
bool list_member(const PGList *list, const void *datum);
|
||||
bool list_member_ptr(const PGList *list, const void *datum);
|
||||
bool list_member_int(const PGList *list, int datum);
|
||||
bool list_member_oid(const PGList *list, PGOid datum);
|
||||
|
||||
PGList *list_delete(PGList *list, void *datum);
|
||||
PGList *list_delete_ptr(PGList *list, void *datum);
|
||||
PGList *list_delete_int(PGList *list, int datum);
|
||||
PGList *list_delete_oid(PGList *list, PGOid datum);
|
||||
PGList *list_delete_first(PGList *list);
|
||||
PGList *list_delete_cell(PGList *list, PGListCell *cell, PGListCell *prev);
|
||||
|
||||
PGList *list_union(const PGList *list1, const PGList *list2);
|
||||
PGList *list_union_ptr(const PGList *list1, const PGList *list2);
|
||||
PGList *list_union_int(const PGList *list1, const PGList *list2);
|
||||
PGList *list_union_oid(const PGList *list1, const PGList *list2);
|
||||
|
||||
PGList *list_intersection(const PGList *list1, const PGList *list2);
|
||||
PGList *list_intersection_int(const PGList *list1, const PGList *list2);
|
||||
|
||||
/* currently, there's no need for list_intersection_ptr etc */
|
||||
|
||||
PGList *list_difference(const PGList *list1, const PGList *list2);
|
||||
PGList *list_difference_ptr(const PGList *list1, const PGList *list2);
|
||||
PGList *list_difference_int(const PGList *list1, const PGList *list2);
|
||||
PGList *list_difference_oid(const PGList *list1, const PGList *list2);
|
||||
|
||||
PGList *list_append_unique(PGList *list, void *datum);
|
||||
PGList *list_append_unique_ptr(PGList *list, void *datum);
|
||||
PGList *list_append_unique_int(PGList *list, int datum);
|
||||
PGList *list_append_unique_oid(PGList *list, PGOid datum);
|
||||
|
||||
PGList *list_concat_unique(PGList *list1, PGList *list2);
|
||||
PGList *list_concat_unique_ptr(PGList *list1, PGList *list2);
|
||||
PGList *list_concat_unique_int(PGList *list1, PGList *list2);
|
||||
PGList *list_concat_unique_oid(PGList *list1, PGList *list2);
|
||||
|
||||
void list_free(PGList *list);
|
||||
void list_free_deep(PGList *list);
|
||||
|
||||
PGList *list_copy(const PGList *list);
|
||||
PGList *list_copy_tail(const PGList *list, int nskip);
|
||||
|
||||
/*
|
||||
* To ease migration to the new list API, a set of compatibility
|
||||
* macros are provided that reduce the impact of the list API changes
|
||||
* as far as possible. Until client code has been rewritten to use the
|
||||
* new list API, the ENABLE_LIST_COMPAT symbol can be defined before
|
||||
* including pg_list.h
|
||||
*/
|
||||
#ifdef ENABLE_LIST_COMPAT
|
||||
|
||||
#define lfirsti(lc) lfirst_int(lc)
|
||||
#define lfirsto(lc) lfirst_oid(lc)
|
||||
|
||||
#define makeList1(x1) list_make1(x1)
|
||||
#define makeList2(x1, x2) list_make2(x1, x2)
|
||||
#define makeList3(x1, x2, x3) list_make3(x1, x2, x3)
|
||||
#define makeList4(x1, x2, x3, x4) list_make4(x1, x2, x3, x4)
|
||||
|
||||
#define makeListi1(x1) list_make1_int(x1)
|
||||
#define makeListi2(x1, x2) list_make2_int(x1, x2)
|
||||
|
||||
#define makeListo1(x1) list_make1_oid(x1)
|
||||
#define makeListo2(x1, x2) list_make2_oid(x1, x2)
|
||||
|
||||
#define lconsi(datum, list) lcons_int(datum, list)
|
||||
#define lconso(datum, list) lcons_oid(datum, list)
|
||||
|
||||
#define lappendi(list, datum) lappend_int(list, datum)
|
||||
#define lappendo(list, datum) lappend_oid(list, datum)
|
||||
|
||||
#define nconc(l1, l2) list_concat(l1, l2)
|
||||
|
||||
#define nth(n, list) list_nth(list, n)
|
||||
|
||||
#define member(datum, list) list_member(list, datum)
|
||||
#define ptrMember(datum, list) list_member_ptr(list, datum)
|
||||
#define intMember(datum, list) list_member_int(list, datum)
|
||||
#define oidMember(datum, list) list_member_oid(list, datum)
|
||||
|
||||
/*
|
||||
* Note that the old lremove() determined equality via pointer
|
||||
* comparison, whereas the new list_delete() uses equal(); in order to
|
||||
* keep the same behavior, we therefore need to map lremove() calls to
|
||||
* list_delete_ptr() rather than list_delete()
|
||||
*/
|
||||
#define lremove(elem, list) list_delete_ptr(list, elem)
|
||||
#define LispRemove(elem, list) list_delete(list, elem)
|
||||
#define lremovei(elem, list) list_delete_int(list, elem)
|
||||
#define lremoveo(elem, list) list_delete_oid(list, elem)
|
||||
|
||||
#define ltruncate(n, list) list_truncate(list, n)
|
||||
|
||||
#define set_union(l1, l2) list_union(l1, l2)
|
||||
#define set_uniono(l1, l2) list_union_oid(l1, l2)
|
||||
#define set_ptrUnion(l1, l2) list_union_ptr(l1, l2)
|
||||
|
||||
#define set_difference(l1, l2) list_difference(l1, l2)
|
||||
#define set_differenceo(l1, l2) list_difference_oid(l1, l2)
|
||||
#define set_ptrDifference(l1, l2) list_difference_ptr(l1, l2)
|
||||
|
||||
#define equali(l1, l2) equal(l1, l2)
|
||||
#define equalo(l1, l2) equal(l1, l2)
|
||||
|
||||
#define freeList(list) list_free(list)
|
||||
|
||||
#define listCopy(list) list_copy(list)
|
||||
|
||||
int length(PGList *list);
|
||||
#endif /* ENABLE_LIST_COMPAT */
|
||||
|
||||
}
|
||||
1412
external/duckdb/third_party/libpg_query/include/nodes/primnodes.hpp
vendored
Executable file
1412
external/duckdb/third_party/libpg_query/include/nodes/primnodes.hpp
vendored
Executable file
File diff suppressed because it is too large
Load Diff
60
external/duckdb/third_party/libpg_query/include/nodes/value.hpp
vendored
Executable file
60
external/duckdb/third_party/libpg_query/include/nodes/value.hpp
vendored
Executable file
@@ -0,0 +1,60 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* value.h
|
||||
* interface for PGValue nodes
|
||||
*
|
||||
*
|
||||
* Copyright (c) 2003-2017, PostgreSQL Global Development PGGroup
|
||||
*
|
||||
* src/include/nodes/value.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "nodes/nodes.hpp"
|
||||
|
||||
namespace duckdb_libpgquery {
|
||||
|
||||
/*----------------------
|
||||
* PGValue node
|
||||
*
|
||||
* The same PGValue struct is used for five node types: duckdb_libpgquery::T_PGInteger,
|
||||
* duckdb_libpgquery::T_PGFloat, duckdb_libpgquery::T_PGString, duckdb_libpgquery::T_PGBitString, T_Null.
|
||||
*
|
||||
* Integral values are actually represented by a machine integer,
|
||||
* but both floats and strings are represented as strings.
|
||||
* Using duckdb_libpgquery::T_PGFloat as the node type simply indicates that
|
||||
* the contents of the string look like a valid numeric literal.
|
||||
*
|
||||
* (Before Postgres 7.0, we used a double to represent duckdb_libpgquery::T_PGFloat,
|
||||
* but that creates loss-of-precision problems when the value is
|
||||
* ultimately destined to be converted to NUMERIC. Since PGValue nodes
|
||||
* are only used in the parsing process, not for runtime data, it's
|
||||
* better to use the more general representation.)
|
||||
*
|
||||
* Note that an integer-looking string will get lexed as duckdb_libpgquery::T_PGFloat if
|
||||
* the value is too large to fit in a 'long'.
|
||||
*
|
||||
* Nulls, of course, don't need the value part at all.
|
||||
*----------------------
|
||||
*/
|
||||
typedef struct PGValue {
|
||||
PGNodeTag type; /* tag appropriately (eg. duckdb_libpgquery::T_PGString) */
|
||||
union ValUnion {
|
||||
long ival; /* machine integer */
|
||||
char *str; /* string */
|
||||
} val;
|
||||
} PGValue;
|
||||
|
||||
#define intVal(v) (((PGValue *)(v))->val.ival)
|
||||
#define floatVal(v) atof(((PGValue *)(v))->val.str)
|
||||
#define strVal(v) (((PGValue *)(v))->val.str)
|
||||
|
||||
PGValue *makeInteger(long i);
|
||||
PGValue *makeFloat(char *numericStr);
|
||||
PGValue *makeString(const char *str);
|
||||
PGValue *makeBitString(char *str);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user