diff --git a/createas.c b/createas.c index 10a09c0..3385255 100644 --- a/createas.c +++ b/createas.c @@ -747,6 +747,8 @@ CreateIvmTrigger(Oid relOid, ImmvAddress immv_addr, int16 type, int16 timing, bo if (type == TRIGGER_TYPE_DELETE || type == TRIGGER_TYPE_UPDATE) ex_lock = true; + ivm_trigger->trigname = psprintf("%s_%d_%d", ivm_trigger->trigname, relOid, + immv_addr.address.objectId); ivm_trigger->funcname = (timing == TRIGGER_TYPE_BEFORE ? PgIvmFuncName("IVM_immediate_before") : PgIvmFuncName("IVM_immediate_maintenance")); @@ -759,12 +761,12 @@ CreateIvmTrigger(Oid relOid, ImmvAddress immv_addr, int16 type, int16 timing, bo ivm_trigger->initdeferred = false; ivm_trigger->constrrel = NULL; ivm_trigger->args = list_make2( - makeString(DatumGetPointer(UUIDPGetDatum(&immv_addr.immv_uuid))), + makeString(DatumGetPointer(DirectFunctionCall1(uuid_out, UUIDPGetDatum(&immv_addr.immv_uuid)))), makeString(DatumGetPointer(DirectFunctionCall1(boolout, BoolGetDatum(ex_lock)))) ); address = CreateTrigger(ivm_trigger, NULL, relOid, InvalidOid, InvalidOid, - InvalidOid, InvalidOid, InvalidOid, NULL, true, false); + InvalidOid, InvalidOid, InvalidOid, NULL, false, false); recordDependencyOn(&address, &refaddr, DEPENDENCY_AUTO); @@ -1733,7 +1735,7 @@ StoreImmvQuery(ImmvAddress immv_addr, Query *viewQuery) */ save_nestlevel = NewGUCNestLevel(); RestrictSearchPath(); - matviewRel = table_open(viewOid, AccessShareLock); + matviewRel = table_open(immv_addr.address.objectId, AccessShareLock); querystring = pg_ivm_get_viewdef_internal(viewQuery, matviewRel, true); table_close(matviewRel, NoLock); /* Roll back the search_path change. */ diff --git a/event_trigger.c b/event_trigger.c index d23b4ac..77685f8 100644 --- a/event_trigger.c +++ b/event_trigger.c @@ -1,6 +1,7 @@ #include "postgres.h" #include "pg_ivm.h" +#include "access/genam.h" #include "access/table.h" #include "catalog/indexing.h" #include "commands/event_trigger.h" diff --git a/matview.c b/matview.c index b42001c..cfce832 100644 --- a/matview.c +++ b/matview.c @@ -857,7 +857,7 @@ IVM_immediate_before(PG_FUNCTION_ARGS) bool found; bool ex_lock; - immv_uuid = DatumGetUUIDP(CStringGetDatum(immv_uuid_text)); + immv_uuid = DatumGetUUIDP(DirectFunctionCall1(uuid_in, (CStringGetDatum(immv_uuid_text)))); ex_lock = DatumGetBool(DirectFunctionCall1(boolin, CStringGetDatum(ex_lock_text))); matviewOid = GetImmvRelid(immv_uuid); @@ -1006,7 +1006,7 @@ IVM_immediate_maintenance(PG_FUNCTION_ARGS) rel = trigdata->tg_relation; relid = rel->rd_id; - immv_uuid = DatumGetUUIDP(CStringGetDatum(immv_uuid_text)); + immv_uuid = DatumGetUUIDP(DirectFunctionCall1(uuid_in, (CStringGetDatum(immv_uuid_text)))); matviewOid = GetImmvRelid(immv_uuid); /* diff --git a/pg_ivm.c b/pg_ivm.c index 6b8e1d4..88c5841 100644 --- a/pg_ivm.c +++ b/pg_ivm.c @@ -320,7 +320,6 @@ CreateChangePreventTrigger(Oid matviewOid) ivm_trigger->row = false; ivm_trigger->timing = TRIGGER_TYPE_BEFORE; - ivm_trigger->trigname = "IVM_prevent_immv_change"; ivm_trigger->funcname = PgIvmFuncName("IVM_prevent_immv_change"); ivm_trigger->columns = NIL; ivm_trigger->transitionRels = NIL; @@ -334,8 +333,10 @@ CreateChangePreventTrigger(Oid matviewOid) for (i = 0; i < 4; i++) { ivm_trigger->events = types[i]; + ivm_trigger->trigname = psprintf("IVM_prevent_immv_change_%d_%d", + matviewOid, i + 1); address = CreateTrigger(ivm_trigger, NULL, matviewOid, InvalidOid, InvalidOid, - InvalidOid, InvalidOid, InvalidOid, NULL, true, false); + InvalidOid, InvalidOid, InvalidOid, NULL, false, false); recordDependencyOn(&address, &refaddr, DEPENDENCY_AUTO); }