7979# pgrx settings
8080PGRX_HOME=" $HOME /.pgrx"
8181PG_PORT=" $(( 28800 + PG_VERSION)) "
82- PG_USER=" $USER "
82+ PG_USER=" postgres "
8383PG_DB=" postgres"
8484
8585# Default non-privileged role for E2E tests (created by 00_setup_playground.sql)
@@ -149,6 +149,11 @@ ensure_config() {
149149 sed -i.bak ' /^#*shared_preload_libraries/d' " $DATA_DIR /postgresql.conf"
150150 echo " shared_preload_libraries = 'pg_durable'" >> " $DATA_DIR /postgresql.conf"
151151 fi
152+ # Ensure worker_role is set
153+ if ! grep -q " ^pg_durable.worker_role" " $DATA_DIR /postgresql.conf" 2> /dev/null; then
154+ echo " Configuring pg_durable.worker_role..."
155+ echo " pg_durable.worker_role = 'postgres'" >> " $DATA_DIR /postgresql.conf"
156+ fi
152157 # Ensure port is set
153158 if ! grep -q " ^port = $PG_PORT " " $DATA_DIR /postgresql.conf" 2> /dev/null; then
154159 sed -i.bak ' /^#*port = /d' " $DATA_DIR /postgresql.conf"
@@ -187,7 +192,7 @@ start_server() {
187192 # Initialize if needed
188193 if [ ! -d " $DATA_DIR " ]; then
189194 echo " Initializing database..."
190- " $PGRX_BIN /initdb" -D " $DATA_DIR " --no-locale -E UTF8 > /dev/null 2>&1
195+ " $PGRX_BIN /initdb" -D " $DATA_DIR " -U postgres - -no-locale -E UTF8 > /dev/null 2>&1
191196 fi
192197
193198 # Ensure config is correct (with or without preload)
@@ -202,7 +207,7 @@ start_server() {
202207 # 2. Restart server (so background worker reconnects with fresh cached plans)
203208 if " $PG_ISREADY " -h localhost -p $PG_PORT & > /dev/null; then
204209 # Drop schemas before restart (background worker will recreate on reconnect)
205- " $PSQL " -h localhost -p $PG_PORT -d $PG_DB -c " DROP SCHEMA IF EXISTS duroxide CASCADE; DROP EXTENSION IF EXISTS pg_durable CASCADE;" > /dev/null 2>&1
210+ " $PSQL " -h localhost -p $PG_PORT -U $PG_USER - d $PG_DB -c " DROP SCHEMA IF EXISTS duroxide CASCADE; DROP EXTENSION IF EXISTS pg_durable CASCADE;" > /dev/null 2>&1
206211 echo -e " ${YELLOW} Restarting PostgreSQL to reload extension...${NC} "
207212 stop_server
208213 fi
@@ -215,10 +220,10 @@ start_server() {
215220 if [ " $NO_PRELOAD " = true ]; then
216221 # Drop extension if it exists from a previous run (e.g., unit tests)
217222 # so the no-preload test can verify CREATE EXTENSION fails correctly
218- " $PSQL " -h localhost -p $PG_PORT -d $PG_DB -c " DROP EXTENSION IF EXISTS pg_durable CASCADE; DROP SCHEMA IF EXISTS duroxide CASCADE;" > /dev/null 2>&1
223+ " $PSQL " -h localhost -p $PG_PORT -U $PG_USER - d $PG_DB -c " DROP EXTENSION IF EXISTS pg_durable CASCADE; DROP SCHEMA IF EXISTS duroxide CASCADE;" > /dev/null 2>&1
219224 else
220225 # Create extension (duroxide schema will be created by background worker on first connect)
221- " $PSQL " -h localhost -p $PG_PORT -d $PG_DB -c " CREATE EXTENSION IF NOT EXISTS pg_durable;" > /dev/null 2>&1
226+ " $PSQL " -h localhost -p $PG_PORT -U $PG_USER - d $PG_DB -c " CREATE EXTENSION IF NOT EXISTS pg_durable;" > /dev/null 2>&1
222227 fi
223228}
224229
@@ -242,7 +247,7 @@ start_server
242247# Show version and run setup (only when extension is loaded, not in --no-preload mode)
243248if [ " $NO_PRELOAD " = false ]; then
244249 echo -n " pg_durable version: "
245- " $PSQL " -h localhost -p $PG_PORT -d $PG_DB -t -c " SELECT df.version();" 2> /dev/null | tr -d ' \n'
250+ " $PSQL " -h localhost -p $PG_PORT -U $PG_USER - d $PG_DB -t -c " SELECT df.version();" 2> /dev/null | tr -d ' \n'
246251 echo " "
247252 echo " "
248253
0 commit comments