From: Massimo Dal Zotto
authorMarc G. Fournier
Tue, 25 Aug 1998 21:37:08 +0000 (21:37 +0000)
committerMarc G. Fournier
Tue, 25 Aug 1998 21:37:08 +0000 (21:37 +0000)
>       these patches define the UNLISTEN sql command. The code already
>       existed but it was unknown to the parser. Now it can be used
>       like the listen command.
>       You must make clean and delete gram.c and parser.h before make.

src/backend/parser/gram.y
src/backend/parser/keywords.c
src/backend/tcop/utility.c
src/bin/psql/psqlHelp.h
src/include/commands/async.h
src/include/nodes/nodes.h
src/include/nodes/parsenodes.h
src/interfaces/ecpg/preproc/keywords.c
src/interfaces/ecpg/preproc/preproc.y

index bdbe286d21f177633ed97943887c79074c05dc95..eb8e2cc6311764c887fbf38f81f475ce6d3d174c 100644 (file)
@@ -10,7 +10,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.25 1998/08/25 15:04:23 thomas Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.26 1998/08/25 21:36:53 scrappy Exp $
  *
  * HISTORY
  *   AUTHOR            DATE            MAJOR EVENT
@@ -122,7 +122,7 @@ Oid param_type(int t); /* used in parse_expr.c */
        CopyStmt, CreateStmt, CreateAsStmt, CreateSeqStmt, DefineStmt, DestroyStmt,
        ExtendStmt, FetchStmt,  GrantStmt, CreateTrigStmt, DropTrigStmt,
        CreatePLangStmt, DropPLangStmt,
-       IndexStmt, ListenStmt, LockStmt, OptimizableStmt,
+       IndexStmt, ListenStmt, UnlistenStmt, LockStmt, OptimizableStmt,
        ProcedureStmt,  RecipeStmt, RemoveAggrStmt, RemoveOperStmt,
        RemoveFuncStmt, RemoveStmt,
        RenameStmt, RevokeStmt, RuleStmt, TransactionStmt, ViewStmt, LoadStmt,
@@ -378,6 +378,7 @@ stmt :    AddAttrStmt
        | GrantStmt
        | IndexStmt
        | ListenStmt
+       | UnlistenStmt
        | LockStmt
        | ProcedureStmt
        | RecipeStmt
@@ -2039,6 +2040,14 @@ ListenStmt:  LISTEN relation_name
                }
 ;
 
+UnlistenStmt:  UNLISTEN relation_name
+               {
+                   UnlistenStmt *n = makeNode(UnlistenStmt);
+                   n->relname = $2;
+                   $$ = (Node *)n;
+               }
+;
+
 
 /*****************************************************************************
  *
index f04dbf63573717da105539076a40e64de78669e7..2d343fe70ea446c2641a0e70abb15909f8894b80 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.41 1998/08/25 15:04:24 thomas Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.42 1998/08/25 21:36:55 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -209,6 +209,7 @@ static ScanKeyword ScanKeywords[] = {
    {"type", TYPE_P},
    {"union", UNION},
    {"unique", UNIQUE},
+   {"unlisten", UNLISTEN},
    {"until", UNTIL},
    {"update", UPDATE},
    {"user", USER},
index dba3403e6b3ecf89c0a6226ab0d655e56c7abe63..a8203a40e4269861cbb7897f413f7b3194e07c85 100644 (file)
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.47 1998/08/25 21:24:09 scrappy Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.48 1998/08/25 21:36:56 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -594,6 +594,17 @@ ProcessUtility(Node *parsetree,
            }
            break;
 
+       case T_UnlistenStmt:
+           {
+               UnlistenStmt *stmt = (UnlistenStmt *) parsetree;
+
+               PS_SET_STATUS( commandTag = "UNLISTEN" );
+               CHECK_IF_ABORTED();
+
+               Async_Unlisten(stmt->relname, MyProcPid);
+           }
+           break;
+
            /*
             * ******************************** dynamic loader ********************************
             *
index f9052d0a95493ec2a66d642738370a4368c7bac1..387561cbd9f64bd311fca668a323aeb1fd1337dc 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: psqlHelp.h,v 1.49 1998/07/26 01:18:09 momjian Exp $
+ * $Id: psqlHelp.h,v 1.50 1998/08/25 21:36:58 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -273,9 +273,9 @@ static struct _helpStruct QL_HELP[] = {
 \t[HAVING having_clause]\n\
 \t[UNION [ALL] SELECT ...];"},
    {"listen",
-       "listen for notification on a relation",
+       "listen for notification on a relation name",
    "\
-\tLISTEN class_name"},
+\tLISTEN class_name|\"name\""},
    {"load",
        "dynamically load a module",
    "\
@@ -345,7 +345,11 @@ set R_PLANS TO 'ON'| 'OFF'"},
    "\
 \tSHOW DateStyle|GEQO|R_PLANS"},
 #endif
-   {"UPDATE",
+   {"unlisten",
+       "unlisten for notification on a relation name",
+   "\
+\tUNLISTEN class_name|\"name\"|\"*\""},
+   {"update",
        "update tuples",
    "\
 \tUPDATE class_name SET attr1 = expr1, ...attrN = exprN\n\
index 498cec4fbfd9c511a1f4ddaf7e2aef01a5da3231..bf92a27ee5439f13f28cf0787faa85272876c6e9 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: async.h,v 1.7 1997/09/08 02:35:37 momjian Exp $
+ * $Id: async.h,v 1.8 1998/08/25 21:37:00 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -20,6 +20,7 @@ extern void Async_Notify(char *relname);
 extern void Async_NotifyAtCommit(void);
 extern void Async_NotifyAtAbort(void);
 extern void Async_Listen(char *relname, int pid);
+extern void Async_Unlisten(char *relname, int pid);
 
 extern GlobalMemory notifyContext;
 
index 8ab0f5e3f53945b1580bd47c9357358d560b4620..9d1f12852ba6d28b7e629a933433a1570048a186 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: nodes.h,v 1.27 1998/08/18 00:49:01 scrappy Exp $
+ * $Id: nodes.h,v 1.28 1998/08/25 21:37:02 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -171,6 +171,7 @@ typedef enum NodeTag
    T_RuleStmt,
    T_NotifyStmt,
    T_ListenStmt,
+   T_UnlistenStmt,
    T_TransactionStmt,
    T_ViewStmt,
    T_LoadStmt,
index 2ffa6081fe7b92ea34a3049530b7007c16426025..eb7bb13d10589b260a07c99255a33d3638390283 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: parsenodes.h,v 1.56 1998/08/25 15:09:31 thomas Exp $
+ * $Id: parsenodes.h,v 1.57 1998/08/25 21:37:04 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -440,6 +440,16 @@ typedef struct ListenStmt
    char       *relname;        /* relation to listen on */
 } ListenStmt;
 
+/* ----------------------
+ *     Unlisten Statement
+ * ----------------------
+ */
+typedef struct UnlistenStmt
+{
+   NodeTag     type;
+   char       *relname;        /* relation to unlisten on */
+} UnlistenStmt;
+
 /* ----------------------
  *     {Begin|Abort|End} Transaction Statement
  * ----------------------
index 9f953cb98f510bd53c1ea7b7e3a1cdc45c3be76f..a17455de3fe6a91be02694bcf0b3deae9d6df02a 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/keywords.c,v 1.2 1998/05/18 16:05:00 scrappy Exp $
+ *   $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/keywords.c,v 1.3 1998/08/25 21:37:06 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -201,6 +201,7 @@ static ScanKeyword ScanKeywords[] = {
    {"type", TYPE_P},
    {"union", UNION},
    {"unique", UNIQUE},
+   {"unlisten", UNLISTEN},
    {"until", UNTIL},
    {"update", UPDATE},
    {"user", USER},
index 5f67ff48d4236e8fe19f8ea978a38d4eeebea111..cc8528e4355854dd939c71bbb7c5db883432b74b 100644 (file)
@@ -563,7 +563,7 @@ output_statement(char * stmt, int mode)
                 DATABASE, DELIMITERS, DO, EACH, EXPLAIN, EXTEND,
                 FORWARD, FUNCTION, HANDLER,
                 INCREMENT, INDEX, INHERITS, INSTEAD, ISNULL,
-                LANCOMPILER, LISTEN, LOAD, LOCK_P, LOCATION, MAXVALUE, MINVALUE, MOVE,
+                LANCOMPILER, LISTEN, UNLISTEN, LOAD, LOCK_P, LOCATION, MAXVALUE, MINVALUE, MOVE,
                 NEW, NONE, NOTHING, NOTNULL, OIDS, OPERATOR, PROCEDURAL,
                 RECIPE, RENAME, RESET, RETURNS, ROW, RULE,
                 SEQUENCE, SETOF, SHOW, START, STATEMENT, STDIN, STDOUT, TRUSTED,
@@ -723,6 +723,7 @@ stmt:  AddAttrStmt          { output_statement($1, 0); }
        | GrantStmt     { output_statement($1, 0); }
        | IndexStmt     { output_statement($1, 0); }
        | ListenStmt        { output_statement($1, 0); }
+       | UnlistenStmt      { output_statement($1, 0); }
        | LockStmt      { output_statement($1, 0); }
        | ProcedureStmt     { output_statement($1, 0); }
        | RecipeStmt        { output_statement($1, 0); }
@@ -2108,6 +2109,12 @@ ListenStmt:  LISTEN relation_name
                                 }
 ;
 
+UnlistenStmt:  UNLISTEN relation_name
+               {
+                   $$ = cat2_str(make1_str("unlisten"), $2);
+                                }
+;
+
 /*****************************************************************************
  *
  *              Transactions: