Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h9Vb0-0004o8-8U for pgsql-docs@arkaria.postgresql.org; Thu, 28 Mar 2019 14:01:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1h9Vay-00016k-Mm for pgsql-docs@arkaria.postgresql.org; Thu, 28 Mar 2019 14:01:28 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h9Vay-00016H-C8 for pgsql-docs@lists.postgresql.org; Thu, 28 Mar 2019 14:01:28 +0000 Received: from cyclops.postgrespro.ru ([93.174.131.138] helo=mail.postgrespro.ru) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1h9Var-0007yL-LN for pgsql-docs@lists.postgresql.org; Thu, 28 Mar 2019 14:01:28 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id 28B9821C3D0D for ; Thu, 28 Mar 2019 17:01:20 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at postgrespro.ru X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=x tagged_above=-99 required=4 WHITELISTED tests=[] autolearn=unavailable Received: from [192.168.27.64] (gw.postgrespro.ru [93.174.131.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id E7AB321C3D07 for ; Thu, 28 Mar 2019 17:01:19 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1553781679; bh=O5y5m4uxyIsmyYz6zQtI+6PPvYCLq8dke/E6icPGUDE=; h=From:Subject:To:Date; b=VAASXHq8ZpzvKl90s1SzAURik337/uVUXgr8NiqxLzHE31kkVf/HQv0eyILsDtPCi 4J4G8fJ2dSciyAYshd9rqptmOafY83WIHZ9W5Q37E9HPv6F9/R+3cFRwwnTrWq9XtJ 4pTcsxFbhm1hQNjVwSNAL7l/MF8CjLm6ykQyyzUE= From: Liudmila Mantrova Subject: improve examples for JSON functions To: pgsql-docs@lists.postgresql.org Message-ID: <1d5ae053-86ad-139e-f7a5-16dfad8dd3ba@postgrespro.ru> Date: Thu, 28 Mar 2019 17:01:19 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------F0BA3CB7B667F2A0DFA51724" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------F0BA3CB7B667F2A0DFA51724 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Hi, Please consider a small documentation patch that adds custom type definition to a couple of JSON function examples, so that they match the provided results. Previously, having "myrowtype" without a definition here could cause confusion as this type does not exist by default, and actually differs between these examples. -- Liudmila Mantrova Technical writer at Postgres Professional:http://www.postgrespro.com The Russian Postgres Company --------------F0BA3CB7B667F2A0DFA51724 Content-Type: text/x-patch; name="json-func-examples.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="json-func-examples.patch" diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 1a01473..c5ab59e 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -12614,7 +12614,10 @@ table2-mapping whose columns match the record type defined by base (see note below). - select * from json_populate_record(null::myrowtype, '{"a": 1, "b": ["2", "a b"], "c": {"d": 4, "e": "a b c"}}') + + create type myrowtype as (a int, b json, c json); + select * from json_populate_record(null::myrowtype, '{"a": 1, "b": ["2", "a b"], "c": {"d": 4, "e": "a b c"}}') + a | b | c @@ -12634,7 +12637,10 @@ table2-mapping columns match the record type defined by base (see note below). - select * from json_populate_recordset(null::myrowtype, '[{"a":1,"b":2},{"a":3,"b":4}]') + + create type myrowtype as (a int, b int); + select * from json_populate_recordset(null::myrowtype, '[{"a":1,"b":2},{"a":3,"b":4}]') as (a int, b int) + a | b @@ -12708,7 +12714,10 @@ table2-mapping explicitly define the structure of the record with an AS clause. - select * from json_to_record('{"a":1,"b":[1,2,3],"c":[1,2,3],"e":"bar","r": {"a": 123, "b": "a b c"}}') as x(a int, b text, c int[], d text, r myrowtype) + + create type myrowtype as (a int, b text); + select * from json_to_record('{"a":1,"b":[1,2,3],"c":[1,2,3],"e":"bar","r": {"a": 123, "b": "a b c"}}') as x(a int, b text, c int[], d text, r myrowtype) + a | b | c | d | r --------------F0BA3CB7B667F2A0DFA51724--