Skip to content
Open
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
4 changes: 4 additions & 0 deletions migrations/tests/extensions/01-postgis.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ begin;
do $_$
begin
if not exists (select 1 from pg_extension where extname = 'orioledb') then
-- create address_standardizer and dependencies first to ensure correct schema placement
create extension if not exists address_standardizer with schema extensions;
create extension if not exists address_standardizer_data_us with schema extensions;

-- create postgis tiger as supabase_admin
create extension if not exists postgis_tiger_geocoder cascade;

Expand Down
5 changes: 2 additions & 3 deletions nix/checks.nix
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,8 @@
check_postgres_ready
log info "Loading prime SQL file"
if ! log_cmd psql -p ${pgPort} -h localhost --no-password --username=supabase_admin -d postgres -v ON_ERROR_STOP=1 -Xf ${./tests/prime.sql} 2>&1; then
log error "Error executing SQL file"
if ! psql -p ${pgPort} -h ${self.supabase.defaults.host} --no-password --username=supabase_admin -d postgres -v ON_ERROR_STOP=1 -Xf ${./tests/prime-production.sql}; then
echo "Error executing SQL file"
exit 1
fi
Expand Down
32 changes: 17 additions & 15 deletions nix/tests/expected/evtrigs.out
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
BEGIN;
set client_min_messages = warning;
select
e.evtname,
e.evtowner::regrole as evtowner,
Expand All @@ -10,19 +12,19 @@ join pg_proc p
join pg_namespace n_func
on p.pronamespace = n_func.oid
where p.prorettype = 'event_trigger'::regtype;
evtname | evtowner | evtfunction_schema | evtfunction | function_owner
----------------------------------------+----------------+--------------------+------------------------------------+----------------
issue_pg_graphql_access | supabase_admin | extensions | grant_pg_graphql_access | supabase_admin
issue_graphql_placeholder | supabase_admin | extensions | set_graphql_placeholder | supabase_admin
pgrst_ddl_watch | supabase_admin | extensions | pgrst_ddl_watch | supabase_admin
pgrst_drop_watch | supabase_admin | extensions | pgrst_drop_watch | supabase_admin
graphql_watch_ddl | supabase_admin | graphql | graphql.increment_schema_version | supabase_admin
graphql_watch_drop | supabase_admin | graphql | graphql.increment_schema_version | supabase_admin
issue_pg_cron_access | supabase_admin | extensions | grant_pg_cron_access | supabase_admin
issue_pg_net_access | supabase_admin | extensions | grant_pg_net_access | supabase_admin
pg_tle_event_trigger_for_drop_function | supabase_admin | pgtle | pgtle.pg_tle_feature_info_sql_drop | supabase_admin
pgaudit_ddl_command_end | supabase_admin | public | pgaudit_ddl_command_end | supabase_admin
pgaudit_sql_drop | supabase_admin | public | pgaudit_sql_drop | supabase_admin
pgsodium_trg_mask_update | supabase_admin | pgsodium | pgsodium.trg_mask_update | supabase_admin
(12 rows)
evtname | evtowner | evtfunction_schema | evtfunction | function_owner
---------------------------+----------------+--------------------+----------------------------------+----------------
issue_pg_graphql_access | supabase_admin | extensions | grant_pg_graphql_access | supabase_admin
issue_graphql_placeholder | supabase_admin | extensions | set_graphql_placeholder | supabase_admin
pgrst_ddl_watch | supabase_admin | extensions | pgrst_ddl_watch | supabase_admin
pgrst_drop_watch | supabase_admin | extensions | pgrst_drop_watch | supabase_admin
graphql_watch_ddl | supabase_admin | graphql | graphql.increment_schema_version | supabase_admin
graphql_watch_drop | supabase_admin | graphql | graphql.increment_schema_version | supabase_admin
issue_pg_cron_access | supabase_admin | extensions | grant_pg_cron_access | supabase_admin
issue_pg_net_access | supabase_admin | extensions | grant_pg_net_access | supabase_admin
pgaudit_ddl_command_end | supabase_admin | extensions | pgaudit_ddl_command_end | supabase_admin
pgaudit_sql_drop | supabase_admin | extensions | pgaudit_sql_drop | supabase_admin
pgsodium_trg_mask_update | supabase_admin | pgsodium | pgsodium.trg_mask_update | supabase_admin
(11 rows)

ROLLBACK;
9 changes: 8 additions & 1 deletion nix/tests/expected/extensions_schema.out
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
BEGIN;
set client_min_messages = warning;
-- all default extensions are installed in a schema "extensions"
-- we don't include the version as that will break often, we only care about
-- ensuring these extensions are present
Expand All @@ -15,8 +17,13 @@ order by
e.extname;
extension_name | schema_name | extension_owner
--------------------+-------------+-----------------
dblink | extensions | supabase_admin
pg_repack | extensions | supabase_admin
pg_stat_statements | extensions | supabase_admin
pgaudit | extensions | supabase_admin
pgcrypto | extensions | supabase_admin
postgis | extensions | supabase_admin
uuid-ossp | extensions | supabase_admin
(3 rows)
(7 rows)

ROLLBACK;
4 changes: 4 additions & 0 deletions nix/tests/expected/http.out
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
-- Test for http extension
-- Basic HTTP functionality tests
BEGIN;
set client_min_messages = warning;
create extension if not exists http with schema extensions;
-- Test basic HTTP GET request
SELECT status FROM http_get('http://localhost:' || (SELECT value FROM test_config WHERE key = 'http_mock_port') || '/get');
status
Expand Down Expand Up @@ -103,3 +106,4 @@ SELECT status FROM http_get('http://localhost:' || (SELECT value FROM test_confi
200
(1 row)

ROLLBACK;
5 changes: 4 additions & 1 deletion nix/tests/expected/hypopg.out
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
BEGIN;
set client_min_messages = warning;
create extension if not exists hypopg with schema extensions;
create schema v;
create table v.samp(
id int
Expand All @@ -11,4 +14,4 @@ $$);
(1 row)

drop schema v cascade;
NOTICE: drop cascades to table v.samp
ROLLBACK;
6 changes: 5 additions & 1 deletion nix/tests/expected/index_advisor.out
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
BEGIN;
set client_min_messages = warning;
create extension if not exists hypopg with schema extensions;
create extension if not exists index_advisor with schema extensions;
create schema v;
create table v.book(
id int primary key,
Expand All @@ -13,4 +17,4 @@ from
(1 row)

drop schema v cascade;
NOTICE: drop cascades to table v.book
ROLLBACK;
4 changes: 4 additions & 0 deletions nix/tests/expected/pg_hashids.out
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
BEGIN;
set client_min_messages = warning;
create extension if not exists pg_hashids with schema extensions;
select id_encode(1001); -- Result: jNl
id_encode
-----------
Expand Down Expand Up @@ -34,3 +37,4 @@ select id_decode('3GJ956J9B9', 'This is my salt', 10, 'abcdefghijABCDxFGHIJ12345
{1234567}
(1 row)

ROLLBACK;
2 changes: 2 additions & 0 deletions nix/tests/expected/pg_jsonschema.out
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
begin;
set client_min_messages = warning;
create extension if not exists pg_jsonschema with schema extensions;
-- Test json_matches_schema
create table customer(
id serial primary key,
Expand Down
4 changes: 4 additions & 0 deletions nix/tests/expected/pg_net.out
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
BEGIN;
set client_min_messages = warning;
create extension if not exists pg_net with schema extensions;
-- This is a very basic test because you can't get the value returned
-- by a pg_net request in the same transaction that created it;
select
Expand All @@ -9,3 +12,4 @@ select
1
(1 row)

ROLLBACK;
7 changes: 4 additions & 3 deletions nix/tests/expected/pg_tle.out
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
BEGIN;
set client_min_messages = warning;
create schema if not exists pgtle;
create extension if not exists pg_tle with schema pgtle;
select
pgtle.install_extension(
'pg_distance',
Expand Down Expand Up @@ -87,6 +90,4 @@ select
t
(1 row)

-- Restore original state if any of the above fails
drop extension pg_tle cascade;
create extension pg_tle;
ROLLBACK;
13 changes: 13 additions & 0 deletions nix/tests/expected/pgmq.out
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
BEGIN;
set client_min_messages = warning;
create extension if not exists pgmq; -- pgmq is non-relocatable (schema = 'pgmq')
-- Test the standard flow
select
pgmq.create('Foo');
Expand Down Expand Up @@ -121,24 +124,33 @@ select
);
*/
-- Make sure SQLI enabling characters are blocked
-- Use savepoints to test error conditions without aborting the transaction
SAVEPOINT test_invalid_names_1;
select pgmq.create('F--oo');
ERROR: queue name contains invalid characters: $, ;, --, or \'
CONTEXT: PL/pgSQL function pgmq.format_table_name(text,text) line 5 at RAISE
PL/pgSQL function pgmq.create_non_partitioned(text) line 3 during statement block local variable initialization
SQL statement "SELECT pgmq.create_non_partitioned(queue_name)"
PL/pgSQL function pgmq."create"(text) line 3 at PERFORM
ROLLBACK TO SAVEPOINT test_invalid_names_1;
SAVEPOINT test_invalid_names_2;
select pgmq.create('F$oo');
ERROR: queue name contains invalid characters: $, ;, --, or \'
CONTEXT: PL/pgSQL function pgmq.format_table_name(text,text) line 5 at RAISE
SQL expression "pgmq.format_table_name(queue_name, 'q')"
PL/pgSQL function pgmq.create_non_partitioned(text) line 3 during statement block local variable initialization
SQL statement "SELECT pgmq.create_non_partitioned(queue_name)"
PL/pgSQL function pgmq."create"(text) line 3 at PERFORM
ROLLBACK TO SAVEPOINT test_invalid_names_2;
SAVEPOINT test_invalid_names_3;
select pgmq.create($$F'oo$$);
ERROR: queue name contains invalid characters: $, ;, --, or \'
CONTEXT: PL/pgSQL function pgmq.format_table_name(text,text) line 5 at RAISE
SQL expression "pgmq.format_table_name(queue_name, 'q')"
PL/pgSQL function pgmq.create_non_partitioned(text) line 3 during statement block local variable initialization
SQL statement "SELECT pgmq.create_non_partitioned(queue_name)"
PL/pgSQL function pgmq."create"(text) line 3 at PERFORM
ROLLBACK TO SAVEPOINT test_invalid_names_3;
\echo

-- pgmq schema functions with owners (ownership is modified on ansible/files/postgresql_extension_custom_scripts/pgmq/after-create.sql)
Expand Down Expand Up @@ -207,3 +219,4 @@ show search_path;
"$user", public, auth, extensions
(1 row)

ROLLBACK;
7 changes: 6 additions & 1 deletion nix/tests/expected/pgroonga.out
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
BEGIN;
set client_min_messages = warning;
create schema if not exists extensions;
create extension if not exists pgroonga with schema extensions;
create extension if not exists pgroonga_database with schema extensions;
create schema v;
create table v.roon(
id serial primary key,
Expand Down Expand Up @@ -73,4 +78,4 @@ select * from v.roon where content &@~ 'supports';
(1 row)

drop schema v cascade;
NOTICE: drop cascades to table v.roon
ROLLBACK;
6 changes: 5 additions & 1 deletion nix/tests/expected/pgrouting.out
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
BEGIN;
set client_min_messages = warning;
create extension if not exists pgrouting with schema extensions;
create extension if not exists postgis with schema extensions;
create schema v;
-- create the roads table
create table v.roads (
Expand Down Expand Up @@ -28,4 +32,4 @@ select * from pgr_dijkstra(
(4 rows)

drop schema v cascade;
NOTICE: drop cascades to table v.roads
ROLLBACK;
2 changes: 2 additions & 0 deletions nix/tests/expected/pgtap.out
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
begin;
set client_min_messages = warning;
create extension if not exists pgtap with schema extensions;
select plan(1);
plan
------
Expand Down
7 changes: 4 additions & 3 deletions nix/tests/expected/plpgsql-check.out
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
BEGIN;
set client_min_messages = warning;
create extension if not exists plpgsql_check with schema extensions;
create schema v;
create table v.t1(
a int,
Expand Down Expand Up @@ -30,6 +33,4 @@ select * from plpgsql_check_function('v.f1()');
(2 rows)

drop schema v cascade;
NOTICE: drop cascades to 2 other objects
DETAIL: drop cascades to table v.t1
drop cascades to function v.f1()
ROLLBACK;
2 changes: 2 additions & 0 deletions nix/tests/expected/postgres_fdw.out
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ https://github.com/supabase/postgres/blob/a638c6fce0baf90b654e762eddcdac1bc8df01

*/
begin;
-- Create the extension within the test (matches production pattern)
create extension if not exists postgres_fdw with schema extensions;
-- Switch to the postgres role (non-superuser) to test supautils behavior
set role postgres;
-- postgres_fdw should be owned by the superuser
Expand Down
Loading
Loading