aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc G. Fournier <scrappy@hub.org>1998-08-25 21:37:08 +0000
committerMarc G. Fournier <scrappy@hub.org>1998-08-25 21:37:08 +0000
commitf62d1253eff4622f6ff0b76f8f0f2eca793bd608 (patch)
treee28e49785256ce9f46f924bc518b0dfeda0d80a6
parent7414d619507ed9e2cdb5113ff77df55feef786c4 (diff)
downloadpostgresql-f62d1253eff4622f6ff0b76f8f0f2eca793bd608.tar.gz
postgresql-f62d1253eff4622f6ff0b76f8f0f2eca793bd608.zip
From: Massimo Dal Zotto <dz@cs.unitn.it>
> 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.
-rw-r--r--src/backend/parser/gram.y13
-rw-r--r--src/backend/parser/keywords.c3
-rw-r--r--src/backend/tcop/utility.c13
-rw-r--r--src/bin/psql/psqlHelp.h12
-rw-r--r--src/include/commands/async.h3
-rw-r--r--src/include/nodes/nodes.h3
-rw-r--r--src/include/nodes/parsenodes.h12
-rw-r--r--src/interfaces/ecpg/preproc/keywords.c3
-rw-r--r--src/interfaces/ecpg/preproc/preproc.y9
9 files changed, 58 insertions, 13 deletions
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index bdbe286d21f..eb8e2cc6311 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -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;
+ }
+;
+
/*****************************************************************************
*
diff --git a/src/backend/parser/keywords.c b/src/backend/parser/keywords.c
index f04dbf63573..2d343fe70ea 100644
--- a/src/backend/parser/keywords.c
+++ b/src/backend/parser/keywords.c
@@ -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},
diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c
index dba3403e6b3..a8203a40e42 100644
--- a/src/backend/tcop/utility.c
+++ b/src/backend/tcop/utility.c
@@ -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 ********************************
*
diff --git a/src/bin/psql/psqlHelp.h b/src/bin/psql/psqlHelp.h
index f9052d0a954..387561cbd9f 100644
--- a/src/bin/psql/psqlHelp.h
+++ b/src/bin/psql/psqlHelp.h
@@ -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\
diff --git a/src/include/commands/async.h b/src/include/commands/async.h
index 498cec4fbfd..bf92a27ee54 100644
--- a/src/include/commands/async.h
+++ b/src/include/commands/async.h
@@ -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;
diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h
index 8ab0f5e3f53..9d1f12852ba 100644
--- a/src/include/nodes/nodes.h
+++ b/src/include/nodes/nodes.h
@@ -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,
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index 2ffa6081fe7..eb7bb13d105 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -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 $
*
*-------------------------------------------------------------------------
*/
@@ -441,6 +441,16 @@ typedef struct ListenStmt
} ListenStmt;
/* ----------------------
+ * Unlisten Statement
+ * ----------------------
+ */
+typedef struct UnlistenStmt
+{
+ NodeTag type;
+ char *relname; /* relation to unlisten on */
+} UnlistenStmt;
+
+/* ----------------------
* {Begin|Abort|End} Transaction Statement
* ----------------------
*/
diff --git a/src/interfaces/ecpg/preproc/keywords.c b/src/interfaces/ecpg/preproc/keywords.c
index 9f953cb98f5..a17455de3fe 100644
--- a/src/interfaces/ecpg/preproc/keywords.c
+++ b/src/interfaces/ecpg/preproc/keywords.c
@@ -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},
diff --git a/src/interfaces/ecpg/preproc/preproc.y b/src/interfaces/ecpg/preproc/preproc.y
index 5f67ff48d42..cc8528e4355 100644
--- a/src/interfaces/ecpg/preproc/preproc.y
+++ b/src/interfaces/ecpg/preproc/preproc.y
@@ -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: