Lookups: fix mysql lookup returns for no-data "queries",
[exim.git] / test / scripts / 2610-MySQL / 2610
CommitLineData
ba0e37b1
JH
1# mysql lookups
2#
3# first, populate a DB to test against
4sudo rm -fr DIR/mysql
5perl
6system 'mysql_install_db --datadir=DIR/mysql';
7****
8sudo rm test-stdout
9#
10# start a db server
11background
12mysqld_safe --datadir=DIR/mysql --log-error=DIR/mysql/log --port=PORT_N --socket=DIR/mysql/sock --pid-file=DIR/mysql/pidfile
13****
14sleep 1
15sudo rm test-stderr-server
16#
17# insert some data
18perl
19system 'mysqladmin --protocol=TCP -P PORT_N -u root create test';
20system 'mysql --protocol=TCP -P PORT_N -u root -D test \
21 -e "CREATE TABLE them ( name text, id text ); \
22 INSERT INTO them VALUES ( \'Philip Hazel\', \'ph10\' ); \
23 INSERT INTO them VALUES ( \'Aristotle\', \'aaaa\' ); \
24 INSERT INTO them VALUES ( \'\', \'nothing\' ); \
25 INSERT INTO them VALUES ( \'\"stquot\', \'quote2\' ); \
26 INSERT INTO them VALUES ( CONCAT(\'before\', CHAR(13), CHAR(10), \'after\'), \'newline\' ); \
27 INSERT INTO them VALUES ( CONCAT(\'x\', CHAR(9), \'x\'), \'tab\' ); \
28 INSERT INTO them VALUES ( CONCAT(CHAR(39), \'stquot\'), \'quote1\' ); \
29 "';
30****
31#
32#
33exim -d-all+lookup -be
34${lookup mysql {select name from them where id='ph10';}}
35${lookup mysql {select name from them where id='ph10';}}
36${lookup mysql {select name from them where id='xxxx';}}
37${lookup mysql {select name from them where id='nothing';}}
38${lookup mysql {select id,name from them where id='nothing';}}
39${lookup mysql {delete from them where id='nonexist';}}
40${lookup mysql {select * from them where id='quote';}}
41${lookup mysql {select * from them where id='filter';}}
42${lookup mysql {select * from them where id='quote2';}}
43${lookup mysql {select * from them where id='nlonly';}}
44${lookup mysql {servers=x:127.0.0.1::PORT_N; select name from them where id='ph10';}}
45${lookup mysql {servers=127.0.0.1::PORT_N:x; select name from them where id='ph10';}}
46${lookup mysql {servers=127.0.0.1::PORT_N/test/root/:x; select name from them where id='ph10';}}
47${lookup mysql {servers=HOSTIPV4::PORT_N/test/root/:127.0.0.1::PORT_N; select name from them where id='ph10';}}
48${lookup mysql {servers=localhost(DIR/mysql/sock)/test/root/; select name from them where id='ph10';}}
49x
50${lookup mysql {SELECT name FROM them WHERE id IN ('ph10', 'aaaa');}}
51${lookup mysql {SELECT * FROM them WHERE id IN ('ph10', 'aaaa');}}
52${lookup mysql {delete from them where id='aaaa'}}
53****
54exim -d -bh 10.0.0.0
55mail from:<a@b>
56rcpt to:<c@d>
57quit
58****
59exim -odi -d ph10
60Test message
61.
62****
63#
64perl
65system 'mysqladmin --protocol=TCP -P PORT_N -u root shutdown';
66****
67killdaemon
68sudo rm -fr DIR/mysql