Make CREATE/ALTER FUNCTION support NOT LEAKPROOF.
authorRobert Haas <rhaas@postgresql.org>
Wed, 15 Feb 2012 15:45:08 +0000 (10:45 -0500)
committerRobert Haas <rhaas@postgresql.org>
Wed, 15 Feb 2012 15:45:08 +0000 (10:45 -0500)
Because it isn't good to be able to turn things on, and not off again.

doc/src/sgml/ref/alter_function.sgml
doc/src/sgml/ref/create_function.sgml
src/backend/parser/gram.y

index 3ceb6123f4f6afee5e13cfe7ad2677420136dd02..013b6f8401ce6687c07309aceea8138fdd31c8c7 100644 (file)
@@ -33,7 +33,7 @@ ALTER FUNCTION <replaceable>name</replaceable> ( [ [ <replaceable class="paramet
 <phrase>where <replaceable class="PARAMETER">action</replaceable> is one of:</phrase>
 
     CALLED ON NULL INPUT | RETURNS NULL ON NULL INPUT | STRICT
-    IMMUTABLE | STABLE | VOLATILE | LEAKPROOF
+    IMMUTABLE | STABLE | VOLATILE | [ NOT ] LEAKPROOF
     [ EXTERNAL ] SECURITY INVOKER | [ EXTERNAL ] SECURITY DEFINER
     COST <replaceable class="parameter">execution_cost</replaceable>
     ROWS <replaceable class="parameter">result_rows</replaceable>
index 7df66ab0e08bc0ad90a02cfb73bd1a7df8ce6a19..4336e4b218231a48d2e3501d7ca23febcad14eec 100644 (file)
@@ -26,7 +26,7 @@ CREATE [ OR REPLACE ] FUNCTION
       | RETURNS TABLE ( <replaceable class="parameter">column_name</replaceable> <replaceable class="parameter">column_type</replaceable> [, ...] ) ]
   { LANGUAGE <replaceable class="parameter">lang_name</replaceable>
     | WINDOW
-    | IMMUTABLE | STABLE | VOLATILE | LEAKPROOF
+    | IMMUTABLE | STABLE | VOLATILE | [ NOT ] LEAKPROOF
     | CALLED ON NULL INPUT | RETURNS NULL ON NULL INPUT | STRICT
     | [ EXTERNAL ] SECURITY INVOKER | [ EXTERNAL ] SECURITY DEFINER
     | COST <replaceable class="parameter">execution_cost</replaceable>
index db63ff23711a19c43ef3cf448fbed542216416ec..d1ce2ab0422ccc0db1befca7481519d009f2b4a0 100644 (file)
@@ -370,7 +370,7 @@ static void processCASbits(int cas_bits, int location, const char *constrType,
 
 %type <istmt>  insert_rest
 
-%type <vsetstmt> set_rest SetResetClause
+%type <vsetstmt> set_rest set_rest_more SetResetClause FunctionSetResetClause
 
 %type <node>   TableElement TypedTableElement ConstraintElem TableFuncElement
                ForeignTableElement
@@ -1227,7 +1227,27 @@ VariableSetStmt:
                }
        ;
 
-set_rest:  /* Generic SET syntaxes: */
+set_rest:
+           TRANSACTION transaction_mode_list
+               {
+                   VariableSetStmt *n = makeNode(VariableSetStmt);
+                   n->kind = VAR_SET_MULTI;
+                   n->name = "TRANSACTION";
+                   n->args = $2;
+                   $$ = n;
+               }
+           | SESSION CHARACTERISTICS AS TRANSACTION transaction_mode_list
+               {
+                   VariableSetStmt *n = makeNode(VariableSetStmt);
+                   n->kind = VAR_SET_MULTI;
+                   n->name = "SESSION CHARACTERISTICS";
+                   n->args = $5;
+                   $$ = n;
+               }
+           | set_rest_more
+           ;
+
+set_rest_more: /* Generic SET syntaxes: */
            var_name TO var_list
                {
                    VariableSetStmt *n = makeNode(VariableSetStmt);
@@ -1277,22 +1297,6 @@ set_rest:    /* Generic SET syntaxes: */
                        n->kind = VAR_SET_DEFAULT;
                    $$ = n;
                }
-           | TRANSACTION transaction_mode_list
-               {
-                   VariableSetStmt *n = makeNode(VariableSetStmt);
-                   n->kind = VAR_SET_MULTI;
-                   n->name = "TRANSACTION";
-                   n->args = $2;
-                   $$ = n;
-               }
-           | SESSION CHARACTERISTICS AS TRANSACTION transaction_mode_list
-               {
-                   VariableSetStmt *n = makeNode(VariableSetStmt);
-                   n->kind = VAR_SET_MULTI;
-                   n->name = "SESSION CHARACTERISTICS";
-                   n->args = $5;
-                   $$ = n;
-               }
            | CATALOG_P Sconst
                {
                    ereport(ERROR,
@@ -1512,6 +1516,12 @@ SetResetClause:
            | VariableResetStmt             { $$ = (VariableSetStmt *) $1; }
        ;
 
+/* SetResetClause allows SET or RESET without LOCAL */
+FunctionSetResetClause:
+           SET set_rest_more               { $$ = $2; }
+           | VariableResetStmt             { $$ = (VariableSetStmt *) $1; }
+       ;
+
 
 VariableShowStmt:
            SHOW var_name
@@ -6119,6 +6129,10 @@ common_func_opt_item:
                {
                    $$ = makeDefElem("leakproof", (Node *)makeInteger(TRUE));
                }
+           | NOT LEAKPROOF
+               {
+                   $$ = makeDefElem("leakproof", (Node *)makeInteger(FALSE));
+               }
            | COST NumericOnly
                {
                    $$ = makeDefElem("cost", (Node *)$2);
@@ -6127,7 +6141,7 @@ common_func_opt_item:
                {
                    $$ = makeDefElem("rows", (Node *)$2);
                }
-           | SetResetClause
+           | FunctionSetResetClause
                {
                    /* we abuse the normal content of a DefElem here */
                    $$ = makeDefElem("set", (Node *)$1);