Skip to content

Postgres Native bindings Segfault when querying with empty buffer #675

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 11, 2014

Conversation

brianc
Copy link
Owner

@brianc brianc commented Nov 11, 2014

var pg = require('pg').native;

pg.connect(function(err, client, done) {
  if (err) throw err;

  var c = 'CREATE TABLE IF NOT EXISTS posts (body TEXT)';

  client.query(c, function(err) {
    if (err) throw err;

    c = 'INSERT INTO posts (body) VALUES ($1)';

    var body = new Buffer('foo');
    client.query(c, [body], function(err) {
      if (err) throw err;

      console.log('inserted foo');

      body = new Buffer([]);
      client.query(c, [body], function(err) {
        done();

        if (err) throw err;

        console.log('inserted empty buffer');

        pg.end();
      });
    });
  });
});

@brianc
Copy link
Owner

brianc commented Nov 8, 2014

what version of pg do you have installed?

@L8D
Copy link
Author

L8D commented Nov 8, 2014

postgres 9.3.5_1 with node-postgres 3.5.0

tries with 3.6.2

@brianc
Copy link
Owner

brianc commented Nov 8, 2014

haha - can you try with pg@4.0.0-beta2 ? You'll also need to npm install pg-native - I completely rewrote the native bindings from scratch in the past few months & want to release them soon. 😄

@L8D
Copy link
Author

L8D commented Nov 8, 2014

segfault with pg@3.6.2

tries with 4.0.0-beta2

@brianc
Copy link
Owner

brianc commented Nov 8, 2014

haha thanks @L8D - I will consider this bug to be fixed in both branches either way - but I do appreciate you testing them for me! ❤️

@L8D
Copy link
Author

L8D commented Nov 8, 2014

Okay so pg@4.0.0-beta2 with pg-native@1.5.0 works perfect other than a new 'NOTICE' message for using IF NOT EXISTS

@brianc
Copy link
Owner

brianc commented Nov 8, 2014

OH! Can you show me the query you used to produce the notice message? I need to squash those in the new native bindings but wasn't able to figure out a query which would produce one. The queries seem to be different depending on the config level of the database & the database version. By default libpq spits the notice message to stdout, but I can catch it.

@L8D
Copy link
Author

L8D commented Nov 8, 2014

CREATE TABLE IF NOT EXISTS posts (body TEXT)

@brianc
Copy link
Owner

brianc commented Nov 8, 2014

radical. good to know it's fixed in the new version! I'll leave it open cause I'm still gonna support the old version for a while - so I'll try to fix it soon. Thanks so much for your help. 😄

@L8D
Copy link
Author

L8D commented Nov 8, 2014

I'll be going through all my older stuff to find the other segfaults with the native bindings soon.

brianc added a commit that referenced this pull request Nov 11, 2014
Postgres Native bindings Segfault when querying with empty buffer
@brianc brianc merged commit 6cb49b6 into master Nov 11, 2014
@brianc
Copy link
Owner

brianc commented Nov 11, 2014

Releasing new patch version with the fix right now!

@brianc brianc deleted the issues/675 branch November 20, 2014 03:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants