src/server/plugins/postgresql/test/createtestdb.sh

Fri, 01 Nov 2024 12:25:52 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Fri, 01 Nov 2024 12:25:52 +0100
changeset 562
69fc4ecc5f60
parent 288
7dd45173f68a
permissions
-rwxr-xr-x

fix pgext uses a wrong field number, if the column has the same name as a resource or property column

#!/bin/sh

BUILD_ROOT=../../../../..

PGTEST=$BUILD_ROOT/build/server/plugins/postgresql/test
TESTDB=$PGTEST/data

echo "## prepare testdb directory"
rm -Rf $TESTDB
mkdir $TESTDB
if [ $? -ne 0 ]; then
	exit 1
fi

TESTDB_ABS=`realpath $TESTDB`
echo "testdb path: " $TESTDB_ABS

echo "## init testdb"
initdb -D $TESTDB_ABS
if [ $? -ne 0 ]; then
	exit 1
fi

cp pg/postgresql.conf $TESTDB
mkdir $TESTDB/run

echo "## start database"
pg_ctl -D $TESTDB_ABS start
if [ $? -ne 0 ]; then
	echo "## start failed"
	exit 1
fi

echo "## create testdb"
createdb -h $TESTDB_ABS/run testdb
if [ $? -ne 0 ]; then
	echo "## createdb failed"
	echo "## stop database"
	pg_ctl -D $TESTDB_ABS stop
	exit 1
fi
echo "success"

echo "## create test data"
psql -h $TESTDB_ABS/run -d testdb -f postgresql_vfs.sql
if [ $? -ne 0 ]; then
	echo "## create test data (1) failed"
	echo "## stop database"
	pg_ctl -D $TESTDB_ABS stop
	exit 1
fi
psql -h $TESTDB_ABS/run -d testdb -f postgresql_vfs_testdata.sql
if [ $? -ne 0 ]; then
	echo "## create test data (2) failed"
	echo "## stop database"
	pg_ctl -D $TESTDB_ABS stop
	exit 1
fi
echo "success"

echo "## stop database"
pg_ctl -D $TESTDB_ABS stop
exit $?


mercurial