From: Tom Lane Date: Thu, 7 Feb 2008 21:08:16 +0000 (+0000) Subject: Some variants of ALTER OWNER tried to make the "object" field of the X-Git-Url: http://git.postgresql.org/gitweb/?a=commitdiff_plain;h=5de9626e044fe39671ef5920b9211876eabd2bb4;p=users%2Fbernd%2Fpostgres.git Some variants of ALTER OWNER tried to make the "object" field of the 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. --- diff --git a/src/backend/commands/alter.c b/src/backend/commands/alter.c index 5621dc03cb..5f7edb08ab 100644 --- a/src/backend/commands/alter.c +++ b/src/backend/commands/alter.c @@ -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: diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y index 4673c7dd5c..d6756f94e7 100644 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -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; }