aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2004-08-12 21:00:34 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2004-08-12 21:00:34 +0000
commit7f7e8cc3f2cc95098154a722a6d5c6f61190a043 (patch)
treec49e2a116b3b09bdbb638ae49a2b3358c7541a6e /src
parent9e01aaa8bfa4c1684a93dca2ca14a9c8edf3bf9a (diff)
downloadpostgresql-7f7e8cc3f2cc95098154a722a6d5c6f61190a043.tar.gz
postgresql-7f7e8cc3f2cc95098154a722a6d5c6f61190a043.zip
Allow commas in BEGIN, START TRANSACTION, and SET TRANSACTION, as required
by the SQL standard. For backwards compatibility, however, continue to accept the syntax without. Minor editorialization in the reference pages for these commands, too.
Diffstat (limited to 'src')
-rw-r--r--src/backend/parser/gram.y54
-rw-r--r--src/backend/tcop/utility.c30
2 files changed, 38 insertions, 46 deletions
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index 6a27714b05e..e8bc3cf5ade 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.470 2004/08/12 19:12:21 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.471 2004/08/12 21:00:28 tgl Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
@@ -161,11 +161,11 @@ static void doNegateFloat(Value *v);
%type <dbehavior> opt_drop_behavior
-%type <list> createdb_opt_list copy_opt_list
-%type <defelt> createdb_opt_item copy_opt_item
+%type <list> createdb_opt_list copy_opt_list transaction_mode_list
+%type <defelt> createdb_opt_item copy_opt_item transaction_mode_item
%type <ival> opt_lock lock_type cast_context
-%type <boolean> opt_force opt_or_replace transaction_access_mode
+%type <boolean> opt_force opt_or_replace
opt_grant_grant_option opt_revoke_grant_option
opt_nowait
@@ -222,7 +222,7 @@ static void doNegateFloat(Value *v);
target_list update_target_list insert_column_list
insert_target_list def_list indirection opt_indirection
group_clause TriggerFuncArgs select_limit
- opt_select_limit opclass_item_list transaction_mode_list
+ opt_select_limit opclass_item_list
transaction_mode_list_or_empty
TableFuncElementList
prep_type_clause prep_type_list
@@ -4021,27 +4021,26 @@ opt_transaction: WORK {}
| /*EMPTY*/ {}
;
-transaction_mode_list:
+transaction_mode_item:
ISOLATION LEVEL iso_level
- { $$ = list_make1(makeDefElem("transaction_isolation",
- makeStringConst($3, NULL))); }
- | transaction_access_mode
- { $$ = list_make1(makeDefElem("transaction_read_only",
- makeIntConst($1))); }
- | ISOLATION LEVEL iso_level transaction_access_mode
- {
- $$ = list_make2(makeDefElem("transaction_isolation",
- makeStringConst($3, NULL)),
- makeDefElem("transaction_read_only",
- makeIntConst($4)));
- }
- | transaction_access_mode ISOLATION LEVEL iso_level
- {
- $$ = list_make2(makeDefElem("transaction_read_only",
- makeIntConst($1)),
- makeDefElem("transaction_isolation",
- makeStringConst($4, NULL)));
- }
+ { $$ = makeDefElem("transaction_isolation",
+ makeStringConst($3, NULL)); }
+ | READ ONLY
+ { $$ = makeDefElem("transaction_read_only",
+ makeIntConst(TRUE)); }
+ | READ WRITE
+ { $$ = makeDefElem("transaction_read_only",
+ makeIntConst(FALSE)); }
+ ;
+
+/* Syntax with commas is SQL-spec, without commas is Postgres historical */
+transaction_mode_list:
+ transaction_mode_item
+ { $$ = list_make1($1); }
+ | transaction_mode_list ',' transaction_mode_item
+ { $$ = lappend($1, $3); }
+ | transaction_mode_list transaction_mode_item
+ { $$ = lappend($1, $2); }
;
transaction_mode_list_or_empty:
@@ -4050,11 +4049,6 @@ transaction_mode_list_or_empty:
{ $$ = NIL; }
;
-transaction_access_mode:
- READ ONLY { $$ = TRUE; }
- | READ WRITE { $$ = FALSE; }
- ;
-
/*****************************************************************************
*
diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c
index 89ac4843ba8..0fff253a61c 100644
--- a/src/backend/tcop/utility.c
+++ b/src/backend/tcop/utility.c
@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/tcop/utility.c,v 1.224 2004/08/12 19:12:21 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/tcop/utility.c,v 1.225 2004/08/12 21:00:34 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -333,23 +333,21 @@ ProcessUtility(Node *parsetree,
case TRANS_STMT_BEGIN:
case TRANS_STMT_START:
{
- BeginTransactionBlock();
+ ListCell *lc;
- if (stmt->options)
+ BeginTransactionBlock();
+ foreach(lc, stmt->options)
{
- ListCell *head;
-
- foreach(head, stmt->options)
- {
- DefElem *item = (DefElem *) lfirst(head);
-
- if (strcmp(item->defname, "transaction_isolation") == 0)
- SetPGVariable("transaction_isolation",
- list_make1(item->arg), false);
- else if (strcmp(item->defname, "transaction_read_only") == 0)
- SetPGVariable("transaction_read_only",
- list_make1(item->arg), false);
- }
+ DefElem *item = (DefElem *) lfirst(lc);
+
+ if (strcmp(item->defname, "transaction_isolation") == 0)
+ SetPGVariable("transaction_isolation",
+ list_make1(item->arg),
+ false);
+ else if (strcmp(item->defname, "transaction_read_only") == 0)
+ SetPGVariable("transaction_read_only",
+ list_make1(item->arg),
+ false);
}
}
break;