Retire xlateSqlType/xlateSqlFunc; all type name translations are now

handled as special productions.  This is needed to keep us honest about
user-schema type names that happen to coincide with system type names.
Per pghackers discussion 24-Apr.  To avoid bloating the keyword list
too much, I removed the translations for datetime, timespan, and lztext,
all of which were slated for destruction several versions back anyway.
This commit is contained in:
Tom Lane 2002-05-03 00:32:19 +00:00
parent c2def1b128
commit 53cedcac22
12 changed files with 186 additions and 186 deletions

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/typecmds.c,v 1.2 2002/04/27 03:45:02 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/typecmds.c,v 1.3 2002/05/03 00:32:16 tgl Exp $
*
* DESCRIPTION
* The "DefineFoo" routines take the parse tree and pick out the
@ -133,21 +133,22 @@ DefineType(List *names, List *parameters)
/*
* Note: if argument was an unquoted identifier, parser will
* have applied xlateSqlType() to it, so be prepared to
* have applied translations to it, so be prepared to
* recognize translated type names as well as the nominal
* form.
*/
if (strcasecmp(a, "double") == 0)
if (strcasecmp(a, "double") == 0 ||
strcasecmp(a, "float8") == 0 ||
strcasecmp(a, "pg_catalog.float8") == 0)
alignment = 'd';
else if (strcasecmp(a, "float8") == 0)
alignment = 'd';
else if (strcasecmp(a, "int4") == 0)
else if (strcasecmp(a, "int4") == 0 ||
strcasecmp(a, "pg_catalog.int4") == 0)
alignment = 'i';
else if (strcasecmp(a, "int2") == 0)
else if (strcasecmp(a, "int2") == 0 ||
strcasecmp(a, "pg_catalog.int2") == 0)
alignment = 's';
else if (strcasecmp(a, "char") == 0)
alignment = 'c';
else if (strcasecmp(a, "bpchar") == 0)
else if (strcasecmp(a, "char") == 0 ||
strcasecmp(a, "pg_catalog.bpchar") == 0)
alignment = 'c';
else
elog(ERROR, "DefineType: \"%s\" alignment not recognized",

View File

@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.311 2002/05/02 18:44:10 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.312 2002/05/03 00:32:16 tgl Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
@ -269,12 +269,12 @@ static void doNegateFloat(Value *v);
%type <range> relation_expr
%type <target> target_el, insert_target_el, update_target_el
%type <typnam> Typename, SimpleTypename, ConstTypename
GenericType, Numeric, Character, ConstDatetime, ConstInterval, Bit
%type <str> character, bit
%type <typnam> Typename, SimpleTypename, ConstTypename,
GenericType, Numeric, opt_float, Character,
ConstDatetime, ConstInterval, Bit
%type <str> character
%type <str> extract_arg
%type <str> opt_charset, opt_collate
%type <str> opt_float
%type <ival> opt_numeric, opt_decimal
%type <boolean> opt_varying, opt_timezone
@ -331,14 +331,16 @@ static void doNegateFloat(Value *v);
ELSE, ENCRYPTED, END_TRANS, ESCAPE, EXCEPT, EXECUTE, EXISTS, EXTRACT,
FALSE_P, FETCH, FLOAT, FOR, FOREIGN, FROM, FULL,
GLOBAL, GRANT, GROUP, HAVING, HOUR_P,
IN, INNER_P, INSENSITIVE, INSERT, INTERSECT, INTERVAL, INTO, IS,
ISOLATION, JOIN, KEY, LANGUAGE, LEADING, LEFT, LEVEL, LIKE, LOCAL,
IN, INNER_P, INSENSITIVE, INSERT, INT, INTEGER, INTERSECT, INTERVAL,
INTO, IS, ISOLATION,
JOIN, KEY, LANGUAGE, LEADING, LEFT, LEVEL, LIKE, LOCAL,
MATCH, MINUTE_P, MONTH_P, NAMES,
NATIONAL, NATURAL, NCHAR, NEXT, NO, NOT, NULLIF, NULL_P, NUMERIC,
OF, OLD, ON, ONLY, OPTION, OR, ORDER, OUTER_P, OVERLAPS,
PARTIAL, POSITION, PRECISION, PRIMARY, PRIOR, PRIVILEGES, PROCEDURE,
READ, REFERENCES, RELATIVE, REVOKE, RIGHT, ROLLBACK,
SCHEMA, SCROLL, SECOND_P, SELECT, SESSION, SESSION_USER, SET, SOME, SUBSTRING,
READ, REAL, REFERENCES, RELATIVE, REVOKE, RIGHT, ROLLBACK,
SCHEMA, SCROLL, SECOND_P, SELECT, SESSION, SESSION_USER, SET,
SMALLINT, SOME, SUBSTRING,
TABLE, TEMPORARY, THEN, TIME, TIMESTAMP,
TO, TRAILING, TRANSACTION, TRIM, TRUE_P,
UNENCRYPTED, UNION, UNIQUE, UNKNOWN, UPDATE, USAGE, USER, USING,
@ -346,7 +348,8 @@ static void doNegateFloat(Value *v);
WHEN, WHERE, WITH, WORK, YEAR_P, ZONE
/* Keywords (in SQL99 reserved words) */
%token <keyword> ASSERTION, CHAIN, CHARACTERISTICS,
%token <keyword> ASSERTION, BINARY, BIT, BOOLEAN,
CHAIN, CHARACTERISTICS,
DEFERRABLE, DEFERRED,
IMMEDIATE, INITIALLY, INOUT,
OFF, OUT,
@ -365,7 +368,7 @@ static void doNegateFloat(Value *v);
* - Todd A. Brandys 1998-01-01?
*/
%token <keyword> ABORT_TRANS, ACCESS, AFTER, AGGREGATE, ANALYSE, ANALYZE,
BACKWARD, BEFORE, BINARY, BIT,
BACKWARD, BEFORE, BIGINT,
CACHE, CHECKPOINT, CLUSTER, COMMENT, COPY, CREATEDB, CREATEUSER, CYCLE,
DATABASE, DELIMITERS, DO,
EACH, ENCODING, EXCLUSIVE, EXPLAIN,
@ -4335,7 +4338,7 @@ ConstTypename: GenericType
GenericType: type_name
{
$$ = makeTypeName(xlateSqlType($1));
$$ = makeTypeName($1);
}
;
@ -4344,29 +4347,53 @@ GenericType: type_name
* Provide real DECIMAL() and NUMERIC() implementations now - Jan 1998-12-30
* - thomas 1997-09-18
*/
Numeric: FLOAT opt_float
Numeric: INT
{
$$ = makeTypeName($2); /* already xlated */
$$ = SystemTypeName("int4");
}
| INTEGER
{
$$ = SystemTypeName("int4");
}
| SMALLINT
{
$$ = SystemTypeName("int2");
}
| BIGINT
{
$$ = SystemTypeName("int8");
}
| REAL
{
$$ = SystemTypeName("float4");
}
| FLOAT opt_float
{
$$ = $2;
}
| DOUBLE PRECISION
{
$$ = makeTypeName(xlateSqlType("float8"));
$$ = SystemTypeName("float8");
}
| DECIMAL opt_decimal
{
$$ = makeTypeName(xlateSqlType("decimal"));
$$ = SystemTypeName("numeric");
$$->typmod = $2;
}
| DEC opt_decimal
{
$$ = makeTypeName(xlateSqlType("decimal"));
$$ = SystemTypeName("numeric");
$$->typmod = $2;
}
| NUMERIC opt_numeric
{
$$ = makeTypeName(xlateSqlType("numeric"));
$$ = SystemTypeName("numeric");
$$->typmod = $2;
}
| BOOLEAN
{
$$ = SystemTypeName("bool");
}
;
opt_float: '(' Iconst ')'
@ -4374,15 +4401,15 @@ opt_float: '(' Iconst ')'
if ($2 < 1)
elog(ERROR, "precision for FLOAT must be at least 1");
else if ($2 < 7)
$$ = xlateSqlType("float4");
$$ = SystemTypeName("float4");
else if ($2 < 16)
$$ = xlateSqlType("float8");
$$ = SystemTypeName("float8");
else
elog(ERROR, "precision for FLOAT must be less than 16");
}
| /*EMPTY*/
{
$$ = xlateSqlType("float8");
$$ = SystemTypeName("float8");
}
;
@ -4443,35 +4470,33 @@ opt_decimal: '(' Iconst ',' Iconst ')'
* SQL92 bit-field data types
* The following implements BIT() and BIT VARYING().
*/
Bit: bit '(' Iconst ')'
Bit: BIT opt_varying '(' Iconst ')'
{
$$ = makeTypeName($1);
if ($3 < 1)
char *typname;
typname = $2 ? "varbit" : "bit";
$$ = SystemTypeName(typname);
if ($4 < 1)
elog(ERROR, "length for type '%s' must be at least 1",
$1);
else if ($3 > (MaxAttrSize * BITS_PER_BYTE))
typname);
else if ($4 > (MaxAttrSize * BITS_PER_BYTE))
elog(ERROR, "length for type '%s' cannot exceed %d",
$1, (MaxAttrSize * BITS_PER_BYTE));
$$->typmod = $3;
typname, (MaxAttrSize * BITS_PER_BYTE));
$$->typmod = $4;
}
| bit
| BIT opt_varying
{
$$ = makeTypeName($1);
/* bit defaults to bit(1), varbit to no limit */
if (strcmp($1, "bit") == 0)
$$->typmod = 1;
else
if ($2)
{
$$ = SystemTypeName("varbit");
$$->typmod = -1;
}
;
bit: BIT opt_varying
{
char *type;
if ($2) type = xlateSqlType("varbit");
else type = xlateSqlType("bit");
$$ = type;
}
else
{
$$ = SystemTypeName("bit");
$$->typmod = 1;
}
}
;
@ -4490,10 +4515,10 @@ Character: character '(' Iconst ')' opt_charset
strcpy(type, $1);
strcat(type, "_");
strcat(type, $5);
$1 = xlateSqlType(type);
$1 = type;
}
$$ = makeTypeName($1);
$$ = SystemTypeName($1);
if ($3 < 1)
elog(ERROR, "length for type '%s' must be at least 1",
@ -4519,10 +4544,10 @@ Character: character '(' Iconst ')' opt_charset
strcpy(type, $1);
strcat(type, "_");
strcat(type, $2);
$1 = xlateSqlType(type);
$1 = type;
}
$$ = makeTypeName($1);
$$ = SystemTypeName($1);
/* char defaults to char(1), varchar to no limit */
if (strcmp($1, "bpchar") == 0)
@ -4532,12 +4557,12 @@ Character: character '(' Iconst ')' opt_charset
}
;
character: CHARACTER opt_varying { $$ = xlateSqlType($2 ? "varchar": "bpchar"); }
| CHAR opt_varying { $$ = xlateSqlType($2 ? "varchar": "bpchar"); }
| VARCHAR { $$ = xlateSqlType("varchar"); }
| NATIONAL CHARACTER opt_varying { $$ = xlateSqlType($3 ? "varchar": "bpchar"); }
| NATIONAL CHAR opt_varying { $$ = xlateSqlType($3 ? "varchar": "bpchar"); }
| NCHAR opt_varying { $$ = xlateSqlType($2 ? "varchar": "bpchar"); }
character: CHARACTER opt_varying { $$ = $2 ? "varchar": "bpchar"; }
| CHAR opt_varying { $$ = $2 ? "varchar": "bpchar"; }
| VARCHAR { $$ = "varchar"; }
| NATIONAL CHARACTER opt_varying { $$ = $3 ? "varchar": "bpchar"; }
| NATIONAL CHAR opt_varying { $$ = $3 ? "varchar": "bpchar"; }
| NCHAR opt_varying { $$ = $2 ? "varchar": "bpchar"; }
;
opt_varying: VARYING { $$ = TRUE; }
@ -4555,9 +4580,9 @@ opt_collate: COLLATE ColId { $$ = $2; }
ConstDatetime: TIMESTAMP '(' Iconst ')' opt_timezone
{
if ($5)
$$ = makeTypeName(xlateSqlType("timestamptz"));
$$ = SystemTypeName("timestamptz");
else
$$ = makeTypeName(xlateSqlType("timestamp"));
$$ = SystemTypeName("timestamp");
/* XXX the timezone field seems to be unused
* - thomas 2001-09-06
*/
@ -4570,9 +4595,9 @@ ConstDatetime: TIMESTAMP '(' Iconst ')' opt_timezone
| TIMESTAMP opt_timezone
{
if ($2)
$$ = makeTypeName(xlateSqlType("timestamptz"));
$$ = SystemTypeName("timestamptz");
else
$$ = makeTypeName(xlateSqlType("timestamp"));
$$ = SystemTypeName("timestamp");
/* XXX the timezone field seems to be unused
* - thomas 2001-09-06
*/
@ -4589,9 +4614,9 @@ ConstDatetime: TIMESTAMP '(' Iconst ')' opt_timezone
| TIME '(' Iconst ')' opt_timezone
{
if ($5)
$$ = makeTypeName(xlateSqlType("timetz"));
$$ = SystemTypeName("timetz");
else
$$ = makeTypeName(xlateSqlType("time"));
$$ = SystemTypeName("time");
if (($3 < 0) || ($3 > MAX_TIME_PRECISION))
elog(ERROR, "TIME(%d)%s precision must be between %d and %d",
$3, ($5 ? " WITH TIME ZONE": ""), 0, MAX_TIME_PRECISION);
@ -4600,9 +4625,9 @@ ConstDatetime: TIMESTAMP '(' Iconst ')' opt_timezone
| TIME opt_timezone
{
if ($2)
$$ = makeTypeName(xlateSqlType("timetz"));
$$ = SystemTypeName("timetz");
else
$$ = makeTypeName(xlateSqlType("time"));
$$ = SystemTypeName("time");
/* SQL99 specified a default precision of zero.
* See comments for timestamp above on why we will
* leave this unspecified for now. - thomas 2001-12-07
@ -4613,7 +4638,7 @@ ConstDatetime: TIMESTAMP '(' Iconst ')' opt_timezone
ConstInterval: INTERVAL
{
$$ = makeTypeName(xlateSqlType("interval"));
$$ = SystemTypeName("interval");
}
;
@ -5246,9 +5271,9 @@ c_expr: columnref
s->val.type = T_String;
s->val.val.str = "now";
s->typename = makeTypeName(xlateSqlType("text"));
s->typename = SystemTypeName("text");
d = makeTypeName(xlateSqlType("date"));
d = SystemTypeName("date");
$$ = (Node *)makeTypeCast((Node *)s, d);
}
@ -5263,9 +5288,9 @@ c_expr: columnref
s->val.type = T_String;
s->val.val.str = "now";
s->typename = makeTypeName(xlateSqlType("text"));
s->typename = SystemTypeName("text");
d = makeTypeName(xlateSqlType("timetz"));
d = SystemTypeName("timetz");
/* SQL99 mandates a default precision of zero for TIME
* fields in schemas. However, for CURRENT_TIME
* let's preserve the microsecond precision we
@ -5286,8 +5311,8 @@ c_expr: columnref
s->val.type = T_String;
s->val.val.str = "now";
s->typename = makeTypeName(xlateSqlType("text"));
d = makeTypeName(xlateSqlType("timetz"));
s->typename = SystemTypeName("text");
d = SystemTypeName("timetz");
if (($3 < 0) || ($3 > MAX_TIME_PRECISION))
elog(ERROR, "CURRENT_TIME(%d) precision must be between %d and %d",
$3, 0, MAX_TIME_PRECISION);
@ -5306,9 +5331,9 @@ c_expr: columnref
s->val.type = T_String;
s->val.val.str = "now";
s->typename = makeTypeName(xlateSqlType("text"));
s->typename = SystemTypeName("text");
d = makeTypeName(xlateSqlType("timestamptz"));
d = SystemTypeName("timestamptz");
/* SQL99 mandates a default precision of 6 for timestamp.
* Also, that is about as precise as we will get since
* we are using a microsecond time interface.
@ -5329,9 +5354,9 @@ c_expr: columnref
s->val.type = T_String;
s->val.val.str = "now";
s->typename = makeTypeName(xlateSqlType("text"));
s->typename = SystemTypeName("text");
d = makeTypeName(xlateSqlType("timestamptz"));
d = SystemTypeName("timestamptz");
if (($3 < 0) || ($3 > MAX_TIMESTAMP_PRECISION))
elog(ERROR, "CURRENT_TIMESTAMP(%d) precision must be between %d and %d",
$3, 0, MAX_TIMESTAMP_PRECISION);
@ -5841,7 +5866,7 @@ index_name: ColId { $$ = $1; };
file_name: Sconst { $$ = $1; };
func_name: function_name
{ $$ = makeList1(makeString(xlateSqlFunc($1))); }
{ $$ = makeList1(makeString($1)); }
| dotted_name
{ $$ = $1; }
;
@ -5929,7 +5954,7 @@ AexprConst: Iconst
A_Const *n = makeNode(A_Const);
n->val.type = T_String;
n->val.val.str = "t";
n->typename = makeTypeName(xlateSqlType("bool"));
n->typename = SystemTypeName("bool");
$$ = (Node *)n;
}
| FALSE_P
@ -5937,7 +5962,7 @@ AexprConst: Iconst
A_Const *n = makeNode(A_Const);
n->val.type = T_String;
n->val.val.str = "f";
n->typename = makeTypeName(xlateSqlType("bool"));
n->typename = SystemTypeName("bool");
$$ = (Node *)n;
}
| NULL_P
@ -6174,7 +6199,9 @@ unreserved_keyword:
* looks too much like a function call for an LR(1) parser.
*/
col_name_keyword:
BIT
BIGINT
| BIT
| BOOLEAN
| CHAR
| CHARACTER
| COALESCE
@ -6183,13 +6210,17 @@ col_name_keyword:
| EXISTS
| EXTRACT
| FLOAT
| INT
| INTEGER
| INTERVAL
| NCHAR
| NONE
| NULLIF
| NUMERIC
| POSITION
| REAL
| SETOF
| SMALLINT
| SUBSTRING
| TIME
| TIMESTAMP
@ -6365,7 +6396,7 @@ makeIntConst(int val)
A_Const *n = makeNode(A_Const);
n->val.type = T_Integer;
n->val.val.ival = val;
n->typename = makeTypeName(xlateSqlType("integer"));
n->typename = SystemTypeName("int4");
return (Node *)n;
}
@ -6377,7 +6408,7 @@ makeFloatConst(char *str)
n->val.type = T_Float;
n->val.val.str = str;
n->typename = makeTypeName(xlateSqlType("float"));
n->typename = SystemTypeName("float8");
return (Node *)n;
}
@ -6524,75 +6555,6 @@ makeSetOp(SetOperation op, bool all, Node *larg, Node *rarg)
return (Node *) n;
}
/* xlateSqlFunc()
* Convert alternate function names to internal Postgres functions.
*
* NOTE: these conversions are only applied to unqualified function names.
*
* Do not convert "float", since that is handled elsewhere
* for FLOAT(p) syntax.
*
* Converting "datetime" to "timestamp" and "timespan" to "interval"
* is a temporary expedient for pre-7.0 to 7.0 compatibility;
* these should go away for v7.1.
*/
char *
xlateSqlFunc(char *name)
{
if (strcmp(name,"character_length") == 0)
return "char_length";
else if (strcmp(name,"datetime") == 0)
return "timestamp";
else if (strcmp(name,"timespan") == 0)
return "interval";
else
return name;
} /* xlateSqlFunc() */
/* xlateSqlType()
* Convert alternate type names to internal Postgres types.
*
* NOTE: these conversions are only applied to unqualified type names.
*
* NB: do NOT put "char" -> "bpchar" here, because that renders it impossible
* to refer to our single-byte char type, even with quotes. (Without quotes,
* CHAR is a keyword, and the code above produces "bpchar" for it.)
*
* Convert "datetime" and "timespan" to allow a transition to SQL92 type names.
* Remove this translation for v7.1 - thomas 2000-03-25
*
* Convert "lztext" to "text" to allow forward compatibility for anyone using
* the undocumented "lztext" type in 7.0. This can go away in 7.2 or later
* - tgl 2000-07-30
*/
char *
xlateSqlType(char *name)
{
if ((strcmp(name,"int") == 0)
|| (strcmp(name,"integer") == 0))
return "int4";
else if (strcmp(name, "smallint") == 0)
return "int2";
else if (strcmp(name, "bigint") == 0)
return "int8";
else if (strcmp(name, "real") == 0)
return "float4";
else if (strcmp(name, "float") == 0)
return "float8";
else if (strcmp(name, "decimal") == 0)
return "numeric";
else if (strcmp(name, "datetime") == 0)
return "timestamp";
else if (strcmp(name, "timespan") == 0)
return "interval";
else if (strcmp(name, "lztext") == 0)
return "text";
else if (strcmp(name, "boolean") == 0)
return "bool";
else
return name;
} /* xlateSqlType() */
/* SystemFuncName()
* Build a properly-qualified reference to a built-in function.
*/
@ -6602,7 +6564,26 @@ SystemFuncName(char *name)
return makeList2(makeString("pg_catalog"), makeString(name));
}
void parser_init(Oid *typev, int nargs)
/* SystemTypeName()
* Build a properly-qualified reference to a built-in type.
*
* typmod is defaulted, but may be changed afterwards by caller.
*/
TypeName *
SystemTypeName(char *name)
{
TypeName *n = makeNode(TypeName);
n->names = makeList2(makeString("pg_catalog"), makeString(name));
n->typmod = -1;
return n;
}
/*
* Initialize to parse one query string
*/
void
parser_init(Oid *typev, int nargs)
{
QueryIsRule = FALSE;
/*
@ -6613,7 +6594,11 @@ void parser_init(Oid *typev, int nargs)
pfunc_num_args = nargs;
}
Oid param_type(int t)
/*
* Fetch a parameter type previously passed to parser_init
*/
Oid
param_type(int t)
{
if ((t > pfunc_num_args) || (t <= 0))
return InvalidOid;

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.108 2002/05/02 18:44:10 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.109 2002/05/03 00:32:16 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -50,8 +50,10 @@ static const ScanKeyword ScanKeywords[] = {
{"before", BEFORE},
{"begin", BEGIN_TRANS},
{"between", BETWEEN},
{"bigint", BIGINT},
{"binary", BINARY},
{"bit", BIT},
{"boolean", BOOLEAN},
{"both", BOTH},
{"by", BY},
{"cache", CACHE},
@ -142,6 +144,8 @@ static const ScanKeyword ScanKeywords[] = {
{"insensitive", INSENSITIVE},
{"insert", INSERT},
{"instead", INSTEAD},
{"int", INT},
{"integer", INTEGER},
{"intersect", INTERSECT},
{"interval", INTERVAL},
{"into", INTO},
@ -213,6 +217,7 @@ static const ScanKeyword ScanKeywords[] = {
{"procedural", PROCEDURAL},
{"procedure", PROCEDURE},
{"read", READ},
{"real", REAL},
{"references", REFERENCES},
{"reindex", REINDEX},
{"relative", RELATIVE},
@ -238,6 +243,7 @@ static const ScanKeyword ScanKeywords[] = {
{"setof", SETOF},
{"share", SHARE},
{"show", SHOW},
{"smallint", SMALLINT},
{"some", SOME},
{"start", START},
{"statement", STATEMENT},

View File

@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: pg_proc.h,v 1.235 2002/04/30 21:01:52 tgl Exp $
* $Id: pg_proc.h,v 1.236 2002/05/03 00:32:16 tgl Exp $
*
* NOTES
* The script catalog/genbki.sh reads this file and generates .bki
@ -1681,6 +1681,14 @@ DESCR("convert date and time with time zone to timestamp with time zone");
DATA(insert OID = 1364 ( time PGNSP PGUID 14 f t f t f i 1 1083 "702" 100 0 0 100 "select time(cast($1 as timestamp without time zone))" - _null_ ));
DESCR("convert abstime to time");
DATA(insert OID = 1367 ( character_length PGNSP PGUID 12 f t f t f i 1 23 "1042" 100 0 0 100 bpcharlen - _null_ ));
DESCR("character length");
DATA(insert OID = 1368 ( character_length PGNSP PGUID 12 f t f t f i 1 23 "1043" 100 0 0 100 varcharlen - _null_ ));
DESCR("character length");
DATA(insert OID = 1369 ( character_length PGNSP PGUID 12 f t f t f i 1 23 "25" 100 0 0 100 textlen - _null_ ));
DESCR("character length");
DATA(insert OID = 1370 ( interval PGNSP PGUID 12 f t t t f i 1 1186 "1083" 100 0 0 100 time_interval - _null_ ));
DESCR("convert time to interval");
DATA(insert OID = 1372 ( char_length PGNSP PGUID 12 f t f t f i 1 23 "1042" 100 0 0 100 bpcharlen - _null_ ));
@ -1705,7 +1713,7 @@ DATA(insert OID = 1380 ( timetz_smaller PGNSP PGUID 12 f t f t f i 2 1266 "12
DESCR("smaller of two");
DATA(insert OID = 1381 ( char_length PGNSP PGUID 12 f t f t f i 1 23 "25" 100 0 0 100 textlen - _null_ ));
DESCR("length");
DESCR("character length");
DATA(insert OID = 1382 ( date_part PGNSP PGUID 14 f t f t f s 2 701 "25 702" 100 0 0 100 "select date_part($1, timestamptz($2))" - _null_ ));
DESCR("extract field from abstime");

View File

@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: gramparse.h,v 1.21 2002/04/20 21:56:15 petere Exp $
* $Id: gramparse.h,v 1.22 2002/05/03 00:32:18 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -16,6 +16,7 @@
#define GRAMPARSE_H
#include "lib/stringinfo.h"
#include "nodes/parsenodes.h"
/* from parser.c */
extern int yylex(void);
@ -30,9 +31,8 @@ extern void yyerror(const char *message);
extern void parser_init(Oid *typev, int nargs);
extern Oid param_type(int t);
extern int yyparse(void);
extern char *xlateSqlFunc(char *name);
extern char *xlateSqlType(char *name);
extern List *SystemFuncName(char *name);
bool exprIsNullConstant(Node *arg);
extern TypeName *SystemTypeName(char *name);
extern bool exprIsNullConstant(Node *arg);
#endif /* GRAMPARSE_H */

View File

@ -3,7 +3,7 @@
* procedural language
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.40 2002/03/29 19:06:27 tgl Exp $
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.41 2002/05/03 00:32:18 tgl Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
@ -889,7 +889,7 @@ plpgsql_parse_wordtype(char *word)
*
* XXX this should be improved to handle qualified-type-name references.
*/
typeOid = LookupTypeName(makeTypeName(xlateSqlType(cp)));
typeOid = LookupTypeName(makeTypeName(cp));
if (OidIsValid(typeOid))
{
HeapTuple typeTup;

View File

@ -24,8 +24,8 @@ ALTER TABLE tmp ADD COLUMN r lseg;
ALTER TABLE tmp ADD COLUMN s path;
ALTER TABLE tmp ADD COLUMN t box;
ALTER TABLE tmp ADD COLUMN u tinterval;
ALTER TABLE tmp ADD COLUMN v datetime;
ALTER TABLE tmp ADD COLUMN w timespan;
ALTER TABLE tmp ADD COLUMN v timestamp;
ALTER TABLE tmp ADD COLUMN w interval;
ALTER TABLE tmp ADD COLUMN x float8[];
ALTER TABLE tmp ADD COLUMN y float4[];
ALTER TABLE tmp ADD COLUMN z int2[];
@ -69,8 +69,8 @@ ALTER TABLE tmp ADD COLUMN r lseg;
ALTER TABLE tmp ADD COLUMN s path;
ALTER TABLE tmp ADD COLUMN t box;
ALTER TABLE tmp ADD COLUMN u tinterval;
ALTER TABLE tmp ADD COLUMN v datetime;
ALTER TABLE tmp ADD COLUMN w timespan;
ALTER TABLE tmp ADD COLUMN v timestamp;
ALTER TABLE tmp ADD COLUMN w interval;
ALTER TABLE tmp ADD COLUMN x float8[];
ALTER TABLE tmp ADD COLUMN y float4[];
ALTER TABLE tmp ADD COLUMN z int2[];
@ -377,14 +377,14 @@ CREATE TEMP TABLE PKTABLE (ptest1 int, ptest2 inet,
PRIMARY KEY(ptest1, ptest2));
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'pktable_pkey' for table 'pktable'
-- This should fail, because we just chose really odd types
CREATE TEMP TABLE FKTABLE (ftest1 cidr, ftest2 datetime);
CREATE TEMP TABLE FKTABLE (ftest1 cidr, ftest2 timestamp);
ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1, ftest2) references pktable;
NOTICE: ALTER TABLE will create implicit trigger(s) for FOREIGN KEY check(s)
ERROR: Unable to identify an operator '=' for types 'cidr' and 'integer'
You will have to retype this query using an explicit cast
-- Again, so should this...
DROP TABLE FKTABLE;
CREATE TEMP TABLE FKTABLE (ftest1 cidr, ftest2 datetime);
CREATE TEMP TABLE FKTABLE (ftest1 cidr, ftest2 timestamp);
ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1, ftest2)
references pktable(ptest1, ptest2);
NOTICE: ALTER TABLE will create implicit trigger(s) for FOREIGN KEY check(s)

View File

@ -747,12 +747,12 @@ DROP TABLE PKTABLE;
CREATE TABLE PKTABLE (ptest1 int, ptest2 inet, PRIMARY KEY(ptest1, ptest2));
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'pktable_pkey' for table 'pktable'
-- This should fail, because we just chose really odd types
CREATE TABLE FKTABLE (ftest1 cidr, ftest2 datetime, FOREIGN KEY(ftest1, ftest2) REFERENCES pktable);
CREATE TABLE FKTABLE (ftest1 cidr, ftest2 timestamp, FOREIGN KEY(ftest1, ftest2) REFERENCES pktable);
NOTICE: CREATE TABLE will create implicit trigger(s) for FOREIGN KEY check(s)
ERROR: Unable to identify an operator '=' for types 'cidr' and 'integer'
You will have to retype this query using an explicit cast
-- Again, so should this...
CREATE TABLE FKTABLE (ftest1 cidr, ftest2 datetime, FOREIGN KEY(ftest1, ftest2) REFERENCES pktable(ptest1, ptest2));
CREATE TABLE FKTABLE (ftest1 cidr, ftest2 timestamp, FOREIGN KEY(ftest1, ftest2) REFERENCES pktable(ptest1, ptest2));
NOTICE: CREATE TABLE will create implicit trigger(s) for FOREIGN KEY check(s)
ERROR: Unable to identify an operator '=' for types 'cidr' and 'integer'
You will have to retype this query using an explicit cast

View File

@ -1013,7 +1013,7 @@ SELECT * FROM shoe_ready WHERE total_avail >= 2;
sl_name char(10), -- shoelace changed
sl_avail integer, -- new available value
log_who name, -- who did it
log_when datetime -- when
log_when timestamp -- when
);
-- Want "log_who" to be CURRENT_USER,
-- but that is non-portable for the regression test

View File

@ -46,9 +46,9 @@ ALTER TABLE tmp ADD COLUMN t box;
ALTER TABLE tmp ADD COLUMN u tinterval;
ALTER TABLE tmp ADD COLUMN v datetime;
ALTER TABLE tmp ADD COLUMN v timestamp;
ALTER TABLE tmp ADD COLUMN w timespan;
ALTER TABLE tmp ADD COLUMN w interval;
ALTER TABLE tmp ADD COLUMN x float8[];
@ -115,9 +115,9 @@ ALTER TABLE tmp ADD COLUMN t box;
ALTER TABLE tmp ADD COLUMN u tinterval;
ALTER TABLE tmp ADD COLUMN v datetime;
ALTER TABLE tmp ADD COLUMN v timestamp;
ALTER TABLE tmp ADD COLUMN w timespan;
ALTER TABLE tmp ADD COLUMN w interval;
ALTER TABLE tmp ADD COLUMN x float8[];
@ -256,11 +256,11 @@ DROP TABLE fktable;
CREATE TEMP TABLE PKTABLE (ptest1 int, ptest2 inet,
PRIMARY KEY(ptest1, ptest2));
-- This should fail, because we just chose really odd types
CREATE TEMP TABLE FKTABLE (ftest1 cidr, ftest2 datetime);
CREATE TEMP TABLE FKTABLE (ftest1 cidr, ftest2 timestamp);
ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1, ftest2) references pktable;
-- Again, so should this...
DROP TABLE FKTABLE;
CREATE TEMP TABLE FKTABLE (ftest1 cidr, ftest2 datetime);
CREATE TEMP TABLE FKTABLE (ftest1 cidr, ftest2 timestamp);
ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1, ftest2)
references pktable(ptest1, ptest2);
-- This fails because we mixed up the column ordering

View File

@ -448,9 +448,9 @@ DROP TABLE PKTABLE;
-- Two columns, two tables
CREATE TABLE PKTABLE (ptest1 int, ptest2 inet, PRIMARY KEY(ptest1, ptest2));
-- This should fail, because we just chose really odd types
CREATE TABLE FKTABLE (ftest1 cidr, ftest2 datetime, FOREIGN KEY(ftest1, ftest2) REFERENCES pktable);
CREATE TABLE FKTABLE (ftest1 cidr, ftest2 timestamp, FOREIGN KEY(ftest1, ftest2) REFERENCES pktable);
-- Again, so should this...
CREATE TABLE FKTABLE (ftest1 cidr, ftest2 datetime, FOREIGN KEY(ftest1, ftest2) REFERENCES pktable(ptest1, ptest2));
CREATE TABLE FKTABLE (ftest1 cidr, ftest2 timestamp, FOREIGN KEY(ftest1, ftest2) REFERENCES pktable(ptest1, ptest2));
-- This fails because we mixed up the column ordering
CREATE TABLE FKTABLE (ftest1 int, ftest2 inet, FOREIGN KEY(ftest2, ftest1) REFERENCES pktable);
-- As does this...

View File

@ -591,7 +591,7 @@ SELECT * FROM shoe_ready WHERE total_avail >= 2;
sl_name char(10), -- shoelace changed
sl_avail integer, -- new available value
log_who name, -- who did it
log_when datetime -- when
log_when timestamp -- when
);
-- Want "log_who" to be CURRENT_USER,