Make SET SESSION CHARACTERISTICS compliant with SQL 99. Remove redundant,
authorPeter Eisentraut <peter_e@gmx.net>
Fri, 24 Nov 2000 20:16:40 +0000 (20:16 +0000)
committerPeter Eisentraut <peter_e@gmx.net>
Fri, 24 Nov 2000 20:16:40 +0000 (20:16 +0000)
non-standard clauses.  Allow CHARACTERISTICS as unquoted identifier.
Merge related reference pages.

doc/src/sgml/ref/allfiles.sgml
doc/src/sgml/ref/set_session.sgml [deleted file]
doc/src/sgml/ref/set_transaction.sgml
src/backend/nodes/copyfuncs.c
src/backend/nodes/equalfuncs.c
src/backend/parser/analyze.c
src/backend/parser/gram.y
src/include/nodes/nodes.h
src/include/nodes/parsenodes.h

index d18aaeaf97ebb799df4a043424e9dc0875d4b021..4a63f5c4efe737484263e58a14ee0aa4005a57b5 100644 (file)
@@ -95,7 +95,6 @@ Complete list of usable sgml source files in this directory.
 <!entity select             system "select.sgml">
 <!entity selectInto         system "select_into.sgml">
 <!entity set                system "set.sgml">
-<!entity setSession         system "set_session.sgml">
 <!entity setConstraints     system "set_constraints.sgml">
 <!entity setTransaction     system "set_transaction.sgml">
 <!entity show               system "show.sgml">
diff --git a/doc/src/sgml/ref/set_session.sgml b/doc/src/sgml/ref/set_session.sgml
deleted file mode 100644 (file)
index d6d90c4..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-<!--
-$Header$
-Postgres documentation
--->
-
-<refentry id="SQL-SET-SESSION">
- <refmeta>
-  <refentrytitle id="SQL-SET-SESSION-TITLE">SET</refentrytitle>
-  <refmiscinfo>SQL - Language Statements</refmiscinfo>
- </refmeta>
- <refnamediv>
-  <refname>SET SESSION CHARACTERISTICS</refname>
-  <refpurpose>Set per-session run-time parameters</refpurpose>
- </refnamediv>
- <refsynopsisdiv>
-  <synopsis>
-SET SESSION CHARACTERISTICS TRANSACTION ISOLATION LEVEL { READ COMMITTED | SERIALIZABLE }
-SET SESSION CHARACTERISTICS TIME ZONE { '<replaceable class="PARAMETER">timezone</replaceable>' | LOCAL | DEFAULT }
-  </synopsis>
- </refsynopsisdiv>
-
- <refsect1 id="R1-SQL-SET-SESSION-1">
-  <title>Description</title>
-  <para>
-   <command>SET SESSION CHARACTERISTICS</command> changes the run-time
-   environment for the entire <acronym>SQL</acronym>
-   session. Currently, transaction isolation level and time zone can
-   be specified by this command.
-  </para>
-
-  <para>
-   Use <xref linkend="SQL-SHOW" endterm="SQL-SHOW-title"> to show the
-   current setting of a parameters.
-  </para>
-
-  <para>
-   Refer to <xref linkend="SQL-SET-TRANSACTION" endterm="SQL-SET-TRANSACTION-TITLE">
-   and to <xref linkend="SQL-SET" endterm="SQL-SET-TITLE"> for more
-   information on allowed parameters.
-  </para>
- </refsect1>
-
- <refsect1>
-  <title>Examples</title>
-
-  <para>
-   Set the timezone for Berkeley, California, using double quotes to
-   preserve the uppercase attributes of the time zone specifier (note
-   that the date/time format is ISO here):
-
-<screen> 
-SET SESSION CHARACTERISTICS TIME ZONE "PST8PDT";
-SELECT CURRENT_TIMESTAMP AS today;
-   
-         today
-------------------------
- 1998-07-14 07:41:21-07
-</screen>
-  </para>
- </refsect1>
-
- <refsect1 id="R1-SQL-SET-SESSION-3">
-  <title>Compatibility</title>
-
-  <refsect2 id="R2-SQL-SET-SESSION-4">
-   <title>SQL99</title>
-
-   <para>
-    <command>SET SESSION</command> is defined in
-    <acronym>SQL99</acronym>.
-   </para>
-  </refsect2>
- </refsect1>
-</refentry>
-
-<!-- Keep this comment at the end of the file
-Local variables:
-mode:sgml
-sgml-omittag:nil
-sgml-shorttag:t
-sgml-minimize-attributes:nil
-sgml-always-quote-attributes:t
-sgml-indent-step:1
-sgml-indent-data:t
-sgml-parent-document:nil
-sgml-default-dtd-file:"../reference.ced"
-sgml-exposed-tags:nil
-sgml-local-catalogs:("/usr/lib/sgml/catalog")
-sgml-local-ecat-files:nil
-End:
--->
index b6a6bfd6f9acd79ffc5c3ee3b1d16f8e2ab657ca..57f949e4176b94a1114aa5cf7b7f0b7845135588 100644 (file)
@@ -1,19 +1,23 @@
 <!-- $Header$ -->
 <refentry id="SQL-SET-TRANSACTION">
+ <docinfo>
+  <date>2000-11-24</date>
+ </docinfo>
+
  <refmeta>
   <refentrytitle id="SQL-SET-TRANSACTION-TITLE">SET TRANSACTION</refentrytitle>
   <refmiscinfo>SQL - Language Statements</refmiscinfo>
  </refmeta>
+
  <refnamediv>
   <refname>SET TRANSACTION</refname>
   <refpurpose>Set the characteristics of the current SQL-transaction</refpurpose>
  </refnamediv>
+
  <refsynopsisdiv>
-  <refsynopsisdivinfo>
-   <date>2000-06-01</date>
-  </refsynopsisdivinfo>
   <synopsis>
 SET TRANSACTION ISOLATION LEVEL { READ COMMITTED | SERIALIZABLE }
+SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL { READ COMMITTED | SERIALIZABLE }
   </synopsis>
  </refsynopsisdiv>
 
@@ -21,13 +25,17 @@ SET TRANSACTION ISOLATION LEVEL { READ COMMITTED | SERIALIZABLE }
   <title>Description</title>
 
   <para>
-   The <command>SET TRANSACTION</command> command sets the
-   characteristics for the current SQL-transaction. It has no effect
-   on any subsequent transactions. This command cannot be used after
-   the first DML statement (<command>SELECT</command>,
-   <command>INSERT</command>, <command>DELETE</command>,
-   <command>UPDATE</command>, <command>FETCH</command>,
-   <command>COPY</command>) of a transaction has been executed.
+   This command sets the transaction isolation level.  The
+   <command>SET TRANSACTION</command> command sets the characteristics
+   for the current SQL-transaction. It has no effect on any subsequent
+   transactions.  This command cannot be used after the first DML
+   statement (<command>SELECT</command>, <command>INSERT</command>,
+   <command>DELETE</command>, <command>UPDATE</command>,
+   <command>FETCH</command>, <command>COPY</command>) of a transaction
+   has been executed.  <command>SET SESSION CHARACTERISTICS</command>
+   sets the default transaction isolation level for each transaction
+   for a session.  <command>SET TRANSACTION</command> can override it
+   for an individual transaction.
   </para>
 
   <para>
@@ -83,7 +91,7 @@ SET TRANSACTION ISOLATION LEVEL { READ COMMITTED | SERIALIZABLE }
 
    <para>
     In <acronym>SQL</acronym> there are two other transaction
-    characteristics that can be set with this command: whether the
+    characteristics that can be set with these commands: whether the
     transaction is read-only and the size of the diagnostics area.
     Neither of these concepts are supported in Postgres.
    </para>
index b3d6ed41a6afbd8630044fd712dc20af989203a1..8bca4f84219dcd8f0208b284329c02503f77e858 100644 (file)
@@ -2513,16 +2513,6 @@ _copyReindexStmt(ReindexStmt *from)
        return newnode;
 }
 
-static SetSessionStmt *
-_copySetSessionStmt(SetSessionStmt *from)
-{
-       SetSessionStmt   *newnode = makeNode(SetSessionStmt);
-
-       Node_Copy(from, newnode, args);
-
-       return newnode;
-}
-
 
 /* ****************************************************************
  *                                     pg_list.h copy functions
@@ -2922,9 +2912,6 @@ copyObject(void *from)
                case T_ReindexStmt:
                        retval = _copyReindexStmt(from);
                        break;
-               case T_SetSessionStmt:
-                       retval = _copySetSessionStmt(from);
-                       break;
                case T_CheckPointStmt:
                        retval = (void*)makeNode(CheckPointStmt);
                        break;
index e4c0871d4572549b4f59f4f1c44052fb17ea18dd..dec01f0b1fbeb556c84afef0143ba1dde19048a9 100644 (file)
@@ -1363,15 +1363,6 @@ _equalReindexStmt(ReindexStmt *a, ReindexStmt *b)
        return true;
 }
 
-static bool
-_equalSetSessionStmt(SetSessionStmt *a, SetSessionStmt *b)
-{
-       if (!equal(a->args, b->args))
-               return false;
-
-       return true;
-}
-
 static bool
 _equalAExpr(A_Expr *a, A_Expr *b)
 {
@@ -2037,9 +2028,6 @@ equal(void *a, void *b)
                case T_ReindexStmt:
                        retval = _equalReindexStmt(a, b);
                        break;
-               case T_SetSessionStmt:
-                       retval = _equalSetSessionStmt(a, b);
-                       break;
                case T_CheckPointStmt:
                        retval = true;
                        break;
index 72ce20def51e30b1b965546f3ed1c574378a80cc..0650cf76c22097f3fe5ac44f3dcc073bbfb0406e 100644 (file)
@@ -208,38 +208,6 @@ transformStmt(ParseState *pstate, Node *parseTree)
                        result = transformAlterTableStmt(pstate, (AlterTableStmt *) parseTree);
                        break;
 
-               case T_SetSessionStmt:
-                       {
-                               List *l;
-                               /* Session is a list of SetVariable nodes
-                                * so just run through the list.
-                                */
-                               SetSessionStmt *stmt = (SetSessionStmt *) parseTree;
-
-                               l = stmt->args;
-                               /* First check for duplicate keywords (disallowed by SQL99) */
-                               while (l != NULL)
-                               {
-                                       VariableSetStmt *v = (VariableSetStmt *) lfirst(l);
-                                       List *ll = lnext(l);
-                                       while (ll != NULL)
-                                       {
-                                               VariableSetStmt *vv = (VariableSetStmt *) lfirst(ll);
-                                               if (strcmp(v->name, vv->name) == 0)
-                                                       elog(ERROR, "SET SESSION CHARACTERISTICS duplicated entry not allowed");
-                                               ll = lnext(ll);
-                                       }
-                                       l = lnext(l);
-                               }
-
-                               l = stmt->args;
-                               result = transformStmt(pstate, lfirst(l));
-                               l = lnext(l);
-                               if (l != NULL)
-                                       extras_after = lappend(extras_after, lfirst(l));
-                       }
-                       break;
-
                        /*------------------------
                         *      Optimizable statements
                         *------------------------
index ebd623126d89a59f1e8d1884a730b07f2232b1a5..66252d7e00ba3fa61a926db274c020da97aae8f6 100644 (file)
@@ -134,15 +134,12 @@ static void doNegateFloat(Value *v);
                NotifyStmt, OptimizableStmt, ProcedureStmt, ReindexStmt,
                RemoveAggrStmt, RemoveFuncStmt, RemoveOperStmt,
                RenameStmt, RevokeStmt, RuleActionStmt, RuleActionStmtOrEmpty,
-               RuleStmt, SelectStmt, SetSessionStmt, TransactionStmt, TruncateStmt,
+               RuleStmt, SelectStmt, TransactionStmt, TruncateStmt,
                UnlistenStmt, UpdateStmt, VacuumStmt, VariableResetStmt,
                VariableSetStmt, VariableShowStmt, ViewStmt, CheckPointStmt
 
 %type <node>   select_no_parens, select_clause, simple_select
 
-%type <list>   SessionList
-%type <node>   SessionClause
-
 %type <node>    alter_column_action
 %type <ival>    drop_behavior
 
@@ -459,7 +456,6 @@ stmt :      AlterSchemaStmt
                | RevokeStmt
                | OptimizableStmt
                | RuleStmt
-               | SetSessionStmt
                | TransactionStmt
                | ViewStmt
                | LoadStmt
@@ -706,55 +702,6 @@ DropSchemaStmt:  DROP SCHEMA UserId
                                }
 
 
-/*****************************************************************************
- *
- * Manipulate a postgresql session
- *
- *
- *****************************************************************************/
-
-SetSessionStmt:  SET SESSION CHARACTERISTICS AS SessionList
-                               {
-                                       SetSessionStmt *n = makeNode(SetSessionStmt);
-                                       n->args = $5;
-                                       $$ = (Node*)n;
-                               }
-               ;
-
-SessionList:  SessionList ',' SessionClause
-                               {
-                                       $$ = lappend($1, $3);
-                               }
-               | SessionClause
-                               {
-                                       $$ = makeList1($1);
-                               }
-               ;
-
-SessionClause:  TRANSACTION COMMIT opt_boolean
-                               {
-                                       VariableSetStmt *n = makeNode(VariableSetStmt);
-                                       n->name  = "autocommit";
-                                       n->value = $3;
-                                       $$ = (Node *) n;
-                               }
-               | TIME ZONE zone_value
-                               {
-                                       VariableSetStmt *n = makeNode(VariableSetStmt);
-                                       n->name  = "timezone";
-                                       n->value = $3;
-                                       $$ = (Node *) n;
-                               }
-               | TRANSACTION ISOLATION LEVEL opt_level
-                               {
-                                       VariableSetStmt *n = makeNode(VariableSetStmt);
-                                       n->name  = "DefaultXactIsoLevel";
-                                       n->value = $4;
-                                       $$ = (Node *) n;
-                               }
-                       ;
-
-
 /*****************************************************************************
  *
  * Set PG internal variable
@@ -792,6 +739,13 @@ VariableSetStmt:  SET ColId TO var_value
                                        n->value = $5;
                                        $$ = (Node *) n;
                                }
+        | SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL opt_level
+                               {
+                                       VariableSetStmt *n = makeNode(VariableSetStmt);
+                                       n->name  = "DefaultXactIsoLevel";
+                                       n->value = $8;
+                                       $$ = (Node *) n;
+                               }
                | SET NAMES opt_encoding
                                {
                                        VariableSetStmt *n = makeNode(VariableSetStmt);
@@ -5444,6 +5398,7 @@ TokenId:  ABSOLUTE                                                { $$ = "absolute"; }
                | CACHE                                                 { $$ = "cache"; }
                | CASCADE                                               { $$ = "cascade"; }
                | CHAIN                                                 { $$ = "chain"; }
+               | CHARACTERISTICS                               { $$ = "characteristics"; }
                | CHECKPOINT                                    { $$ = "checkpoint"; }
                | CLOSE                                                 { $$ = "close"; }
                | COMMENT                                               { $$ = "comment"; }
index 6581971f9584ec526e8a1292eba245dd4b7d847a..5bc48f55b3928928c3cff8ee8dbed7cf5f84b560 100644 (file)
@@ -202,7 +202,6 @@ typedef enum NodeTag
        T_AlterGroupStmt,
        T_DropGroupStmt,
        T_ReindexStmt,
-       T_SetSessionStmt,
        T_CheckPointStmt,
 
        T_A_Expr = 700,
index adeda942ed50394eb58fb9807a3e49c500093edf..dfa2cb05deb6f574cff3897ff067c75a821d6445 100644 (file)
@@ -697,15 +697,9 @@ typedef struct ExplainStmt
 } ExplainStmt;
 
 /* ----------------------
- *             Set Session Statement
+ * Checkpoint Statement
  * ----------------------
  */
-typedef struct SetSessionStmt
-{
-       NodeTag         type;
-       List       *args;
-} SetSessionStmt;
-
 typedef struct CheckPointStmt
 {
        NodeTag         type;