There was some nasty global-ish variable reference updating happening when the native module 'initializes' after its require with `require('pg').native`
This fixes the issue by making sure both `require('pg')` and `require('pg').native` each initialize their own context in isolation and no weird global-ish references are used & subsequently stomped on.
When a __prepared statement__ has no body in the query the backend responds with an `emptyQuery` message but never with a `commandComplete` or `errorResponse` message. The client was hanging forever waiting for one of the other two expected messages. The server was hanging forever waiting for the client to respond with a `sync` message. This change has the client send the required `sync` on receipt of an `emptyQuery` message when the query is a prepared statement. Fixes#822
This completes the port from the old native bindings to the new node-pg-native bindings!
Time to build in support for older versions of postgres & start the pull request process.
Postgres generally does not emit a SELECT tag after a SELECT query, but
it does emit that tag after a CREATE TABLE x AS SELECT query.
Example:
postgres=# create table t as select 1;
SELECT 1
End statements with semicolons, to be consistent with the surrounding
code.
Added a new unit test to ensure environment variables are honored when
parsing a
connection string.
Added a TODO to cleanup a test that emits messages using console.log().
Correct a query's syntax. Looks like a good thing to do even though the
syntax
doesn't matter in mocked out tests.
Removed a test that tests for SELECT tags; AFAIK, SELECT commands don't
emit a
tag.
Improve the code and clarity of unit tests in escape-tests.js. And
removed the related integration tests since it has been demonstrated in
the unit tests that a connection is not needed for escaping the literals
and identifiers.