-- delete
select delete('a=>1 , b=>2, c=>3'::hstore, 'a');
- delete
-----------------
- "b"=>2, "c"=>3
+ delete
+--------------------
+ "b"=>"2", "c"=>"3"
(1 row)
select delete('a=>null , b=>2, c=>3'::hstore, 'a');
- delete
-----------------
- "b"=>2, "c"=>3
+ delete
+--------------------
+ "b"=>"2", "c"=>"3"
(1 row)
select delete('a=>1 , b=>2, c=>3'::hstore, 'b');
- delete
-----------------
- "a"=>1, "c"=>3
+ delete
+--------------------
+ "a"=>"1", "c"=>"3"
(1 row)
select delete('a=>1 , b=>2, c=>3'::hstore, 'c');
- delete
-----------------
- "a"=>1, "b"=>2
+ delete
+--------------------
+ "a"=>"1", "b"=>"2"
(1 row)
select delete('a=>1 , b=>2, c=>3'::hstore, 'd');
- delete
-------------------------
- "a"=>1, "b"=>2, "c"=>3
+ delete
+------------------------------
+ "a"=>"1", "b"=>"2", "c"=>"3"
(1 row)
select 'a=>1 , b=>2, c=>3'::hstore - 'a'::text;
- ?column?
-----------------
- "b"=>2, "c"=>3
+ ?column?
+--------------------
+ "b"=>"2", "c"=>"3"
(1 row)
select 'a=>null , b=>2, c=>3'::hstore - 'a'::text;
- ?column?
-----------------
- "b"=>2, "c"=>3
+ ?column?
+--------------------
+ "b"=>"2", "c"=>"3"
(1 row)
select 'a=>1 , b=>2, c=>3'::hstore - 'b'::text;
- ?column?
-----------------
- "a"=>1, "c"=>3
+ ?column?
+--------------------
+ "a"=>"1", "c"=>"3"
(1 row)
select 'a=>1 , b=>2, c=>3'::hstore - 'c'::text;
- ?column?
-----------------
- "a"=>1, "b"=>2
+ ?column?
+--------------------
+ "a"=>"1", "b"=>"2"
(1 row)
select 'a=>1 , b=>2, c=>3'::hstore - 'd'::text;
- ?column?
-------------------------
- "a"=>1, "b"=>2, "c"=>3
+ ?column?
+------------------------------
+ "a"=>"1", "b"=>"2", "c"=>"3"
(1 row)
select pg_column_size('a=>1 , b=>2, c=>3'::hstore - 'b'::text)
-- delete (array)
select delete('a=>1 , b=>2, c=>3'::hstore, ARRAY['d','e']);
- delete
-------------------------
- "a"=>1, "b"=>2, "c"=>3
+ delete
+------------------------------
+ "a"=>"1", "b"=>"2", "c"=>"3"
(1 row)
select delete('a=>1 , b=>2, c=>3'::hstore, ARRAY['d','b']);
- delete
-----------------
- "a"=>1, "c"=>3
+ delete
+--------------------
+ "a"=>"1", "c"=>"3"
(1 row)
select delete('a=>1 , b=>2, c=>3'::hstore, ARRAY['a','c']);
- delete
---------
- "b"=>2
+ delete
+----------
+ "b"=>"2"
(1 row)
select delete('a=>1 , b=>2, c=>3'::hstore, ARRAY[['b'],['c'],['a']]);
(1 row)
select delete('a=>1 , b=>2, c=>3'::hstore, '{}'::text[]);
- delete
-------------------------
- "a"=>1, "b"=>2, "c"=>3
+ delete
+------------------------------
+ "a"=>"1", "b"=>"2", "c"=>"3"
(1 row)
select 'a=>1 , b=>2, c=>3'::hstore - ARRAY['d','e'];
- ?column?
-------------------------
- "a"=>1, "b"=>2, "c"=>3
+ ?column?
+------------------------------
+ "a"=>"1", "b"=>"2", "c"=>"3"
(1 row)
select 'a=>1 , b=>2, c=>3'::hstore - ARRAY['d','b'];
- ?column?
-----------------
- "a"=>1, "c"=>3
+ ?column?
+--------------------
+ "a"=>"1", "c"=>"3"
(1 row)
select 'a=>1 , b=>2, c=>3'::hstore - ARRAY['a','c'];
?column?
----------
- "b"=>2
+ "b"=>"2"
(1 row)
select 'a=>1 , b=>2, c=>3'::hstore - ARRAY[['b'],['c'],['a']];
(1 row)
select 'a=>1 , b=>2, c=>3'::hstore - '{}'::text[];
- ?column?
-------------------------
- "a"=>1, "b"=>2, "c"=>3
+ ?column?
+------------------------------
+ "a"=>"1", "b"=>"2", "c"=>"3"
(1 row)
select pg_column_size('a=>1 , b=>2, c=>3'::hstore - ARRAY['a','c'])
-- delete (hstore)
select delete('aa=>1 , b=>2, c=>3'::hstore, 'aa=>4, b=>2'::hstore);
- delete
------------------
- "c"=>3, "aa"=>1
+ delete
+---------------------
+ "c"=>"3", "aa"=>"1"
(1 row)
select delete('aa=>1 , b=>2, c=>3'::hstore, 'aa=>NULL, c=>3'::hstore);
- delete
------------------
- "b"=>2, "aa"=>1
+ delete
+---------------------
+ "b"=>"2", "aa"=>"1"
(1 row)
select delete('aa=>1 , b=>2, c=>3'::hstore, 'aa=>1, b=>2, c=>3'::hstore);
(1 row)
select delete('aa=>1 , b=>2, c=>3'::hstore, 'b=>2'::hstore);
- delete
------------------
- "c"=>3, "aa"=>1
+ delete
+---------------------
+ "c"=>"3", "aa"=>"1"
(1 row)
select delete('aa=>1 , b=>2, c=>3'::hstore, ''::hstore);
- delete
--------------------------
- "b"=>2, "c"=>3, "aa"=>1
+ delete
+-------------------------------
+ "b"=>"2", "c"=>"3", "aa"=>"1"
(1 row)
select 'aa=>1 , b=>2, c=>3'::hstore - 'aa=>4, b=>2'::hstore;
- ?column?
------------------
- "c"=>3, "aa"=>1
+ ?column?
+---------------------
+ "c"=>"3", "aa"=>"1"
(1 row)
select 'aa=>1 , b=>2, c=>3'::hstore - 'aa=>NULL, c=>3'::hstore;
- ?column?
------------------
- "b"=>2, "aa"=>1
+ ?column?
+---------------------
+ "b"=>"2", "aa"=>"1"
(1 row)
select 'aa=>1 , b=>2, c=>3'::hstore - 'aa=>1, b=>2, c=>3'::hstore;
(1 row)
select 'aa=>1 , b=>2, c=>3'::hstore - 'b=>2'::hstore;
- ?column?
------------------
- "c"=>3, "aa"=>1
+ ?column?
+---------------------
+ "c"=>"3", "aa"=>"1"
(1 row)
select 'aa=>1 , b=>2, c=>3'::hstore - ''::hstore;
- ?column?
--------------------------
- "b"=>2, "c"=>3, "aa"=>1
+ ?column?
+-------------------------------
+ "b"=>"2", "c"=>"3", "aa"=>"1"
(1 row)
select pg_column_size('a=>1 , b=>2, c=>3'::hstore - 'b=>2'::hstore)
-- ||
select 'aa=>1 , b=>2, cq=>3'::hstore || 'cq=>l, b=>g, fg=>f';
- ?column?
----------------------------------------
- "b"=>"g", "aa"=>1, "cq"=>"l", "fg"=>f
+ ?column?
+-------------------------------------------
+ "b"=>"g", "aa"=>"1", "cq"=>"l", "fg"=>"f"
(1 row)
select 'aa=>1 , b=>2, cq=>3'::hstore || 'aq=>l';
- ?column?
--------------------------------------
- "b"=>2, "aa"=>1, "aq"=>"l", "cq"=>3
+ ?column?
+-------------------------------------------
+ "b"=>"2", "aa"=>"1", "aq"=>"l", "cq"=>"3"
(1 row)
select 'aa=>1 , b=>2, cq=>3'::hstore || 'aa=>l';
- ?column?
-----------------------------
- "b"=>2, "aa"=>"l", "cq"=>3
+ ?column?
+--------------------------------
+ "b"=>"2", "aa"=>"l", "cq"=>"3"
(1 row)
select 'aa=>1 , b=>2, cq=>3'::hstore || '';
- ?column?
---------------------------
- "b"=>2, "aa"=>1, "cq"=>3
+ ?column?
+--------------------------------
+ "b"=>"2", "aa"=>"1", "cq"=>"3"
(1 row)
select ''::hstore || 'cq=>l, b=>g, fg=>f';
- ?column?
-------------------------------
- "b"=>"g", "cq"=>"l", "fg"=>f
+ ?column?
+--------------------------------
+ "b"=>"g", "cq"=>"l", "fg"=>"f"
(1 row)
select pg_column_size(''::hstore || ''::hstore) = pg_column_size(''::hstore);
(1 row)
select slice(hstore 'aa=>1, b=>2, c=>3', ARRAY['c','b']);
- slice
-----------------
- "b"=>2, "c"=>3
+ slice
+--------------------
+ "b"=>"2", "c"=>"3"
(1 row)
select slice(hstore 'aa=>1, b=>2, c=>3', ARRAY['aa','b']);
- slice
------------------
- "b"=>2, "aa"=>1
+ slice
+---------------------
+ "b"=>"2", "aa"=>"1"
(1 row)
select slice(hstore 'aa=>1, b=>2, c=>3', ARRAY['c','b','aa']);
- slice
--------------------------
- "b"=>2, "c"=>3, "aa"=>1
+ slice
+-------------------------------
+ "b"=>"2", "c"=>"3", "aa"=>"1"
(1 row)
select pg_column_size(slice(hstore 'aa=>1, b=>2, c=>3', ARRAY['c','b']))
-- records
select hstore(v) from (values (1, 'foo', 1.2, 3::float8)) v(a,b,c,d);
- hstore
---------------------------------------
- "a"=>1, "b"=>"foo", "c"=>1.2, "d"=>3
+ hstore
+--------------------------------------------
+ "a"=>"1", "b"=>"foo", "c"=>"1.2", "d"=>"3"
(1 row)
create domain hstestdom1 as integer not null default 0;
insert into testhstore0 values (1, 'foo', 1.2, 3::float8);
insert into testhstore1 values (1, 'foo', 1.2, 3::float8);
select hstore(v) from testhstore1 v;
- hstore
-----------------------------------------------
- "a"=>1, "b"=>"foo", "c"=>1.2, "d"=>3, "e"=>0
+ hstore
+------------------------------------------------------
+ "a"=>"1", "b"=>"foo", "c"=>"1.2", "d"=>"3", "e"=>"0"
(1 row)
select hstore(null::testhstore0);
(1 row)
select pg_column_size(hstore(v))
- = pg_column_size('a=>1, b=>"foo", c=>1.2, d=>3, e=>0'::hstore)
+ = pg_column_size('a=>1, b=>"foo", c=>"1.2", d=>"3", e=>"0"'::hstore)
from testhstore1 v;
?column?
----------
drop index hidx;
-- json
select hstore_to_json('"a key" =>1, b => t, c => null, d=> 12345, e => 012345, f=> 1.234, g=> 2.345e+4');
- hstore_to_json
-------------------------------------------------------------------------------------
- {"b": true, "c": null, "d": 12345, "e": 12345, "f": 1.234, "g": 23450, "a key": 1}
+ hstore_to_json
+-------------------------------------------------------------------------------------------------
+ {"b": "t", "c": null, "d": "12345", "e": "012345", "f": "1.234", "g": "2.345e+4", "a key": "1"}
(1 row)
select cast( hstore '"a key" =>1, b => t, c => null, d=> 12345, e => 012345, f=> 1.234, g=> 2.345e+4' as json);
- json
-------------------------------------------------------------------------------------
- {"b": true, "c": null, "d": 12345, "e": 12345, "f": 1.234, "g": 23450, "a key": 1}
+ json
+-------------------------------------------------------------------------------------------------
+ {"b": "t", "c": null, "d": "12345", "e": "012345", "f": "1.234", "g": "2.345e+4", "a key": "1"}
(1 row)
select hstore_to_json_loose('"a key" =>1, b => t, c => null, d=> 12345, e => 012345, f=> 1.234, g=> 2.345e+4');
- hstore_to_json_loose
-------------------------------------------------------------------------------------
- {"b": true, "c": null, "d": 12345, "e": 12345, "f": 1.234, "g": 23450, "a key": 1}
+ hstore_to_json_loose
+------------------------------------------------------------------------------------------
+ {"b": true, "c": null, "d": 12345, "e": "012345", "f": 1.234, "g": 2.345e+4, "a key": 1}
(1 row)
create table test_json_agg (f1 text, f2 hstore);
insert into test_json_agg values ('rec1','"a key" =>1, b => t, c => null, d=> 12345, e => 012345, f=> 1.234, g=> 2.345e+4'),
('rec2','"a key" =>2, b => f, c => "null", d=> -12345, e => 012345.6, f=> -1.234, g=> 0.345e-4');
select json_agg(q) from test_json_agg q;
- json_agg
---------------------------------------------------------------------------------------------------------------------
- [{"f1":"rec1","f2":{"b": true, "c": null, "d": 12345, "e": 12345, "f": 1.234, "g": 23450, "a key": 1}}, +
- {"f1":"rec2","f2":{"b": false, "c": "null", "d": -12345, "e": 12345.6, "f": -1.234, "g": 0.0000345, "a key": 2}}]
+ json_agg
+----------------------------------------------------------------------------------------------------------------------------
+ [{"f1":"rec1","f2":{"b": "t", "c": null, "d": "12345", "e": "012345", "f": "1.234", "g": "2.345e+4", "a key": "1"}}, +
+ {"f1":"rec2","f2":{"b": "f", "c": "null", "d": "-12345", "e": "012345.6", "f": "-1.234", "g": "0.345e-4", "a key": "2"}}]
(1 row)
select json_agg(q) from (select f1, hstore_to_json_loose(f2) as f2 from test_json_agg) q;
- json_agg
---------------------------------------------------------------------------------------------------------------------
- [{"f1":"rec1","f2":{"b": true, "c": null, "d": 12345, "e": 12345, "f": 1.234, "g": 23450, "a key": 1}}, +
- {"f1":"rec2","f2":{"b": false, "c": "null", "d": -12345, "e": 12345.6, "f": -1.234, "g": 0.0000345, "a key": 2}}]
+ json_agg
+----------------------------------------------------------------------------------------------------------------------
+ [{"f1":"rec1","f2":{"b": true, "c": null, "d": 12345, "e": "012345", "f": 1.234, "g": 2.345e+4, "a key": 1}}, +
+ {"f1":"rec2","f2":{"b": false, "c": "null", "d": -12345, "e": "012345.6", "f": -1.234, "g": 0.345e-4, "a key": 2}}]
(1 row)