Skip to content

Commit

Permalink
[misc] status change after changing user
Browse files Browse the repository at this point in the history
  • Loading branch information
rusher committed May 15, 2018
1 parent f5eac9e commit 15ea477
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/cmd/handshake/handshake.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ class Handshake extends Command {
//* OK_Packet - authentication succeeded
//*********************************************************************************************************
case 0x00:
packet.skip(1); //skip header
packet.skipLengthCodedNumber(); //skip affected rows
packet.skipLengthCodedNumber(); //skip last insert id
info.status = packet.readUInt16();
this.authEnded();
this.emit("cmd_end");
this.emit("end");
Expand Down
21 changes: 21 additions & 0 deletions test/integration/test-change-user.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const base = require("../base.js");
const assert = require("chai").assert;
const ServerStatus = require("../../lib/const/server-status");

describe("change user", () => {
before(done => {
Expand Down Expand Up @@ -76,4 +77,24 @@ describe("change user", () => {
done();
});
});

it("autocommit state after changing user", done => {
if (!shareConn.isMariaDB()) this.skip();
const conn = base.createConnection();
conn.connect(err => {
if (err) done(err);
assert.equal(conn.__tests.getInfo().status & ServerStatus.STATUS_AUTOCOMMIT, 2);
conn.query("SET autocommit=1", () => {
assert.equal(conn.__tests.getInfo().status & ServerStatus.STATUS_AUTOCOMMIT, 2);
conn.query("SET autocommit=0", () => {
assert.equal(conn.__tests.getInfo().status & ServerStatus.STATUS_AUTOCOMMIT, 0);
conn.changeUser({ user: "ChangeUser", password: "mypassword" }, err => {
assert.equal(conn.__tests.getInfo().status & ServerStatus.STATUS_AUTOCOMMIT, 2);
conn.end();
done();
});
});
});
});
});
});

0 comments on commit 15ea477

Please sign in to comment.