Some variants of ALTER OWNER tried to make the "object" field of the
authorTom Lane <[email protected]>
Thu, 7 Feb 2008 21:08:25 +0000 (21:08 +0000)
committerTom Lane <[email protected]>
Thu, 7 Feb 2008 21:08:25 +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 c5c09e113fd1b531e5453cd7a31f27bb060f0d59..52d19f704324ff3b8e958a306f764b1d2598694d 100644 (file)
@@ -168,7 +168,7 @@ ExecAlterOwnerStmt(AlterOwnerStmt *stmt)
                        break;
 
                case OBJECT_DATABASE:
-                       AlterDatabaseOwner((char *) linitial(stmt->object), newowner);
+                       AlterDatabaseOwner(strVal(linitial(stmt->object)), newowner);
                        break;
 
                case OBJECT_FUNCTION:
@@ -187,11 +187,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 ea21a9861529c544cefa87f0d91ff1fa7d739b31..6f26d9a9cb781b70fc306ce69ee286051eee4192 100644 (file)
@@ -3751,7 +3751,7 @@ AlterOwnerStmt: ALTER AGGREGATE func_name '(' aggr_argtype ')' OWNER TO UserId
                                {
                                        AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                                        n->objectType = OBJECT_DATABASE;
-                                       n->object = list_make1($3);
+                                       n->object = list_make1(makeString($3));
                                        n->newowner = $6;
                                        $$ = (Node *)n;
                                }
@@ -3794,7 +3794,7 @@ AlterOwnerStmt: ALTER AGGREGATE func_name '(' aggr_argtype ')' OWNER TO UserId
                                {
                                        AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                                        n->objectType = OBJECT_SCHEMA;
-                                       n->object = list_make1($3);
+                                       n->object = list_make1(makeString($3));
                                        n->newowner = $6;
                                        $$ = (Node *)n;
                                }
@@ -3810,7 +3810,7 @@ AlterOwnerStmt: ALTER AGGREGATE func_name '(' aggr_argtype ')' OWNER TO UserId
                                {
                                        AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                                        n->objectType = OBJECT_TABLESPACE;
-                                       n->object = list_make1($3);
+                                       n->object = list_make1(makeString($3));
                                        n->newowner = $6;
                                        $$ = (Node *)n;
                                }