Commit 53cedcac authored by Tom Lane's avatar Tom Lane

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.
parent c2def1b1
......@@ -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",
......
This diff is collapsed.
......@@ -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},
......
......@@ -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");
......
......@@ -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 */
......@@ -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;
......
......@@ -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)
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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...
......
......@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment