538
by Kay Roepke
merge copyright changes |
1 |
--[[ $%BEGINLICENSE%$
|
2 |
Copyright (C) 2008 MySQL AB, 2008 Sun Microsystems, Inc
|
|
3 |
||
4 |
This program is free software; you can redistribute it and/or modify
|
|
5 |
it under the terms of the GNU General Public License as published by
|
|
6 |
the Free Software Foundation; version 2 of the License.
|
|
7 |
||
8 |
This program is distributed in the hope that it will be useful,
|
|
9 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
GNU General Public License for more details.
|
|
12 |
||
13 |
You should have received a copy of the GNU General Public License
|
|
14 |
along with this program; if not, write to the Free Software
|
|
15 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
16 |
||
17 |
$%ENDLICENSE%$ --]]
|
|
634
by jan at mysql
let the -test.lua handle mysqltest's default-connection and run the real test |
18 |
local proto = require("mysql.proto") |
19 |
||
20 |
---
|
|
21 |
-- Bug#35669 is about failing lua scripts should case a error-msg on the MySQL protocol
|
|
22 |
--
|
|
23 |
-- we have to jump through some hoops to make this testable with mysqltest as it
|
|
24 |
-- expects that the initial, default connection always succeeds
|
|
25 |
--
|
|
26 |
-- To get this working we use 2 proxy scripts and chain them:
|
|
27 |
-- 1) ACK the initial connection, forward the 2nd connection to the faulty script
|
|
28 |
-- 2) loading a faulty script and generate the error-msg
|
|
29 |
--
|
|
30 |
||
31 |
function connect_server() |
|
32 |
if not proxy.global.is_faulty then |
|
33 |
-- only ACK mysqltest's default connection
|
|
34 |
proxy.response = { |
|
35 |
type = proxy.MYSQLD_PACKET_RAW, |
|
36 |
packets = { |
|
37 |
proto.to_challenge_packet({}) |
|
38 |
}
|
|
39 |
}
|
|
40 |
||
41 |
-- the next connection is the faulty connection
|
|
42 |
proxy.global.is_faulty = true |
|
43 |
is_initial_connection = true |
|
44 |
return proxy.PROXY_SEND_RESULT |
|
45 |
end
|
|
356
by Jan Kneschke
merged kays changes |
46 |
end
|
47 |
||
634
by jan at mysql
let the -test.lua handle mysqltest's default-connection and run the real test |
48 |
---
|
49 |
-- provide a mock function for all commands that mysqltest sends
|
|
50 |
-- on the default connection
|
|
51 |
--
|
|
52 |
function read_query(packet) |
|
53 |
-- pass on everything that is not on the initial connection
|
|
54 |
if not is_initial_connection then return end |
|
55 |
||
56 |
if packet:byte() ~= proxy.COM_QUERY then |
|
57 |
proxy.response = { |
|
58 |
type = proxy.MYSQLD_PACKET_OK |
|
59 |
}
|
|
60 |
return proxy.PROXY_SEND_RESULT |
|
61 |
end
|
|
62 |
||
63 |
proxy.response = { |
|
64 |
type = proxy.MYSQLD_PACKET_ERR, |
|
65 |
errmsg = "(bug_35669-mock) >" .. packet:sub(2) .. "<" |
|
66 |
}
|
|
67 |
return proxy.PROXY_SEND_RESULT |
|
356
by Jan Kneschke
merged kays changes |
68 |
end
|