Re: jsonb and nested hstore - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: jsonb and nested hstore
Date
Msg-id 20140128155004.GN10723@eldon.alvh.no-ip.org
Whole thread Raw
In response to Re: jsonb and nested hstore  (Andrew Dunstan <andrew@dunslane.net>)
Responses Re: jsonb and nested hstore  (Andrew Dunstan <andrew@dunslane.net>)
List pgsql-hackers
Andrew Dunstan wrote:

>     <para>
> +    There are two JSON data types: <type>json</type> and <type>jsonb</type>.
> +    Both accept identical sets of values as input. The difference is primarily
> +    a matter of efficiency. The <type>json</type> data type stores an exact
> +    copy of the the input text, and the processing functions have to reparse
> +    it to precess it, while the <type>jsonb</type> is stored in a decomposed
> +    form that makes it slightly less efficient to input but very much faster
> +    to process, since it never needs reparsing.
> +   </para>

typo "precess"
duplicated word "of the the input"


> +         </indexterm><indexterm>
> +          <primary>jsonb_each</primary>
> +         </indexterm><para><literal>json_each(json)</literal>
> +         </para><para><literal>jsonb_each(jsonb)</literal>
> +       </para></entry>

This SGML nesting is odd and hard to read.  Please place opening tags in
separate lines (or at least not immediately following a closing tag).  I
am not sure whether the mentions of jsonb_each vs. json_each there are
correct or typos.  This also occurs in other places.

>           Expands the object in <replaceable>from_json</replaceable> to a row whose columns match
>           the record type defined by base. Conversion will be best
>           effort; columns in base with no corresponding key in <replaceable>from_json</replaceable>
> -         will be left null. If a column is specified more than once, the last value is used.
> +         will be left null. When processing <type>json</type>, if a column is 
> +         specified more than once, the last value is used.

Maybe you also need to specify what happens with jsonb?


> diff --git a/src/backend/utils/adt/jsonb.c b/src/backend/utils/adt/jsonb.c
> new file mode 100644
> index 0000000..107ebf0
> --- /dev/null
> +++ b/src/backend/utils/adt/jsonb.c
> @@ -0,0 +1,544 @@
> +/*-------------------------------------------------------------------------
> + *
> + * jsonb.c
> + *        I/O for jsonb type
> + *
> + * Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group

2014.  Why "Portions", if we don't attribute any portion to UCB?

> + * NOTE. JSONB type is designed to be binary compatible with hstore.
> + *
> + * src/backend/utils/adt/jsonb_support.c

Typo'ed name here.

> +#include "postgres.h"
+
> +#include "libpq/pqformat.h"
> +#include "utils/builtins.h"
> +#include "utils/json.h"
> +#include "utils/jsonapi.h"
> +#include "utils/jsonb.h"



Misplaced prototype?

> +static void recvJsonb(StringInfo buf, JsonbValue *v, uint32 level, uint32 header);


Not sure about the jsonb_1.out file.  Is that only due to encoding
differences?  What happens if you run it in a completely different
encoding than whatever you tested with?  (I would assume Latin-9 and
UTF8)  If it fails, then I think you'll end up ripping those tests out,
so probably the _1.out file will have no value at all.

I also wonder if it'd be better to have one large .sql file that
produces the same output in all platforms that tests most of the common
stuff, so that tests that changes output in different platforms can have
smaller alternative expected files.

-- 
Álvaro Herrera                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: proposal: hide application_name from other users
Next
From: Andres Freund
Date:
Subject: Re: proposal: hide application_name from other users