mirror of
https://github.com/postgres/postgres.git
synced 2025-08-22 21:53:06 +03:00
Add optional "validator" function to languages that can validate the
function body (and other properties) as a function in the language is created. This generalizes ad hoc code that already existed for the built-in languages. The validation now happens after the pg_proc tuple of the new function is created, so it is possible to define recursive SQL functions. Add some regression test cases that cover bogus function definition attempts.
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.318 2002/05/19 15:16:55 petere Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.319 2002/05/22 17:20:59 petere Exp $
|
||||
*
|
||||
* HISTORY
|
||||
* AUTHOR DATE MAJOR EVENT
|
||||
@@ -182,7 +182,7 @@ static void doNegateFloat(Value *v);
|
||||
index_name, name, function_name, file_name
|
||||
|
||||
%type <list> func_name, handler_name, qual_Op, qual_all_Op, OptUseOp,
|
||||
opt_class
|
||||
opt_class, opt_validator
|
||||
|
||||
%type <range> qualified_name, OptConstrFromTable
|
||||
|
||||
@@ -375,7 +375,7 @@ static void doNegateFloat(Value *v);
|
||||
UNENCRYPTED, UNION, UNIQUE, UNKNOWN, UNLISTEN, UNTIL, UPDATE, USAGE,
|
||||
USER, USING,
|
||||
|
||||
VACUUM, VALID, VALUES, VARCHAR, VARYING, VERBOSE, VERSION, VIEW, VOLATILE,
|
||||
VACUUM, VALID, VALIDATOR, VALUES, VARCHAR, VARYING, VERBOSE, VERSION, VIEW, VOLATILE,
|
||||
WHEN, WHERE, WITH, WITHOUT, WORK,
|
||||
YEAR_P,
|
||||
ZONE
|
||||
@@ -1835,12 +1835,13 @@ IntegerOnly: Iconst
|
||||
*****************************************************************************/
|
||||
|
||||
CreatePLangStmt: CREATE opt_trusted opt_procedural LANGUAGE ColId_or_Sconst
|
||||
HANDLER handler_name opt_lancompiler
|
||||
HANDLER handler_name opt_validator opt_lancompiler
|
||||
{
|
||||
CreatePLangStmt *n = makeNode(CreatePLangStmt);
|
||||
n->plname = $5;
|
||||
n->plhandler = $7;
|
||||
n->plcompiler = $8;
|
||||
n->plvalidator = $8;
|
||||
n->plcompiler = $9;
|
||||
n->pltrusted = $2;
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
@@ -1864,6 +1865,10 @@ opt_lancompiler: LANCOMPILER Sconst { $$ = $2; }
|
||||
| /*EMPTY*/ { $$ = ""; }
|
||||
;
|
||||
|
||||
opt_validator: VALIDATOR handler_name { $$ = $2; }
|
||||
| /*EMPTY*/ { $$ = NULL; }
|
||||
;
|
||||
|
||||
DropPLangStmt: DROP opt_procedural LANGUAGE ColId_or_Sconst
|
||||
{
|
||||
DropPLangStmt *n = makeNode(DropPLangStmt);
|
||||
@@ -6357,6 +6362,7 @@ unreserved_keyword:
|
||||
| USAGE
|
||||
| VACUUM
|
||||
| VALID
|
||||
| VALIDATOR
|
||||
| VALUES
|
||||
| VARYING
|
||||
| VERSION
|
||||
|
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.110 2002/05/17 18:32:52 petere Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.111 2002/05/22 17:20:59 petere Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -292,6 +292,7 @@ static const ScanKeyword ScanKeywords[] = {
|
||||
{"using", USING},
|
||||
{"vacuum", VACUUM},
|
||||
{"valid", VALID},
|
||||
{"validator", VALIDATOR},
|
||||
{"values", VALUES},
|
||||
{"varchar", VARCHAR},
|
||||
{"varying", VARYING},
|
||||
|
Reference in New Issue
Block a user