]> granicus.if.org Git - postgresql/commitdiff
Some variants of ALTER OWNER tried to make the "object" field of the
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 7 Feb 2008 21:07:55 +0000 (21:07 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 7 Feb 2008 21:07:55 +0000 (21:07 +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 9a33d38d2692667fa227c736fbb323710d6c4496..8cf833a921894420f7db03efd6c17f10e70003d0 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/commands/alter.c,v 1.26 2008/01/01 19:45:48 momjian Exp $
+ *       $PostgreSQL: pgsql/src/backend/commands/alter.c,v 1.27 2008/02/07 21:07:55 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -216,7 +216,7 @@ ExecAlterOwnerStmt(AlterOwnerStmt *stmt)
                        break;
 
                case OBJECT_DATABASE:
-                       AlterDatabaseOwner((char *) linitial(stmt->object), newowner);
+                       AlterDatabaseOwner(strVal(linitial(stmt->object)), newowner);
                        break;
 
                case OBJECT_FUNCTION:
@@ -224,7 +224,7 @@ ExecAlterOwnerStmt(AlterOwnerStmt *stmt)
                        break;
 
                case OBJECT_LANGUAGE:
-                       AlterLanguageOwner((char *) linitial(stmt->object), newowner);
+                       AlterLanguageOwner(strVal(linitial(stmt->object)), newowner);
                        break;
 
                case OBJECT_OPERATOR:
@@ -244,11 +244,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 f95ea8a67258fef9de3668206f2bc98b315f45f7..2b992fab4a7d06e5f2d9ba659a8b29520ab970bd 100644 (file)
@@ -11,7 +11,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.605 2008/01/01 19:45:50 momjian Exp $
+ *       $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.606 2008/02/07 21:07:55 tgl Exp $
  *
  * HISTORY
  *       AUTHOR                        DATE                    MAJOR EVENT
@@ -4825,7 +4825,7 @@ AlterOwnerStmt: ALTER AGGREGATE func_name aggr_args 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;
                                }
@@ -4850,7 +4850,7 @@ AlterOwnerStmt: ALTER AGGREGATE func_name aggr_args OWNER TO RoleId
                                {
                                        AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
                                        n->objectType = OBJECT_LANGUAGE;
-                                       n->object = list_make1($4);
+                                       n->object = list_make1(makeString($4));
                                        n->newowner = $7;
                                        $$ = (Node *)n;
                                }
@@ -4885,7 +4885,7 @@ AlterOwnerStmt: ALTER AGGREGATE func_name aggr_args 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;
                                }
@@ -4901,7 +4901,7 @@ AlterOwnerStmt: ALTER AGGREGATE func_name aggr_args 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;
                                }