brianc / node-postgres

PostgreSQL client for node.js.
https://node-postgres.com
MIT License
12.27k stars 1.22k forks source link

invalid string in message #64

Closed chowey closed 12 years ago

chowey commented 12 years ago

This just popped up starting with node v0.5.10. I am not able to get any query to work. The pg module seems to connect to the database, but it gets an error when it runs a query.

Here is some sample code that will produce this error:

var pg = require('pg'),
    util = require('util');
var connectstring = 'pg://user:password@127.0.0.1/db1';

function getTheTime() {
  pg.connect(connectstring, function (err, client) {
    if (err) util.log('Error with pg.connect!'), util.log(util.inspect(err));
    else client.query('SELECT now() as when', function (err, result) {
      if (err) util.log('Error with client.query!'), util.log(util.inspect(err));
      else util.log('The postres time is: ' + result.rows[0].when);
    });
  });
}

getTheTime();

This gives the following output:

31 Oct 13:24:35 - Error with client.query!
31 Oct 13:24:35 - { [error: invalid string in message]
  length: 100,
  name: 'error',
  severity: 'ERROR',
  code: '08P01',
  detail: undefined,
  hint: undefined,
  position: undefined,
  internalPosition: undefined,
  internalQuery: undefined,
  where: undefined,
  file: '.\\src\\backend\\libpq\\pqformat.c',
  line: '636',
  routine: 'pq_getmsgstring' }

I don't know what invalid string in message means or even where to begin looking in the module code. I tried it with postgres v8.4, and with postgres v9.0.

Per the node blog, node v0.5.10 is supposed to be the last version before node v0.6.

chowey commented 12 years ago

No worries, I upgraded to the latest version of pg and it works.