-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed
Description
I've simplified my postgres function to illustrate an unexpected result. Here is how to recreate the scenario:
CREATE DOMAIN route AS bytea CHECK(length(value) <= 8);
CREATE DOMAIN rand AS bytea CHECK(length(value) <=8);
CREATE TYPE rkey AS ( route route, rand rand, created bigint );
CREATE OR REPLACE FUNCTION rkeytohex( Prkey rkey )
RETURNS TEXT AS $$
SELECT lower( (Prkey).route ||':'|| (Prkey).rand ||':'|| to_hex((Prkey).created) );
$$ LANGUAGE SQL VOLATILE;
CREATE OR REPLACE FUNCTION test_1356 () RETURNS json AS $$
BEGIN
RETURN json_build_array('0:0:0',rkeytohex('(0,0,0)'::rkey));
END;
$$ LANGUAGE plpgsql;
Executing test_1356 in psql or pgadmin returns json as expected:
[ "0:0:0", "0:0:0" ]
via nodepostgres I get:
[ '0:0:0', '\\x303a303a0' ]
Stepping through code (in connection.js), I saw that it seems that is what is indeed emitted from the postgres server. It looks like some kind of escaping that is not being managed by node-postgres but is being handled by psql and pgadmin. And, I suspect, it seems it has something to do with the domain and types I've created although I'm not returning types as my function rkeytohex returns text... it's odd.
Metadata
Metadata
Assignees
Labels
No labels