Skip to content

Commit ce51747

Browse files
committed
Remove hstore % text[] operator; use slice() function instead.
David Wheeler, with one small correction by me.
1 parent bb0fe9f commit ce51747

File tree

5 files changed

+33
-39
lines changed

5 files changed

+33
-39
lines changed

contrib/hstore/expected/hstore.out

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
--
55
SET client_min_messages = warning;
66
\set ECHO none
7-
psql:hstore.sql:234: WARNING: => is deprecated as an operator name
7+
psql:hstore.sql:228: WARNING: => is deprecated as an operator name
88
DETAIL: This name may be disallowed altogether in future versions of PostgreSQL.
99
RESET client_min_messages;
1010
set escape_string_warning=off;
@@ -759,39 +759,39 @@ select pg_column_size('a=>g, b=>c'::hstore || ('b'=>'gf'))
759759
t
760760
(1 row)
761761

762-
-- %
763-
select hstore 'aa=>1, b=>2, c=>3' % ARRAY['g','h','i'];
764-
?column?
765-
----------
762+
-- slice()
763+
select slice(hstore 'aa=>1, b=>2, c=>3', ARRAY['g','h','i']);
764+
slice
765+
-------
766766

767767
(1 row)
768768

769-
select hstore 'aa=>1, b=>2, c=>3' % ARRAY['c','b'];
770-
?column?
769+
select slice(hstore 'aa=>1, b=>2, c=>3', ARRAY['c','b']);
770+
slice
771771
--------------------
772772
"b"=>"2", "c"=>"3"
773773
(1 row)
774774

775-
select hstore 'aa=>1, b=>2, c=>3' % ARRAY['aa','b'];
776-
?column?
775+
select slice(hstore 'aa=>1, b=>2, c=>3', ARRAY['aa','b']);
776+
slice
777777
---------------------
778778
"b"=>"2", "aa"=>"1"
779779
(1 row)
780780

781-
select hstore 'aa=>1, b=>2, c=>3' % ARRAY['c','b','aa'];
782-
?column?
781+
select slice(hstore 'aa=>1, b=>2, c=>3', ARRAY['c','b','aa']);
782+
slice
783783
-------------------------------
784784
"b"=>"2", "c"=>"3", "aa"=>"1"
785785
(1 row)
786786

787-
select pg_column_size(hstore 'aa=>1, b=>2, c=>3' % ARRAY['c','b'])
787+
select pg_column_size(slice(hstore 'aa=>1, b=>2, c=>3', ARRAY['c','b']))
788788
= pg_column_size('b=>2, c=>3'::hstore);
789789
?column?
790790
----------
791791
t
792792
(1 row)
793793

794-
select pg_column_size(hstore 'aa=>1, b=>2, c=>3' % ARRAY['c','b','aa'])
794+
select pg_column_size(slice(hstore 'aa=>1, b=>2, c=>3', ARRAY['c','b','aa']))
795795
= pg_column_size('aa=>1, b=>2, c=>3'::hstore);
796796
?column?
797797
----------

contrib/hstore/hstore.sql.in

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/contrib/hstore/hstore.sql.in,v 1.14 2010/06/18 03:52:02 rhaas Exp $ */
1+
/* $PostgreSQL: pgsql/contrib/hstore/hstore.sql.in,v 1.15 2010/07/02 20:36:48 rhaas Exp $ */
22

33
-- Adjust this setting to control where the objects get created.
44
SET search_path = public;
@@ -61,17 +61,11 @@ CREATE OPERATOR -> (
6161
PROCEDURE = slice_array
6262
);
6363

64-
CREATE OR REPLACE FUNCTION slice_hstore(hstore,text[])
64+
CREATE OR REPLACE FUNCTION slice(hstore,text[])
6565
RETURNS hstore
6666
AS 'MODULE_PATHNAME','hstore_slice_to_hstore'
6767
LANGUAGE C STRICT IMMUTABLE;
6868

69-
CREATE OPERATOR % (
70-
LEFTARG = hstore,
71-
RIGHTARG = text[],
72-
PROCEDURE = slice_hstore
73-
);
74-
7569
CREATE OR REPLACE FUNCTION isexists(hstore,text)
7670
RETURNS bool
7771
AS 'MODULE_PATHNAME','hstore_exists'

contrib/hstore/sql/hstore.sql

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -171,14 +171,14 @@ select pg_column_size(('b'=>'gf'))
171171
select pg_column_size('a=>g, b=>c'::hstore || ('b'=>'gf'))
172172
= pg_column_size('a=>g, b=>gf'::hstore);
173173

174-
-- %
175-
select hstore 'aa=>1, b=>2, c=>3' % ARRAY['g','h','i'];
176-
select hstore 'aa=>1, b=>2, c=>3' % ARRAY['c','b'];
177-
select hstore 'aa=>1, b=>2, c=>3' % ARRAY['aa','b'];
178-
select hstore 'aa=>1, b=>2, c=>3' % ARRAY['c','b','aa'];
179-
select pg_column_size(hstore 'aa=>1, b=>2, c=>3' % ARRAY['c','b'])
174+
-- slice()
175+
select slice(hstore 'aa=>1, b=>2, c=>3', ARRAY['g','h','i']);
176+
select slice(hstore 'aa=>1, b=>2, c=>3', ARRAY['c','b']);
177+
select slice(hstore 'aa=>1, b=>2, c=>3', ARRAY['aa','b']);
178+
select slice(hstore 'aa=>1, b=>2, c=>3', ARRAY['c','b','aa']);
179+
select pg_column_size(slice(hstore 'aa=>1, b=>2, c=>3', ARRAY['c','b']))
180180
= pg_column_size('b=>2, c=>3'::hstore);
181-
select pg_column_size(hstore 'aa=>1, b=>2, c=>3' % ARRAY['c','b','aa'])
181+
select pg_column_size(slice(hstore 'aa=>1, b=>2, c=>3', ARRAY['c','b','aa']))
182182
= pg_column_size('aa=>1, b=>2, c=>3'::hstore);
183183

184184
-- array input

contrib/hstore/uninstall_hstore.sql

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/contrib/hstore/uninstall_hstore.sql,v 1.10 2010/06/18 03:52:02 rhaas Exp $ */
1+
/* $PostgreSQL: pgsql/contrib/hstore/uninstall_hstore.sql,v 1.11 2010/07/02 20:36:48 rhaas Exp $ */
22

33
-- Adjust this setting to control where the objects get dropped.
44
SET search_path = public;
@@ -22,7 +22,6 @@ DROP OPERATOR <@ ( hstore, hstore );
2222
DROP OPERATOR @ ( hstore, hstore );
2323
DROP OPERATOR ~ ( hstore, hstore );
2424
DROP OPERATOR => ( text, text );
25-
DROP OPERATOR % ( hstore, text[] );
2625
DROP OPERATOR #= ( anyelement, hstore );
2726
DROP OPERATOR %% ( NONE, hstore );
2827
DROP OPERATOR %# ( NONE, hstore );
@@ -44,7 +43,7 @@ DROP FUNCTION hstore_le(hstore,hstore);
4443
DROP FUNCTION hstore_cmp(hstore,hstore);
4544
DROP FUNCTION hstore_hash(hstore);
4645
DROP FUNCTION slice_array(hstore,text[]);
47-
DROP FUNCTION slice_hstore(hstore,text[]);
46+
DROP FUNCTION slice(hstore,text[]);
4847
DROP FUNCTION fetchval(hstore,text);
4948
DROP FUNCTION isexists(hstore,text);
5049
DROP FUNCTION exist(hstore,text);

doc/src/sgml/hstore.sgml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/hstore.sgml,v 1.11 2010/06/22 11:36:16 rhaas Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/hstore.sgml,v 1.12 2010/07/02 20:36:49 rhaas Exp $ -->
22

33
<sect1 id="hstore">
44
<title>hstore</title>
@@ -120,13 +120,6 @@
120120
<entry><literal>"a"=&gt;"b"</literal></entry>
121121
</row>
122122

123-
<row>
124-
<entry><type>hstore</> <literal>%</> <type>text[]</></entry>
125-
<entry>extract a subset of an <type>hstore</></entry>
126-
<entry><literal>'a=&gt;1,b=&gt;2,c=&gt;3'::hstore % ARRAY['b','c','x']</literal></entry>
127-
<entry><literal>"b"=&gt;"2", "c"=&gt;"3"</literal></entry>
128-
</row>
129-
130123
<row>
131124
<entry><type>hstore</> <literal>||</> <type>hstore</></entry>
132125
<entry>concatenate <type>hstore</>s</entry>
@@ -338,6 +331,14 @@ b
338331
<entry><literal>{{a,1},{b,2}}</literal></entry>
339332
</row>
340333

334+
<row>
335+
<entry><function>slice(hstore, text[])</function></entry>
336+
<entry><type>hstore</type></entry>
337+
<entry>extract a subset of an <type>hstore</></entry>
338+
<entry><literal>slice('a=&gt;1,b=&gt;2,c=&gt;3'::hstore, ARRAY['b','c','x'])</literal></entry>
339+
<entry><literal>"b"=&gt;"2", "c"=&gt;"3"</literal></entry>
340+
</row>
341+
341342
<row>
342343
<entry><function>each(hstore)</function></entry>
343344
<entry><type>setof(key text, value text)</type></entry>

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy