## create the database
psql <<EOF
drop table a;
create table a (id int primary key,c1 text, c2 int);

CREATE OR REPLACE FUNCTION a_f(c1_in text, c2 integer DEFAULT 60)
 RETURNS void
LANGUAGE sql
BEGIN ATOMIC
 INSERT INTO a (c1, c2)
   VALUES (a_f.c1_in, a_f.c2) ON CONFLICT ON CONSTRAINT a_pkey DO UPDATE SET c2 = excluded.c2;
 END;
EOF

## dump the database
pg_dump -Fc -b -v -f /tmp/a.dump

## drop the table to repare for a pg_restore
psql <<EOF
drop table a cascade;
EOF

## pg_restore fails as the dependency is not yet created
pg_restore -d postgres /tmp/a.dump
