Skip to content

Commit 7f60be7

Browse files
committed
Fix crash in ALTER OPERATOR CLASS/FAMILY .. SET SCHEMA.
In the previous coding, the parser emitted a List containing a C string, which is no good, because copyObject() can't handle it. Dimitri Fontaine
1 parent dc8a143 commit 7f60be7

File tree

4 files changed

+8
-13
lines changed

4 files changed

+8
-13
lines changed

src/backend/commands/alter.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,11 @@ ExecAlterObjectSchemaStmt(AlterObjectSchemaStmt *stmt)
198198
break;
199199

200200
case OBJECT_OPCLASS:
201-
AlterOpClassNamespace(stmt->object, stmt->objarg, stmt->newschema);
201+
AlterOpClassNamespace(stmt->object, stmt->addname, stmt->newschema);
202202
break;
203203

204204
case OBJECT_OPFAMILY:
205-
AlterOpFamilyNamespace(stmt->object, stmt->objarg, stmt->newschema);
205+
AlterOpFamilyNamespace(stmt->object, stmt->addname, stmt->newschema);
206206
break;
207207

208208
case OBJECT_SEQUENCE:

src/backend/commands/opclasscmds.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1993,16 +1993,13 @@ AlterOpClassOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerId)
19931993
* ALTER OPERATOR CLASS any_name USING access_method SET SCHEMA name
19941994
*/
19951995
void
1996-
AlterOpClassNamespace(List *name, List *argam, const char *newschema)
1996+
AlterOpClassNamespace(List *name, char *access_method, const char *newschema)
19971997
{
19981998
Oid amOid;
1999-
char *access_method = linitial(argam);
20001999
Relation rel;
20012000
Oid oid;
20022001
Oid nspOid;
20032002

2004-
Assert(list_length(argam) == 1);
2005-
20062003
amOid = get_am_oid(access_method, false);
20072004

20082005
rel = heap_open(OperatorClassRelationId, RowExclusiveLock);
@@ -2185,15 +2182,13 @@ get_am_oid(const char *amname, bool missing_ok)
21852182
* ALTER OPERATOR FAMILY any_name USING access_method SET SCHEMA name
21862183
*/
21872184
void
2188-
AlterOpFamilyNamespace(List *name, List *argam, const char *newschema)
2185+
AlterOpFamilyNamespace(List *name, char *access_method, const char *newschema)
21892186
{
21902187
Oid amOid;
2191-
char *access_method = linitial(argam);
21922188
Relation rel;
21932189
Oid nspOid;
21942190
Oid oid;
21952191

2196-
Assert(list_length(argam) == 1);
21972192
amOid = get_am_oid(access_method, false);
21982193

21992194
rel = heap_open(OperatorFamilyRelationId, RowExclusiveLock);

src/backend/parser/gram.y

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6225,7 +6225,7 @@ AlterObjectSchemaStmt:
62256225
AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
62266226
n->objectType = OBJECT_OPCLASS;
62276227
n->object = $4;
6228-
n->objarg = list_make1($6);
6228+
n->addname = $6;
62296229
n->newschema = $9;
62306230
$$ = (Node *)n;
62316231
}
@@ -6234,7 +6234,7 @@ AlterObjectSchemaStmt:
62346234
AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
62356235
n->objectType = OBJECT_OPFAMILY;
62366236
n->object = $4;
6237-
n->objarg = list_make1($6);
6237+
n->addname = $6;
62386238
n->newschema = $9;
62396239
$$ = (Node *)n;
62406240
}

src/include/commands/defrem.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,11 @@ extern void RenameOpClass(List *name, const char *access_method, const char *new
101101
extern void RenameOpFamily(List *name, const char *access_method, const char *newname);
102102
extern void AlterOpClassOwner(List *name, const char *access_method, Oid newOwnerId);
103103
extern void AlterOpClassOwner_oid(Oid opclassOid, Oid newOwnerId);
104-
extern void AlterOpClassNamespace(List *name, List *argam, const char *newschema);
104+
extern void AlterOpClassNamespace(List *name, char *access_method, const char *newschema);
105105
extern void AlterOpFamilyOwner(List *name, const char *access_method, Oid newOwnerId);
106106
extern void AlterOpFamilyOwner_oid(Oid opfamilyOid, Oid newOwnerId);
107107
extern Oid get_am_oid(const char *amname, bool missing_ok);
108-
extern void AlterOpFamilyNamespace(List *name, List *argam, const char *newschema);
108+
extern void AlterOpFamilyNamespace(List *name, char *access_method, const char *newschema);
109109

110110
/* commands/tsearchcmds.c */
111111
extern void DefineTSParser(List *names, List *parameters);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy