-
-
Notifications
You must be signed in to change notification settings - Fork 622
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: binary parser sometimes reads out of packet bounds when results …
…contain null and typecast is false
- Loading branch information
Showing
2 changed files
with
39 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
test/integration/config/test-typecast-global-false.test.cjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
'use strict'; | ||
|
||
const common = require('../../common.test.cjs'); | ||
const connection = common.createConnection({ | ||
typeCast: false, | ||
}); | ||
|
||
const { assert } = require('poku'); | ||
|
||
const COL_1_VALUE = 'col v1'; | ||
const COL_2_VALUE = 'col v2'; | ||
|
||
function executeTests(res) { | ||
assert.equal(res[0].v1.toString('ascii'), COL_1_VALUE); | ||
assert.equal(res[0].n1, null); | ||
assert.equal(res[0].v2.toString('ascii'), COL_2_VALUE); | ||
} | ||
|
||
connection.query( | ||
'CREATE TEMPORARY TABLE binpar_null_test (v1 VARCHAR(16) NOT NULL, n1 VARCHAR(16), v2 VARCHAR(16) NOT NULL)', | ||
); | ||
connection.query( | ||
`INSERT INTO binpar_null_test (v1, n1, v2) VALUES ("${COL_1_VALUE}", NULL, "${COL_2_VALUE}")`, | ||
(err) => { | ||
if (err) throw err; | ||
}, | ||
); | ||
|
||
connection.execute('SELECT * FROM binpar_null_test', (err, res) => { | ||
if (err) throw err; | ||
executeTests(res); | ||
connection.end(); | ||
}); |