Skip site navigation (1) Skip section navigation (2)

pgsql: Introduce jsonb, a structured format for storing json.

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Introduce jsonb, a structured format for storing json.
Date: 2014-03-23 21:17:51
Message-ID: E1WRpmB-0002et-MT@gemulon.postgresql.org (view raw or whole thread)
Thread:
Lists: pgsql-committers
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

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/d9134d0a355cfa447adc80db4505d5931084278a

Modified Files
--------------
contrib/hstore/Makefile                  |    3 +-
contrib/hstore/expected/hstore.out       |   20 +-
contrib/hstore/hstore--1.2--1.3.sql      |   17 +
contrib/hstore/hstore--1.2.sql           |  537 --------
contrib/hstore/hstore--1.3.sql           |  550 ++++++++
contrib/hstore/hstore.control            |    2 +-
contrib/hstore/hstore_io.c               |  165 +++
contrib/hstore/sql/hstore.sql            |    6 +-
doc/src/sgml/datatype.sgml               |   37 +-
doc/src/sgml/filelist.sgml               |    1 +
doc/src/sgml/func.sgml                   |  500 +++++---
doc/src/sgml/json.sgml                   |  413 ++++++
src/backend/catalog/system_views.sql     |    8 +
src/backend/utils/adt/Makefile           |   10 +-
src/backend/utils/adt/json.c             |   42 +-
src/backend/utils/adt/jsonb.c            |  468 +++++++
src/backend/utils/adt/jsonb_gin.c        |  646 ++++++++++
src/backend/utils/adt/jsonb_op.c         |  295 +++++
src/backend/utils/adt/jsonb_util.c       | 1872 +++++++++++++++++++++++++++
src/backend/utils/adt/jsonfuncs.c        | 1229 ++++++++++++++++--
src/backend/utils/adt/numeric.c          |   38 +
src/include/catalog/pg_amop.h            |   27 +
src/include/catalog/pg_amproc.h          |   13 +-
src/include/catalog/pg_cast.h            |    4 +
src/include/catalog/pg_opclass.h         |    4 +
src/include/catalog/pg_operator.h        |   37 +-
src/include/catalog/pg_opfamily.h        |    5 +
src/include/catalog/pg_proc.h            |   81 +-
src/include/catalog/pg_type.h            |    6 +
src/include/funcapi.h                    |    9 +
src/include/utils/json.h                 |   15 +
src/include/utils/jsonapi.h              |    8 +-
src/include/utils/jsonb.h                |  320 +++++
src/include/utils/numeric.h              |    1 +
src/test/regress/data/jsonb.data         | 1009 +++++++++++++++
src/test/regress/expected/json.out       |   49 +-
src/test/regress/expected/json_1.out     |   49 +-
src/test/regress/expected/jsonb.out      | 2056 ++++++++++++++++++++++++++++++
src/test/regress/expected/jsonb_1.out    | 2056 ++++++++++++++++++++++++++++++
src/test/regress/expected/opr_sanity.out |    6 +-
src/test/regress/parallel_schedule       |    3 +-
src/test/regress/serial_schedule         |    1 +
src/test/regress/sql/json.sql            |   18 +-
src/test/regress/sql/jsonb.sql           |  479 +++++++
44 files changed, 12198 insertions(+), 917 deletions(-)


Responses

pgsql-committers by date

Next:From: Thom BrownDate: 2014-03-23 22:18:42
Subject: Re: pgsql: Introduce jsonb, a structured format for storing json.
Previous:From: Greg StarkDate: 2014-03-23 16:07:54
Subject: Re: pgsql: Allow opclasses to provide tri-valued GIN consistent functions.

Privacy Policy | About PostgreSQL
Copyright © 1996-2016 The PostgreSQL Global Development Group