Allow BEGIN WORK to specify transaction isolation level, like START
authorBruce Momjian
Sat, 10 Jan 2004 02:21:08 +0000 (02:21 +0000)
committerBruce Momjian
Sat, 10 Jan 2004 02:21:08 +0000 (02:21 +0000)
TRANSACTION.

doc/src/sgml/ref/begin.sgml
doc/src/sgml/ref/start_transaction.sgml
src/backend/parser/gram.y
src/bin/psql/tab-complete.c

index 66fcda1776dc776e612dd6fe8a231ee00bf875cb..03fcbf97f276e7082d639c2585758d72fed4b877 100644 (file)
@@ -1,5 +1,5 @@
 
 
@@ -21,6 +21,8 @@ PostgreSQL documentation
  
 
 BEGIN [ WORK | TRANSACTION ]
+    [ ISOLATION LEVEL { READ UNCOMMITTED | READ COMMITTED | REPEATABLE READ | SERIALIZABLE } ]
+    [ READ WRITE | READ ONLY ]
 
  
  
@@ -49,6 +51,13 @@ BEGIN [ WORK | TRANSACTION ]
    other sessions will be unable to see the intermediate states
    wherein not all the related updates have been done.
   
+
+  
+   If the isolation level or read/write mode is specified, the new
+   transaction has those characteristics, as if
+    
+   was executed.
+  
  
   
  
@@ -65,6 +74,12 @@ BEGIN [ WORK | TRANSACTION ]
     
    
   
+
+  
+   See under 
+   endterm="sql-set-transaction-title"> about the meaning of the
+   other parameters.
+  
  
   
  
index 3ac66c883aa2a940e1734a06c5d0dcec09b15784..98881920baee0a1e4745484036ba1c700cdf6a50 100644 (file)
@@ -1,5 +1,5 @@
 
 
@@ -33,9 +33,8 @@ START TRANSACTION
    This command begins a new transaction. If the isolation level or
    read/write mode is specified, the new transaction has those
    characteristics, as if 
-   endterm="sql-set-transaction-title"> was executed. In all other
-   respects, the behavior of this command is identical to the 
-   linkend="sql-begin" endterm="sql-begin-title"> command.
+   endterm="sql-set-transaction-title"> was executed. It is the same
+   as the  command.
   
  
 
index fa7ba0ecde75fede76f92afbdad2d82e1c724c04..cd8c092a45f3e45b5bdee01c10e2a2951e419a1d 100644 (file)
@@ -11,7 +11,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.443 2004/01/07 18:56:27 neilc Exp $
+ *   $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.444 2004/01/10 02:21:08 momjian Exp $
  *
  * HISTORY
  *   AUTHOR            DATE            MAJOR EVENT
@@ -3674,11 +3674,11 @@ TransactionStmt:
                    n->options = NIL;
                    $$ = (Node *)n;
                }
-           | BEGIN_P opt_transaction
+           | BEGIN_P opt_transaction transaction_mode_list_or_empty
                {
                    TransactionStmt *n = makeNode(TransactionStmt);
                    n->kind = TRANS_STMT_BEGIN;
-                   n->options = NIL;
+                   n->options = $3;
                    $$ = (Node *)n;
                }
            | START TRANSACTION transaction_mode_list_or_empty
index 955e70deb8b471e6687ca646206466089a82731d..58ef84f9a525207b101e4af8c2c5a38d21481614 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 2000-2003, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.97 2003/12/01 22:21:54 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.98 2004/01/10 02:21:08 momjian Exp $
  */
 
 /*----------------------------------------------------------------------
@@ -723,6 +723,18 @@ psql_completion(char *text, int start, int end)
    else if (strcasecmp(prev2_wd, "ANALYZE") == 0)
        COMPLETE_WITH_CONST(";");
 
+/* BEGIN, COMMIT, ROLLBACK, ABORT, */
+   else if (strcasecmp(prev_wd, "BEGIN") == 0 ||
+            strcasecmp(prev_wd, "END") == 0 ||
+            strcasecmp(prev_wd, "COMMIT") == 0 ||
+            strcasecmp(prev_wd, "ROLLBACK") == 0 ||
+            strcasecmp(prev_wd, "ABORT") == 0)
+   {
+       static const char * const list_TRANS[] =
+       {"WORK", "TRANSACTION", NULL};
+
+       COMPLETE_WITH_LIST(list_TRANS);
+   }
 /* CLUSTER */
    /* If the previous word is CLUSTER, produce list of indexes. */
    else if (strcasecmp(prev_wd, "CLUSTER") == 0)
@@ -1099,10 +1111,14 @@ psql_completion(char *text, int start, int end)
             strcasecmp(prev_wd, "SHOW") == 0)
        COMPLETE_WITH_LIST(pgsql_variables);
    /* Complete "SET TRANSACTION" */
-   else if ((strcasecmp(prev2_wd, "SET") == 0
-             && strcasecmp(prev_wd, "TRANSACTION") == 0)
+   else if ((strcasecmp(prev2_wd, "SET") == 0 &&
+             strcasecmp(prev_wd, "TRANSACTION") == 0)
             || (strcasecmp(prev2_wd, "START") == 0
                 && strcasecmp(prev_wd, "TRANSACTION") == 0)
+            || (strcasecmp(prev2_wd, "BEGIN") == 0
+                && strcasecmp(prev_wd, "WORK") == 0)
+            || (strcasecmp(prev2_wd, "BEGIN") == 0
+                && strcasecmp(prev_wd, "TRANSACTION") == 0)
             || (strcasecmp(prev4_wd, "SESSION") == 0
                 && strcasecmp(prev3_wd, "CHARACTERISTICS") == 0
                 && strcasecmp(prev2_wd, "AS") == 0