Commit 7f60be72 authored by Robert Haas's avatar Robert Haas

Fix crash in ALTER OPERATOR CLASS/FAMILY .. SET SCHEMA.

In the previous coding, the parser emitted a List containing a C string,
which is no good, because copyObject() can't handle it.

Dimitri Fontaine
parent dc8a1431
...@@ -198,11 +198,11 @@ ExecAlterObjectSchemaStmt(AlterObjectSchemaStmt *stmt) ...@@ -198,11 +198,11 @@ ExecAlterObjectSchemaStmt(AlterObjectSchemaStmt *stmt)
break; break;
case OBJECT_OPCLASS: case OBJECT_OPCLASS:
AlterOpClassNamespace(stmt->object, stmt->objarg, stmt->newschema); AlterOpClassNamespace(stmt->object, stmt->addname, stmt->newschema);
break; break;
case OBJECT_OPFAMILY: case OBJECT_OPFAMILY:
AlterOpFamilyNamespace(stmt->object, stmt->objarg, stmt->newschema); AlterOpFamilyNamespace(stmt->object, stmt->addname, stmt->newschema);
break; break;
case OBJECT_SEQUENCE: case OBJECT_SEQUENCE:
......
...@@ -1993,16 +1993,13 @@ AlterOpClassOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerId) ...@@ -1993,16 +1993,13 @@ AlterOpClassOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerId)
* ALTER OPERATOR CLASS any_name USING access_method SET SCHEMA name * ALTER OPERATOR CLASS any_name USING access_method SET SCHEMA name
*/ */
void void
AlterOpClassNamespace(List *name, List *argam, const char *newschema) AlterOpClassNamespace(List *name, char *access_method, const char *newschema)
{ {
Oid amOid; Oid amOid;
char *access_method = linitial(argam);
Relation rel; Relation rel;
Oid oid; Oid oid;
Oid nspOid; Oid nspOid;
Assert(list_length(argam) == 1);
amOid = get_am_oid(access_method, false); amOid = get_am_oid(access_method, false);
rel = heap_open(OperatorClassRelationId, RowExclusiveLock); rel = heap_open(OperatorClassRelationId, RowExclusiveLock);
...@@ -2185,15 +2182,13 @@ get_am_oid(const char *amname, bool missing_ok) ...@@ -2185,15 +2182,13 @@ get_am_oid(const char *amname, bool missing_ok)
* ALTER OPERATOR FAMILY any_name USING access_method SET SCHEMA name * ALTER OPERATOR FAMILY any_name USING access_method SET SCHEMA name
*/ */
void void
AlterOpFamilyNamespace(List *name, List *argam, const char *newschema) AlterOpFamilyNamespace(List *name, char *access_method, const char *newschema)
{ {
Oid amOid; Oid amOid;
char *access_method = linitial(argam);
Relation rel; Relation rel;
Oid nspOid; Oid nspOid;
Oid oid; Oid oid;
Assert(list_length(argam) == 1);
amOid = get_am_oid(access_method, false); amOid = get_am_oid(access_method, false);
rel = heap_open(OperatorFamilyRelationId, RowExclusiveLock); rel = heap_open(OperatorFamilyRelationId, RowExclusiveLock);
......
...@@ -6225,7 +6225,7 @@ AlterObjectSchemaStmt: ...@@ -6225,7 +6225,7 @@ AlterObjectSchemaStmt:
AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt); AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
n->objectType = OBJECT_OPCLASS; n->objectType = OBJECT_OPCLASS;
n->object = $4; n->object = $4;
n->objarg = list_make1($6); n->addname = $6;
n->newschema = $9; n->newschema = $9;
$$ = (Node *)n; $$ = (Node *)n;
} }
...@@ -6234,7 +6234,7 @@ AlterObjectSchemaStmt: ...@@ -6234,7 +6234,7 @@ AlterObjectSchemaStmt:
AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt); AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
n->objectType = OBJECT_OPFAMILY; n->objectType = OBJECT_OPFAMILY;
n->object = $4; n->object = $4;
n->objarg = list_make1($6); n->addname = $6;
n->newschema = $9; n->newschema = $9;
$$ = (Node *)n; $$ = (Node *)n;
} }
......
...@@ -101,11 +101,11 @@ extern void RenameOpClass(List *name, const char *access_method, const char *new ...@@ -101,11 +101,11 @@ extern void RenameOpClass(List *name, const char *access_method, const char *new
extern void RenameOpFamily(List *name, const char *access_method, const char *newname); extern void RenameOpFamily(List *name, const char *access_method, const char *newname);
extern void AlterOpClassOwner(List *name, const char *access_method, Oid newOwnerId); extern void AlterOpClassOwner(List *name, const char *access_method, Oid newOwnerId);
extern void AlterOpClassOwner_oid(Oid opclassOid, Oid newOwnerId); extern void AlterOpClassOwner_oid(Oid opclassOid, Oid newOwnerId);
extern void AlterOpClassNamespace(List *name, List *argam, const char *newschema); extern void AlterOpClassNamespace(List *name, char *access_method, const char *newschema);
extern void AlterOpFamilyOwner(List *name, const char *access_method, Oid newOwnerId); extern void AlterOpFamilyOwner(List *name, const char *access_method, Oid newOwnerId);
extern void AlterOpFamilyOwner_oid(Oid opfamilyOid, Oid newOwnerId); extern void AlterOpFamilyOwner_oid(Oid opfamilyOid, Oid newOwnerId);
extern Oid get_am_oid(const char *amname, bool missing_ok); extern Oid get_am_oid(const char *amname, bool missing_ok);
extern void AlterOpFamilyNamespace(List *name, List *argam, const char *newschema); extern void AlterOpFamilyNamespace(List *name, char *access_method, const char *newschema);
/* commands/tsearchcmds.c */ /* commands/tsearchcmds.c */
extern void DefineTSParser(List *names, List *parameters); extern void DefineTSParser(List *names, List *parameters);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment