support for 'emptyQuery' command

This commit is contained in:
bmc 2010-10-29 21:33:53 -04:00
parent adcadd5810
commit cafded964e
3 changed files with 23 additions and 7 deletions

View File

@ -198,7 +198,8 @@ var messageNames = {
1: 'parseComplete',
2: 'bindComplete',
A: 'notification',
n: 'noData'
n: 'noData',
I: 'emptyQuery'
};
p.parseMessage = function() {
@ -334,15 +335,18 @@ p.parseE = function(msg) {
//same thing, different name
p.parseN = p.parseE;
//some messages are only a header portion and
//require no more parsing
var noParse = function(msg) { return msg; };
//parses parseComplete
p.parse1 = function(msg) {
return msg;
};
p.parse1 = noParse;
//parses bindComplete
p.parse2 = function(msg) {
return msg;
};
p.parse2 = noParse;
//parse emptyQuery
p.parseI = noParse;
p.parseA = function(msg) {
msg.processId = this.parseInt32();

View File

@ -0,0 +1,8 @@
var helper = require(__dirname+'/test-helper');
var client = helper.client();
test("empty query message handling", function() {
client.query("");
assert.raises(client.connection, 'emptyQuery');
client.on('drain', client.end.bind(client));
});

View File

@ -113,4 +113,8 @@ buffers.notification = function(id, channel, payload) {
.join(true, 'A')
};
buffers.emptyQuery = function() {
return new BufferList().join(true, 'I');
};
module.exports = buffers;