2014-05-20 21:45 GMT+02:00 Peter Geoghegan <p...@heroku.com>: > On Tue, May 20, 2014 at 12:38 PM, Pavel Stehule <pavel.steh...@gmail.com> > wrote: > > NOTICE: a:>> {"type": "Feature", "geometry": null, "properties": > {"TO_ST": > > null, "BLKLOT": "1245063", "STREET": null, "FROM_ST": null, "LOT_NUM": > > "063", "ST_TYPE": null, "ODD_EVEN": null, "BLOCK_NUM": "1245", > "MAPBLKLOT": > > "1245061"}}<<< > > NOTICE: b:>> {"type": "Feature", "geometry": {"type": "Polygon", > > "coordinates": [[[-122.476849622729347, 37.784637268897804, 0.0], > > [-122.47693599079787, 37.784633351359254, 0.0], [-122.477005086381169, > > 37.784630217263818, 0.0], [-122.477010255706205, 37.784701504178585, > 0.0], > > [-122.476590928382066, 37.784720524837788, 0.0], [-122.476585758323125, > > 37.784649237923851, 0.0], [-122.476849622729347, 37.784637268897804, > > 0.0]]]}, "properties": {"TO_ST": null, "BLKLOT": "1377060", "STREET": > null, > > "FROM_ST": null, "LOT_NUM": "060", "ST_TYPE": null, "ODD_EVEN": null, > > "BLOCK_NUM": "1377", "MAPBLKLOT": "1377060"}}<<< > > I cannot immediately reproduce the problem. > > Is this the original JSON? Can you show the psql output from a query > with a predicate that returns both jsonb datums? >
This json is printed by JsonToCString Datum jsonb_cmp(PG_FUNCTION_ARGS) { Jsonb *jba = PG_GETARG_JSONB(0); Jsonb *jbb = PG_GETARG_JSONB(1); int res; char *jba_str = JsonbToCString(NULL, &jba->root, VARSIZE(jba)); char *jbb_str = JsonbToCString(NULL, &jbb->root, VARSIZE(jbb)); elog(NOTICE, "a:>> %s<<<", jba_str); elog(NOTICE, "b:>> %s<<<", jbb_str); pfree(jba_str); pfree(jbb_str); res = compareJsonbContainers(&jba->root, &jbb->root); PG_FREE_IF_COPY(jba, 0); PG_FREE_IF_COPY(jbb, 1); PG_RETURN_INT32(res); } postgres=# select * from t3 where data->'properties'->>'MAPBLKLOT' = '1377060' and data->'properties'->>'LOT_NUM' = '060';; data ------------------------------------------------------------------------------------------------------------------------------------- { "type": "Feature", "properties": { "MAPBLKLOT": "1377060", "BLKLOT": "1377060", "BLOCK_NUM": "1377", "LOT_NUM": "060", "FROM_ST":. . null, "TO_ST": null, "STREET": null, "ST_TYPE": null, "ODD_EVEN": null }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -1. .22.476849622729347, 37.784637268897804, 0.0 ], [ -122.47693599079787, 37.784633351359254, 0.0 ], [ -122.477005086381169, 37.7846302. .17263818, 0.0 ], [ -122.477010255706205, 37.784701504178585, 0.0 ], [ -122.476590928382066, 37.784720524837788, 0.0 ], [ -122.47658. .5758323125, 37.784649237923851, 0.0 ], [ -122.476849622729347, 37.784637268897804, 0.0 ] ] ] } } (1 row) postgres=# select * from t3 where data->'properties'->>'MAPBLKLOT' = '1245061' and data->'properties'->>'LOT_NUM' = '063';; data ------------------------------------------------------------------------------------------------------------------------------------- { "type": "Feature", "properties": { "MAPBLKLOT": "1245061", "BLKLOT": "1245063", "BLOCK_NUM": "1245", "LOT_NUM": "063", "FROM_ST":. . null, "TO_ST": null, "STREET": null, "ST_TYPE": null, "ODD_EVEN": null }, "geometry": null } (1 row) table dump is downloadable from http://pgsql.cz/data/data.dump.gz Regards Pavel > > Thanks > -- > Peter Geoghegan >