Merge lp://qastaging/~ben-kersten/mysql-proxy/packet-empty-set into lp://qastaging/mysql-proxy/0.8

Proposed by bkersten
Status: Needs review
Proposed branch: lp://qastaging/~ben-kersten/mysql-proxy/packet-empty-set
Merge into: lp://qastaging/mysql-proxy/0.8
Diff against target: 11 lines (+1/-0)
1 file modified
src/network-mysqld-packet.c (+1/-0)
To merge this branch: bzr merge lp://qastaging/~ben-kersten/mysql-proxy/packet-empty-set
Reviewer Review Type Date Requested Status
Registry Administrators Pending
Review via email:

Description of the change

When a query goes through the lua layer and mysqld returns an error it is possible for the query status to be set to OK if the error packet is preceded by field header packets.


-- test script for a failing query that gets error packet after field packets

function read_query(packet)

  if string.byte(packet) ~= proxy.COM_QUERY then

  local query = string.sub(packet, 2)
  if string.match(string.upper(query), "TEST") then
    print("testing the bug")
    proxy.queries:append(1, string.char(proxy.COM_QUERY) .. "EXPLAIN SELECT * FROM dual", {resultset_is_needed = true})
    return proxy.PROXY_SEND_QUERY

function read_query_result (inj)
  if == 1 then
    local status = inj.resultset.query_status

    if not status or status == proxy.MYSQLD_PACKET_ERR then
      print("An error occurred in query: " .. inj.query:sub(2))
      return -- original results

    -- resultset rewrite
    local response = {
      ['type'] = proxy.MYSQLD_PACKET_OK,
      ['resultset'] = {
        ['fields'] = {
            type = proxy.MYSQL_TYPE_STRING,
            name = "fake_field",
        ['rows'] = {}

    -- copy the hopefully empty resultset
    local rows = response.resultset.rows
    for row in inj.resultset.rows do
      rows[#rows+1] = row

    print("row count: " .. #rows)

    proxy.response = response
    return proxy.PROXY_SEND_RESULT

To post a comment you must log in.

Unmerged revisions

1133. By Ben Kersten <bkersten@mel601855>

Fixed bug where query status is not set to error when error packet is preceded by field header packets.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.


People subscribed via source and target branches