<tbody>
<row>
- <entry><function>hstore(record)</function></entry>
+ <entry><function>hstore(record)</function><indexterm><primary>hstore</primary></indexterm></entry>
<entry><type>hstore</type></entry>
<entry>construct an <type>hstore</> from a record or row</entry>
<entry><literal>hstore(ROW(1,2))</literal></entry>
</row>
<row>
- <entry><function>akeys(hstore)</function></entry>
+ <entry><function>akeys(hstore)</function><indexterm><primary>akeys</primary></indexterm></entry>
<entry><type>text[]</type></entry>
<entry>get <type>hstore</>'s keys as an array</entry>
<entry><literal>akeys('a=>1,b=>2')</literal></entry>
</row>
<row>
- <entry><function>skeys(hstore)</function></entry>
+ <entry><function>skeys(hstore)</function><indexterm><primary>skeys</primary></indexterm></entry>
<entry><type>setof text</type></entry>
<entry>get <type>hstore</>'s keys as a set</entry>
<entry><literal>skeys('a=>1,b=>2')</literal></entry>
</row>
<row>
- <entry><function>avals(hstore)</function></entry>
+ <entry><function>avals(hstore)</function><indexterm><primary>avals</primary></indexterm></entry>
<entry><type>text[]</type></entry>
<entry>get <type>hstore</>'s values as an array</entry>
<entry><literal>avals('a=>1,b=>2')</literal></entry>
</row>
<row>
- <entry><function>svals(hstore)</function></entry>
+ <entry><function>svals(hstore)</function><indexterm><primary>svals</primary></indexterm></entry>
<entry><type>setof text</type></entry>
<entry>get <type>hstore</>'s values as a set</entry>
<entry><literal>svals('a=>1,b=>2')</literal></entry>
</row>
<row>
- <entry><function>hstore_to_array(hstore)</function></entry>
+ <entry><function>hstore_to_array(hstore)</function><indexterm><primary>hstore_to_array</primary></indexterm></entry>
<entry><type>text[]</type></entry>
<entry>get <type>hstore</>'s keys and values as an array of alternating
keys and values</entry>
</row>
<row>
- <entry><function>hstore_to_matrix(hstore)</function></entry>
+ <entry><function>hstore_to_matrix(hstore)</function><indexterm><primary>hstore_to_matrix</primary></indexterm></entry>
<entry><type>text[]</type></entry>
<entry>get <type>hstore</>'s keys and values as a two-dimensional array</entry>
<entry><literal>hstore_to_matrix('a=>1,b=>2')</literal></entry>
</row>
<row>
- <entry><function>hstore_to_json(hstore)</function></entry>
+ <entry><function>hstore_to_json(hstore)</function><indexterm><primary>hstore_to_json</primary></indexterm></entry>
<entry><type>json</type></entry>
- <entry>get <type>hstore</type> as a <type>json</type> value</entry>
+ <entry>get <type>hstore</type> as a <type>json</type> value, converting
+ all non-null values to JSON strings</entry>
<entry><literal>hstore_to_json('"a key"=>1, b=>t, c=>null, d=>12345, e=>012345, f=>1.234, g=>2.345e+4')</literal></entry>
<entry><literal>{"a key": "1", "b": "t", "c": null, "d": "12345", "e": "012345", "f": "1.234", "g": "2.345e+4"}</literal></entry>
</row>
<row>
- <entry><function>hstore_to_json_loose(hstore)</function></entry>
+ <entry><function>hstore_to_jsonb(hstore)</function><indexterm><primary>hstore_to_jsonb</primary></indexterm></entry>
+ <entry><type>jsonb</type></entry>
+ <entry>get <type>hstore</type> as a <type>jsonb</type> value, converting
+ all non-null values to JSON strings</entry>
+ <entry><literal>hstore_to_jsonb('"a key"=>1, b=>t, c=>null, d=>12345, e=>012345, f=>1.234, g=>2.345e+4')</literal></entry>
+ <entry><literal>{"a key": "1", "b": "t", "c": null, "d": "12345", "e": "012345", "f": "1.234", "g": "2.345e+4"}</literal></entry>
+ </row>
+
+ <row>
+ <entry><function>hstore_to_json_loose(hstore)</function><indexterm><primary>hstore_to_json_loose</primary></indexterm></entry>
<entry><type>json</type></entry>
- <entry>get <type>hstore</type> as a <type>json</type> value, but attempting to distinguish numerical and Boolean values so they are unquoted in the JSON</entry>
+ <entry>get <type>hstore</type> as a <type>json</type> value, but attempt to distinguish numerical and Boolean values so they are unquoted in the JSON</entry>
<entry><literal>hstore_to_json_loose('"a key"=>1, b=>t, c=>null, d=>12345, e=>012345, f=>1.234, g=>2.345e+4')</literal></entry>
<entry><literal>{"a key": 1, "b": true, "c": null, "d": 12345, "e": "012345", "f": 1.234, "g": 2.345e+4}</literal></entry>
</row>
<row>
- <entry><function>slice(hstore, text[])</function></entry>
+ <entry><function>hstore_to_jsonb_loose(hstore)</function><indexterm><primary>hstore_to_jsonb_loose</primary></indexterm></entry>
+ <entry><type>jsonb</type></entry>
+ <entry>get <type>hstore</type> as a <type>jsonb</type> value, but attempt to distinguish numerical and Boolean values so they are unquoted in the JSON</entry>
+ <entry><literal>hstore_to_jsonb_loose('"a key"=>1, b=>t, c=>null, d=>12345, e=>012345, f=>1.234, g=>2.345e+4')</literal></entry>
+ <entry><literal>{"a key": 1, "b": true, "c": null, "d": 12345, "e": "012345", "f": 1.234, "g": 2.345e+4}</literal></entry>
+ </row>
+
+ <row>
+ <entry><function>slice(hstore, text[])</function><indexterm><primary>slice</primary></indexterm></entry>
<entry><type>hstore</type></entry>
<entry>extract a subset of an <type>hstore</></entry>
<entry><literal>slice('a=>1,b=>2,c=>3'::hstore, ARRAY['b','c','x'])</literal></entry>
</row>
<row>
- <entry><function>each(hstore)</function></entry>
+ <entry><function>each(hstore)</function><indexterm><primary>each</primary></indexterm></entry>
<entry><type>setof(key text, value text)</type></entry>
<entry>get <type>hstore</>'s keys and values as a set</entry>
<entry><literal>select * from each('a=>1,b=>2')</literal></entry>
</row>
<row>
- <entry><function>exist(hstore,text)</function></entry>
+ <entry><function>exist(hstore,text)</function><indexterm><primary>exist</primary></indexterm></entry>
<entry><type>boolean</type></entry>
<entry>does <type>hstore</> contain key?</entry>
<entry><literal>exist('a=>1','a')</literal></entry>
</row>
<row>
- <entry><function>defined(hstore,text)</function></entry>
+ <entry><function>defined(hstore,text)</function><indexterm><primary>defined</primary></indexterm></entry>
<entry><type>boolean</type></entry>
<entry>does <type>hstore</> contain non-<literal>NULL</> value for key?</entry>
<entry><literal>defined('a=>NULL','a')</literal></entry>
</row>
<row>
- <entry><function>delete(hstore,text)</function></entry>
+ <entry><function>delete(hstore,text)</function><indexterm><primary>delete</primary></indexterm></entry>
<entry><type>hstore</type></entry>
<entry>delete pair with matching key</entry>
<entry><literal>delete('a=>1,b=>2','b')</literal></entry>
- <entry><literal>"a"=>"1"</literal></entry>
+ <entry><literal>"a"=>"1"</literal></entry>
</row>
<row>
<entry><type>hstore</type></entry>
<entry>delete pairs with matching keys</entry>
<entry><literal>delete('a=>1,b=>2,c=>3',ARRAY['a','b'])</literal></entry>
- <entry><literal>"c"=>"3"</literal></entry>
+ <entry><literal>"c"=>"3"</literal></entry>
</row>
<row>
<entry><type>hstore</type></entry>
<entry>delete pairs matching those in the second argument</entry>
<entry><literal>delete('a=>1,b=>2','a=>4,b=>2'::hstore)</literal></entry>
- <entry><literal>"a"=>"1"</literal></entry>
+ <entry><literal>"a"=>"1"</literal></entry>
</row>
<row>
- <entry><function>populate_record(record,hstore)</function></entry>
+ <entry><function>populate_record(record,hstore)</function><indexterm><primary>populate_record</primary></indexterm></entry>
<entry><type>record</type></entry>
<entry>replace fields in <type>record</> with matching values from <type>hstore</></entry>
<entry>see Examples section</entry>
<note>
<para>
- The function <function>hstore_to_json</function> is used when an <type>hstore</type>
- value is cast to <type>json</type>.
+ The function <function>hstore_to_json</function> is used when
+ an <type>hstore</type> value is cast to <type>json</type>.
+ Likewise, <function>hstore_to_jsonb</function> is used when
+ an <type>hstore</type> value is cast to <type>jsonb</type>.
</para>
</note>
</sect2>
+ <sect2>
+ <title>Transforms</title>
+
+ <para>
+ Additional extensions are available that implement transforms for
+ the <type>hstore</type> type for the languages PL/Perl and PL/Python. The
+ extensions for PL/Perl are called <literal>hstore_plperl</literal>
+ and <literal>hstore_plperlu</literal>, for trusted and untrusted PL/Perl.
+ If you install these transforms and specify them when creating a
+ function, <type>hstore</type> values are mapped to Perl hashes. The
+ extensions for PL/Python are
+ called <literal>hstore_plpythonu</literal>, <literal>hstore_plpython2u</literal>,
+ and <literal>hstore_plpython3u</literal>
+ (see <xref linkend="plpython-python23"> for the PL/Python naming
+ convention). If you use them, <type>hstore</type> values are mapped to
+ Python dictionaries.
+ </para>
+ </sect2>
+
<sect2>
<title>Authors</title>