diff options
author | Tomas Vondra | 2017-07-30 16:17:27 +0000 |
---|---|---|
committer | Tomas Vondra | 2017-07-31 01:21:29 +0000 |
commit | b0ef8d636450ec47a8a546126e6602e03c9bae3f (patch) | |
tree | b7f7aead7955e5bb006944f5f936dc64fe11793d /src | |
parent | a60df4b535c3f2be055ea44a627ac86ead57ef04 (diff) |
Reject SQL functions containing utility statements
The check was not effective for the same reason as 5a54abb7acd, that is
not accounting for XL wrapping the original command into RawStmt. Fix
that by checking parsetree->stmt, and also add an assert checking we
actually got a RawStmt in the first place.
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/catalog/pg_proc.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/backend/catalog/pg_proc.c b/src/backend/catalog/pg_proc.c index 3ba00c34ca..088111f0d5 100644 --- a/src/backend/catalog/pg_proc.c +++ b/src/backend/catalog/pg_proc.c @@ -937,9 +937,11 @@ fmgr_sql_validator(PG_FUNCTION_ARGS) RawStmt *parsetree = lfirst_node(RawStmt, lc); List *querytree_sublist; + Assert(IsA(parsetree, RawStmt)); + #ifdef PGXC /* Block CTAS in SQL functions */ - if (IsA(parsetree, CreateTableAsStmt)) + if (IsA(parsetree->stmt, CreateTableAsStmt)) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("In XC, SQL functions cannot contain utility statements"))); |