Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1ab19a3

Browse files
committed
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.
1 parent 49a7301 commit 1ab19a3

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/backend/commands/alter.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/commands/alter.c,v 1.26 2008/01/01 19:45:48 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/commands/alter.c,v 1.27 2008/02/07 21:07:55 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -216,15 +216,15 @@ ExecAlterOwnerStmt(AlterOwnerStmt *stmt)
216216
break;
217217

218218
case OBJECT_DATABASE:
219-
AlterDatabaseOwner((char *) linitial(stmt->object), newowner);
219+
AlterDatabaseOwner(strVal(linitial(stmt->object)), newowner);
220220
break;
221221

222222
case OBJECT_FUNCTION:
223223
AlterFunctionOwner(stmt->object, stmt->objarg, newowner);
224224
break;
225225

226226
case OBJECT_LANGUAGE:
227-
AlterLanguageOwner((char *) linitial(stmt->object), newowner);
227+
AlterLanguageOwner(strVal(linitial(stmt->object)), newowner);
228228
break;
229229

230230
case OBJECT_OPERATOR:
@@ -244,11 +244,11 @@ ExecAlterOwnerStmt(AlterOwnerStmt *stmt)
244244
break;
245245

246246
case OBJECT_SCHEMA:
247-
AlterSchemaOwner((char *) linitial(stmt->object), newowner);
247+
AlterSchemaOwner(strVal(linitial(stmt->object)), newowner);
248248
break;
249249

250250
case OBJECT_TABLESPACE:
251-
AlterTableSpaceOwner((char *) linitial(stmt->object), newowner);
251+
AlterTableSpaceOwner(strVal(linitial(stmt->object)), newowner);
252252
break;
253253

254254
case OBJECT_TYPE:

src/backend/parser/gram.y

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.605 2008/01/01 19:45:50 momjian Exp $
14+
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.606 2008/02/07 21:07:55 tgl Exp $
1515
*
1616
* HISTORY
1717
* AUTHOR DATE MAJOR EVENT
@@ -4825,7 +4825,7 @@ AlterOwnerStmt: ALTER AGGREGATE func_name aggr_args OWNER TO RoleId
48254825
{
48264826
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
48274827
n->objectType = OBJECT_DATABASE;
4828-
n->object = list_make1($3);
4828+
n->object = list_make1(makeString($3));
48294829
n->newowner = $6;
48304830
$$ = (Node *)n;
48314831
}
@@ -4850,7 +4850,7 @@ AlterOwnerStmt: ALTER AGGREGATE func_name aggr_args OWNER TO RoleId
48504850
{
48514851
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
48524852
n->objectType = OBJECT_LANGUAGE;
4853-
n->object = list_make1($4);
4853+
n->object = list_make1(makeString($4));
48544854
n->newowner = $7;
48554855
$$ = (Node *)n;
48564856
}
@@ -4885,7 +4885,7 @@ AlterOwnerStmt: ALTER AGGREGATE func_name aggr_args OWNER TO RoleId
48854885
{
48864886
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
48874887
n->objectType = OBJECT_SCHEMA;
4888-
n->object = list_make1($3);
4888+
n->object = list_make1(makeString($3));
48894889
n->newowner = $6;
48904890
$$ = (Node *)n;
48914891
}
@@ -4901,7 +4901,7 @@ AlterOwnerStmt: ALTER AGGREGATE func_name aggr_args OWNER TO RoleId
49014901
{
49024902
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
49034903
n->objectType = OBJECT_TABLESPACE;
4904-
n->object = list_make1($3);
4904+
n->object = list_make1(makeString($3));
49054905
n->newowner = $6;
49064906
$$ = (Node *)n;
49074907
}

0 commit comments

Comments
 (0)