Skip to content

Commit

Permalink
[misc] connection.end() immediate resolution on socket QUIT packet send.
Browse files Browse the repository at this point in the history
  • Loading branch information
rusher committed Sep 19, 2018
1 parent 1c65cc7 commit 6df9209
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 14 deletions.
4 changes: 2 additions & 2 deletions lib/connection-callback.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function ConnectionCallback(options) {
throw new Errors.createError(
"missing callback parameter",
false,
this.getInfo(),
this.info,
"HY000",
Errors.ER_MISSING_PARAMETER
);
Expand All @@ -81,7 +81,7 @@ function ConnectionCallback(options) {
Errors.createError(
"Connection closed",
true,
this.getInfo(),
this.info,
"08S01",
Errors.ER_CONNECTION_ALREADY_CLOSED
)
Expand Down
7 changes: 2 additions & 5 deletions lib/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,9 @@ function Connection(options) {
let sock = _socket;
_clear();
_status = Status.CLOSED;
setImmediate(resolve);
sock.destroy();
_receiveQueue.clear();
resolve();
};
const quitCmd = new Quit(ended, ended);
_sendQueue.push(quitCmd);
Expand Down Expand Up @@ -396,10 +396,6 @@ function Connection(options) {
);
};

this.getInfo = () => {
return info;
};

/**
* Change option "debug" during connection.
* @param val debug value
Expand Down Expand Up @@ -979,6 +975,7 @@ function Connection(options) {
return info ? info.threadId : undefined;
}
});

}

util.inherits(Connection, EventEmitter);
Expand Down
27 changes: 27 additions & 0 deletions test/integration/datatype/test-enum.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"use strict";

const base = require("../../base.js");
const { assert } = require("chai");

describe("enum", () => {
it("enum type verification", done => {
shareConn.query(
"CREATE TEMPORARY TABLE fruits (\n" +
" id INT NOT NULL auto_increment PRIMARY KEY,\n" +
" fruit ENUM('apple','orange','pear'),\n" +
" bushels INT)"
);
shareConn.query("INSERT INTO fruits (fruit,bushels) VALUES (?, ?)", ["pear", 20]);
shareConn.query("INSERT INTO fruits (fruit,bushels) VALUES (?, ?)", ["apple", 100]);
shareConn
.query("SELECT * FROM fruits")
.then(rows => {
assert.deepEqual(rows, [
{ id: 1, fruit: "pear", bushels: 20 },
{ id: 2, fruit: "apple", bushels: 100 }
]);
done();
})
.catch(done);
});
});
14 changes: 7 additions & 7 deletions test/integration/datatype/test-geometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe("geometry data type", () => {
.catch(done);
});

it("Point Insert", function (done) {
it("Point Insert", function(done) {
//mysql < 8 doesn't permit sending empty data
if (!shareConn.isMariaDB() && !shareConn.hasMinVersion(8, 0, 0)) this.skip();

Expand Down Expand Up @@ -136,7 +136,7 @@ describe("geometry data type", () => {
.catch(done);
});

it("LineString insert", function (done) {
it("LineString insert", function(done) {
//mysql < 8 doesn't permit sending empty data
if (!shareConn.isMariaDB() && !shareConn.hasMinVersion(8, 0, 0)) this.skip();

Expand Down Expand Up @@ -234,7 +234,7 @@ describe("geometry data type", () => {
.catch(done);
});

it("Polygon insert", function (done) {
it("Polygon insert", function(done) {
//mysql < 8 doesn't permit sending empty data
if (!shareConn.isMariaDB() && !shareConn.hasMinVersion(8, 0, 0)) this.skip();

Expand Down Expand Up @@ -335,7 +335,7 @@ describe("geometry data type", () => {
.catch(done);
});

it("MultiPoint insert", function (done) {
it("MultiPoint insert", function(done) {
//mysql < 8 doesn't permit sending empty data
if (!shareConn.isMariaDB() && !shareConn.hasMinVersion(8, 0, 0)) this.skip();

Expand Down Expand Up @@ -426,7 +426,7 @@ describe("geometry data type", () => {
.catch(done);
});

it("Multi-line insert", function (done) {
it("Multi-line insert", function(done) {
//mysql < 8 doesn't permit sending empty data
if (!shareConn.isMariaDB() && !shareConn.hasMinVersion(8, 0, 0)) this.skip();

Expand Down Expand Up @@ -540,7 +540,7 @@ describe("geometry data type", () => {
.catch(done);
});

it("Multi-polygon insert", function (done) {
it("Multi-polygon insert", function(done) {
//mysql < 8 doesn't permit sending empty data
if (!shareConn.isMariaDB() && !shareConn.hasMinVersion(8, 0, 0)) this.skip();

Expand Down Expand Up @@ -755,7 +755,7 @@ describe("geometry data type", () => {
.catch(done);
});

it("Geometry collection insert", function (done) {
it("Geometry collection insert", function(done) {
//mysql < 8 doesn't permit sending empty data
if (!shareConn.isMariaDB() && !shareConn.hasMinVersion(8, 0, 0)) this.skip();

Expand Down

0 comments on commit 6df9209

Please sign in to comment.