Introduce jsonb, a structured format for storing json.

Andrew Dunstan <andrew@dunslane.net>

Commit: d9134d0a355cfa447adc80db4505d5931084278a
Author: Andrew Dunstan <andrew@dunslane.net>
Date: 2014-03-23T20:40:19Z
Releases: 9.4.0
Introduce jsonb, a structured format for storing json.

The new format accepts exactly the same data as the json type. However, it is
stored in a format that does not require reparsing the orgiginal text in order
to process it, making it much more suitable for indexing and other operations.
Insignificant whitespace is discarded, and the order of object keys is not
preserved. Neither are duplicate object keys kept - the later value for a given
key is the only one stored.

The new type has all the functions and operators that the json type has,
with the exception of the json generation functions (to_json, json_agg etc.)
and with identical semantics. In addition, there are operator classes for
hash and btree indexing, and two classes for GIN indexing, that have no
equivalent in the json type.

This feature grew out of previous work by Oleg Bartunov and Teodor Sigaev, which
was intended to provide similar facilities to a nested hstore type, but which
in the end proved to have some significant compatibility issues.

Authors: Oleg Bartunov,  Teodor Sigaev, Peter Geoghegan and Andrew Dunstan.
Review: Andres Freund

Files

PathChange+/−
contrib/hstore/expected/hstore.out modified +19 −1
contrib/hstore/hstore--1.2--1.3.sql added +17 −0
contrib/hstore/hstore--1.3.sql (from contrib/hstore/hstore--1.2.sql) renamed +14 −1
contrib/hstore/hstore.control modified +1 −1
contrib/hstore/hstore_io.c modified +165 −0
contrib/hstore/Makefile modified +2 −1
contrib/hstore/sql/hstore.sql modified +5 −1
doc/src/sgml/datatype.sgml modified +8 −29
doc/src/sgml/filelist.sgml modified +1 −0
doc/src/sgml/func.sgml modified +321 −179
doc/src/sgml/json.sgml added +413 −0
src/backend/catalog/system_views.sql modified +8 −0
src/backend/utils/adt/jsonb.c added +468 −0
src/backend/utils/adt/jsonb_gin.c added +646 −0
src/backend/utils/adt/jsonb_op.c added +295 −0
src/backend/utils/adt/jsonb_util.c added +1872 −0
src/backend/utils/adt/json.c modified +26 −16
src/backend/utils/adt/jsonfuncs.c modified +1099 −130
src/backend/utils/adt/Makefile modified +5 −5
src/backend/utils/adt/numeric.c modified +38 −0
src/include/catalog/pg_amop.h modified +27 −0
src/include/catalog/pg_amproc.h modified +12 −1
src/include/catalog/pg_cast.h modified +4 −0
src/include/catalog/pg_opclass.h modified +4 −0
src/include/catalog/pg_operator.h modified +35 −2
src/include/catalog/pg_opfamily.h modified +5 −0
src/include/catalog/pg_proc.h modified +79 −2
src/include/catalog/pg_type.h modified +6 −0
src/include/funcapi.h modified +9 −0
src/include/utils/jsonapi.h modified +7 −1
src/include/utils/jsonb.h added +320 −0
src/include/utils/json.h modified +15 −0
src/include/utils/numeric.h modified +1 −0
src/test/regress/data/jsonb.data added +1009 −0
src/test/regress/expected/json_1.out modified +46 −3
src/test/regress/expected/jsonb_1.out added +2056 −0
src/test/regress/expected/jsonb.out added +2056 −0
src/test/regress/expected/json.out modified +46 −3
src/test/regress/expected/opr_sanity.out modified +5 −1
src/test/regress/parallel_schedule modified +1 −2
src/test/regress/serial_schedule modified +1 −0
src/test/regress/sql/jsonb.sql added +479 −0
src/test/regress/sql/json.sql modified +16 −2