#include "catalog/objectaccess.h"
#include "catalog/pg_event_trigger.h"
#include "catalog/pg_namespace.h"
+#include "catalog/pg_opfamily.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_trigger.h"
#include "catalog/pg_type.h"
MemoryContextSwitchTo(oldcxt);
}
+/*
+ * EventTriggerStashAlterOpFam
+ * Save data about an ALTER OPERATOR FAMILY ADD/DROP command being
+ * executed
+ */
+void
+EventTriggerStashAlterOpFam(AlterOpFamilyStmt *stmt, Oid opfamoid,
+ List *operators, List *procedures)
+{
+ MemoryContext oldcxt;
+ StashedCommand *stashed;
+
+ if (currentEventTriggerState->commandCollectionInhibited)
+ return;
+
+ oldcxt = MemoryContextSwitchTo(currentEventTriggerState->cxt);
+
+ stashed = palloc(sizeof(StashedCommand));
+ stashed->type = SCT_AlterOpFamily;
+ stashed->in_extension = creating_extension;
+ stashed->d.opfam.opfamOid = opfamoid;
+ stashed->d.opfam.operators = operators; /* XXX prolly need to copy */
+ stashed->d.opfam.procedures = procedures; /* XXX ditto */
+ stashed->parsetree = copyObject(stmt);
+
+ currentEventTriggerState->stash = lappend(currentEventTriggerState->stash,
+ stashed);
+
+ MemoryContextSwitchTo(oldcxt);
+}
+
Datum
pg_event_trigger_get_creation_commands(PG_FUNCTION_ARGS)
{
MemSet(nulls, 0, sizeof(nulls));
if (cmd->type == SCT_Simple ||
- cmd->type == SCT_AlterTable)
+ cmd->type == SCT_AlterTable ||
+ cmd->type == SCT_AlterOpFamily)
{
const char *tag;
char *identity;
ObjectAddressSet(addr,
cmd->d.alterTable.classId,
cmd->d.alterTable.objectId);
+ else if (cmd->type == SCT_AlterOpFamily)
+ ObjectAddressSet(addr,
+ OperatorFamilyRelationId,
+ cmd->d.opfam.opfamOid);
tag = CreateCommandTag(cmd->parsetree);
#include "catalog/dependency.h"
#include "catalog/indexing.h"
#include "catalog/objectaccess.h"
+#include "catalog/opfam_internal.h"
#include "catalog/pg_amop.h"
#include "catalog/pg_amproc.h"
#include "catalog/pg_namespace.h"
#include "utils/tqual.h"
-/*
- * We use lists of this struct type to keep track of both operators and
- * procedures while building or adding to an opfamily.
- */
-typedef struct
-{
- Oid object; /* operator or support proc's OID */
- int number; /* strategy or support proc number */
- Oid lefttype; /* lefttype */
- Oid righttype; /* righttype */
- Oid sortfamily; /* ordering operator's sort opfamily, or 0 */
-} OpFamilyMember;
-
-
static void AlterOpFamilyAdd(List *opfamilyname, Oid amoid, Oid opfamilyoid,
int maxOpNumber, int maxProcNumber,
List *items);
break;
case T_AlterOpFamilyStmt:
- elog(ERROR, "unimplemented deparse of %s", CreateCommandTag(parsetree));
+ /* handled elsewhere */
+ elog(ERROR, "unexpected command type %s", CreateCommandTag(parsetree));
break;
case T_AlterTSDictionaryStmt:
case SCT_Grant:
tree = deparse_GrantStmt(cmd);
break;
+ case SCT_AlterOpFamily:
+ tree = deparse_AlterOpFamily(cmd);
+ break;
default:
elog(ERROR, "unexpected deparse node type %d", cmd->type);
}
--- /dev/null
+/*-------------------------------------------------------------------------
+ *
+ * opfam_internal.h
+ *
+ * Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1994, Regents of the University of California
+ *
+ * src/include/catalog/opfam_internal.h
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef OPFAM_INTERNAL_H
+#define OPFAM_INTERNAL_H
+
+/*
+ * We use lists of this struct type to keep track of both operators and
+ * procedures while building or adding to an opfamily.
+ */
+typedef struct
+{
+ Oid object; /* operator or support proc's OID */
+ int number; /* strategy or support proc number */
+ Oid lefttype; /* lefttype */
+ Oid righttype; /* righttype */
+ Oid sortfamily; /* ordering operator's sort opfamily, or 0 */
+} OpFamilyMember;
+
+#endif /* OPFAM_INTERNAL_H */
extern void EventTriggerAlterTableEnd(void);
extern void EventTriggerStashGrant(InternalGrant *istmt);
+extern void EventTriggerStashAlterOpFam(AlterOpFamilyStmt *stmt, Oid opfamoid,
+ List *operators, List *procedures);
#endif /* EVENT_TRIGGER_H */
{
SCT_Simple,
SCT_AlterTable,
- SCT_Grant
+ SCT_Grant,
+ SCT_AlterOpFamily
} StashedCommandType;
/*
InternalGrant *istmt;
const char *type;
} grant;
+
+ /* ALTER OPERATOR FAMILY */
+ struct
+ {
+ Oid opfamOid;
+ List *operators;
+ List *procedures;
+ } opfam;
} d;
} StashedCommand;