diff options
author | Marc G. Fournier | 1998-07-24 03:32:46 +0000 |
---|---|---|
committer | Marc G. Fournier | 1998-07-24 03:32:46 +0000 |
commit | bf00bbb0c4940b80b46b7e5b379cd64184f2262f (patch) | |
tree | bf32bf3bafe6f367ee97249c83afb4c9e9a637af /src/backend/parser | |
parent | 6e66468f3a160878111578a93be2852635eb4f4d (diff) |
I really hope that I haven't missed anything in this one...
From: t-ishii@sra.co.jp
Attached are patches to enhance the multi-byte support. (patches are
against 7/18 snapshot)
* determine encoding at initdb/createdb rather than compile time
Now initdb/createdb has an option to specify the encoding. Also, I
modified the syntax of CREATE DATABASE to accept encoding option. See
README.mb for more details.
For this purpose I have added new column "encoding" to pg_database.
Also pg_attribute and pg_class are changed to catch up the
modification to pg_database. Actually I haved added pg_database_mb.h,
pg_attribute_mb.h and pg_class_mb.h. These are used only when MB is
enabled. The reason having separate files is I couldn't find a way to
use ifdef or whatever in those files. I have to admit it looks
ugly. No way.
* support for PGCLIENTENCODING when issuing COPY command
commands/copy.c modified.
* support for SQL92 syntax "SET NAMES"
See gram.y.
* support for LATIN2-5
* add UNICODE regression test case
* new test suite for MB
New directory test/mb added.
* clean up source files
Basic idea is to have MB's own subdirectory for easier maintenance.
These are include/mb and backend/utils/mb.
Diffstat (limited to 'src/backend/parser')
-rw-r--r-- | src/backend/parser/Makefile | 5 | ||||
-rw-r--r-- | src/backend/parser/gram.y | 64 | ||||
-rw-r--r-- | src/backend/parser/keywords.c | 4 |
3 files changed, 64 insertions, 9 deletions
diff --git a/src/backend/parser/Makefile b/src/backend/parser/Makefile index 33702f6da14..2ee71b73808 100644 --- a/src/backend/parser/Makefile +++ b/src/backend/parser/Makefile @@ -4,7 +4,7 @@ # Makefile for parser # # IDENTIFICATION -# $Header: /cvsroot/pgsql/src/backend/parser/Makefile,v 1.17 1998/05/13 04:54:16 thomas Exp $ +# $Header: /cvsroot/pgsql/src/backend/parser/Makefile,v 1.18 1998/07/24 03:31:21 scrappy Exp $ # #------------------------------------------------------------------------- @@ -17,6 +17,9 @@ ifeq ($(CC), gcc) CFLAGS+= -Wno-error endif +ifdef MB +CFLAGS+= -DMB=$(MB) +endif OBJS= analyze.o gram.o keywords.o parser.o parse_agg.o parse_clause.o \ parse_expr.o parse_func.o parse_node.o parse_oper.o parse_relation.o \ diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y index 71d4a204c65..6d5f1a3d250 100644 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.15 1998/07/19 05:49:22 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.16 1998/07/24 03:31:23 scrappy Exp $ * * HISTORY * AUTHOR DATE MAJOR EVENT @@ -46,6 +46,10 @@ #include "utils/elog.h" #include "access/xact.h" +#ifdef MB +#include "mb/pg_wchar.h" +#endif + static char saved_relname[NAMEDATALEN]; /* need this for complex attributes */ static bool QueryIsRule = FALSE; static List *saved_In_Expr = NIL; @@ -126,7 +130,7 @@ Oid param_type(int t); /* used in parse_expr.c */ ExplainStmt, VariableSetStmt, VariableShowStmt, VariableResetStmt, CreateUserStmt, AlterUserStmt, DropUserStmt -%type <str> opt_database, location +%type <str> opt_database1, opt_database2, location, encoding %type <pboolean> user_createdb_clause, user_createuser_clause %type <str> user_passwd_clause @@ -262,7 +266,7 @@ Oid param_type(int t); /* used in parse_expr.c */ GRANT, GROUP, HAVING, HOUR_P, IN, INNER_P, INSERT, INTERVAL, INTO, IS, JOIN, KEY, LANGUAGE, LEADING, LEFT, LIKE, LOCAL, - MATCH, MINUTE_P, MONTH_P, + MATCH, MINUTE_P, MONTH_P, NAMES, NATIONAL, NATURAL, NCHAR, NO, NOT, NOTIFY, NULL_P, NUMERIC, ON, OPTION, OR, ORDER, OUTER_P, PARTIAL, POSITION, PRECISION, PRIMARY, PRIVILEGES, PROCEDURE, PUBLIC, @@ -290,7 +294,7 @@ Oid param_type(int t); /* used in parse_expr.c */ NEW, NONE, NOTHING, NOTNULL, OIDS, OPERATOR, PROCEDURAL, RECIPE, RENAME, RESET, RETURNS, ROW, RULE, SEQUENCE, SETOF, SHOW, START, STATEMENT, STDIN, STDOUT, TRUSTED, - VACUUM, VERBOSE, VERSION + VACUUM, VERBOSE, VERSION, ENCODING /* Keywords (obsolete; retain through next version for parser - thomas 1997-12-04) */ %token ARCHIVE @@ -535,6 +539,17 @@ VariableSetStmt: SET ColId TO var_value n->value = $4; $$ = (Node *) n; } + | SET NAMES encoding + { +#ifdef MB + VariableSetStmt *n = makeNode(VariableSetStmt); + n->name = "client_encoding"; + n->value = $3; + $$ = (Node *) n; +#else + elog(ERROR, "SET NAMES is not supported"); +#endif + } ; var_value: Sconst { $$ = $1; } @@ -2094,16 +2109,45 @@ LoadStmt: LOAD file_name * *****************************************************************************/ -CreatedbStmt: CREATE DATABASE database_name opt_database +CreatedbStmt: CREATE DATABASE database_name WITH opt_database1 opt_database2 { CreatedbStmt *n = makeNode(CreatedbStmt); + if ($5 == NULL && $6 == NULL) { + elog(ERROR, "CREATE DATABASE WITH requires at least an option"); + } n->dbname = $3; - n->dbpath = $4; + n->dbpath = $5; +#ifdef MB + if ($6 != NULL) { + n->encoding = pg_char_to_encoding($6); + if (n->encoding < 0) { + elog(ERROR, "invalid encoding name %s", $6); + } + } else { + n->encoding = GetTemplateEncoding(); + } +#else + elog(ERROR, "WITH ENCODING is not supported"); +#endif $$ = (Node *)n; } + | CREATE DATABASE database_name + { + CreatedbStmt *n = makeNode(CreatedbStmt); + n->dbname = $3; + n->dbpath = NULL; +#ifdef MB + n->encoding = GetTemplateEncoding(); +#endif + $$ = (Node *)n; + } + ; + +opt_database1: LOCATION '=' location { $$ = $3; } + | /*EMPTY*/ { $$ = NULL; } ; -opt_database: WITH LOCATION '=' location { $$ = $4; } +opt_database2: ENCODING '=' encoding { $$ = $3; } | /*EMPTY*/ { $$ = NULL; } ; @@ -2112,6 +2156,11 @@ location: Sconst { $$ = $1; } | /*EMPTY*/ { $$ = NULL; } ; +encoding: Sconst { $$ = $1; } + | DEFAULT { $$ = NULL; } + | /*EMPTY*/ { $$ = NULL; } + ; + /***************************************************************************** * * QUERY: @@ -4487,6 +4536,7 @@ ColId: IDENT { $$ = $1; } | DELIMITERS { $$ = "delimiters"; } | DOUBLE { $$ = "double"; } | EACH { $$ = "each"; } + | ENCODING { $$ = "encoding"; } | FUNCTION { $$ = "function"; } | INCREMENT { $$ = "increment"; } | INDEX { $$ = "index"; } diff --git a/src/backend/parser/keywords.c b/src/backend/parser/keywords.c index b94a59d49ca..c3b53722a31 100644 --- a/src/backend/parser/keywords.c +++ b/src/backend/parser/keywords.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.37 1998/05/09 23:28:49 thomas Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.38 1998/07/24 03:31:24 scrappy Exp $ * *------------------------------------------------------------------------- */ @@ -86,6 +86,7 @@ static ScanKeyword ScanKeywords[] = { {"double", DOUBLE}, {"drop", DROP}, {"each", EACH}, + {"encoding", ENCODING}, {"end", END_TRANS}, {"execute", EXECUTE}, {"exists", EXISTS}, @@ -135,6 +136,7 @@ static ScanKeyword ScanKeywords[] = { {"minvalue", MINVALUE}, {"month", MONTH_P}, {"move", MOVE}, + {"names", NAMES}, {"national", NATIONAL}, {"natural", NATURAL}, {"nchar", NCHAR}, |