mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-30 19:00:29 +08:00
Fix parse tree of DROP TRANSFORM and COMMENT ON TRANSFORM
The plain C string language name needs to be wrapped in makeString() so that the parse tree is copyable. This is detectable by -DCOPY_PARSE_PLAN_TREES. Add a test case for the COMMENT case. Also make the quoting in the error messages more consistent. discovered by Tom Lane
This commit is contained in:
parent
b82a7be603
commit
0779f2ba2d
@ -23,21 +23,22 @@ CREATE TRANSFORM FOR hstore LANGUAGE plperl (FROM SQL WITH FUNCTION internal_in(
|
|||||||
ERROR: first argument of transform function must be type "internal"
|
ERROR: first argument of transform function must be type "internal"
|
||||||
CREATE TRANSFORM FOR hstore LANGUAGE plperl (FROM SQL WITH FUNCTION hstore_to_plperl(internal), TO SQL WITH FUNCTION plperl_to_hstore(internal)); -- ok
|
CREATE TRANSFORM FOR hstore LANGUAGE plperl (FROM SQL WITH FUNCTION hstore_to_plperl(internal), TO SQL WITH FUNCTION plperl_to_hstore(internal)); -- ok
|
||||||
CREATE TRANSFORM FOR hstore LANGUAGE plperl (FROM SQL WITH FUNCTION hstore_to_plperl(internal), TO SQL WITH FUNCTION plperl_to_hstore(internal)); -- fail
|
CREATE TRANSFORM FOR hstore LANGUAGE plperl (FROM SQL WITH FUNCTION hstore_to_plperl(internal), TO SQL WITH FUNCTION plperl_to_hstore(internal)); -- fail
|
||||||
ERROR: transform for type hstore language plperl already exists
|
ERROR: transform for type hstore language "plperl" already exists
|
||||||
CREATE OR REPLACE TRANSFORM FOR hstore LANGUAGE plperl (FROM SQL WITH FUNCTION hstore_to_plperl(internal), TO SQL WITH FUNCTION plperl_to_hstore(internal)); -- ok
|
CREATE OR REPLACE TRANSFORM FOR hstore LANGUAGE plperl (FROM SQL WITH FUNCTION hstore_to_plperl(internal), TO SQL WITH FUNCTION plperl_to_hstore(internal)); -- ok
|
||||||
CREATE OR REPLACE TRANSFORM FOR hstore LANGUAGE plperl (FROM SQL WITH FUNCTION hstore_to_plperl(internal)); -- ok
|
CREATE OR REPLACE TRANSFORM FOR hstore LANGUAGE plperl (FROM SQL WITH FUNCTION hstore_to_plperl(internal)); -- ok
|
||||||
CREATE OR REPLACE TRANSFORM FOR hstore LANGUAGE plperl (TO SQL WITH FUNCTION plperl_to_hstore(internal)); -- ok
|
CREATE OR REPLACE TRANSFORM FOR hstore LANGUAGE plperl (TO SQL WITH FUNCTION plperl_to_hstore(internal)); -- ok
|
||||||
|
COMMENT ON TRANSFORM FOR hstore LANGUAGE plperl IS 'test';
|
||||||
DROP TRANSFORM IF EXISTS FOR fake_type LANGUAGE plperl;
|
DROP TRANSFORM IF EXISTS FOR fake_type LANGUAGE plperl;
|
||||||
NOTICE: type "fake_type" does not exist, skipping
|
NOTICE: type "fake_type" does not exist, skipping
|
||||||
DROP TRANSFORM IF EXISTS FOR hstore LANGUAGE fake_lang;
|
DROP TRANSFORM IF EXISTS FOR hstore LANGUAGE fake_lang;
|
||||||
NOTICE: transform for type hstore language fake_lang does not exist, skipping
|
NOTICE: transform for type hstore language "fake_lang" does not exist, skipping
|
||||||
DROP TRANSFORM FOR foo LANGUAGE plperl;
|
DROP TRANSFORM FOR foo LANGUAGE plperl;
|
||||||
ERROR: type "foo" does not exist
|
ERROR: type "foo" does not exist
|
||||||
DROP TRANSFORM FOR hstore LANGUAGE foo;
|
DROP TRANSFORM FOR hstore LANGUAGE foo;
|
||||||
ERROR: language "foo" does not exist
|
ERROR: language "foo" does not exist
|
||||||
DROP TRANSFORM FOR hstore LANGUAGE plperl;
|
DROP TRANSFORM FOR hstore LANGUAGE plperl;
|
||||||
DROP TRANSFORM IF EXISTS FOR hstore LANGUAGE plperl;
|
DROP TRANSFORM IF EXISTS FOR hstore LANGUAGE plperl;
|
||||||
NOTICE: transform for type hstore language plperl does not exist, skipping
|
NOTICE: transform for type hstore language "plperl" does not exist, skipping
|
||||||
DROP FUNCTION hstore_to_plperl(val internal);
|
DROP FUNCTION hstore_to_plperl(val internal);
|
||||||
DROP FUNCTION plperl_to_hstore(val internal);
|
DROP FUNCTION plperl_to_hstore(val internal);
|
||||||
CREATE EXTENSION hstore_plperl;
|
CREATE EXTENSION hstore_plperl;
|
||||||
|
@ -26,6 +26,8 @@ CREATE OR REPLACE TRANSFORM FOR hstore LANGUAGE plperl (FROM SQL WITH FUNCTION h
|
|||||||
CREATE OR REPLACE TRANSFORM FOR hstore LANGUAGE plperl (FROM SQL WITH FUNCTION hstore_to_plperl(internal)); -- ok
|
CREATE OR REPLACE TRANSFORM FOR hstore LANGUAGE plperl (FROM SQL WITH FUNCTION hstore_to_plperl(internal)); -- ok
|
||||||
CREATE OR REPLACE TRANSFORM FOR hstore LANGUAGE plperl (TO SQL WITH FUNCTION plperl_to_hstore(internal)); -- ok
|
CREATE OR REPLACE TRANSFORM FOR hstore LANGUAGE plperl (TO SQL WITH FUNCTION plperl_to_hstore(internal)); -- ok
|
||||||
|
|
||||||
|
COMMENT ON TRANSFORM FOR hstore LANGUAGE plperl IS 'test';
|
||||||
|
|
||||||
DROP TRANSFORM IF EXISTS FOR fake_type LANGUAGE plperl;
|
DROP TRANSFORM IF EXISTS FOR fake_type LANGUAGE plperl;
|
||||||
DROP TRANSFORM IF EXISTS FOR hstore LANGUAGE fake_lang;
|
DROP TRANSFORM IF EXISTS FOR hstore LANGUAGE fake_lang;
|
||||||
DROP TRANSFORM FOR foo LANGUAGE plperl;
|
DROP TRANSFORM FOR foo LANGUAGE plperl;
|
||||||
|
@ -770,7 +770,7 @@ get_object_address(ObjectType objtype, List *objname, List *objargs,
|
|||||||
case OBJECT_TRANSFORM:
|
case OBJECT_TRANSFORM:
|
||||||
{
|
{
|
||||||
TypeName *typename = (TypeName *) linitial(objname);
|
TypeName *typename = (TypeName *) linitial(objname);
|
||||||
char *langname = (char *) linitial(objargs);
|
char *langname = strVal(linitial(objargs));
|
||||||
Oid type_id = LookupTypeNameOid(NULL, typename, missing_ok);
|
Oid type_id = LookupTypeNameOid(NULL, typename, missing_ok);
|
||||||
Oid lang_id = get_language_oid(langname, missing_ok);
|
Oid lang_id = get_language_oid(langname, missing_ok);
|
||||||
|
|
||||||
|
@ -369,9 +369,9 @@ does_not_exist_skipping(ObjectType objtype, List *objname, List *objargs)
|
|||||||
case OBJECT_TRANSFORM:
|
case OBJECT_TRANSFORM:
|
||||||
if (!type_in_list_does_not_exist_skipping(objname, &msg, &name))
|
if (!type_in_list_does_not_exist_skipping(objname, &msg, &name))
|
||||||
{
|
{
|
||||||
msg = gettext_noop("transform for type %s language %s does not exist, skipping");
|
msg = gettext_noop("transform for type %s language \"%s\" does not exist, skipping");
|
||||||
name = TypeNameToString((TypeName *) linitial(objname));
|
name = TypeNameToString((TypeName *) linitial(objname));
|
||||||
args = (char *) linitial(objargs);
|
args = strVal(linitial(objargs));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OBJECT_TRIGGER:
|
case OBJECT_TRIGGER:
|
||||||
|
@ -1867,7 +1867,7 @@ CreateTransform(CreateTransformStmt *stmt)
|
|||||||
if (!stmt->replace)
|
if (!stmt->replace)
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_DUPLICATE_OBJECT),
|
(errcode(ERRCODE_DUPLICATE_OBJECT),
|
||||||
errmsg("transform for type %s language %s already exists",
|
errmsg("transform for type %s language \"%s\" already exists",
|
||||||
format_type_be(typeid),
|
format_type_be(typeid),
|
||||||
stmt->lang)));
|
stmt->lang)));
|
||||||
|
|
||||||
|
@ -4112,7 +4112,7 @@ AlterExtensionContentsStmt:
|
|||||||
n->action = $4;
|
n->action = $4;
|
||||||
n->objtype = OBJECT_TRANSFORM;
|
n->objtype = OBJECT_TRANSFORM;
|
||||||
n->objname = list_make1($7);
|
n->objname = list_make1($7);
|
||||||
n->objargs = list_make1($9);
|
n->objargs = list_make1(makeString($9));
|
||||||
$$ = (Node *)n;
|
$$ = (Node *)n;
|
||||||
}
|
}
|
||||||
| ALTER EXTENSION name add_drop TYPE_P Typename
|
| ALTER EXTENSION name add_drop TYPE_P Typename
|
||||||
@ -5773,7 +5773,7 @@ CommentStmt:
|
|||||||
CommentStmt *n = makeNode(CommentStmt);
|
CommentStmt *n = makeNode(CommentStmt);
|
||||||
n->objtype = OBJECT_TRANSFORM;
|
n->objtype = OBJECT_TRANSFORM;
|
||||||
n->objname = list_make1($5);
|
n->objname = list_make1($5);
|
||||||
n->objargs = list_make1($7);
|
n->objargs = list_make1(makeString($7));
|
||||||
n->comment = $9;
|
n->comment = $9;
|
||||||
$$ = (Node *) n;
|
$$ = (Node *) n;
|
||||||
}
|
}
|
||||||
@ -7389,7 +7389,7 @@ DropTransformStmt: DROP TRANSFORM opt_if_exists FOR Typename LANGUAGE name opt_d
|
|||||||
DropStmt *n = makeNode(DropStmt);
|
DropStmt *n = makeNode(DropStmt);
|
||||||
n->removeType = OBJECT_TRANSFORM;
|
n->removeType = OBJECT_TRANSFORM;
|
||||||
n->objects = list_make1(list_make1($5));
|
n->objects = list_make1(list_make1($5));
|
||||||
n->arguments = list_make1(list_make1($7));
|
n->arguments = list_make1(list_make1(makeString($7)));
|
||||||
n->behavior = $8;
|
n->behavior = $8;
|
||||||
n->missing_ok = $3;
|
n->missing_ok = $3;
|
||||||
$$ = (Node *)n;
|
$$ = (Node *)n;
|
||||||
|
Loading…
Reference in New Issue
Block a user