2 # The pgsql-devel (or equivalent) package will be need for Exim to build, and
3 # the postgresql-server (or equivalent) package for this test to run.
5 # first, populate a DB to test against
7 echo Starting DB server
9 system 'DIR/bin.sys/initdb -D DIR/pgsql/data';
12 # I don not understand why, but the DB fails to start if this rm is present.
17 DIR/bin.sys/postgres -D DIR/pgsql/data -p PORT_N -k DIR/pgsql
21 echo Waiting for DB server
23 system 'DIR/bin.sys/pg_ctl -w -D DIR/pgsql/data status';
24 system 'createdb -h localhost -p PORT_N test';
25 system 'DIR/bin.sys/psql -h localhost -p PORT_N -d test \
26 -c "CREATE TABLE them ( name text, id text ); \
27 INSERT INTO them VALUES ( \'Philip Hazel\', \'ph10\' ); \
28 INSERT INTO them VALUES ( \'Aristotle\', \'aaaa\' ); \
29 INSERT INTO them VALUES ( \'\', \'nothing\' ); \
30 INSERT INTO them VALUES ( \'\"stquot\', \'quote2\' ); \
31 INSERT INTO them VALUES ( \'before\' || CHR(13) || CHR(10) || \'after\', \'newline\' ); \
32 INSERT INTO them VALUES ( \'x\' || CHR(9) || \'x\', \'tab\' ); \
33 INSERT INTO them VALUES ( CHR(39) || \'stquot\', \'quote1\' );" \
37 echo Populated DB server
40 exim -d-all+lookup -be
41 ${lookup pgsql {select name from them where id='ph10';}}
42 ${lookup pgsql {select name from them where id='ph10';}}
43 ${lookup pgsql {select name from them where id='xxxx';}}
44 ${lookup pgsql {select name from them where id='nothing';}}
45 ${lookup pgsql {select id,name from them where id='nothing';}}
46 ${lookup pgsql {delete from them where id='nonexist';}}
47 ${lookup pgsql {select * from them where id='quote2';}}
48 ${lookup pgsql {select * from them where id='newline';}}
49 ${lookup pgsql {select * from them where id='tab';}}
50 ${lookup pgsql {select * from them where name='${quote_pgsql:'stquot}';}}
51 ${lookup pgsql {servers=x:localhost; select name from them where id='ph10';}}
52 ${lookup pgsql {servers=localhost::PORT_N:x; select name from them where id='ph10';}}
53 name: ${lookup pgsql {servers=localhost::PORT_N/test/CALLER/:x; select name from them where id='ph10';}}
54 ipv4: ${lookup pgsql {servers=127.0.0.1::PORT_N/test/CALLER/:x; select name from them where id='ph10';}}
55 oldsyntax ipv6: ${lookup pgsql {servers=<!::1.PORT_N/test/CALLER/!x; select name from them where id='ph10';}}
56 newsyntax ipv6: ${lookup pgsql,servers=<!::1.PORT_N/test/CALLER/!x { select name from them where id='ph10';}}
57 ${lookup pgsql {servers=(DIR/pgsql/.s.PGSQL.PORT_N)/test/CALLER/:x; select name from them where id='ph10';}}
59 ${lookup pgsql {SELECT name FROM them WHERE id IN ('ph10', 'aaaa');}}
60 ${lookup pgsql {SELECT * FROM them WHERE id IN ('ph10', 'aaaa');}}
61 ${lookup pgsql {delete from them where id='aaaa'}}
74 exim -DSERVERS=\(DIR/pgsql/.s.PGSQL.PORT_N\)/test/CALLER/ -d-all+lookup -be
75 ${lookup pgsql {select name from them where id='ph10';}}
79 system 'DIR/bin.sys/pg_ctl stop -D DIR/pgsql/data -m immediate';