mysqlsails.jswaterline

What means mysql "serverStatus: 34" in response of waterline orm in sails.js?


Sails.js version 0.12.13.

User.query(`CALL someProc()`, function(err, data){
    console.log(data);
}

Response:

data: OkPacket {
    fieldCount: 0,
    affectedRows: 0,
    insertId: 0,
    serverStatus: 32,
    warningCount: 0,
    message: '',
    protocol41: true,
    changedRows: 0 
}

What means "serverStatus: 32"? And what means "serverStatus: 34"?


Solution

  • The response from a .query call in Sails comes directly from the driver, in this case mysql. The serverStatus is a bitfield. You can get the list of constants in the MySQL source code docs -- the first one in the list represents a value of 1, the next 2, then 4, etc.

    So serverStatus: 32 means that only the sixth bit is set, corresponding to SERVER_STATUS_CURSOR_EXISTS:

    The server was able to fulfill the clients request and opened a read-only non-scrollable cursor for a query.

    This flag comes in reply to COM_STMT_EXECUTE and COM_STMT_FETCH commands. Used by Binary Protocol Resultset to signal that COM_STMT_FETCH must be used to fetch the row-data.

    If you see serverStatus: 34, it means both the above and the second bit, SERVER_STATUS_AUTOCOMMIT, was set:

    Server in auto_commit mode.