mirror of
https://github.com/postgres/postgres.git
synced 2025-07-03 20:02:46 +03:00
Fix DDL deparse of CREATE OPERATOR CLASS
When an implicit operator family is created, it wasn't getting reported. Make it do so. This has always been missing. Backpatch to 10. Author: Masahiko Sawada <sawada.mshk@gmail.com> Reported-by: Leslie LEMAIRE <leslie.lemaire@developpement-durable.gouv.fr> Reviewed-by: Amit Kapila <amit.kapila16@gmail.com> Reviewed-by: Michael Paquiër <michael@paquier.xyz> Discussion: https://postgr.es/m/f74d69e151b22171e8829551b1159e77@developpement-durable.gouv.fr
This commit is contained in:
@ -240,7 +240,8 @@ get_opclass_oid(Oid amID, List *opclassname, bool missing_ok)
|
||||
* Caller must have done permissions checks etc. already.
|
||||
*/
|
||||
static ObjectAddress
|
||||
CreateOpFamily(const char *amname, const char *opfname, Oid namespaceoid, Oid amoid)
|
||||
CreateOpFamily(CreateOpFamilyStmt *stmt, const char *opfname,
|
||||
Oid namespaceoid, Oid amoid)
|
||||
{
|
||||
Oid opfamilyoid;
|
||||
Relation rel;
|
||||
@ -264,7 +265,7 @@ CreateOpFamily(const char *amname, const char *opfname, Oid namespaceoid, Oid am
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DUPLICATE_OBJECT),
|
||||
errmsg("operator family \"%s\" for access method \"%s\" already exists",
|
||||
opfname, amname)));
|
||||
opfname, stmt->amname)));
|
||||
|
||||
/*
|
||||
* Okay, let's create the pg_opfamily entry.
|
||||
@ -312,6 +313,10 @@ CreateOpFamily(const char *amname, const char *opfname, Oid namespaceoid, Oid am
|
||||
/* dependency on extension */
|
||||
recordDependencyOnCurrentExtension(&myself, false);
|
||||
|
||||
/* Report the new operator family to possibly interested event triggers */
|
||||
EventTriggerCollectSimpleCommand(myself, InvalidObjectAddress,
|
||||
(Node *) stmt);
|
||||
|
||||
/* Post creation hook for new operator family */
|
||||
InvokeObjectPostCreateHook(OperatorFamilyRelationId, opfamilyoid, 0);
|
||||
|
||||
@ -447,13 +452,17 @@ DefineOpClass(CreateOpClassStmt *stmt)
|
||||
}
|
||||
else
|
||||
{
|
||||
CreateOpFamilyStmt *opfstmt;
|
||||
ObjectAddress tmpAddr;
|
||||
|
||||
opfstmt = makeNode(CreateOpFamilyStmt);
|
||||
opfstmt->opfamilyname = stmt->opclassname;
|
||||
opfstmt->amname = stmt->amname;
|
||||
|
||||
/*
|
||||
* Create it ... again no need for more permissions ...
|
||||
*/
|
||||
tmpAddr = CreateOpFamily(stmt->amname, opcname,
|
||||
namespaceoid, amoid);
|
||||
tmpAddr = CreateOpFamily(opfstmt, opcname, namespaceoid, amoid);
|
||||
opfamilyoid = tmpAddr.objectId;
|
||||
}
|
||||
}
|
||||
@ -792,7 +801,7 @@ DefineOpFamily(CreateOpFamilyStmt *stmt)
|
||||
errmsg("must be superuser to create an operator family")));
|
||||
|
||||
/* Insert pg_opfamily catalog entry */
|
||||
return CreateOpFamily(stmt->amname, opfname, namespaceoid, amoid);
|
||||
return CreateOpFamily(stmt, opfname, namespaceoid, amoid);
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user