Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions test/deps.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@ SET client_min_messages = NOTICE;
\set TT extension_drop_test_table
CREATE TEMP TABLE :TT (i int);

CREATE SCHEMA :TEST_SCHEMA;
SET search_path = :TEST_SCHEMA, tap, "$user";
/*
* :TEST_SCHEMA can be mixed-case (see test/sql/schema.sql), so it MUST be
* identifier-quoted here -- an unquoted interpolation would silently fold
* to lowercase and every test would end up running against a different,
* unquoted schema than the one it thinks it's using.
*/
CREATE SCHEMA :"TEST_SCHEMA";
SET search_path = :"TEST_SCHEMA", tap, "$user";

/*
* Now load our extension. We don't use IF NOT EXISTs here because we want an
Expand Down
10 changes: 5 additions & 5 deletions test/expected/schema.out
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ ok 1 - Create test extension
ok 2 - Test extension exists
ok 3 - Drop test extension
ok 4 - Test extension does not exist
ok 5 - Table _test_ed.extension_drop__commands should exist
ok 5 - Table "_Test_Ed".extension_drop__commands should exist
ok 6 - Drop extension
ok 7 - Create extension in schema _test_ed_2
ok 8 - Table _test_ed_2.extension_drop__commands should exist
ok 9 - Create test extension in _test_ed_2
ok 7 - Create extension in schema _Test_Ed_2
ok 8 - Table "_Test_Ed_2".extension_drop__commands should exist
ok 9 - Create test extension in _Test_Ed_2
ok 10 - extension_drop__update()
ok 11 - Verify extension_drop__get()
ok 12 - Drop schema _test_ed without cascade succeeds
ok 12 - Drop schema _Test_Ed without cascade succeeds
# TRANSACTION INTENTIONALLY LEFT OPEN!
18 changes: 13 additions & 5 deletions test/sql/schema.sql
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
\set ECHO none
\set TEST_SCHEMA _test_ed
\set TEST_SCHEMA _Test_Ed
\i test/pgxntool/setup.sql

CREATE SCHEMA _test_ed_2;
/*
* :TEST_SCHEMA and :TEST_SCHEMA_2 are mixed-case, so every reference to
* them MUST be identifier-quoted (:"TEST_SCHEMA", or %I via format()) --
* an unquoted reference would silently fold to lowercase and test a
* different, unquoted schema instead of this one, without erroring.
* That's deliberate: it turns a missing-quote bug in the code under test
* into a hard failure instead of a silent pass.
*/
CREATE SCHEMA "_Test_Ed_2";

SELECT plan(
0
Expand All @@ -28,7 +36,7 @@ SELECT lives_ok(
, 'Drop extension'
);

\set TEST_SCHEMA_2 _test_ed_2
\set TEST_SCHEMA_2 _Test_Ed_2
SELECT lives_ok(
format( $$CREATE EXTENSION extension_drop SCHEMA %I$$, :'TEST_SCHEMA_2' )
, 'Create extension in schema ' || :'TEST_SCHEMA_2'
Expand All @@ -44,11 +52,11 @@ SELECT lives_ok(
SET search_path = "$user", public, tap;

SELECT lives_ok(
$$SELECT _test_ed_2.extension_drop__update('extension_drop_test', 'moo')$$
format( $$SELECT %I.extension_drop__update('extension_drop_test', 'moo')$$, :'TEST_SCHEMA_2' )
, 'extension_drop__update()'
);
SELECT bag_eq(
$$SELECT * FROM _test_ed_2.extension_drop__get('extension_drop_test')$$
format( $$SELECT * FROM %I.extension_drop__get('extension_drop_test')$$, :'TEST_SCHEMA_2' )
, $$SELECT 'extension_drop_test'::name , 'moo'::text$$
, 'Verify extension_drop__get()'
);
Expand Down