非互換
FUJITSU Enterprise Postgres 14では、下記の場合、「INSERT...SELECT」動作を実施不可に変更します。
CTE(WITH句)を利用する。かつ、
CTEでテーブルの更新(UPDATEとか、DELETEなど)を実施する。かつ、
「INSERT...SELECT」のルールを指定する
「INSERT...SELECT」は実施できます。
[例]
=# CREATE TEMP TABLE test AS -# select i from generate_series(1,3) as t(i); SELECT 3 =# CREATE TEMP TABLE test1 (i int); CREATE TABLE =# CREATE OR REPLACE RULE test_ins AS ON INSERT TO test -# DO INSTEAD INSERT INTO test1 SELECT NEW.i; CREATE RULE =# WITH t1 AS ( DELETE FROM test RETURNING * ) -# INSERT INTO test SELECT * FROM t1; INSERT 0 3
「INSERT...SELECT」は実施不可になります。
[例]
=# CREATE TEMP TABLE test AS -# select i from generate_series(1,3) as t(i); SELECT 3 =# CREATE TEMP TABLE test1 (i int); CREATE TABLE =# CREATE OR REPLACE RULE test_ins AS ON INSERT TO test -# DO INSTEAD INSERT INTO test1 SELECT NEW.i; CREATE RULE =# WITH t1 AS ( DELETE FROM test RETURNING * ) -# INSERT INTO test SELECT * FROM t1; ERROR: INSERT...SELECT rule actions are not supported for queries having data-modifying statements in WITH
対処方法
ありません。