summaryrefslogtreecommitdiff
path: root/src/backend/parser
diff options
context:
space:
mode:
authorTatsuo Ishii <ishii@postgresql.org>2002-07-11 07:39:28 +0000
committerTatsuo Ishii <ishii@postgresql.org>2002-07-11 07:39:28 +0000
commitfcc962566a7cf0461778c97ef713fa4855303dfe (patch)
tree507fb3d31a7cba6a6258b40ec5c9364f3ec9a3a6 /src/backend/parser
parentf2bb1cfa85eba18b185c8883a8da6077f7888ec2 (diff)
Add new CREATE CONVERSION/DROP CONVERSION command.
This is the first cut toward CREATE CONVERSION/DROP CONVERSION implementaion. The commands can now add/remove tuples to the new pg_conversion system catalog, but that's all. Still need work to make them actually working. Documentations, regression tests also need work.
Diffstat (limited to 'src/backend/parser')
-rw-r--r--src/backend/parser/gram.y37
-rw-r--r--src/backend/parser/keywords.c3
2 files changed, 35 insertions, 5 deletions
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index e8e5aeabc77..18b349c4ee2 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.337 2002/07/06 20:16:35 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.338 2002/07/11 07:39:25 ishii Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
@@ -157,7 +157,7 @@ static void doNegateFloat(Value *v);
SelectStmt, TransactionStmt, TruncateStmt,
UnlistenStmt, UpdateStmt, VacuumStmt,
VariableResetStmt, VariableSetStmt, VariableShowStmt,
- ViewStmt, CheckPointStmt
+ ViewStmt, CheckPointStmt, CreateConversionStmt
%type <node> select_no_parens, select_with_parens, select_clause,
simple_select
@@ -246,7 +246,7 @@ static void doNegateFloat(Value *v);
%type <boolean> opt_instead, opt_cursor
%type <boolean> index_opt_unique, opt_verbose, opt_full
-%type <boolean> opt_freeze
+%type <boolean> opt_freeze, opt_default
%type <defelt> opt_binary, opt_oids, copy_delimiter
%type <boolean> copy_from
@@ -335,7 +335,7 @@ static void doNegateFloat(Value *v);
CACHE, CALLED, CASCADE, CASE, CAST, CHAIN, CHAR_P,
CHARACTER, CHARACTERISTICS, CHECK, CHECKPOINT, CLOSE,
CLUSTER, COALESCE, COLLATE, COLUMN, COMMENT, COMMIT,
- COMMITTED, CONSTRAINT, CONSTRAINTS, COPY, CREATE, CREATEDB,
+ COMMITTED, CONSTRAINT, CONSTRAINTS, CONVERSION_P, COPY, CREATE, CREATEDB,
CREATEUSER, CROSS, CURRENT_DATE, CURRENT_TIME,
CURRENT_TIMESTAMP, CURRENT_USER, CURSOR, CYCLE,
@@ -532,6 +532,7 @@ stmt :
| VariableResetStmt
| ConstraintsSetStmt
| CheckPointStmt
+ | CreateConversionStmt
| /*EMPTY*/
{ $$ = (Node *)NULL; }
;
@@ -2299,6 +2300,7 @@ drop_type: TABLE { $$ = DROP_TABLE; }
| INDEX { $$ = DROP_INDEX; }
| TYPE_P { $$ = DROP_TYPE; }
| DOMAIN_P { $$ = DROP_DOMAIN; }
+ | CONVERSION_P { $$ = DROP_CONVERSION; }
;
any_name_list:
@@ -3675,6 +3677,33 @@ opt_as: AS {}
/*****************************************************************************
*
+ * Manipulate a conversion
+ *
+ * CREATE [DEFAULT] CONVERSION <conversion_name>
+ * FOR <encoding_name> TO <encoding_name> FROM <func_name>
+ *
+ *****************************************************************************/
+
+CreateConversionStmt:
+ CREATE opt_default CONVERSION_P any_name FOR Sconst
+ TO Sconst FROM any_name
+ {
+ CreateConversionStmt *n = makeNode(CreateConversionStmt);
+ n->conversion_name = $4;
+ n->for_encoding_name = $6;
+ n->to_encoding_name = $8;
+ n->func_name = $10;
+ n->def = $2;
+ $$ = (Node *)n;
+ }
+ ;
+
+opt_default: DEFAULT { $$ = TRUE; }
+ | /*EMPTY*/ { $$ = FALSE; }
+ ;
+
+/*****************************************************************************
+ *
* QUERY:
* cluster <index_name> on <qualified_name>
*
diff --git a/src/backend/parser/keywords.c b/src/backend/parser/keywords.c
index 92920ee4f7d..907a26baee6 100644
--- a/src/backend/parser/keywords.c
+++ b/src/backend/parser/keywords.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.118 2002/07/04 15:24:01 thomas Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.119 2002/07/11 07:39:26 ishii Exp $
*
*-------------------------------------------------------------------------
*/
@@ -78,6 +78,7 @@ static const ScanKeyword ScanKeywords[] = {
{"committed", COMMITTED},
{"constraint", CONSTRAINT},
{"constraints", CONSTRAINTS},
+ {"conversion", CONVERSION_P},
{"copy", COPY},
{"create", CREATE},
{"createdb", CREATEDB},