Re: [HACKERS] BEGIN vs START TRANSACTION

Поиск
Список
Период
Сортировка
От Bruce Momjian
Тема Re: [HACKERS] BEGIN vs START TRANSACTION
Дата
Msg-id 200311090307.hA937Te11012@candle.pha.pa.us
обсуждение исходный текст
Ответы Re: [HACKERS] BEGIN vs START TRANSACTION  (Peter Eisentraut <peter_e@gmx.net>)
Список pgsql-patches
Gaetano Mendola wrote:
> Hi all,
> why START TRANSACTION READ ONLY is allowed
> and not BEGIN READ ONLY ?

Seems it should be allowed so that BEGIN and START TRANSACTION behave
the same.

In fact, the BEGIN manual page says:

   <xref linkend="sql-start-transaction"
   endterm="sql-start-transaction-title"> has the same functionality
   as <command>BEGIN</>.

which is currently not true because START TRANSACTION has additional
options.  The following patch fixes it.  I will put it into 7.5 after an
appropriate delay.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
Index: doc/src/sgml/ref/begin.sgml
===================================================================
RCS file: /cvsroot/pgsql-server/doc/src/sgml/ref/begin.sgml,v
retrieving revision 1.26
diff -c -c -r1.26 begin.sgml
*** doc/src/sgml/ref/begin.sgml    9 Sep 2003 18:28:52 -0000    1.26
--- doc/src/sgml/ref/begin.sgml    9 Nov 2003 03:06:01 -0000
***************
*** 21,26 ****
--- 21,28 ----
   <refsynopsisdiv>
  <synopsis>
  BEGIN [ WORK | TRANSACTION ]
+     [ ISOLATION LEVEL { READ UNCOMMITTED | READ COMMITTED | REPEATABLE READ | SERIALIZABLE } ]
+     [ READ WRITE | READ ONLY ]
  </synopsis>
   </refsynopsisdiv>

***************
*** 49,54 ****
--- 51,63 ----
     other sessions will be unable to see the intermediate states
     wherein not all the related updates have been done.
    </para>
+
+   <para>
+    If the isolation level or read/write mode is specified, the new
+    transaction has those characteristics, as if
+    <xref linkend="sql-set-transaction" endterm="sql-set-transaction-title">
+    was executed.
+   </para>
   </refsect1>

   <refsect1>
***************
*** 65,70 ****
--- 74,85 ----
      </listitem>
     </varlistentry>
    </variablelist>
+
+   <para>
+    See under <xref linkend="sql-set-transaction"
+    endterm="sql-set-transaction-title"> about the meaning of the
+    other parameters.
+   </para>
   </refsect1>

   <refsect1>
Index: doc/src/sgml/ref/start_transaction.sgml
===================================================================
RCS file: /cvsroot/pgsql-server/doc/src/sgml/ref/start_transaction.sgml,v
retrieving revision 1.8
diff -c -c -r1.8 start_transaction.sgml
*** doc/src/sgml/ref/start_transaction.sgml    6 Nov 2003 22:08:14 -0000    1.8
--- doc/src/sgml/ref/start_transaction.sgml    9 Nov 2003 03:06:01 -0000
***************
*** 33,41 ****
     This command begins a new transaction. If the isolation level or
     read/write mode is specified, the new transaction has those
     characteristics, as if <xref linkend="sql-set-transaction"
!    endterm="sql-set-transaction-title"> was executed. In all other
!    respects, the behavior of this command is identical to the <xref
!    linkend="sql-begin" endterm="sql-begin-title"> command.
    </para>
   </refsect1>

--- 33,40 ----
     This command begins a new transaction. If the isolation level or
     read/write mode is specified, the new transaction has those
     characteristics, as if <xref linkend="sql-set-transaction"
!    endterm="sql-set-transaction-title"> was executed. It is the same
!    as the <xref linkend="sql-begin" endterm="sql-begin-title"> command.
    </para>
   </refsect1>

Index: src/backend/parser/gram.y
===================================================================
RCS file: /cvsroot/pgsql-server/src/backend/parser/gram.y,v
retrieving revision 2.437
diff -c -c -r2.437 gram.y
*** src/backend/parser/gram.y    6 Nov 2003 22:08:14 -0000    2.437
--- src/backend/parser/gram.y    9 Nov 2003 03:06:07 -0000
***************
*** 3607,3617 ****
                      n->options = NIL;
                      $$ = (Node *)n;
                  }
!             | BEGIN_P opt_transaction
                  {
                      TransactionStmt *n = makeNode(TransactionStmt);
                      n->kind = TRANS_STMT_BEGIN;
!                     n->options = NIL;
                      $$ = (Node *)n;
                  }
              | START TRANSACTION transaction_mode_list_or_empty
--- 3607,3617 ----
                      n->options = NIL;
                      $$ = (Node *)n;
                  }
!             | BEGIN_P opt_transaction transaction_mode_list_or_empty
                  {
                      TransactionStmt *n = makeNode(TransactionStmt);
                      n->kind = TRANS_STMT_BEGIN;
!                     n->options = $3;
                      $$ = (Node *)n;
                  }
              | START TRANSACTION transaction_mode_list_or_empty

В списке pgsql-patches по дате отправления:

Предыдущее
От: "Marc G. Fournier"
Дата:
Сообщение: Re: [pgsql-hackers-win32] WIN32_DEV CVS branch
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: pg_autovacuum README patch