mirror of
https://github.com/brianc/node-postgres.git
synced 2025-12-08 20:16:25 +00:00
removed last Buffer.copy from outgoing packet construction
This commit is contained in:
parent
da34dab55e
commit
ab76f648b8
@ -75,21 +75,12 @@ p.startup = function(config) {
|
||||
|
||||
p.password = function(password) {
|
||||
//0x70 = 'p'
|
||||
this.send(0x70, this.writer.addCString(password).flush());
|
||||
this._send(0x70, this.writer.addCString(password));
|
||||
};
|
||||
|
||||
p.send = function(code, bodyBuffer) {
|
||||
var length = bodyBuffer.length + 4;
|
||||
var buffer = Buffer(length + 1);
|
||||
var offset = 0;
|
||||
buffer[offset++] = code;
|
||||
buffer[offset++] = length >>> 24 & 0xFF;
|
||||
buffer[offset++] = length >>> 16 & 0xFF;
|
||||
buffer[offset++] = length >>> 8 & 0xFF;
|
||||
buffer[offset++] = length >>> 0 & 0xFF;
|
||||
bodyBuffer.copy(buffer, offset, 0);
|
||||
return this.stream.write(buffer);
|
||||
};
|
||||
p._send = function(code, writer) {
|
||||
return this.stream.write(writer.flush(code));
|
||||
}
|
||||
|
||||
var termBuffer = new Buffer([0x58, 0, 0, 0, 4]);
|
||||
p.end = function() {
|
||||
@ -98,7 +89,7 @@ p.end = function() {
|
||||
|
||||
p.query = function(text) {
|
||||
//0x51 = Q
|
||||
this.send(0x51, this.writer.addCString(text).flush());
|
||||
this.stream.write(this.writer.addCString(text).flush(0x51));
|
||||
};
|
||||
|
||||
p.parse = function(query) {
|
||||
@ -121,7 +112,7 @@ p.parse = function(query) {
|
||||
}
|
||||
|
||||
//0x50 = 'P'
|
||||
this.send(0x50, buffer.flush());
|
||||
this._send(0x50, buffer);
|
||||
|
||||
return this;
|
||||
};
|
||||
@ -150,7 +141,8 @@ p.bind = function(config) {
|
||||
}
|
||||
buffer.addInt16(0); //no format codes, use text
|
||||
//0x42 = 'B'
|
||||
this.send(0x42, buffer.flush());
|
||||
|
||||
this._send(0x42, buffer);
|
||||
};
|
||||
|
||||
p.execute = function(config) {
|
||||
@ -159,30 +151,31 @@ p.execute = function(config) {
|
||||
config.rows = config.rows || '';
|
||||
var buffer = this.writer
|
||||
.addCString(config.portal)
|
||||
.addInt32(config.rows)
|
||||
.flush();
|
||||
|
||||
.addInt32(config.rows);
|
||||
|
||||
//0x45 = 'E'
|
||||
this.send(0x45, buffer);
|
||||
this._send(0x45, buffer);
|
||||
};
|
||||
|
||||
var emptyBuffer = Buffer(0);
|
||||
|
||||
p.flush = function() {
|
||||
//0x48 = 'H'
|
||||
this.send(0x48,Buffer(0));
|
||||
this._send(0x48,this.writer.add(emptyBuffer));
|
||||
}
|
||||
|
||||
p.sync = function() {
|
||||
//0x53 = 'S'
|
||||
this.send(0x53, Buffer(0));
|
||||
this._send(0x53, this.writer.add(emptyBuffer));
|
||||
};
|
||||
|
||||
p.end = function() {
|
||||
//0x58 = 'X'
|
||||
this.send(0x58, Buffer(0));
|
||||
this._send(0x58, this.writer.add(emptyBuffer));
|
||||
};
|
||||
|
||||
p.describe = function(msg) {
|
||||
this.send(0x44, this.writer.addCString(msg.type + (msg.name || '')).flush());
|
||||
this._send(0x44, this.writer.addCString(msg.type + (msg.name || '')));
|
||||
};
|
||||
|
||||
//parsing methods
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user