\pset null _null_

\i test/sql/pg11.sql

SET client_min_messages = warning;
SET ROLE postgres;

create table tab_generated12 (
       a integer generated by default as identity,
       b integer generated always as identity,
       c integer generated always as (a+b) stored,
       d integer default 42,
       e serial,
       f integer
);

-- select * from ddlx_describe('tab_generated12'::regclass) d;

\pset format unaligned
select ddlx_script('tab_generated12');
do $$ begin execute ddlx_script('tab_generated12'::regclass,'{drop,nowrap}'); end $$;

create table cons1 (id serial primary key,x int, label text generated always as ('a label') stored);
create table cons2 (id serial primary key,x int, label text default 'a label');
alter table cons1 add foreign key (x) references cons2;
alter table cons2 add foreign key (x) references cons1;

do $$ begin execute ddlx_script('cons1'::regclass,'{drop,nowrap}'); end $$;
do $$ begin execute ddlx_script('cons2'::regclass,'{drop,nowrap}'); end $$;

-- check rebuild of partitioned tables
SET client_min_messages = notice;
\pset format aligned
\d 

select rebuild(i.name::regclass), i.sql_kind, i.sql_identifier 
  from pg_class c, ddlx_identify(c.oid) i 
 where relnamespace='public'::regnamespace
 order by c.oid;

select sql_kind,sql_identifier
  from ddlx_get_dependants('customers'::regclass),ddlx_identify(objid);

\d 
\pset format unaligned

