Some variants of ALTER OWNER tried to make the "object" field of the
authorTom Lane <[email protected]>
Thu, 7 Feb 2008 21:08:16 +0000 (21:08 +0000)
committerTom Lane <[email protected]>
Thu, 7 Feb 2008 21:08:16 +0000 (21:08 +0000)
statement be a list of bare C strings, rather than String nodes, which is
what they need to be for copyfuncs/equalfuncs to work.  Fortunately these
node types never go out to disk (if they did, we'd likely have noticed the
problem sooner), so we can just fix it without creating a need for initdb.
This bug has been there since 8.0, but 8.3 exposes it in a more common
code path (Parse messages) than prior releases did.  Per bug #3940 from
Vladimir Kokovic.

src/backend/commands/alter.c
src/backend/parser/gram.y

index 5621dc03cbbca1adfb1da04bf557f7555561d36d..5f7edb08abb73afa7d60098f7868aec8f68f4403 100644 (file)
@@ -196,7 +196,7 @@ ExecAlterOwnerStmt(AlterOwnerStmt *stmt)
                        break;
 
                case OBJECT_DATABASE:
-                       AlterDatabaseOwner((char *) linitial(stmt->object), newowner);
+                       AlterDatabaseOwner(strVal(linitial(stmt->object)), newowner);
                        break;
 
                case OBJECT_FUNCTION:
@@ -215,11 +215,11 @@ ExecAlterOwnerStmt(AlterOwnerStmt *stmt)
                        break;
 
                case OBJECT_SCHEMA:
-                       AlterSchemaOwner((char *) linitial(stmt->object), newowner);
+                       AlterSchemaOwner(strVal(linitial(stmt->object)), newowner);
                        break;
 
                case OBJECT_TABLESPACE:
-                       AlterTableSpaceOwner((char *) linitial(stmt->object), newowner);
+                       AlterTableSpaceOwner(strVal(linitial(stmt->object)), newowner);
                        break;
 
                case OBJECT_TYPE:
index 4673c7dd5c83f7effed108dab6f24870c2f571a3..d6756f94e7e54e97ead2ecf14f1f8d962a9da906 100644 (file)
@@ -4142,7 +4142,7 @@ AlterOwnerStmt: ALTER AGGREGATE func_name '(' aggr_argtype ')' OWNER TO RoleId
                                {
                                        AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                                        n->objectType = OBJECT_DATABASE;
-                                       n->object = list_make1($3);
+                                       n->object = list_make1(makeString($3));
                                        n->newowner = $6;
                                        $$ = (Node *)n;
                                }
@@ -4185,7 +4185,7 @@ AlterOwnerStmt: ALTER AGGREGATE func_name '(' aggr_argtype ')' OWNER TO RoleId
                                {
                                        AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                                        n->objectType = OBJECT_SCHEMA;
-                                       n->object = list_make1($3);
+                                       n->object = list_make1(makeString($3));
                                        n->newowner = $6;
                                        $$ = (Node *)n;
                                }
@@ -4201,7 +4201,7 @@ AlterOwnerStmt: ALTER AGGREGATE func_name '(' aggr_argtype ')' OWNER TO RoleId
                                {
                                        AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                                        n->objectType = OBJECT_TABLESPACE;
-                                       n->object = list_make1($3);
+                                       n->object = list_make1(makeString($3));
                                        n->newowner = $6;
                                        $$ = (Node *)n;
                                }