Remove hstore's text[] => text[] operator.

This is not yet in any released version, so we still have the option to
backtrack.  Instead, document hstore(text[], text[]).  Per discussion.
This commit is contained in:
Robert Haas 2010-06-15 19:48:30 +00:00
parent 3b3706d2cf
commit b17129b589
4 changed files with 77 additions and 79 deletions

View File

@ -758,36 +758,6 @@ select pg_column_size('a=>g, b=>c'::hstore || ('b'=>'gf'))
(1 row)
-- => arrays
select ARRAY['a','b','asd'] => ARRAY['g','h','i'];
?column?
--------------------------------
"a"=>"g", "b"=>"h", "asd"=>"i"
(1 row)
select ARRAY['a','b','asd'] => ARRAY['g','h',NULL];
?column?
---------------------------------
"a"=>"g", "b"=>"h", "asd"=>NULL
(1 row)
select ARRAY['z','y','x'] => ARRAY['1','2','3'];
?column?
------------------------------
"x"=>"3", "y"=>"2", "z"=>"1"
(1 row)
select ARRAY['aaa','bb','c','d'] => ARRAY[null::text,null,null,null];
?column?
-----------------------------------------------
"c"=>NULL, "d"=>NULL, "bb"=>NULL, "aaa"=>NULL
(1 row)
select ARRAY['aaa','bb','c','d'] => null;
?column?
-----------------------------------------------
"c"=>NULL, "d"=>NULL, "bb"=>NULL, "aaa"=>NULL
(1 row)
select hstore 'aa=>1, b=>2, c=>3' => ARRAY['g','h','i'];
?column?
----------
@ -812,29 +782,6 @@ select hstore 'aa=>1, b=>2, c=>3' => ARRAY['c','b','aa'];
"b"=>"2", "c"=>"3", "aa"=>"1"
(1 row)
select quote_literal('{}'::text[] => '{}'::text[]);
quote_literal
---------------
''
(1 row)
select quote_literal('{}'::text[] => null);
quote_literal
---------------
''
(1 row)
select ARRAY['a'] => '{}'::text[]; -- error
ERROR: arrays must have same bounds
select '{}'::text[] => ARRAY['a']; -- error
ERROR: arrays must have same bounds
select pg_column_size(ARRAY['a','b','asd'] => ARRAY['g','h','i'])
= pg_column_size('a=>g, b=>h, asd=>i'::hstore);
?column?
----------
t
(1 row)
select pg_column_size(hstore 'aa=>1, b=>2, c=>3' => ARRAY['c','b'])
= pg_column_size('b=>2, c=>3'::hstore);
?column?
@ -910,6 +857,60 @@ select hstore('[0:2][1:2]={{a,g},{b,h},{asd,i}}'::text[]);
"a"=>"g", "b"=>"h", "asd"=>"i"
(1 row)
-- pairs of arrays
select hstore(ARRAY['a','b','asd'], ARRAY['g','h','i']);
hstore
--------------------------------
"a"=>"g", "b"=>"h", "asd"=>"i"
(1 row)
select hstore(ARRAY['a','b','asd'], ARRAY['g','h',NULL]);
hstore
---------------------------------
"a"=>"g", "b"=>"h", "asd"=>NULL
(1 row)
select hstore(ARRAY['z','y','x'], ARRAY['1','2','3']);
hstore
------------------------------
"x"=>"3", "y"=>"2", "z"=>"1"
(1 row)
select hstore(ARRAY['aaa','bb','c','d'], ARRAY[null::text,null,null,null]);
hstore
-----------------------------------------------
"c"=>NULL, "d"=>NULL, "bb"=>NULL, "aaa"=>NULL
(1 row)
select hstore(ARRAY['aaa','bb','c','d'], null);
hstore
-----------------------------------------------
"c"=>NULL, "d"=>NULL, "bb"=>NULL, "aaa"=>NULL
(1 row)
select quote_literal(hstore('{}'::text[], '{}'::text[]));
quote_literal
---------------
''
(1 row)
select quote_literal(hstore('{}'::text[], null));
quote_literal
---------------
''
(1 row)
select hstore(ARRAY['a'], '{}'::text[]); -- error
ERROR: arrays must have same bounds
select hstore('{}'::text[], ARRAY['a']); -- error
ERROR: arrays must have same bounds
select pg_column_size(hstore(ARRAY['a','b','asd'], ARRAY['g','h','i']))
= pg_column_size('a=>g, b=>h, asd=>i'::hstore);
?column?
----------
t
(1 row)
-- records
select hstore(v) from (values (1, 'foo', 1.2, 3::float8)) v(a,b,c,d);
hstore

View File

@ -1,4 +1,4 @@
/* $PostgreSQL: pgsql/contrib/hstore/hstore.sql.in,v 1.12 2009/09/30 19:50:22 tgl Exp $ */
/* $PostgreSQL: pgsql/contrib/hstore/hstore.sql.in,v 1.13 2010/06/15 19:48:30 rhaas Exp $ */
-- Adjust this setting to control where the objects get created.
SET search_path = public;
@ -238,12 +238,6 @@ RETURNS hstore
AS 'MODULE_PATHNAME', 'hstore_from_arrays'
LANGUAGE C IMMUTABLE; -- not STRICT; allows (keys,null)
CREATE OPERATOR => (
LEFTARG = text[],
RIGHTARG = text[],
PROCEDURE = hstore
);
CREATE FUNCTION hstore(text[])
RETURNS hstore
AS 'MODULE_PATHNAME', 'hstore_from_array'

View File

@ -172,21 +172,10 @@ select pg_column_size('a=>g, b=>c'::hstore || ('b'=>'gf'))
= pg_column_size('a=>g, b=>gf'::hstore);
-- => arrays
select ARRAY['a','b','asd'] => ARRAY['g','h','i'];
select ARRAY['a','b','asd'] => ARRAY['g','h',NULL];
select ARRAY['z','y','x'] => ARRAY['1','2','3'];
select ARRAY['aaa','bb','c','d'] => ARRAY[null::text,null,null,null];
select ARRAY['aaa','bb','c','d'] => null;
select hstore 'aa=>1, b=>2, c=>3' => ARRAY['g','h','i'];
select hstore 'aa=>1, b=>2, c=>3' => ARRAY['c','b'];
select hstore 'aa=>1, b=>2, c=>3' => ARRAY['aa','b'];
select hstore 'aa=>1, b=>2, c=>3' => ARRAY['c','b','aa'];
select quote_literal('{}'::text[] => '{}'::text[]);
select quote_literal('{}'::text[] => null);
select ARRAY['a'] => '{}'::text[]; -- error
select '{}'::text[] => ARRAY['a']; -- error
select pg_column_size(ARRAY['a','b','asd'] => ARRAY['g','h','i'])
= pg_column_size('a=>g, b=>h, asd=>i'::hstore);
select pg_column_size(hstore 'aa=>1, b=>2, c=>3' => ARRAY['c','b'])
= pg_column_size('b=>2, c=>3'::hstore);
select pg_column_size(hstore 'aa=>1, b=>2, c=>3' => ARRAY['c','b','aa'])
@ -208,6 +197,19 @@ select hstore(ARRAY[[['a','g'],['b','h'],['asd','i']]]);
select hstore('[0:5]={a,g,b,h,asd,i}'::text[]);
select hstore('[0:2][1:2]={{a,g},{b,h},{asd,i}}'::text[]);
-- pairs of arrays
select hstore(ARRAY['a','b','asd'], ARRAY['g','h','i']);
select hstore(ARRAY['a','b','asd'], ARRAY['g','h',NULL]);
select hstore(ARRAY['z','y','x'], ARRAY['1','2','3']);
select hstore(ARRAY['aaa','bb','c','d'], ARRAY[null::text,null,null,null]);
select hstore(ARRAY['aaa','bb','c','d'], null);
select quote_literal(hstore('{}'::text[], '{}'::text[]));
select quote_literal(hstore('{}'::text[], null));
select hstore(ARRAY['a'], '{}'::text[]); -- error
select hstore('{}'::text[], ARRAY['a']); -- error
select pg_column_size(hstore(ARRAY['a','b','asd'], ARRAY['g','h','i']))
= pg_column_size('a=>g, b=>h, asd=>i'::hstore);
-- records
select hstore(v) from (values (1, 'foo', 1.2, 3::float8)) v(a,b,c,d);
create domain hstestdom1 as integer not null default 0;

View File

@ -1,4 +1,4 @@
<!-- $PostgreSQL: pgsql/doc/src/sgml/hstore.sgml,v 1.8 2010/02/27 04:29:44 tgl Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/hstore.sgml,v 1.9 2010/06/15 19:48:30 rhaas Exp $ -->
<sect1 id="hstore">
<title>hstore</title>
@ -120,13 +120,6 @@
<entry><literal>"a"=&gt;"b"</literal></entry>
</row>
<row>
<entry><type>text[]</> <literal>=&gt;</> <type>text[]</></entry>
<entry>construct an <type>hstore</> from separate key and value arrays</entry>
<entry><literal>ARRAY['a','b'] =&gt; ARRAY['1','2']</literal></entry>
<entry><literal>"a"=&gt;"1","b"=&gt;"2"</literal></entry>
</row>
<row>
<entry><type>hstore</> <literal>=&gt;</> <type>text[]</></entry>
<entry>extract a subset of an <type>hstore</></entry>
@ -264,6 +257,14 @@
<entry><literal>a=&gt;1, b=&gt;2, c=&gt;3, d=&gt;4</literal></entry>
</row>
<row>
<entry><function>hstore(text[], text[])</function></entry>
<entry><type>hstore</type></entry>
<entry>construct an <type>hstore</> from separate key and value arrays</entry>
<entry><literal>hstore(ARRAY['a','b'], ARRAY['1','2'])</literal></entry>
<entry><literal>"a"=&gt;"1","b"=&gt;"2"</literal></entry>
</row>
<row>
<entry><function>akeys(hstore)</function></entry>
<entry><type>text[]</type></entry>