postgresql/src/include/nodes/makefuncs.h

82 lines
2.3 KiB
C
Raw Normal View History

/*-------------------------------------------------------------------------
*
* makefuncs.h
* prototypes for the creator functions (for primitive nodes)
*
*
2011-01-01 19:18:15 +01:00
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
2010-09-20 22:08:53 +02:00
* src/include/nodes/makefuncs.h
*
*-------------------------------------------------------------------------
*/
#ifndef MAKEFUNC_H
#define MAKEFUNC_H
#include "nodes/parsenodes.h"
extern A_Expr *makeA_Expr(A_Expr_Kind kind, List *name,
Node *lexpr, Node *rexpr, int location);
extern A_Expr *makeSimpleA_Expr(A_Expr_Kind kind, const char *name,
Node *lexpr, Node *rexpr, int location);
extern Var *makeVar(Index varno,
1999-05-25 18:15:34 +02:00
AttrNumber varattno,
Oid vartype,
int32 vartypmod,
Oid varcollid,
Index varlevelsup);
extern Var *makeVarFromTargetEntry(Index varno,
2011-04-10 17:42:00 +02:00
TargetEntry *tle);
extern Var *makeWholeRowVar(RangeTblEntry *rte,
Index varno,
Index varlevelsup);
extern TargetEntry *makeTargetEntry(Expr *expr,
2005-10-15 04:49:52 +02:00
AttrNumber resno,
char *resname,
bool resjunk);
1998-07-20 22:48:54 +02:00
extern TargetEntry *flatCopyTargetEntry(TargetEntry *src_tle);
extern FromExpr *makeFromExpr(List *fromlist, Node *quals);
extern Const *makeConst(Oid consttype,
int32 consttypmod,
Oid constcollid,
1999-05-25 18:15:34 +02:00
int constlen,
Datum constvalue,
bool constisnull,
bool constbyval);
extern Const *makeNullConst(Oid consttype, int32 consttypmod, Oid constcollid);
extern Node *makeBoolConst(bool value, bool isnull);
extern Expr *makeBoolExpr(BoolExprType boolop, List *args, int location);
extern Alias *makeAlias(const char *aliasname, List *colnames);
extern RelabelType *makeRelabelType(Expr *arg, Oid rtype, int32 rtypmod,
2011-04-10 17:42:00 +02:00
Oid rcollid, CoercionForm rformat);
2002-03-20 20:45:13 +01:00
extern RangeVar *makeRangeVar(char *schemaname, char *relname, int location);
extern TypeName *makeTypeName(char *typnam);
extern TypeName *makeTypeNameFromNameList(List *names);
Remove collation information from TypeName, where it does not belong. The initial collations patch treated a COLLATE spec as part of a TypeName, following what can only be described as brain fade on the part of the SQL committee. It's a lot more reasonable to treat COLLATE as a syntactically separate object, so that it can be added in only the productions where it actually belongs, rather than needing to reject it in a boatload of places where it doesn't belong (something the original patch mostly failed to do). In addition this change lets us meet the spec's requirement to allow COLLATE anywhere in the clauses of a ColumnDef, and it avoids unfriendly behavior for constructs such as "foo::type COLLATE collation". To do this, pull collation information out of TypeName and put it in ColumnDef instead, thus reverting most of the collation-related changes in parse_type.c's API. I made one additional structural change, which was to use a ColumnDef as an intermediate node in AT_AlterColumnType AlterTableCmd nodes. This provides enough room to get rid of the "transform" wart in AlterTableCmd too, since the ColumnDef can carry the USING expression easily enough. Also fix some other minor bugs that have crept in in the same areas, like failure to copy recently-added fields of ColumnDef in copyfuncs.c. While at it, document the formerly secret ability to specify a collation in ALTER TABLE ALTER COLUMN TYPE, ALTER TYPE ADD ATTRIBUTE, and ALTER TYPE ALTER ATTRIBUTE TYPE; and correct some misstatements about what the default collation selection will be when COLLATE is omitted. BTW, the three-parameter form of format_type() should go away too, since it just contributes to the confusion in this area; but I'll do that in a separate patch.
2011-03-10 04:38:52 +01:00
extern TypeName *makeTypeNameFromOid(Oid typeOid, int32 typmod);
extern FuncExpr *makeFuncExpr(Oid funcid, Oid rettype, List *args,
Oid funccollid, Oid inputcollid, CoercionForm fformat);
extern DefElem *makeDefElem(char *name, Node *arg);
extern DefElem *makeDefElemExtended(char *nameSpace, char *name, Node *arg,
DefElemAction defaction);
#endif /* MAKEFUNC_H */