@@ -758,36 +758,6 @@ select pg_column_size('a=>g, b=>c'::hstore || ('b'=>'gf'))
758
758
(1 row)
759
759
760
760
-- => arrays
761
- select ARRAY['a','b','asd'] => ARRAY['g','h','i'];
762
- ?column?
763
- --------------------------------
764
- "a"=>"g", "b"=>"h", "asd"=>"i"
765
- (1 row)
766
-
767
- select ARRAY['a','b','asd'] => ARRAY['g','h',NULL];
768
- ?column?
769
- ---------------------------------
770
- "a"=>"g", "b"=>"h", "asd"=>NULL
771
- (1 row)
772
-
773
- select ARRAY['z','y','x'] => ARRAY['1','2','3'];
774
- ?column?
775
- ------------------------------
776
- "x"=>"3", "y"=>"2", "z"=>"1"
777
- (1 row)
778
-
779
- select ARRAY['aaa','bb','c','d'] => ARRAY[null::text,null,null,null];
780
- ?column?
781
- -----------------------------------------------
782
- "c"=>NULL, "d"=>NULL, "bb"=>NULL, "aaa"=>NULL
783
- (1 row)
784
-
785
- select ARRAY['aaa','bb','c','d'] => null;
786
- ?column?
787
- -----------------------------------------------
788
- "c"=>NULL, "d"=>NULL, "bb"=>NULL, "aaa"=>NULL
789
- (1 row)
790
-
791
761
select hstore 'aa=>1, b=>2, c=>3' => ARRAY['g','h','i'];
792
762
?column?
793
763
----------
@@ -812,29 +782,6 @@ select hstore 'aa=>1, b=>2, c=>3' => ARRAY['c','b','aa'];
812
782
"b"=>"2", "c"=>"3", "aa"=>"1"
813
783
(1 row)
814
784
815
- select quote_literal('{}'::text[] => '{}'::text[]);
816
- quote_literal
817
- ---------------
818
- ''
819
- (1 row)
820
-
821
- select quote_literal('{}'::text[] => null);
822
- quote_literal
823
- ---------------
824
- ''
825
- (1 row)
826
-
827
- select ARRAY['a'] => '{}'::text[]; -- error
828
- ERROR: arrays must have same bounds
829
- select '{}'::text[] => ARRAY['a']; -- error
830
- ERROR: arrays must have same bounds
831
- select pg_column_size(ARRAY['a','b','asd'] => ARRAY['g','h','i'])
832
- = pg_column_size('a=>g, b=>h, asd=>i'::hstore);
833
- ?column?
834
- ----------
835
- t
836
- (1 row)
837
-
838
785
select pg_column_size(hstore 'aa=>1, b=>2, c=>3' => ARRAY['c','b'])
839
786
= pg_column_size('b=>2, c=>3'::hstore);
840
787
?column?
@@ -910,6 +857,60 @@ select hstore('[0:2][1:2]={{a,g},{b,h},{asd,i}}'::text[]);
910
857
"a"=>"g", "b"=>"h", "asd"=>"i"
911
858
(1 row)
912
859
860
+ -- pairs of arrays
861
+ select hstore(ARRAY['a','b','asd'], ARRAY['g','h','i']);
862
+ hstore
863
+ --------------------------------
864
+ "a"=>"g", "b"=>"h", "asd"=>"i"
865
+ (1 row)
866
+
867
+ select hstore(ARRAY['a','b','asd'], ARRAY['g','h',NULL]);
868
+ hstore
869
+ ---------------------------------
870
+ "a"=>"g", "b"=>"h", "asd"=>NULL
871
+ (1 row)
872
+
873
+ select hstore(ARRAY['z','y','x'], ARRAY['1','2','3']);
874
+ hstore
875
+ ------------------------------
876
+ "x"=>"3", "y"=>"2", "z"=>"1"
877
+ (1 row)
878
+
879
+ select hstore(ARRAY['aaa','bb','c','d'], ARRAY[null::text,null,null,null]);
880
+ hstore
881
+ -----------------------------------------------
882
+ "c"=>NULL, "d"=>NULL, "bb"=>NULL, "aaa"=>NULL
883
+ (1 row)
884
+
885
+ select hstore(ARRAY['aaa','bb','c','d'], null);
886
+ hstore
887
+ -----------------------------------------------
888
+ "c"=>NULL, "d"=>NULL, "bb"=>NULL, "aaa"=>NULL
889
+ (1 row)
890
+
891
+ select quote_literal(hstore('{}'::text[], '{}'::text[]));
892
+ quote_literal
893
+ ---------------
894
+ ''
895
+ (1 row)
896
+
897
+ select quote_literal(hstore('{}'::text[], null));
898
+ quote_literal
899
+ ---------------
900
+ ''
901
+ (1 row)
902
+
903
+ select hstore(ARRAY['a'], '{}'::text[]); -- error
904
+ ERROR: arrays must have same bounds
905
+ select hstore('{}'::text[], ARRAY['a']); -- error
906
+ ERROR: arrays must have same bounds
907
+ select pg_column_size(hstore(ARRAY['a','b','asd'], ARRAY['g','h','i']))
908
+ = pg_column_size('a=>g, b=>h, asd=>i'::hstore);
909
+ ?column?
910
+ ----------
911
+ t
912
+ (1 row)
913
+
913
914
-- records
914
915
select hstore(v) from (values (1, 'foo', 1.2, 3::float8)) v(a,b,c,d);
915
916
hstore
0 commit comments