mirror of
https://github.com/brianc/node-postgres.git
synced 2025-12-08 20:16:25 +00:00
work on executing query
This commit is contained in:
parent
7478b74d9a
commit
1ef03e27a9
25
lib/index.js
25
lib/index.js
@ -3,14 +3,15 @@ var sys = require('sys');
|
||||
var net = require('net');
|
||||
var NUL = '\0';
|
||||
|
||||
var chars = Buffer('RSKZQC','utf8');
|
||||
var chars = Buffer('RSKZQCT','utf8');
|
||||
var UTF8 = {
|
||||
R: chars[0],
|
||||
S: chars[1],
|
||||
K: chars[2],
|
||||
Z: chars[3],
|
||||
Q: chars[4],
|
||||
C: chars[5]
|
||||
C: chars[5],
|
||||
T: chars[6]
|
||||
};
|
||||
|
||||
|
||||
@ -125,6 +126,8 @@ p.parseMessage = function() {
|
||||
return this.parseZ();
|
||||
case UTF8.C:
|
||||
return this.parseC();
|
||||
case UTF8.T:
|
||||
return this.parseT();
|
||||
default:
|
||||
throw new Error("Unsupported message ID: " + Buffer([messageID]).toString('utf8') + " (" + messageID.toString(16) + ")");
|
||||
}
|
||||
@ -183,6 +186,20 @@ p.parseZ = function() {
|
||||
return msg;
|
||||
};
|
||||
|
||||
p.parseT = function() {
|
||||
var msg = this.parseStart('RowDescription');
|
||||
msg.rowCount = this.readInt16();
|
||||
msg.rows = [];
|
||||
for(var i = 0; i < msg.rowCount; i++){
|
||||
msg.rows[i] = this.parseRow();
|
||||
}
|
||||
return msg;
|
||||
};
|
||||
|
||||
p.parseRow = function() {
|
||||
return {}
|
||||
};
|
||||
|
||||
p.readInt32 = function() {
|
||||
var buffer = this.buffer;
|
||||
return ((buffer[this.offset++] << 24) +
|
||||
@ -191,6 +208,10 @@ p.readInt32 = function() {
|
||||
buffer[this.offset++]);
|
||||
};
|
||||
|
||||
p.readInt16 = function() {
|
||||
return ((this.buffer[this.offset++] << 8) + (this.buffer[this.offset++] << 0));
|
||||
};
|
||||
|
||||
p.parseLength = function() {
|
||||
return this.readInt32();
|
||||
};
|
||||
|
||||
@ -22,5 +22,8 @@ assert.equal(client.port, 321);
|
||||
client.port = 5432;
|
||||
client.connect();
|
||||
|
||||
var query = client.query('create temporary table bang (id integer)');
|
||||
|
||||
client.query('create temporary table bang (id integer)');
|
||||
client.query('insert into bang(id) VALUES(1)');
|
||||
client.query('select * from bang',function(err, results, fields) {
|
||||
assert.equal(err, null);
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user