]> granicus.if.org Git - postgresql/commitdiff
Fix crash in ALTER OPERATOR CLASS/FAMILY .. SET SCHEMA.
authorRobert Haas <rhaas@postgresql.org>
Tue, 4 Jan 2011 03:08:55 +0000 (22:08 -0500)
committerRobert Haas <rhaas@postgresql.org>
Tue, 4 Jan 2011 03:08:55 +0000 (22:08 -0500)
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

src/backend/commands/alter.c
src/backend/commands/opclasscmds.c
src/backend/parser/gram.y
src/include/commands/defrem.h

index 6a9b21d01fe86bb02df0be4cecc24ff11405ddfd..1c6ae0243e4cb2f20a840dc81af8320717b9e01d 100644 (file)
@@ -198,11 +198,11 @@ ExecAlterObjectSchemaStmt(AlterObjectSchemaStmt *stmt)
                        break;
 
                case OBJECT_OPCLASS:
-                       AlterOpClassNamespace(stmt->object, stmt->objarg, stmt->newschema);
+                       AlterOpClassNamespace(stmt->object, stmt->addname, stmt->newschema);
                        break;
 
                case OBJECT_OPFAMILY:
-                       AlterOpFamilyNamespace(stmt->object, stmt->objarg, stmt->newschema);
+                       AlterOpFamilyNamespace(stmt->object, stmt->addname, stmt->newschema);
                        break;
 
                case OBJECT_SEQUENCE:
index ab9bc327feb186bb1b008f1197b2c1748aaf8734..662b9420387f90bf3c9b6e656ed7b90583319d98 100644 (file)
@@ -1993,16 +1993,13 @@ AlterOpClassOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerId)
  * ALTER OPERATOR CLASS any_name USING access_method SET SCHEMA name
  */
 void
-AlterOpClassNamespace(List *name, List *argam, const char *newschema)
+AlterOpClassNamespace(List *name, char *access_method, const char *newschema)
 {
        Oid                     amOid;
-       char       *access_method = linitial(argam);
        Relation        rel;
        Oid                     oid;
        Oid                     nspOid;
 
-       Assert(list_length(argam) == 1);
-
        amOid = get_am_oid(access_method, false);
 
        rel = heap_open(OperatorClassRelationId, RowExclusiveLock);
@@ -2185,15 +2182,13 @@ get_am_oid(const char *amname, bool missing_ok)
  * ALTER OPERATOR FAMILY any_name USING access_method SET SCHEMA name
  */
 void
-AlterOpFamilyNamespace(List *name, List *argam, const char *newschema)
+AlterOpFamilyNamespace(List *name, char *access_method, const char *newschema)
 {
        Oid                     amOid;
-       char       *access_method = linitial(argam);
        Relation        rel;
        Oid                     nspOid;
        Oid                     oid;
 
-       Assert(list_length(argam) == 1);
        amOid = get_am_oid(access_method, false);
 
        rel = heap_open(OperatorFamilyRelationId, RowExclusiveLock);
index 43e8fdbd724d696adba6913bd810b1a22a85e5d6..660947c8f8bdd663821a4588c8b462b645d7e5ab 100644 (file)
@@ -6225,7 +6225,7 @@ AlterObjectSchemaStmt:
                                        AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                                        n->objectType = OBJECT_OPCLASS;
                                        n->object = $4;
-                                       n->objarg = list_make1($6);
+                                       n->addname = $6;
                                        n->newschema = $9;
                                        $$ = (Node *)n;
                                }
@@ -6234,7 +6234,7 @@ AlterObjectSchemaStmt:
                                        AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
                                        n->objectType = OBJECT_OPFAMILY;
                                        n->object = $4;
-                                       n->objarg = list_make1($6);
+                                       n->addname = $6;
                                        n->newschema = $9;
                                        $$ = (Node *)n;
                                }
index 3d3e9f959aeb41206cd6f227202e9f7de195a44a..a806f9efcbe946d5869f1c0d7901d93342b95627 100644 (file)
@@ -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 AlterOpClassOwner(List *name, const char *access_method, 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_oid(Oid opfamilyOid, Oid newOwnerId);
 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 */
 extern void DefineTSParser(List *names, List *parameters);