-- a child matching parent
create table child1 partition of parent for values in ('AAA');
-- a child with a dropped column
-create table child2 (x int, a text, b int);
+create table child2 (a text, b int, x int);
alter table child2 drop column x;
alter table parent attach partition child2 for values in ('BBB');
-- a child with a different column order
-create table child3 (b int, a text);
+-- XXX XL does not support child with different column order, so change that,
+-- though it probably defeats the purpose of the test
+create table child3 (a text, b int);
alter table parent attach partition child3 for values in ('CCC');
create trigger parent_insert_trig
after insert on parent referencing new table as new_table
-- insert directly into children sees respective child-format tuples
insert into child1 values ('AAA', 42);
insert into child2 values ('BBB', 42);
-insert into child3 values (42, 'CCC');
+insert into child3 (b, a) values (42, 'CCC');
-- update via parent sees parent-format tuples
update parent set b = b + 1;
-- delete via parent sees parent-format tuples
ERROR: Postgres-XL does not support TRIGGER yet
DETAIL: The feature is not currently supported
-- but now we're not allowed to reattach it
+-- XXX This does not fail in XL because trigger creation itself fails
alter table parent attach partition child for values in ('AAA');
-- drop the trigger, and now we're allowed to attach it again
drop trigger child_row_trig on child;
ERROR: trigger "child_row_trig" for table "child" does not exist
+-- XXX and this fails because the previous attach worked ok
alter table parent attach partition child for values in ('AAA');
+ERROR: "child" is already a partition
drop table child, parent;
--
-- Verify behavior of statement triggers on (non-partition)
-- a child matching parent
create table child1 () inherits (parent);
-- a child with a different column order
+-- XXX this fails in XL because we don't allow different column ordering
create table child2 (b int, a text);
alter table child2 inherit parent;
+ERROR: table "child2" contains column "a" at position 2, but parent "parent" has it at position 1
+DETAIL: Postgres-XL requires attribute positions to match
+HINT: Check for column ordering and dropped columns, if any
-- a child with an extra column
create table child3 (c text) inherits (parent);
create trigger parent_insert_trig
create table child1 partition of parent for values in ('AAA');
-- a child with a dropped column
-create table child2 (x int, a text, b int);
+create table child2 (a text, b int, x int);
alter table child2 drop column x;
alter table parent attach partition child2 for values in ('BBB');
-- a child with a different column order
-create table child3 (b int, a text);
+-- XXX XL does not support child with different column order, so change that,
+-- though it probably defeats the purpose of the test
+create table child3 (a text, b int);
alter table parent attach partition child3 for values in ('CCC');
create trigger parent_insert_trig
-- insert directly into children sees respective child-format tuples
insert into child1 values ('AAA', 42);
insert into child2 values ('BBB', 42);
-insert into child3 values (42, 'CCC');
+insert into child3 (b, a) values (42, 'CCC');
-- update via parent sees parent-format tuples
update parent set b = b + 1;
for each row execute procedure dump_insert();
-- but now we're not allowed to reattach it
+-- XXX This does not fail in XL because trigger creation itself fails
alter table parent attach partition child for values in ('AAA');
-- drop the trigger, and now we're allowed to attach it again
drop trigger child_row_trig on child;
+
+-- XXX and this fails because the previous attach worked ok
alter table parent attach partition child for values in ('AAA');
drop table child, parent;
create table child1 () inherits (parent);
-- a child with a different column order
+-- XXX this fails in XL because we don't allow different column ordering
create table child2 (b int, a text);
alter table child2 inherit parent;