summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPallavi Sontakke2015-09-02 11:25:02 +0000
committerPallavi Sontakke2015-09-02 11:25:02 +0000
commit5d0972e357b21890b402f6737760f10d22ceff7e (patch)
treef7b87338d09fe25c4cc8efb0029d097bea3cd75c
parentb1ce32739df95a898e881dc9cd9ab85ab211f5d5 (diff)
Complex update and delete related tests for Major Differences - Limitations section.
-rwxr-xr-xsrc/test/regress/expected/xl_complex_delete.out171
-rwxr-xr-xsrc/test/regress/expected/xl_complex_update.out312
-rw-r--r--src/test/regress/serial_schedule3
-rwxr-xr-xsrc/test/regress/sql/xl_complex_delete.sql93
-rwxr-xr-xsrc/test/regress/sql/xl_complex_update.sql245
5 files changed, 824 insertions, 0 deletions
diff --git a/src/test/regress/expected/xl_complex_delete.out b/src/test/regress/expected/xl_complex_delete.out
new file mode 100755
index 0000000000..12f5fa1f2a
--- /dev/null
+++ b/src/test/regress/expected/xl_complex_delete.out
@@ -0,0 +1,171 @@
+-- Some complex delete from/DELETE queries also known to have problems
+-- Check delete from with inherited target and an inherited source table
+create table xl_d_foo(f1 int, f2 int);
+create table xl_d_foo2(f3 int) inherits (xl_d_foo);
+create table xl_d_bar(f1 int, f2 int);
+create table xl_d_bar2(f3 int) inherits (xl_d_bar);
+create table xl_d_foo1(f1 int, f2 int);--non inherited or inheriting table
+insert into xl_d_foo values(1,1);
+insert into xl_d_foo values(3,3);
+insert into xl_d_foo1 values(1,1);
+insert into xl_d_foo1 values(3,3);
+insert into xl_d_foo2 values(2,2,2);
+insert into xl_d_foo2 values(3,3,3);
+insert into xl_d_bar values(1,1);
+insert into xl_d_bar values(2,2);
+insert into xl_d_bar values(3,3);
+insert into xl_d_bar values(4,4);
+insert into xl_d_bar2 values(1,1,1);
+insert into xl_d_bar2 values(2,2,2);
+insert into xl_d_bar2 values(3,3,3);
+insert into xl_d_bar2 values(4,4,4);
+create function xl_cd_nodename_from_id(integer) returns name as $$
+declare
+ n name;
+BEGIN
+ select node_name into n from pgxc_node where node_id = $1;
+ RETURN n;
+END;$$ language plpgsql;
+select xl_cd_nodename_from_id(xc_node_id), * from xl_d_foo;
+ xl_cd_nodename_from_id | f1 | f2
+------------------------+----+----
+ datanode_1 | 1 | 1
+ datanode_2 | 3 | 3
+ datanode_1 | 2 | 2
+ datanode_2 | 3 | 3
+(4 rows)
+
+select xl_cd_nodename_from_id(xc_node_id), * from only xl_d_foo;
+ xl_cd_nodename_from_id | f1 | f2
+------------------------+----+----
+ datanode_1 | 1 | 1
+ datanode_2 | 3 | 3
+(2 rows)
+
+select xl_cd_nodename_from_id(xc_node_id), * from xl_d_foo2;
+ xl_cd_nodename_from_id | f1 | f2 | f3
+------------------------+----+----+----
+ datanode_1 | 2 | 2 | 2
+ datanode_2 | 3 | 3 | 3
+(2 rows)
+
+select xl_cd_nodename_from_id(xc_node_id), * from xl_d_bar;
+ xl_cd_nodename_from_id | f1 | f2
+------------------------+----+----
+ datanode_1 | 1 | 1
+ datanode_1 | 2 | 2
+ datanode_2 | 3 | 3
+ datanode_2 | 4 | 4
+ datanode_1 | 1 | 1
+ datanode_1 | 2 | 2
+ datanode_2 | 3 | 3
+ datanode_2 | 4 | 4
+(8 rows)
+
+select xl_cd_nodename_from_id(xc_node_id), * from only xl_d_bar;
+ xl_cd_nodename_from_id | f1 | f2
+------------------------+----+----
+ datanode_1 | 1 | 1
+ datanode_1 | 2 | 2
+ datanode_2 | 3 | 3
+ datanode_2 | 4 | 4
+(4 rows)
+
+select xl_cd_nodename_from_id(xc_node_id), * from xl_d_bar2;
+ xl_cd_nodename_from_id | f1 | f2 | f3
+------------------------+----+----+----
+ datanode_1 | 1 | 1 | 1
+ datanode_1 | 2 | 2 | 2
+ datanode_2 | 3 | 3 | 3
+ datanode_2 | 4 | 4 | 4
+(4 rows)
+
+delete from xl_d_bar where f1 in (select f1 from xl_d_foo);-- fail as complex query part has parent table
+ERROR: could not plan this distributed delete
+DETAIL: correlated or complex DELETE is currently not supported in Postgres-XL.
+delete from xl_d_bar where f1 in (select f1 from only xl_d_foo);-- pass as complex query part has only parent table
+select xl_cd_nodename_from_id(xc_node_id), * from xl_d_bar;
+ xl_cd_nodename_from_id | f1 | f2
+------------------------+----+----
+ datanode_1 | 2 | 2
+ datanode_2 | 4 | 4
+ datanode_1 | 2 | 2
+ datanode_2 | 4 | 4
+(4 rows)
+
+select xl_cd_nodename_from_id(xc_node_id), * from only xl_d_bar;
+ xl_cd_nodename_from_id | f1 | f2
+------------------------+----+----
+ datanode_1 | 2 | 2
+ datanode_2 | 4 | 4
+(2 rows)
+
+delete from only xl_d_bar where f1 in (select f1 from xl_d_foo);-- fail as complex query part has parent table
+ERROR: could not plan this distributed delete
+DETAIL: correlated or complex DELETE is currently not supported in Postgres-XL.
+delete from only xl_d_bar where f1 in (select f1 from only xl_d_foo);-- pass as complex query part has only parent table
+select xl_cd_nodename_from_id(xc_node_id), * from xl_d_bar;
+ xl_cd_nodename_from_id | f1 | f2
+------------------------+----+----
+ datanode_1 | 2 | 2
+ datanode_2 | 4 | 4
+ datanode_1 | 2 | 2
+ datanode_2 | 4 | 4
+(4 rows)
+
+select xl_cd_nodename_from_id(xc_node_id), * from only xl_d_bar;
+ xl_cd_nodename_from_id | f1 | f2
+------------------------+----+----
+ datanode_1 | 2 | 2
+ datanode_2 | 4 | 4
+(2 rows)
+
+-- checking independent working of union all
+select f1 from only xl_d_foo;
+ f1
+----
+ 1
+ 3
+(2 rows)
+
+select f1+3 from only xl_d_foo;
+ ?column?
+----------
+ 4
+ 6
+(2 rows)
+
+select f1 from only xl_d_foo union all select f1+3 from only xl_d_foo;
+ f1
+----
+ 1
+ 3
+ 4
+ 6
+(4 rows)
+
+-- Check delete from with inherited target and an appendrel subquery
+-- All below cases fail as union all in complex delete from subquery is not yet supported.
+delete from xl_d_bar
+where f1 in ( select f1 from xl_d_foo union all select f1+3 from xl_d_foo );--fail
+ERROR: could not plan this distributed delete
+DETAIL: correlated or complex DELETE is currently not supported in Postgres-XL.
+delete from xl_d_bar
+where f1 in ( select f1 from only xl_d_foo union all select f1+3 from xl_d_foo );--fail
+ERROR: could not plan this distributed delete
+DETAIL: correlated or complex DELETE is currently not supported in Postgres-XL.
+delete from xl_d_bar
+where f1 in ( select f1 from only xl_d_foo union all select f1+3 from only xl_d_foo );--pass
+delete from only xl_d_bar
+where f1 in ( select f1 from only xl_d_foo union all select f1+3 from only xl_d_foo );--pass
+-- xl_d_foo1 is a non-inheriting or inherited table, still union in subquery fails
+delete from xl_d_bar
+where f1 in ( select f1 from xl_d_foo1 union all select f1+3 from xl_d_foo1 );--pass
+delete from only xl_d_bar
+where f1 in ( select f1 from xl_d_foo1 union all select f1+3 from xl_d_foo1 );--pass
+drop function xl_cd_nodename_from_id(integer);
+drop table xl_d_foo2;
+drop table xl_d_bar2;
+drop table xl_d_bar;
+drop table xl_d_foo;
+drop table xl_d_foo1;
diff --git a/src/test/regress/expected/xl_complex_update.out b/src/test/regress/expected/xl_complex_update.out
new file mode 100755
index 0000000000..e2ce2c06d2
--- /dev/null
+++ b/src/test/regress/expected/xl_complex_update.out
@@ -0,0 +1,312 @@
+-- Some complex UPDATE/DELETE queries also known to have problems
+-- Check UPDATE with inherited target and an inherited source table
+create table xl_foo(f1 int, f2 int);
+create table xl_foo2(f3 int) inherits (xl_foo);
+create table xl_bar(f1 int, f2 int);
+create table xl_bar2(f3 int) inherits (xl_bar);
+create table xl_foo1(f1 int, f2 int);--non inherited or inheriting table
+insert into xl_foo values(1,1);
+insert into xl_foo values(3,3);
+insert into xl_foo1 values(1,1);
+insert into xl_foo1 values(3,3);
+insert into xl_foo2 values(2,2,2);
+insert into xl_foo2 values(3,3,3);
+insert into xl_bar values(1,1);
+insert into xl_bar values(2,2);
+insert into xl_bar values(3,3);
+insert into xl_bar values(4,4);
+insert into xl_bar2 values(1,1,1);
+insert into xl_bar2 values(2,2,2);
+insert into xl_bar2 values(3,3,3);
+insert into xl_bar2 values(4,4,4);
+create function xl_cu_nodename_from_id(integer) returns name as $$
+declare
+ n name;
+BEGIN
+ select node_name into n from pgxc_node where node_id = $1;
+ RETURN n;
+END;$$ language plpgsql;
+select xl_cu_nodename_from_id(xc_node_id), * from xl_foo;
+ xl_cu_nodename_from_id | f1 | f2
+------------------------+----+----
+ datanode_1 | 1 | 1
+ datanode_2 | 3 | 3
+ datanode_1 | 2 | 2
+ datanode_2 | 3 | 3
+(4 rows)
+
+select xl_cu_nodename_from_id(xc_node_id), * from only xl_foo;
+ xl_cu_nodename_from_id | f1 | f2
+------------------------+----+----
+ datanode_1 | 1 | 1
+ datanode_2 | 3 | 3
+(2 rows)
+
+select xl_cu_nodename_from_id(xc_node_id), * from xl_foo2;
+ xl_cu_nodename_from_id | f1 | f2 | f3
+------------------------+----+----+----
+ datanode_1 | 2 | 2 | 2
+ datanode_2 | 3 | 3 | 3
+(2 rows)
+
+select xl_cu_nodename_from_id(xc_node_id), * from xl_bar;
+ xl_cu_nodename_from_id | f1 | f2
+------------------------+----+----
+ datanode_1 | 1 | 1
+ datanode_1 | 2 | 2
+ datanode_2 | 3 | 3
+ datanode_2 | 4 | 4
+ datanode_1 | 1 | 1
+ datanode_1 | 2 | 2
+ datanode_2 | 3 | 3
+ datanode_2 | 4 | 4
+(8 rows)
+
+select xl_cu_nodename_from_id(xc_node_id), * from only xl_bar;
+ xl_cu_nodename_from_id | f1 | f2
+------------------------+----+----
+ datanode_1 | 1 | 1
+ datanode_1 | 2 | 2
+ datanode_2 | 3 | 3
+ datanode_2 | 4 | 4
+(4 rows)
+
+select xl_cu_nodename_from_id(xc_node_id), * from xl_bar2;
+ xl_cu_nodename_from_id | f1 | f2 | f3
+------------------------+----+----+----
+ datanode_1 | 1 | 1 | 1
+ datanode_1 | 2 | 2 | 2
+ datanode_2 | 3 | 3 | 3
+ datanode_2 | 4 | 4 | 4
+(4 rows)
+
+update xl_bar set f2 = f2 + 100 where f1 in (select f1 from xl_foo);-- fail as complex query part has parent table
+ERROR: could not plan this distributed update
+DETAIL: correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
+update xl_bar set f2 = f2 + 100 where f1 in (select f1 from only xl_foo);-- pass as complex query part has only parent table
+select xl_cu_nodename_from_id(xc_node_id), * from xl_bar;
+ xl_cu_nodename_from_id | f1 | f2
+------------------------+----+-----
+ datanode_1 | 2 | 2
+ datanode_1 | 1 | 101
+ datanode_2 | 4 | 4
+ datanode_2 | 3 | 103
+ datanode_1 | 2 | 2
+ datanode_1 | 1 | 101
+ datanode_2 | 4 | 4
+ datanode_2 | 3 | 103
+(8 rows)
+
+select xl_cu_nodename_from_id(xc_node_id), * from only xl_bar;
+ xl_cu_nodename_from_id | f1 | f2
+------------------------+----+-----
+ datanode_1 | 2 | 2
+ datanode_1 | 1 | 101
+ datanode_2 | 4 | 4
+ datanode_2 | 3 | 103
+(4 rows)
+
+update only xl_bar set f2 = f2 + 100 where f1 in (select f1 from xl_foo);-- fail as complex query part has parent table
+ERROR: could not plan this distributed update
+DETAIL: correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
+update only xl_bar set f2 = f2 + 100 where f1 in (select f1 from only xl_foo);-- pass as complex query part has only parent table
+select xl_cu_nodename_from_id(xc_node_id), * from xl_bar;
+ xl_cu_nodename_from_id | f1 | f2
+------------------------+----+-----
+ datanode_1 | 2 | 2
+ datanode_1 | 1 | 201
+ datanode_2 | 4 | 4
+ datanode_2 | 3 | 203
+ datanode_1 | 2 | 2
+ datanode_1 | 1 | 101
+ datanode_2 | 4 | 4
+ datanode_2 | 3 | 103
+(8 rows)
+
+select xl_cu_nodename_from_id(xc_node_id), * from only xl_bar;
+ xl_cu_nodename_from_id | f1 | f2
+------------------------+----+-----
+ datanode_1 | 2 | 2
+ datanode_1 | 1 | 201
+ datanode_2 | 4 | 4
+ datanode_2 | 3 | 203
+(4 rows)
+
+-- checking independent working of union all
+select f1 from only xl_foo;
+ f1
+----
+ 1
+ 3
+(2 rows)
+
+select f1+3 from only xl_foo;
+ ?column?
+----------
+ 4
+ 6
+(2 rows)
+
+select f1 from only xl_foo union all select f1+3 from only xl_foo;
+ f1
+----
+ 1
+ 3
+ 4
+ 6
+(4 rows)
+
+-- Check UPDATE with inherited target and an appendrel subquery
+-- All below cases fail as union all in complex update subquery is not yet supported.
+update xl_bar set f2 = f2 + 100
+from
+ ( select f1 from xl_foo union all select f1+3 from xl_foo ) ss
+where xl_bar.f1 = ss.f1;--fail
+ERROR: could not plan this distributed update
+DETAIL: correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
+update xl_bar set f2 = f2 + 100
+from
+ ( select f1 from only xl_foo union all select f1+3 from xl_foo ) ss
+where xl_bar.f1 = ss.f1;--fail
+ERROR: could not plan this distributed update
+DETAIL: correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
+update xl_bar set f2 = f2 + 100
+from
+ ( select f1 from only xl_foo union all select f1+3 from only xl_foo ) ss
+where xl_bar.f1 = ss.f1;--pass
+update only xl_bar set f2 = f2 + 100
+from
+ ( select f1 from only xl_foo union all select f1+3 from only xl_foo ) ss
+where xl_bar.f1 = ss.f1;--pass
+-- xl_foo1 is a non-inheriting or inherited table, still union in subquery fails
+update xl_bar set f2 = f2 + 100
+from
+ ( select f1 from xl_foo1 union all select f1+3 from xl_foo1 ) ss
+where xl_bar.f1 = ss.f1;--pass
+update only xl_bar set f2 = f2 + 100
+from
+ ( select f1 from xl_foo1 union all select f1+3 from xl_foo1 ) ss
+where xl_bar.f1 = ss.f1;--pass
+--FROM is supported but only when the join is on the distribution column
+-- distributed by default by HASH(tmpunique1)
+CREATE TABLE xl_tmp (
+tmpunique1 int4,
+stringu1 name,
+stringu2 name,
+string4 name
+);
+-- distributed by default by HASH(unique1)
+CREATE TABLE xl_onek (
+unique1 int4,
+unique2 int4,
+two int4,
+four int4,
+stringu1 name,
+stringu2 name,
+string4 name
+);
+--Explicit join on distribution columns of table with similar distribution type is supported.
+UPDATE xl_tmp
+ SET stringu1 = xl_onek.stringu1
+ FROM xl_onek
+ WHERE xl_onek.unique1 = xl_tmp.tmpunique1;--pass as join is on distribution column
+UPDATE xl_tmp
+ SET stringu1 = xl_onek.stringu1
+ FROM xl_onek
+ WHERE xl_onek.stringu1 = xl_tmp.stringu1;--fail as join is on normal non-distribution column
+ERROR: could not plan this distributed update
+DETAIL: correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
+--With explicit join, other equation clauses supported:
+ -- on distribution column of from-list table
+ -- on non-distribution column of from-list table
+ -- on distribution column of target table
+ -- on non-distribution column of target table
+ -- However currently ‘=’ for integer is not supported. (bug)
+ -- on distribution column of from-list table
+UPDATE xl_tmp
+ SET stringu1 = xl_onek.stringu1
+ FROM xl_onek
+ WHERE xl_onek.unique1 <= 3 and
+ xl_onek.unique1 = xl_tmp.tmpunique1;
+ -- on non-distribution column of from-list table
+UPDATE xl_tmp
+ SET stringu1 = xl_onek.stringu1
+ FROM xl_onek
+ WHERE xl_onek.stringu1 = 'test-string' and
+ xl_onek.unique1 = xl_tmp.tmpunique1;
+ -- on distribution column of target table
+UPDATE xl_tmp
+ SET stringu1 = xl_onek.stringu1
+ FROM xl_onek
+ WHERE xl_tmp.tmpunique1 <= 3 and
+ xl_onek.unique1 = xl_tmp.tmpunique1;
+ -- on non-distribution column of target table
+UPDATE xl_tmp
+ SET stringu1 = xl_onek.stringu1
+ FROM xl_onek
+ WHERE xl_tmp.stringu1 = 'test-string' and
+ xl_onek.unique1 = xl_tmp.tmpunique1;
+ -- However currently ‘=’ for integer is not supported. (bug)
+UPDATE xl_tmp
+ SET stringu1 = xl_onek.stringu1
+ FROM xl_onek
+ WHERE xl_onek.unique1 = 3 and
+ xl_onek.unique1 = xl_tmp.tmpunique1;
+UPDATE xl_tmp
+ SET stringu1 = xl_onek.stringu1
+ FROM xl_onek
+ WHERE xl_tmp.tmpunique1 = 3 and
+ xl_onek.unique1 = xl_tmp.tmpunique1;
+--Implicit / cartesian join with explicit equation clause not supported:
+ -- on distribution columns of from-list table
+ -- on non-distribution column of from-list table
+ -- on distribution column of target table
+ -- on non-distribution column of target table
+ -- on distribution columns of from-list table
+UPDATE xl_tmp
+ SET stringu1 = xl_onek.stringu1
+ FROM xl_onek
+ WHERE xl_onek.unique1 = 3;
+ERROR: could not plan this distributed update
+DETAIL: correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
+UPDATE xl_tmp
+ SET stringu1 = xl_onek.stringu1
+ FROM xl_onek
+ WHERE xl_onek.unique1 <= 3;
+ERROR: could not plan this distributed update
+DETAIL: correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
+ -- on non-distribution column of from-list table
+UPDATE xl_tmp
+ SET stringu1 = xl_onek.stringu1
+ FROM xl_onek
+ WHERE xl_onek.stringu1 = 'test-string';
+ERROR: could not plan this distributed update
+DETAIL: correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
+ -- on distribution column of target table
+UPDATE xl_tmp
+ SET stringu1 = xl_onek.stringu1
+ FROM xl_onek
+ WHERE xl_tmp.tmpunique1 = 3;
+ERROR: could not plan this distributed update
+DETAIL: correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
+UPDATE xl_tmp
+ SET stringu1 = xl_onek.stringu1
+ FROM xl_onek
+ WHERE xl_tmp.tmpunique1 <= 3;
+ERROR: could not plan this distributed update
+DETAIL: correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
+ -- on non-distribution column of target table
+UPDATE xl_tmp
+ SET stringu1 = xl_onek.stringu1
+ FROM xl_onek
+ WHERE xl_tmp.stringu1 = 'test-string';
+ERROR: could not plan this distributed update
+DETAIL: correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
+drop function xl_cu_nodename_from_id(integer);
+drop table xl_foo2;
+drop table xl_bar2;
+drop table xl_bar;
+drop table xl_foo;
+drop table xl_foo1;
+drop table xl_tmp;
+drop table xl_onek;
diff --git a/src/test/regress/serial_schedule b/src/test/regress/serial_schedule
index 12dd2d5f77..c80e4b549e 100644
--- a/src/test/regress/serial_schedule
+++ b/src/test/regress/serial_schedule
@@ -185,3 +185,6 @@ test: xl_plan_pushdown
test: xl_functions
test: xl_limitations
test: xl_user_defined_functions
+test: xl_complex_update
+test: xl_complex_delete
+
diff --git a/src/test/regress/sql/xl_complex_delete.sql b/src/test/regress/sql/xl_complex_delete.sql
new file mode 100755
index 0000000000..ba5a6ddc70
--- /dev/null
+++ b/src/test/regress/sql/xl_complex_delete.sql
@@ -0,0 +1,93 @@
+-- Some complex delete from/DELETE queries also known to have problems
+-- Check delete from with inherited target and an inherited source table
+create table xl_d_foo(f1 int, f2 int);
+create table xl_d_foo2(f3 int) inherits (xl_d_foo);
+create table xl_d_bar(f1 int, f2 int);
+create table xl_d_bar2(f3 int) inherits (xl_d_bar);
+create table xl_d_foo1(f1 int, f2 int);--non inherited or inheriting table
+
+insert into xl_d_foo values(1,1);
+insert into xl_d_foo values(3,3);
+insert into xl_d_foo1 values(1,1);
+insert into xl_d_foo1 values(3,3);
+insert into xl_d_foo2 values(2,2,2);
+insert into xl_d_foo2 values(3,3,3);
+insert into xl_d_bar values(1,1);
+insert into xl_d_bar values(2,2);
+insert into xl_d_bar values(3,3);
+insert into xl_d_bar values(4,4);
+insert into xl_d_bar2 values(1,1,1);
+insert into xl_d_bar2 values(2,2,2);
+insert into xl_d_bar2 values(3,3,3);
+insert into xl_d_bar2 values(4,4,4);
+
+create function xl_cd_nodename_from_id(integer) returns name as $$
+declare
+ n name;
+BEGIN
+ select node_name into n from pgxc_node where node_id = $1;
+ RETURN n;
+END;$$ language plpgsql;
+
+select xl_cd_nodename_from_id(xc_node_id), * from xl_d_foo;
+
+select xl_cd_nodename_from_id(xc_node_id), * from only xl_d_foo;
+
+select xl_cd_nodename_from_id(xc_node_id), * from xl_d_foo2;
+
+select xl_cd_nodename_from_id(xc_node_id), * from xl_d_bar;
+
+select xl_cd_nodename_from_id(xc_node_id), * from only xl_d_bar;
+
+select xl_cd_nodename_from_id(xc_node_id), * from xl_d_bar2;
+
+delete from xl_d_bar where f1 in (select f1 from xl_d_foo);-- fail as complex query part has parent table
+
+delete from xl_d_bar where f1 in (select f1 from only xl_d_foo);-- pass as complex query part has only parent table
+
+select xl_cd_nodename_from_id(xc_node_id), * from xl_d_bar;
+
+select xl_cd_nodename_from_id(xc_node_id), * from only xl_d_bar;
+
+delete from only xl_d_bar where f1 in (select f1 from xl_d_foo);-- fail as complex query part has parent table
+
+delete from only xl_d_bar where f1 in (select f1 from only xl_d_foo);-- pass as complex query part has only parent table
+
+select xl_cd_nodename_from_id(xc_node_id), * from xl_d_bar;
+
+select xl_cd_nodename_from_id(xc_node_id), * from only xl_d_bar;
+
+-- checking independent working of union all
+select f1 from only xl_d_foo;
+
+select f1+3 from only xl_d_foo;
+
+select f1 from only xl_d_foo union all select f1+3 from only xl_d_foo;
+
+-- Check delete from with inherited target and an appendrel subquery
+-- All below cases fail as union all in complex delete from subquery is not yet supported.
+delete from xl_d_bar
+where f1 in ( select f1 from xl_d_foo union all select f1+3 from xl_d_foo );--fail
+
+delete from xl_d_bar
+where f1 in ( select f1 from only xl_d_foo union all select f1+3 from xl_d_foo );--fail
+
+delete from xl_d_bar
+where f1 in ( select f1 from only xl_d_foo union all select f1+3 from only xl_d_foo );--pass
+
+delete from only xl_d_bar
+where f1 in ( select f1 from only xl_d_foo union all select f1+3 from only xl_d_foo );--pass
+
+-- xl_d_foo1 is a non-inheriting or inherited table, still union in subquery fails
+delete from xl_d_bar
+where f1 in ( select f1 from xl_d_foo1 union all select f1+3 from xl_d_foo1 );--pass
+
+delete from only xl_d_bar
+where f1 in ( select f1 from xl_d_foo1 union all select f1+3 from xl_d_foo1 );--pass
+
+drop function xl_cd_nodename_from_id(integer);
+drop table xl_d_foo2;
+drop table xl_d_bar2;
+drop table xl_d_bar;
+drop table xl_d_foo;
+drop table xl_d_foo1;
diff --git a/src/test/regress/sql/xl_complex_update.sql b/src/test/regress/sql/xl_complex_update.sql
new file mode 100755
index 0000000000..2acccfbbb0
--- /dev/null
+++ b/src/test/regress/sql/xl_complex_update.sql
@@ -0,0 +1,245 @@
+-- Some complex UPDATE/DELETE queries also known to have problems
+-- Check UPDATE with inherited target and an inherited source table
+create table xl_foo(f1 int, f2 int);
+create table xl_foo2(f3 int) inherits (xl_foo);
+create table xl_bar(f1 int, f2 int);
+create table xl_bar2(f3 int) inherits (xl_bar);
+create table xl_foo1(f1 int, f2 int);--non inherited or inheriting table
+
+insert into xl_foo values(1,1);
+insert into xl_foo values(3,3);
+insert into xl_foo1 values(1,1);
+insert into xl_foo1 values(3,3);
+insert into xl_foo2 values(2,2,2);
+insert into xl_foo2 values(3,3,3);
+insert into xl_bar values(1,1);
+insert into xl_bar values(2,2);
+insert into xl_bar values(3,3);
+insert into xl_bar values(4,4);
+insert into xl_bar2 values(1,1,1);
+insert into xl_bar2 values(2,2,2);
+insert into xl_bar2 values(3,3,3);
+insert into xl_bar2 values(4,4,4);
+
+create function xl_cu_nodename_from_id(integer) returns name as $$
+declare
+ n name;
+BEGIN
+ select node_name into n from pgxc_node where node_id = $1;
+ RETURN n;
+END;$$ language plpgsql;
+
+select xl_cu_nodename_from_id(xc_node_id), * from xl_foo;
+
+select xl_cu_nodename_from_id(xc_node_id), * from only xl_foo;
+
+select xl_cu_nodename_from_id(xc_node_id), * from xl_foo2;
+
+select xl_cu_nodename_from_id(xc_node_id), * from xl_bar;
+
+select xl_cu_nodename_from_id(xc_node_id), * from only xl_bar;
+
+select xl_cu_nodename_from_id(xc_node_id), * from xl_bar2;
+
+update xl_bar set f2 = f2 + 100 where f1 in (select f1 from xl_foo);-- fail as complex query part has parent table
+
+update xl_bar set f2 = f2 + 100 where f1 in (select f1 from only xl_foo);-- pass as complex query part has only parent table
+
+select xl_cu_nodename_from_id(xc_node_id), * from xl_bar;
+
+select xl_cu_nodename_from_id(xc_node_id), * from only xl_bar;
+
+update only xl_bar set f2 = f2 + 100 where f1 in (select f1 from xl_foo);-- fail as complex query part has parent table
+
+update only xl_bar set f2 = f2 + 100 where f1 in (select f1 from only xl_foo);-- pass as complex query part has only parent table
+
+select xl_cu_nodename_from_id(xc_node_id), * from xl_bar;
+
+select xl_cu_nodename_from_id(xc_node_id), * from only xl_bar;
+
+-- checking independent working of union all
+select f1 from only xl_foo;
+
+select f1+3 from only xl_foo;
+
+select f1 from only xl_foo union all select f1+3 from only xl_foo;
+
+-- Check UPDATE with inherited target and an appendrel subquery
+-- All below cases fail as union all in complex update subquery is not yet supported.
+update xl_bar set f2 = f2 + 100
+from
+ ( select f1 from xl_foo union all select f1+3 from xl_foo ) ss
+where xl_bar.f1 = ss.f1;--fail
+
+update xl_bar set f2 = f2 + 100
+from
+ ( select f1 from only xl_foo union all select f1+3 from xl_foo ) ss
+where xl_bar.f1 = ss.f1;--fail
+
+update xl_bar set f2 = f2 + 100
+from
+ ( select f1 from only xl_foo union all select f1+3 from only xl_foo ) ss
+where xl_bar.f1 = ss.f1;--pass
+
+update only xl_bar set f2 = f2 + 100
+from
+ ( select f1 from only xl_foo union all select f1+3 from only xl_foo ) ss
+where xl_bar.f1 = ss.f1;--pass
+
+-- xl_foo1 is a non-inheriting or inherited table, still union in subquery fails
+update xl_bar set f2 = f2 + 100
+from
+ ( select f1 from xl_foo1 union all select f1+3 from xl_foo1 ) ss
+where xl_bar.f1 = ss.f1;--pass
+
+update only xl_bar set f2 = f2 + 100
+from
+ ( select f1 from xl_foo1 union all select f1+3 from xl_foo1 ) ss
+where xl_bar.f1 = ss.f1;--pass
+
+--FROM is supported but only when the join is on the distribution column
+-- distributed by default by HASH(tmpunique1)
+CREATE TABLE xl_tmp (
+tmpunique1 int4,
+stringu1 name,
+stringu2 name,
+string4 name
+);
+-- distributed by default by HASH(unique1)
+CREATE TABLE xl_onek (
+unique1 int4,
+unique2 int4,
+two int4,
+four int4,
+stringu1 name,
+stringu2 name,
+string4 name
+);
+
+
+--Explicit join on distribution columns of table with similar distribution type is supported.
+
+UPDATE xl_tmp
+ SET stringu1 = xl_onek.stringu1
+ FROM xl_onek
+ WHERE xl_onek.unique1 = xl_tmp.tmpunique1;--pass as join is on distribution column
+
+UPDATE xl_tmp
+ SET stringu1 = xl_onek.stringu1
+ FROM xl_onek
+ WHERE xl_onek.stringu1 = xl_tmp.stringu1;--fail as join is on normal non-distribution column
+
+
+--With explicit join, other equation clauses supported:
+ -- on distribution column of from-list table
+ -- on non-distribution column of from-list table
+ -- on distribution column of target table
+ -- on non-distribution column of target table
+ -- However currently ‘=’ for integer is not supported. (bug)
+
+ -- on distribution column of from-list table
+
+
+UPDATE xl_tmp
+ SET stringu1 = xl_onek.stringu1
+ FROM xl_onek
+ WHERE xl_onek.unique1 <= 3 and
+ xl_onek.unique1 = xl_tmp.tmpunique1;
+
+
+ -- on non-distribution column of from-list table
+UPDATE xl_tmp
+ SET stringu1 = xl_onek.stringu1
+ FROM xl_onek
+ WHERE xl_onek.stringu1 = 'test-string' and
+ xl_onek.unique1 = xl_tmp.tmpunique1;
+
+
+ -- on distribution column of target table
+
+
+UPDATE xl_tmp
+ SET stringu1 = xl_onek.stringu1
+ FROM xl_onek
+ WHERE xl_tmp.tmpunique1 <= 3 and
+ xl_onek.unique1 = xl_tmp.tmpunique1;
+
+
+ -- on non-distribution column of target table
+
+UPDATE xl_tmp
+ SET stringu1 = xl_onek.stringu1
+ FROM xl_onek
+ WHERE xl_tmp.stringu1 = 'test-string' and
+ xl_onek.unique1 = xl_tmp.tmpunique1;
+
+ -- However currently ‘=’ for integer is not supported. (bug)
+
+UPDATE xl_tmp
+ SET stringu1 = xl_onek.stringu1
+ FROM xl_onek
+ WHERE xl_onek.unique1 = 3 and
+ xl_onek.unique1 = xl_tmp.tmpunique1;
+
+UPDATE xl_tmp
+ SET stringu1 = xl_onek.stringu1
+ FROM xl_onek
+ WHERE xl_tmp.tmpunique1 = 3 and
+ xl_onek.unique1 = xl_tmp.tmpunique1;
+
+--Implicit / cartesian join with explicit equation clause not supported:
+ -- on distribution columns of from-list table
+ -- on non-distribution column of from-list table
+ -- on distribution column of target table
+ -- on non-distribution column of target table
+
+ -- on distribution columns of from-list table
+UPDATE xl_tmp
+ SET stringu1 = xl_onek.stringu1
+ FROM xl_onek
+ WHERE xl_onek.unique1 = 3;
+
+
+UPDATE xl_tmp
+ SET stringu1 = xl_onek.stringu1
+ FROM xl_onek
+ WHERE xl_onek.unique1 <= 3;
+
+ -- on non-distribution column of from-list table
+
+
+UPDATE xl_tmp
+ SET stringu1 = xl_onek.stringu1
+ FROM xl_onek
+ WHERE xl_onek.stringu1 = 'test-string';
+
+ -- on distribution column of target table
+
+
+UPDATE xl_tmp
+ SET stringu1 = xl_onek.stringu1
+ FROM xl_onek
+ WHERE xl_tmp.tmpunique1 = 3;
+
+
+UPDATE xl_tmp
+ SET stringu1 = xl_onek.stringu1
+ FROM xl_onek
+ WHERE xl_tmp.tmpunique1 <= 3;
+
+ -- on non-distribution column of target table
+
+UPDATE xl_tmp
+ SET stringu1 = xl_onek.stringu1
+ FROM xl_onek
+ WHERE xl_tmp.stringu1 = 'test-string';
+
+
+drop function xl_cu_nodename_from_id(integer);
+drop table xl_foo2;
+drop table xl_bar2;
+drop table xl_bar;
+drop table xl_foo;
+drop table xl_foo1;
+drop table xl_tmp;
+drop table xl_onek;