Commit | Line | Data |
---|---|---|
de1294ea | 1 | # pgsql lookups |
ff059213 JH |
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. | |
de1294ea JH |
4 | # |
5 | # first, populate a DB to test against | |
6 | sudo rm -fr DIR/pgsql | |
7 | perl | |
6481e125 | 8 | system 'DIR/bin.sys/initdb -D DIR/pgsql/data'; |
de1294ea | 9 | **** |
2b665c13 | 10 | sudo rm test-stdout |
de1294ea | 11 | background |
6481e125 | 12 | DIR/bin.sys/postgres -D DIR/pgsql/data -p PORT_N -k DIR/pgsql |
de1294ea | 13 | **** |
2b665c13 | 14 | sleep 1 |
de1294ea JH |
15 | perl |
16 | system 'createdb -h localhost -p PORT_N test'; | |
17 | system 'psql -h localhost -p PORT_N -d test \ | |
2b665c13 JH |
18 | -c "CREATE TABLE them ( name text, id text ); \ |
19 | INSERT INTO them VALUES ( \'Philip Hazel\', \'ph10\' ); \ | |
20 | INSERT INTO them VALUES ( \'Aristotle\', \'aaaa\' ); \ | |
21 | INSERT INTO them VALUES ( \'\', \'nothing\' ); \ | |
22 | INSERT INTO them VALUES ( \'\"stquot\', \'quote2\' ); \ | |
23 | INSERT INTO them VALUES ( \'before\' || CHR(13) || CHR(10) || \'after\', \'newline\' ); \ | |
24 | INSERT INTO them VALUES ( \'x\' || CHR(9) || \'x\', \'tab\' ); \ | |
25 | INSERT INTO them VALUES ( CHR(39) || \'stquot\', \'quote1\' );" \ | |
de1294ea JH |
26 | '; |
27 | **** | |
28 | # | |
29 | # now, the tests | |
59371ea7 PH |
30 | exim -d-all+lookup -be |
31 | ${lookup pgsql {select name from them where id='ph10';}} | |
32 | ${lookup pgsql {select name from them where id='ph10';}} | |
33 | ${lookup pgsql {select name from them where id='xxxx';}} | |
34 | ${lookup pgsql {select name from them where id='nothing';}} | |
35 | ${lookup pgsql {select id,name from them where id='nothing';}} | |
36 | ${lookup pgsql {delete from them where id='nonexist';}} | |
37 | ${lookup pgsql {select * from them where id='quote2';}} | |
38 | ${lookup pgsql {select * from them where id='newline';}} | |
39 | ${lookup pgsql {select * from them where id='tab';}} | |
5547e2c5 | 40 | ${lookup pgsql {select * from them where name='${quote_pgsql:'stquot}';}} |
b7670459 | 41 | ${lookup pgsql {servers=x:localhost; select name from them where id='ph10';}} |
de1294ea JH |
42 | ${lookup pgsql {servers=localhost::PORT_N:x; select name from them where id='ph10';}} |
43 | ${lookup pgsql {servers=localhost::PORT_N/test/CALLER/:x; select name from them where id='ph10';}} | |
44 | ${lookup pgsql {servers=(DIR/pgsql/.s.PGSQL.PORT_N)/test/CALLER/:x; select name from them where id='ph10';}} | |
bbfb5dcd JH |
45 | x |
46 | ${lookup pgsql {SELECT name FROM them WHERE id IN ('ph10', 'aaaa');}} | |
47 | ${lookup pgsql {SELECT * FROM them WHERE id IN ('ph10', 'aaaa');}} | |
ba0e37b1 | 48 | ${lookup pgsql {delete from them where id='aaaa'}} |
59371ea7 PH |
49 | **** |
50 | exim -d -bh 10.0.0.0 | |
51 | mail from:<a@b> | |
52 | rcpt to:<c@d> | |
53 | rcpt to:<c@d> | |
54 | quit | |
55 | **** | |
56 | exim -odi -d CALLER | |
57 | Test message | |
58 | . | |
59 | **** | |
de1294ea JH |
60 | exim -DSERVERS=\(DIR/pgsql/.s.PGSQL.PORT_N\)/test/CALLER/ -d-all+lookup -be |
61 | ${lookup pgsql {select name from them where id='ph10';}} | |
62 | **** | |
63 | # | |
64 | perl | |
65 | system 'pg_ctl stop -D DIR/pgsql/data -m immediate'; | |
59371ea7 | 66 | **** |
de1294ea JH |
67 | killdaemon |
68 | sudo rm -fr DIR/pgsql |