text: --
  -- IF EXISTS tests
  --
  
  -- table (will be really dropped at the end)
  
  --DDL_STATEMENT_BEGIN--
  DROP TABLE test_exists;
  --DDL_STATEMENT_END--
  
  --DDL_STATEMENT_BEGIN--
  DROP TABLE IF EXISTS test_exists;
  --DDL_STATEMENT_END--
  
  --DDL_STATEMENT_BEGIN--
  CREATE TABLE test_exists (a int, b text);
  --DDL_STATEMENT_END--
  
  -- view
  
  --DDL_STATEMENT_BEGIN--
  DROP VIEW test_view_exists;
  --DDL_STATEMENT_END--
  
  --DDL_STATEMENT_BEGIN--
  DROP VIEW IF EXISTS test_view_exists;
  --DDL_STATEMENT_END--
  
  --DDL_STATEMENT_BEGIN--
  CREATE VIEW test_view_exists AS select * from test_exists;
  --DDL_STATEMENT_END--
  
  --DDL_STATEMENT_BEGIN--
  DROP VIEW IF EXISTS test_view_exists;
  --DDL_STATEMENT_END--
  
  --DDL_STATEMENT_BEGIN--
  DROP VIEW test_view_exists;
  --DDL_STATEMENT_END--
  
  -- index
  
  --DDL_STATEMENT_BEGIN--
  DROP INDEX test_index_exists;
  --DDL_STATEMENT_END--
  
  --DDL_STATEMENT_BEGIN--
  DROP INDEX IF EXISTS test_index_exists;
  --DDL_STATEMENT_END--
  
  --DDL_STATEMENT_BEGIN--
  CREATE INDEX test_index_exists on test_exists(a);
  --DDL_STATEMENT_END--
  
  --DDL_STATEMENT_BEGIN--
  DROP INDEX IF EXISTS test_index_exists;
  --DDL_STATEMENT_END--
  
  --DDL_STATEMENT_BEGIN--
  DROP INDEX test_index_exists;
  --DDL_STATEMENT_END--
  
  -- sequence
  
  --DDL_STATEMENT_BEGIN--
  DROP SEQUENCE test_sequence_exists;
  --DDL_STATEMENT_END--
  
  --DDL_STATEMENT_BEGIN--
  DROP SEQUENCE IF EXISTS test_sequence_exists;
  --DDL_STATEMENT_END--
  
  --DDL_STATEMENT_BEGIN--
  CREATE SEQUENCE test_sequence_exists;
  --DDL_STATEMENT_END--
  
  --DDL_STATEMENT_BEGIN--
  DROP SEQUENCE IF EXISTS test_sequence_exists;
  --DDL_STATEMENT_END--
  
  --DDL_STATEMENT_BEGIN--
  DROP SEQUENCE test_sequence_exists;
  --DDL_STATEMENT_END--
  
  -- schema
  
  --DDL_STATEMENT_BEGIN--
  DROP SCHEMA test_schema_exists;
  --DDL_STATEMENT_END--
  
  --DDL_STATEMENT_BEGIN--
  DROP SCHEMA IF EXISTS test_schema_exists;
  --DDL_STATEMENT_END--
  
  --DDL_STATEMENT_BEGIN--
  CREATE SCHEMA test_schema_exists;
  --DDL_STATEMENT_END--
  
  --DDL_STATEMENT_BEGIN--
  DROP SCHEMA IF EXISTS test_schema_exists;
  --DDL_STATEMENT_END--
  
  --DDL_STATEMENT_BEGIN--
  DROP SCHEMA test_schema_exists;
  --DDL_STATEMENT_END--
  
  -- type
  
  --DDL_STATEMENT_BEGIN--
  DROP TYPE test_type_exists;
  --DDL_STATEMENT_END--
  
  --DDL_STATEMENT_BEGIN--
  DROP TYPE IF EXISTS test_type_exists;
  --DDL_STATEMENT_END--
  
  --DDL_STATEMENT_BEGIN--
  CREATE type test_type_exists as (a int, b text);
  --DDL_STATEMENT_END--
  
  --DDL_STATEMENT_BEGIN--
  DROP TYPE IF EXISTS test_type_exists;
  --DDL_STATEMENT_END--
  
  --DDL_STATEMENT_BEGIN--
  DROP TYPE test_type_exists;
  --DDL_STATEMENT_END--
  
  ---
  --- role/user/group
  ---
  
  --DDL_STATEMENT_BEGIN--
  CREATE USER regress_test_u1;
  --DDL_STATEMENT_END--
  
  --DDL_STATEMENT_BEGIN--
  CREATE ROLE regress_test_r1;
  --DDL_STATEMENT_END--
  
  --DDL_STATEMENT_BEGIN--
  CREATE GROUP regress_test_g1;
  --DDL_STATEMENT_END--
  
  --DDL_STATEMENT_BEGIN--
  DROP USER regress_test_u2;
  --DDL_STATEMENT_END--
  
  --DDL_STATEMENT_BEGIN--
  DROP USER IF EXISTS regress_test_u1, regress_test_u2;
  --DDL_STATEMENT_END--
  
  --DDL_STATEMENT_BEGIN--
  DROP USER regress_test_u1;
  --DDL_STATEMENT_END--
  
  --DDL_STATEMENT_BEGIN--
  DROP ROLE regress_test_r2;
  --DDL_STATEMENT_END--
  
  --DDL_STATEMENT_BEGIN--
  DROP ROLE IF EXISTS regress_test_r1, regress_test_r2;
  --DDL_STATEMENT_END--
  
  --DDL_STATEMENT_BEGIN--
  DROP ROLE regress_test_r1;
  --DDL_STATEMENT_END--
  
  --DDL_STATEMENT_BEGIN--
  DROP GROUP regress_test_g2;
  --DDL_STATEMENT_END--
  
  --DDL_STATEMENT_BEGIN--
  DROP GROUP IF EXISTS regress_test_g1, regress_test_g2;
  --DDL_STATEMENT_END--
  
  --DDL_STATEMENT_BEGIN--
  DROP GROUP regress_test_g1;
  --DDL_STATEMENT_END--
  
  --DDL_STATEMENT_BEGIN--
  -- collation
  DROP COLLATION IF EXISTS test_collation_exists;
  --DDL_STATEMENT_END--
  
  --DDL_STATEMENT_BEGIN--
  -- conversion
  DROP CONVERSION test_conversion_exists;
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  DROP CONVERSION IF EXISTS test_conversion_exists;
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  CREATE CONVERSION test_conversion_exists
      FOR 'LATIN1' TO 'UTF8' FROM iso8859_1_to_utf8;
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  DROP CONVERSION test_conversion_exists;
  --DDL_STATEMENT_END--
  
  -- text search parser
  --DDL_STATEMENT_BEGIN--
  DROP TEXT SEARCH PARSER test_tsparser_exists;
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  DROP TEXT SEARCH PARSER IF EXISTS test_tsparser_exists;
  --DDL_STATEMENT_END--
  
  -- text search dictionary
  --DDL_STATEMENT_BEGIN--
  DROP TEXT SEARCH DICTIONARY test_tsdict_exists;
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  DROP TEXT SEARCH DICTIONARY IF EXISTS test_tsdict_exists;
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  CREATE TEXT SEARCH DICTIONARY test_tsdict_exists (
          Template=ispell,
          DictFile=ispell_sample,
          AffFile=ispell_sample
  );
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  DROP TEXT SEARCH DICTIONARY test_tsdict_exists;
  --DDL_STATEMENT_END--
  
  -- test search template
  --DDL_STATEMENT_BEGIN--
  DROP TEXT SEARCH TEMPLATE test_tstemplate_exists;
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  DROP TEXT SEARCH TEMPLATE IF EXISTS test_tstemplate_exists;
  --DDL_STATEMENT_END--
  
  -- text search configuration
  --DDL_STATEMENT_BEGIN--
  DROP TEXT SEARCH CONFIGURATION test_tsconfig_exists;
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  DROP TEXT SEARCH CONFIGURATION IF EXISTS test_tsconfig_exists;
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  CREATE TEXT SEARCH CONFIGURATION test_tsconfig_exists (COPY=english);
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  DROP TEXT SEARCH CONFIGURATION test_tsconfig_exists;
  --DDL_STATEMENT_END--
  
  -- extension
  --DDL_STATEMENT_BEGIN--
  DROP EXTENSION test_extension_exists;
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  DROP EXTENSION IF EXISTS test_extension_exists;
  --DDL_STATEMENT_END--
  
  -- functions
  --DDL_STATEMENT_BEGIN--
  DROP FUNCTION test_function_exists();
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  DROP FUNCTION IF EXISTS test_function_exists();
  --DDL_STATEMENT_END--
  
  --DDL_STATEMENT_BEGIN--
  DROP FUNCTION test_function_exists(int, text, int[]);
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  DROP FUNCTION IF EXISTS test_function_exists(int, text, int[]);
  --DDL_STATEMENT_END--
  
  -- aggregate
  --DDL_STATEMENT_BEGIN--
  DROP AGGREGATE test_aggregate_exists(*);
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  DROP AGGREGATE IF EXISTS test_aggregate_exists(*);
  --DDL_STATEMENT_END--
  
  --DDL_STATEMENT_BEGIN--
  DROP AGGREGATE test_aggregate_exists(int);
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  DROP AGGREGATE IF EXISTS test_aggregate_exists(int);
  --DDL_STATEMENT_END--
  
  -- operator
  --DDL_STATEMENT_BEGIN--
  DROP OPERATOR @#@ (int, int);
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  DROP OPERATOR IF EXISTS @#@ (int, int);
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  CREATE OPERATOR @#@
          (leftarg = int8, rightarg = int8, procedure = int8xor);
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  DROP OPERATOR @#@ (int8, int8);
  --DDL_STATEMENT_END--
  
  -- language
  --DDL_STATEMENT_BEGIN--
  DROP LANGUAGE test_language_exists;
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  DROP LANGUAGE IF EXISTS test_language_exists;
  --DDL_STATEMENT_END--
  
  -- cast
  --DDL_STATEMENT_BEGIN--
  DROP CAST (text AS text);
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  DROP CAST IF EXISTS (text AS text);
  --DDL_STATEMENT_END--
  
  -- foreign data wrapper
  --DDL_STATEMENT_BEGIN--
  DROP FOREIGN DATA WRAPPER test_fdw_exists;
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  DROP FOREIGN DATA WRAPPER IF EXISTS test_fdw_exists;
  --DDL_STATEMENT_END--
  
  -- foreign server
  --DDL_STATEMENT_BEGIN--
  DROP SERVER test_server_exists;
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  DROP SERVER IF EXISTS test_server_exists;
  --DDL_STATEMENT_END--
  
  -- operator class
  --DDL_STATEMENT_BEGIN--
  DROP OPERATOR CLASS test_operator_class USING btree;
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  DROP OPERATOR CLASS IF EXISTS test_operator_class USING btree;
  --DDL_STATEMENT_END--
  
  --DDL_STATEMENT_BEGIN--
  DROP OPERATOR CLASS test_operator_class USING no_such_am;
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  DROP OPERATOR CLASS IF EXISTS test_operator_class USING no_such_am;
  --DDL_STATEMENT_END--
  
  -- operator family
  --DDL_STATEMENT_BEGIN--
  DROP OPERATOR FAMILY test_operator_family USING btree;
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  DROP OPERATOR FAMILY IF EXISTS test_operator_family USING btree;
  --DDL_STATEMENT_END--
  
  --DDL_STATEMENT_BEGIN--
  DROP OPERATOR FAMILY test_operator_family USING no_such_am;
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  DROP OPERATOR FAMILY IF EXISTS test_operator_family USING no_such_am;
  --DDL_STATEMENT_END--
  
  -- access method
  --DDL_STATEMENT_BEGIN--
  DROP ACCESS METHOD no_such_am;
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  DROP ACCESS METHOD IF EXISTS no_such_am;
  --DDL_STATEMENT_END--
  
  -- drop the table
  
  --DDL_STATEMENT_BEGIN--
  DROP TABLE IF EXISTS test_exists;
  --DDL_STATEMENT_END--
  
  --DDL_STATEMENT_BEGIN--
  DROP TABLE test_exists;
  --DDL_STATEMENT_END--
  
  -- be tolerant with missing schemas, types, etc
  
  --DDL_STATEMENT_BEGIN--
  DROP AGGREGATE IF EXISTS no_such_schema.foo(int);
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  DROP AGGREGATE IF EXISTS foo(no_such_type);
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  DROP AGGREGATE IF EXISTS foo(no_such_schema.no_such_type);
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  DROP CAST IF EXISTS (INTEGER AS no_such_type2);
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  DROP CAST IF EXISTS (no_such_type1 AS INTEGER);
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  DROP CAST IF EXISTS (INTEGER AS no_such_schema.bar);
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  DROP CAST IF EXISTS (no_such_schema.foo AS INTEGER);
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  DROP COLLATION IF EXISTS no_such_schema.foo;
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  DROP CONVERSION IF EXISTS no_such_schema.foo;
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  DROP FOREIGN TABLE IF EXISTS no_such_schema.foo;
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  DROP FUNCTION IF EXISTS no_such_schema.foo();
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  DROP FUNCTION IF EXISTS foo(no_such_type);
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  DROP FUNCTION IF EXISTS foo(no_such_schema.no_such_type);
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  DROP INDEX IF EXISTS no_such_schema.foo;
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  DROP MATERIALIZED VIEW IF EXISTS no_such_schema.foo;
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  DROP OPERATOR IF EXISTS no_such_schema.+ (int, int);
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  DROP OPERATOR IF EXISTS + (no_such_type, no_such_type);
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  DROP OPERATOR IF EXISTS + (no_such_schema.no_such_type, no_such_schema.no_such_type);
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  DROP OPERATOR IF EXISTS # (NONE, no_such_schema.no_such_type);
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  DROP OPERATOR CLASS IF EXISTS no_such_schema.widget_ops USING btree;
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  DROP OPERATOR FAMILY IF EXISTS no_such_schema.float_ops USING btree;
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  DROP RULE IF EXISTS foo ON no_such_schema.bar;
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  DROP SEQUENCE IF EXISTS no_such_schema.foo;
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  DROP TABLE IF EXISTS no_such_schema.foo;
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  DROP TEXT SEARCH CONFIGURATION IF EXISTS no_such_schema.foo;
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  DROP TEXT SEARCH DICTIONARY IF EXISTS no_such_schema.foo;
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  DROP TEXT SEARCH PARSER IF EXISTS no_such_schema.foo;
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  DROP TEXT SEARCH TEMPLATE IF EXISTS no_such_schema.foo;
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  DROP TYPE IF EXISTS no_such_schema.foo;
  --DDL_STATEMENT_END--
  --DDL_STATEMENT_BEGIN--
  DROP VIEW IF EXISTS no_such_schema.foo;
  --DDL_STATEMENT_END--
  