#!/bin/sh
PGSRC=~/pgsql
PGBIN=/usr/local/pgsql/bin
PGDATA=/spool/pg_data

PATH=$PGBIN:$PATH

ulimit -c unlimited

su2 -c 'killall -9 postgres'
sleep 2
su2 -c "rm -rf $PGDATA && mkdir $PGDATA && chown pgsql: $PGDATA"

su2 pgsql -c "$PGBIN/initdb -E KOI8-R --locale ru_RU.KOI8-R -D $PGDATA"
su2 pgsql -c "$PGBIN/pg_ctl -D $PGDATA -l $PGBIN/../pgsql.log -o '-B 4096 -F -N 16' start"
sleep 3

su2  pgsql -c "createuser -d -a -e teodor"

CURPWD=`pwd`
cd $PGSRC/contrib/intarray
gmake && su2 -c 'gmake install'
#cd $PGSRC/contrib/gevel
#gmake && su2 -c 'gmake install'

$PGBIN/createdb qq 
$PGBIN/psql qq < $PGBIN/../share/contrib/_int.sql
#$PGBIN/psql qq < $PGBIN/../share/contrib/gevel.sql

cd $CURPWD
pwd

while( touch 1 )
do
$PGBIN/psql  qq -c 'drop table wow;' 
$PGBIN/psql  qq -c 'create table wow ( n int, a int[] );' 
$PGBIN/psql  qq -c "create index idx on wow using gist (a);"
perl concur.pl -d qq -n 100000 -c 4 || exit 
$PGBIN/psql  qq -c 'vacuum full verbose wow;'
done 


