1996-08-28 03:59:28 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
1999-02-14 00:22:53 +01:00
|
|
|
* makefuncs.h
|
1997-09-07 07:04:48 +02:00
|
|
|
* prototypes for the creator functions (for primitive nodes)
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
|
|
|
*
|
2011-01-01 19:18:15 +01:00
|
|
|
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
|
2000-01-26 06:58:53 +01:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
2010-09-20 22:08:53 +02:00
|
|
|
* src/include/nodes/makefuncs.h
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
#ifndef MAKEFUNC_H
|
|
|
|
#define MAKEFUNC_H
|
|
|
|
|
1999-07-16 01:04:24 +02:00
|
|
|
#include "nodes/parsenodes.h"
|
1996-08-28 03:59:28 +02:00
|
|
|
|
Extend pg_cast castimplicit column to a three-way value; this allows us
to be flexible about assignment casts without introducing ambiguity in
operator/function resolution. Introduce a well-defined promotion hierarchy
for numeric datatypes (int2->int4->int8->numeric->float4->float8).
Change make_const to initially label numeric literals as int4, int8, or
numeric (never float8 anymore).
Explicitly mark Func and RelabelType nodes to indicate whether they came
from a function call, explicit cast, or implicit cast; use this to do
reverse-listing more accurately and without so many heuristics.
Explicit casts to char, varchar, bit, varbit will truncate or pad without
raising an error (the pre-7.2 behavior), while assigning to a column without
any explicit cast will still raise an error for wrong-length data like 7.3.
This more nearly follows the SQL spec than 7.2 behavior (we should be
reporting a 'completion condition' in the explicit-cast cases, but we have
no mechanism for that, so just do silent truncation).
Fix some problems with enforcement of typmod for array elements;
it didn't work at all in 'UPDATE ... SET array[n] = foo', for example.
Provide a generalized array_length_coerce() function to replace the
specialized per-array-type functions that used to be needed (and were
missing for NUMERIC as well as all the datetime types).
Add missing conversions int8<->float4, text<->numeric, oid<->int8.
initdb forced.
2002-09-18 23:35:25 +02:00
|
|
|
|
2003-02-10 05:44:47 +01:00
|
|
|
extern A_Expr *makeA_Expr(A_Expr_Kind kind, List *name,
|
2006-03-14 23:48:25 +01:00
|
|
|
Node *lexpr, Node *rexpr, int location);
|
2002-04-17 01:08:12 +02:00
|
|
|
|
2003-02-10 05:44:47 +01:00
|
|
|
extern A_Expr *makeSimpleA_Expr(A_Expr_Kind kind, const char *name,
|
2006-03-14 23:48:25 +01:00
|
|
|
Node *lexpr, Node *rexpr, int location);
|
2002-04-17 01:08:12 +02:00
|
|
|
|
1998-09-01 06:40:42 +02:00
|
|
|
extern Var *makeVar(Index varno,
|
1999-05-25 18:15:34 +02:00
|
|
|
AttrNumber varattno,
|
|
|
|
Oid vartype,
|
|
|
|
int32 vartypmod,
|
2011-02-08 22:04:18 +01:00
|
|
|
Oid varcollid,
|
1999-08-22 22:15:04 +02:00
|
|
|
Index varlevelsup);
|
1996-08-28 03:59:28 +02:00
|
|
|
|
2010-08-27 22:30:08 +02:00
|
|
|
extern Var *makeVarFromTargetEntry(Index varno,
|
|
|
|
TargetEntry *tle);
|
|
|
|
|
2010-10-19 21:08:37 +02:00
|
|
|
extern Var *makeWholeRowVar(RangeTblEntry *rte,
|
|
|
|
Index varno,
|
|
|
|
Index varlevelsup);
|
|
|
|
|
2005-04-06 18:34:07 +02:00
|
|
|
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
|
|
|
|
2005-04-06 18:34:07 +02:00
|
|
|
extern TargetEntry *flatCopyTargetEntry(TargetEntry *src_tle);
|
1996-08-28 03:59:28 +02:00
|
|
|
|
2007-06-24 00:12:52 +02:00
|
|
|
extern FromExpr *makeFromExpr(List *fromlist, Node *quals);
|
|
|
|
|
1998-09-01 06:40:42 +02:00
|
|
|
extern Const *makeConst(Oid consttype,
|
2007-03-17 01:11:05 +01:00
|
|
|
int32 consttypmod,
|
1999-05-25 18:15:34 +02:00
|
|
|
int constlen,
|
|
|
|
Datum constvalue,
|
|
|
|
bool constisnull,
|
2002-11-25 22:29:42 +01:00
|
|
|
bool constbyval);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2007-09-06 19:31:58 +02:00
|
|
|
extern Const *makeNullConst(Oid consttype, int32 consttypmod);
|
2000-11-16 23:30:52 +01:00
|
|
|
|
2004-05-11 00:44:49 +02:00
|
|
|
extern Node *makeBoolConst(bool value, bool isnull);
|
|
|
|
|
2008-08-29 01:09:48 +02:00
|
|
|
extern Expr *makeBoolExpr(BoolExprType boolop, List *args, int location);
|
2002-12-12 16:49:42 +01:00
|
|
|
|
2002-03-21 17:02:16 +01:00
|
|
|
extern Alias *makeAlias(const char *aliasname, List *colnames);
|
2001-10-28 07:26:15 +01:00
|
|
|
|
2002-12-12 16:49:42 +01:00
|
|
|
extern RelabelType *makeRelabelType(Expr *arg, Oid rtype, int32 rtypmod,
|
2011-03-20 01:29:08 +01:00
|
|
|
Oid rcollid, CoercionForm rformat);
|
2002-03-20 20:45:13 +01:00
|
|
|
|
2008-09-01 22:42:46 +02:00
|
|
|
extern RangeVar *makeRangeVar(char *schemaname, char *relname, int location);
|
2002-03-22 03:56:37 +01:00
|
|
|
|
2002-03-29 20:06:29 +01:00
|
|
|
extern TypeName *makeTypeName(char *typnam);
|
2006-03-14 23:48:25 +01:00
|
|
|
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);
|
2002-03-29 20:06:29 +01:00
|
|
|
|
2011-03-20 01:29:08 +01:00
|
|
|
extern FuncExpr *makeFuncExpr(Oid funcid, Oid rettype, List *args,
|
|
|
|
Oid funccollid, Oid inputcollid, CoercionForm fformat);
|
2003-07-01 21:10:53 +02:00
|
|
|
|
2006-08-21 02:57:26 +02:00
|
|
|
extern DefElem *makeDefElem(char *name, Node *arg);
|
2009-07-16 08:33:46 +02:00
|
|
|
extern DefElem *makeDefElemExtended(char *nameSpace, char *name, Node *arg,
|
2009-06-11 16:49:15 +02:00
|
|
|
DefElemAction defaction);
|
2009-02-02 20:31:40 +01:00
|
|
|
|
2001-11-05 18:46:40 +01:00
|
|
|
#endif /* MAKEFUNC_H */
|