mirror of
https://github.com/brianc/node-postgres.git
synced 2025-12-08 20:16:25 +00:00
read dataTypeID and tableID as unsigned uint (#3347)
* read dataTypeID and tableID as unsigned uint this is causing issues in other projects, like https://github.com/sequelize/sequelize/issues/15466 * added tests for oids larger than 2^31
This commit is contained in:
parent
373093d176
commit
9fbcf17908
@ -31,6 +31,12 @@ export class BufferReader {
|
||||
return result
|
||||
}
|
||||
|
||||
public uint32(): number {
|
||||
const result = this.buffer.readUInt32BE(this.offset)
|
||||
this.offset += 4
|
||||
return result
|
||||
}
|
||||
|
||||
public string(length: number): string {
|
||||
const result = this.buffer.toString(this.encoding, this.offset, this.offset + length)
|
||||
this.offset += length
|
||||
|
||||
@ -39,6 +39,17 @@ var twoRowBuf = buffers.rowDescription([
|
||||
},
|
||||
])
|
||||
|
||||
var rowWithBigOids = {
|
||||
name: 'bigoid',
|
||||
tableID: 3000000001,
|
||||
attributeNumber: 2,
|
||||
dataTypeID: 3000000003,
|
||||
dataTypeSize: 4,
|
||||
typeModifier: 5,
|
||||
formatCode: 0,
|
||||
}
|
||||
var bigOidDescBuff = buffers.rowDescription([rowWithBigOids])
|
||||
|
||||
var emptyRowFieldBuf = new BufferList().addInt16(0).join(true, 'D')
|
||||
|
||||
var emptyRowFieldBuf = buffers.dataRow([])
|
||||
@ -132,6 +143,22 @@ var expectedTwoRowMessage = {
|
||||
},
|
||||
],
|
||||
}
|
||||
var expectedBigOidMessage = {
|
||||
name: 'rowDescription',
|
||||
length: 31,
|
||||
fieldCount: 1,
|
||||
fields: [
|
||||
{
|
||||
name: 'bigoid',
|
||||
tableID: 3000000001,
|
||||
columnID: 2,
|
||||
dataTypeID: 3000000003,
|
||||
dataTypeSize: 4,
|
||||
dataTypeModifier: 5,
|
||||
format: 'text',
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
var emptyParameterDescriptionBuffer = new BufferList()
|
||||
.addInt16(0) // number of parameters
|
||||
@ -261,6 +288,7 @@ describe('PgPacketStream', function () {
|
||||
testForMessage(emptyRowDescriptionBuffer, expectedEmptyRowDescriptionMessage)
|
||||
testForMessage(oneRowDescBuff, expectedOneRowMessage)
|
||||
testForMessage(twoRowBuf, expectedTwoRowMessage)
|
||||
testForMessage(bigOidDescBuff, expectedBigOidMessage)
|
||||
})
|
||||
|
||||
describe('parameterDescription messages', function () {
|
||||
|
||||
@ -258,9 +258,9 @@ export class Parser {
|
||||
|
||||
private parseField(): Field {
|
||||
const name = this.reader.cstring()
|
||||
const tableID = this.reader.int32()
|
||||
const tableID = this.reader.uint32()
|
||||
const columnID = this.reader.int16()
|
||||
const dataTypeID = this.reader.int32()
|
||||
const dataTypeID = this.reader.uint32()
|
||||
const dataTypeSize = this.reader.int16()
|
||||
const dataTypeModifier = this.reader.int32()
|
||||
const mode = this.reader.int16() === 0 ? 'text' : 'binary'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user