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.
This commit is contained in:
Marc G. Fournier 1998-08-25 21:37:08 +00:00
parent 7414d61950
commit f62d1253ef
9 changed files with 58 additions and 13 deletions

View 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;
}
;
/*****************************************************************************
*

View 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},

View 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 ********************************
*

View 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\

View 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;

View 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,

View 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
* ----------------------

View 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},

View 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: