ERROR: Table 'public.deny_test' to queue 'noqueue': change not allowed (I)
truncate deny_test;
ERROR: Table 'public.deny_test' to queue 'noqueue': change not allowed (R)
+-- test pk update
+insert into udata (id, txt) values (1, 'txt');
+NOTICE: insert_event(udata_que, I:id, id=1&txt=txt, public.udata)
+CONTEXT: SQL statement "select pgq.insert_event($1, $2, $3, $4, $5, $6, $7)"
+update udata set id = 2;
+ERROR: primary key update not allowed
truncate custom_expr;
NOTICE: insert_event(que3, R, , public.custom_expr)
CONTEXT: SQL statement "select pgq.insert_event($1, $2, $3, $4, $5, $6, $7)"
+-- test pk update
+insert into rtest values (1, 'value1');
+NOTICE: insert_event(que3, I, (id,dat,dat2) values ('1','value1',null), public.rtest)
+CONTEXT: SQL statement "select pgq.insert_event($1, $2, $3, $4, $5, $6, $7)"
+update rtest set id = 2;
+ERROR: primary key update not allowed
insert into deny_test values ('1', '2');
truncate deny_test;
+-- test pk update
+insert into udata (id, txt) values (1, 'txt');
+update udata set id = 2;
create trigger customtrc_triga after truncate on custom_expr
for each statement execute procedure pgq.sqltriga('que3');
truncate custom_expr;
+
+-- test pk update
+insert into rtest values (1, 'value1');
+update rtest set id = 2;
+
Datum new_value;
bool old_isnull;
bool new_isnull;
+ bool is_pk;
int i, attkind_idx = -1;
int ignore_count = 0;
if (!TRIGGER_FIRED_BY_UPDATE(tg->tg_event))
return 1;
- /* if no columns are ignored, all events are interesting */
- if (ev->tgargs->ignore_list == NULL)
- return 1;
-
for (i = 0; i < tupdesc->natts; i++) {
/*
* Ignore dropped columns
continue;
attkind_idx++;
+ is_pk = pgqtriga_is_pkey(ev, i, attkind_idx);
+ if (!is_pk && ev->tgargs->ignore_list == NULL)
+ continue;
+
old_value = SPI_getbinval(old_row, tupdesc, i + 1, &old_isnull);
new_value = SPI_getbinval(new_row, tupdesc, i + 1, &new_isnull);
}
}
+ if (is_pk)
+ elog(ERROR, "primary key update not allowed");
+
if (pgqtriga_skip_col(ev, i, attkind_idx)) {
/* this change should be ignored */
ignore_count++;
}
}
+ if (pgqtriga_is_pkey(ev, i, attkind_idx))
+ elog(ERROR, "primary key update not allowed");
+
if (pgqtriga_skip_col(ev, i, attkind_idx)) {
/* this change should be ignored */
ignore_count++;