-- -- Test cases for COPY (INSERT/UPDATE/DELETE) TO -- createtable copydml_test (id serial, t text); insertinto copydml_test (t) values ('a'); insertinto copydml_test (t) values ('b'); insertinto copydml_test (t) values ('c'); insertinto copydml_test (t) values ('d'); insertinto copydml_test (t) values ('e');
-- -- Test COPY (insert/update/delete ...) --
copy (insertinto copydml_test (t) values ('f') returning id) to stdout;
copy (update copydml_test set t = 'g'where t = 'f' returning id) to stdout;
copy (deletefrom copydml_test where t = 'g' returning id) to stdout;
-- -- Test \copy (insert/update/delete ...) --
\copy (insertinto copydml_test (t) values ('f') returning id) to stdout;
\copy (update copydml_test set t = 'g'where t = 'f' returning id) to stdout;
\copy (deletefrom copydml_test where t = 'g' returning id) to stdout;
-- Error cases
copy (insertinto copydml_test defaultvalues) to stdout;
copy (update copydml_test set t = 'g') to stdout;
copy (deletefrom copydml_test) to stdout;
create rule qqq asoninsertto copydml_test do instead nothing;
copy (insertinto copydml_test defaultvalues) to stdout; drop rule qqq on copydml_test; create rule qqq asoninsertto copydml_test do also deletefrom copydml_test;
copy (insertinto copydml_test defaultvalues) to stdout; drop rule qqq on copydml_test; create rule qqq asoninsertto copydml_test do instead (deletefrom copydml_test; deletefromcopydml_test);
copy (insertinto copydml_test defaultvalues) to stdout; drop rule qqq on copydml_test; create rule qqq asoninsertto copydml_test where new.t <> 'f' do instead deletefrom copydml_test;
copy (insertinto copydml_test defaultvalues) to stdout; drop rule qqq on copydml_test;
create rule qqq asonupdateto copydml_test do instead nothing;
copy (update copydml_test set t = 'f') to stdout; drop rule qqq on copydml_test; create rule qqq asonupdateto copydml_test do also deletefrom copydml_test;
copy (update copydml_test set t = 'f') to stdout; drop rule qqq on copydml_test; create rule qqq asonupdateto copydml_test do instead (deletefrom copydml_test; deletefromcopydml_test);
copy (update copydml_test set t = 'f') to stdout; drop rule qqq on copydml_test; create rule qqq asonupdateto copydml_test where new.t <> 'f' do instead deletefrom copydml_test;
copy (update copydml_test set t = 'f') to stdout; drop rule qqq on copydml_test;
create rule qqq asondeleteto copydml_test do instead nothing;
copy (deletefrom copydml_test) to stdout; drop rule qqq on copydml_test; create rule qqq asondeleteto copydml_test do also insertinto copydml_test defaultvalues;
copy (deletefrom copydml_test) to stdout; drop rule qqq on copydml_test; create rule qqq asondeleteto copydml_test do instead (insertinto copydml_test defaultvalues; insertinto copydml_test defaultvalues);
copy (deletefrom copydml_test) to stdout; drop rule qqq on copydml_test; create rule qqq asondeleteto copydml_test where old.t <> 'f' do instead insertinto copydml_test defaultvalues;
copy (deletefrom copydml_test) to stdout; drop rule qqq on copydml_test;
create rule qqq asoninsertto copydml_test do instead notify copydml_test;
copy (insertinto copydml_test defaultvalues) to stdout; drop rule qqq on copydml_test;
-- triggers create function qqq_trig() returns triggeras $$
begin if tg_op in ('INSERT', 'UPDATE') then
raise notice '% % %', tg_when, tg_op, new.id; return new; else
raise notice '% % %', tg_when, tg_op, old.id; return old;
end if;
end
$$ language plpgsql; createtrigger qqqbef beforeinsertorupdateordeleteon copydml_test foreach row execute procedure qqq_trig(); createtrigger qqqaf after insertorupdateordeleteon copydml_test foreach row execute procedure qqq_trig();
copy (insertinto copydml_test (t) values ('f') returning id) to stdout;
copy (update copydml_test set t = 'g'where t = 'f' returning id) to stdout;
copy (deletefrom copydml_test where t = 'g' returning id) to stdout;
droptable copydml_test; drop function qqq_trig();
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.1 Sekunden
(vorverarbeitet am 2026-08-08)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.