Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XJreN-0008EI-CU for pgsql-bugs@arkaria.postgresql.org; Tue, 19 Aug 2014 22:13:07 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XJreM-0000qC-RE for pgsql-bugs@arkaria.postgresql.org; Tue, 19 Aug 2014 22:13:06 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XJgyR-0005Af-7K for pgsql-bugs@postgresql.org; Tue, 19 Aug 2014 10:49:07 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XJgyN-0007ra-H0 for pgsql-bugs@postgresql.org; Tue, 19 Aug 2014 10:49:05 +0000 MIME-Version: 1.0 Subject: BUG #11210: Limit on Query causes error or no JSON labels in output To: pgsql-bugs@postgresql.org From: rqmedes@gmail.com Date: Tue, 19 Aug 2014 10:48:59 +0000 Message-ID: <20140819104859.2544.49278@wrigleys.postgresql.org> X-Pg-Spam-Score: -0.3 (/) Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org The following bug has been logged on the website: Bug reference: 11210 Logged by: darryl Email address: rqmedes@gmail.com PostgreSQL version: 9.3.5 Operating system: Windows Description: -- Does not show labels for json. when a limit is used. -- To replicate CREATE SCHEMA test32 ; SET search_path = test32, pg_catalog, public; CREATE SEQUENCE _id INCREMENT 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1003480 CACHE 1; CREATE TABLE item ( id integer NOT NULL DEFAULT nextval('test32._id'::regclass), code text, name text NOT NULL, ttype text ) WITH ( OIDS=FALSE ); CREATE TABLE _inventory ( id integer NOT NULL DEFAULT nextval('test32._id'::regclass), name text NOT NULL, ttype text DEFAULT 'inventory'::text ) INHERITS (item) WITH ( OIDS=FALSE ); CREATE TABLE _service ( id integer NOT NULL DEFAULT nextval('test32._id'::regclass), name text NOT NULL, ttype text DEFAULT 'service'::text ) INHERITS (item) WITH ( OIDS=FALSE ); INSERT INTO _inventory (id, name) VALUES (1002376,'test32'); INSERT INTO _service (id, name) VALUES (1001498, 'Service1'); /* Labels missing from json output when LIMIT IS added. In version 9.3.5 -- FAILS WHEN LIMIT IS ADDED -- Select row_to_json(_r) from ( select true as success,array_agg(row_to_json(result)) as rows from (Select _0."id" as "[id]" , _0."name" as "[name]" From "item" _0 Limit 10 OFFSET 0) result ) _r ; OUTPUT = {"success":true,"rows":[{"":1002376,"":"test32"},{"":1001498,"":"Service1"}]} EXPECTED OUTPUT = {"success":true,"rows":[{"[id]":1002376,"[name]":"test32"},{"[id]":1001498,"[name]":"Service1"}]} -- WORKS WITH NO LIMIT Select row_to_json(_r) from ( select true as success,array_agg(row_to_json(result)) as rows from (Select _0."id" as "[id]" , _0."name" as "[name]" From "item" _0 ) result ) _r ; OUTPUT = {"success":true,"rows":[{"[id]":1002376,"[name]":"test32"},{"[id]":1001498,"[name]":"Service1"}]} In version 9.3.5 the limit causes the query to return json with blank labels, IN version 9.3.4 the limit causes the query to fail with an error of. ERROR: record type has not been registered ********** Error ********** ERROR: record type has not been registered SQL state: 42809 -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs