Skip to content

Commit b9ea050

Browse files
authored
Update 0002-enable-md-pg_duckdb.sql (#932)
Update 0002-enable-md-pg_duckdb.sql to make it compatible with Postgresql 14. Resolves #928
1 parent c0e80c7 commit b9ea050

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

docker/init.d/0002-enable-md-pg_duckdb.sql

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
-- This script is used to enable MotherDuck support if
22
-- the token is provided in the environment variables.
33

4-
\getenv lc_token motherduck_token
5-
\getenv uc_token MOTHERDUCK_TOKEN
4+
-- Once we stop supporting PG14 we can use \getenv again
5+
-- For grepability: PG_VERSION_NUM < 150000
6+
\set lc_token `echo $motherduck_token`
7+
\set uc_token `echo $MOTHERDUCK_TOKEN`
68

7-
\if :{?lc_token}
9+
SELECT
10+
LENGTH(:'lc_token') > 0 as lc_token_set,
11+
LENGTH(:'uc_token') > 0 as uc_token_set
12+
\gset
13+
14+
\if :lc_token_set
815
CALL duckdb.enable_motherduck(:'lc_token'::TEXT);
9-
\elif :{?uc_token}
16+
\elif :uc_token_set
1017
CALL duckdb.enable_motherduck(:'uc_token'::TEXT);
1118
\else
1219
-- MotherDuck was not enabled, so we can skip the rest of the script

0 commit comments

Comments
 (0)