Debian Codegraph @

contrib/hstore/expected/hstore.out

raw
1 CREATE EXTENSION hstore;
2 -- Check whether any of our opclasses fail amvalidate
3 SELECT amname, opcname
4 FROM pg_opclass opc LEFT JOIN pg_am am ON am.oid = opcmethod
5 WHERE opc.oid >= 16384 AND NOT amvalidate(opc.oid);
6 amname | opcname
7 --------+---------
8 (0 rows)
9
10 set escape_string_warning=off;
11 --hstore;
12 select ''::hstore;
13 hstore
14 --------
15
16 (1 row)
17
18 select 'a=>b'::hstore;
19 hstore
20 ----------
21 "a"=>"b"
22 (1 row)
23
24 select ' a=>b'::hstore;
25 hstore
26 ----------
27 "a"=>"b"
28 (1 row)
29
30 select 'a =>b'::hstore;
31 hstore
32 ----------
33 "a"=>"b"
34 (1 row)
35
36 select 'a=>b '::hstore;
37 hstore
38 ----------
39 "a"=>"b"
40 (1 row)
41
42 select 'a=> b'::hstore;
43 hstore
44 ----------
45 "a"=>"b"
46 (1 row)
47
48 select '"a"=>"b"'::hstore;
49 hstore
50 ----------
51 "a"=>"b"
52 (1 row)
53
54 select ' "a"=>"b"'::hstore;
55 hstore
56 ----------
57 "a"=>"b"
58 (1 row)
59
60 select '"a" =>"b"'::hstore;
61 hstore
62 ----------
63 "a"=>"b"
64 (1 row)
65
66 select '"a"=>"b" '::hstore;
67 hstore
68 ----------
69 "a"=>"b"
70 (1 row)
71
72 select '"a"=> "b"'::hstore;
73 hstore
74 ----------
75 "a"=>"b"
76 (1 row)
77
78 select 'aa=>bb'::hstore;
79 hstore
80 ------------
81 "aa"=>"bb"
82 (1 row)
83
84 select ' aa=>bb'::hstore;
85 hstore
86 ------------
87 "aa"=>"bb"
88 (1 row)
89
90 select 'aa =>bb'::hstore;
91 hstore
92 ------------
93 "aa"=>"bb"
94 (1 row)
95
96 select 'aa=>bb '::hstore;
97 hstore
98 ------------
99 "aa"=>"bb"
100 (1 row)
101
102 select 'aa=> bb'::hstore;
103 hstore
104 ------------
105 "aa"=>"bb"
106 (1 row)
107
108 select '"aa"=>"bb"'::hstore;
109 hstore
110 ------------
111 "aa"=>"bb"
112 (1 row)
113
114 select ' "aa"=>"bb"'::hstore;
115 hstore
116 ------------
117 "aa"=>"bb"
118 (1 row)
119
120 select '"aa" =>"bb"'::hstore;
121 hstore
122 ------------
123 "aa"=>"bb"
124 (1 row)
125
126 select '"aa"=>"bb" '::hstore;
127 hstore
128 ------------
129 "aa"=>"bb"
130 (1 row)
131
132 select '"aa"=> "bb"'::hstore;
133 hstore
134 ------------
135 "aa"=>"bb"
136 (1 row)
137
138 select 'aa=>bb, cc=>dd'::hstore;
139 hstore
140 ------------------------
141 "aa"=>"bb", "cc"=>"dd"
142 (1 row)
143
144 select 'aa=>bb , cc=>dd'::hstore;
145 hstore
146 ------------------------
147 "aa"=>"bb", "cc"=>"dd"
148 (1 row)
149
150 select 'aa=>bb ,cc=>dd'::hstore;
151 hstore
152 ------------------------
153 "aa"=>"bb", "cc"=>"dd"
154 (1 row)
155
156 select 'aa=>bb, "cc"=>dd'::hstore;
157 hstore
158 ------------------------
159 "aa"=>"bb", "cc"=>"dd"
160 (1 row)
161
162 select 'aa=>bb , "cc"=>dd'::hstore;
163 hstore
164 ------------------------
165 "aa"=>"bb", "cc"=>"dd"
166 (1 row)
167
168 select 'aa=>bb ,"cc"=>dd'::hstore;
169 hstore
170 ------------------------
171 "aa"=>"bb", "cc"=>"dd"
172 (1 row)
173
174 select 'aa=>"bb", cc=>dd'::hstore;
175 hstore
176 ------------------------
177 "aa"=>"bb", "cc"=>"dd"
178 (1 row)
179
180 select 'aa=>"bb" , cc=>dd'::hstore;
181 hstore
182 ------------------------
183 "aa"=>"bb", "cc"=>"dd"
184 (1 row)
185
186 select 'aa=>"bb" ,cc=>dd'::hstore;
187 hstore
188 ------------------------
189 "aa"=>"bb", "cc"=>"dd"
190 (1 row)
191
192 select 'aa=>null'::hstore;
193 hstore
194 ------------
195 "aa"=>NULL
196 (1 row)
197
198 select 'aa=>NuLl'::hstore;
199 hstore
200 ------------
201 "aa"=>NULL
202 (1 row)
203
204 select 'aa=>"NuLl"'::hstore;
205 hstore
206 --------------
207 "aa"=>"NuLl"
208 (1 row)
209
210 select e'\\=a=>q=w'::hstore;
211 hstore
212 -------------
213 "=a"=>"q=w"
214 (1 row)
215
216 select e'"=a"=>q\\=w'::hstore;
217 hstore
218 -------------
219 "=a"=>"q=w"
220 (1 row)
221
222 select e'"\\"a"=>q>w'::hstore;
223 hstore
224 --------------
225 "\"a"=>"q>w"
226 (1 row)
227
228 select e'\\"a=>q"w'::hstore;
229 hstore
230 ---------------
231 "\"a"=>"q\"w"
232 (1 row)
233
234 select ''::hstore;
235 hstore
236 --------
237
238 (1 row)
239
240 select ' '::hstore;
241 hstore
242 --------
243
244 (1 row)
245
246 -- invalid input
247 select ' =>null'::hstore;
248 ERROR: syntax error in hstore, near "=" at position 2
249 LINE 1: select ' =>null'::hstore;
250 ^
251 select 'aa=>"'::hstore;
252 ERROR: syntax error in hstore: unexpected end of string
253 LINE 1: select 'aa=>"'::hstore;
254 ^
255 -- also try it with non-error-throwing API
256 select pg_input_is_valid('a=>b', 'hstore');
257 pg_input_is_valid
258 -------------------
259 t
260 (1 row)
261
262 select pg_input_is_valid('a=b', 'hstore');
263 pg_input_is_valid
264 -------------------
265 f
266 (1 row)
267
268 select * from pg_input_error_info('a=b', 'hstore');
269 message | detail | hint | sql_error_code
270 ------------------------------------------------+--------+------+----------------
271 syntax error in hstore, near "b" at position 2 | | | 42601
272 (1 row)
273
274 select * from pg_input_error_info(' =>b', 'hstore');
275 message | detail | hint | sql_error_code
276 ------------------------------------------------+--------+------+----------------
277 syntax error in hstore, near "=" at position 1 | | | 42601
278 (1 row)
279
280 -- -> operator
281 select 'aa=>b, c=>d , b=>16'::hstore->'c';
282 ?column?
283 ----------
284 d
285 (1 row)
286
287 select 'aa=>b, c=>d , b=>16'::hstore->'b';
288 ?column?
289 ----------
290 16
291 (1 row)
292
293 select 'aa=>b, c=>d , b=>16'::hstore->'aa';
294 ?column?
295 ----------
296 b
297 (1 row)
298
299 select ('aa=>b, c=>d , b=>16'::hstore->'gg') is null;
300 ?column?
301 ----------
302 t
303 (1 row)
304
305 select ('aa=>NULL, c=>d , b=>16'::hstore->'aa') is null;
306 ?column?
307 ----------
308 t
309 (1 row)
310
311 select ('aa=>"NULL", c=>d , b=>16'::hstore->'aa') is null;
312 ?column?
313 ----------
314 f
315 (1 row)
316
317 -- -> array operator
318 select 'aa=>"NULL", c=>d , b=>16'::hstore -> ARRAY['aa','c'];
319 ?column?
320 ------------
321 {"NULL",d}
322 (1 row)
323
324 select 'aa=>"NULL", c=>d , b=>16'::hstore -> ARRAY['c','aa'];
325 ?column?
326 ------------
327 {d,"NULL"}
328 (1 row)
329
330 select 'aa=>NULL, c=>d , b=>16'::hstore -> ARRAY['aa','c',null];
331 ?column?
332 ---------------
333 {NULL,d,NULL}
334 (1 row)
335
336 select 'aa=>1, c=>3, b=>2, d=>4'::hstore -> ARRAY[['b','d'],['aa','c']];
337 ?column?
338 ---------------
339 {{2,4},{1,3}}
340 (1 row)
341
342 -- exists/defined
343 select exist('a=>NULL, b=>qq', 'a');
344 exist
345 -------
346 t
347 (1 row)
348
349 select exist('a=>NULL, b=>qq', 'b');
350 exist
351 -------
352 t
353 (1 row)
354
355 select exist('a=>NULL, b=>qq', 'c');
356 exist
357 -------
358 f
359 (1 row)
360
361 select exist('a=>"NULL", b=>qq', 'a');
362 exist
363 -------
364 t
365 (1 row)
366
367 select defined('a=>NULL, b=>qq', 'a');
368 defined
369 ---------
370 f
371 (1 row)
372
373 select defined('a=>NULL, b=>qq', 'b');
374 defined
375 ---------
376 t
377 (1 row)
378
379 select defined('a=>NULL, b=>qq', 'c');
380 defined
381 ---------
382 f
383 (1 row)
384
385 select defined('a=>"NULL", b=>qq', 'a');
386 defined
387 ---------
388 t
389 (1 row)
390
391 select hstore 'a=>NULL, b=>qq' ? 'a';
392 ?column?
393 ----------
394 t
395 (1 row)
396
397 select hstore 'a=>NULL, b=>qq' ? 'b';
398 ?column?
399 ----------
400 t
401 (1 row)
402
403 select hstore 'a=>NULL, b=>qq' ? 'c';
404 ?column?
405 ----------
406 f
407 (1 row)
408
409 select hstore 'a=>"NULL", b=>qq' ? 'a';
410 ?column?
411 ----------
412 t
413 (1 row)
414
415 select hstore 'a=>NULL, b=>qq' ?| ARRAY['a','b'];
416 ?column?
417 ----------
418 t
419 (1 row)
420
421 select hstore 'a=>NULL, b=>qq' ?| ARRAY['b','a'];
422 ?column?
423 ----------
424 t
425 (1 row)
426
427 select hstore 'a=>NULL, b=>qq' ?| ARRAY['c','a'];
428 ?column?
429 ----------
430 t
431 (1 row)
432
433 select hstore 'a=>NULL, b=>qq' ?| ARRAY['c','d'];
434 ?column?
435 ----------
436 f
437 (1 row)
438
439 select hstore 'a=>NULL, b=>qq' ?| '{}'::text[];
440 ?column?
441 ----------
442 f
443 (1 row)
444
445 select hstore 'a=>NULL, b=>qq' ?& ARRAY['a','b'];
446 ?column?
447 ----------
448 t
449 (1 row)
450
451 select hstore 'a=>NULL, b=>qq' ?& ARRAY['b','a'];
452 ?column?
453 ----------
454 t
455 (1 row)
456
457 select hstore 'a=>NULL, b=>qq' ?& ARRAY['c','a'];
458 ?column?
459 ----------
460 f
461 (1 row)
462
463 select hstore 'a=>NULL, b=>qq' ?& ARRAY['c','d'];
464 ?column?
465 ----------
466 f
467 (1 row)
468
469 select hstore 'a=>NULL, b=>qq' ?& '{}'::text[];
470 ?column?
471 ----------
472 t
473 (1 row)
474
475 -- delete
476 select delete('a=>1 , b=>2, c=>3'::hstore, 'a');
477 delete
478 --------------------
479 "b"=>"2", "c"=>"3"
480 (1 row)
481
482 select delete('a=>null , b=>2, c=>3'::hstore, 'a');
483 delete
484 --------------------
485 "b"=>"2", "c"=>"3"
486 (1 row)
487
488 select delete('a=>1 , b=>2, c=>3'::hstore, 'b');
489 delete
490 --------------------
491 "a"=>"1", "c"=>"3"
492 (1 row)
493
494 select delete('a=>1 , b=>2, c=>3'::hstore, 'c');
495 delete
496 --------------------
497 "a"=>"1", "b"=>"2"
498 (1 row)
499
500 select delete('a=>1 , b=>2, c=>3'::hstore, 'd');
501 delete
502 ------------------------------
503 "a"=>"1", "b"=>"2", "c"=>"3"
504 (1 row)
505
506 select 'a=>1 , b=>2, c=>3'::hstore - 'a'::text;
507 ?column?
508 --------------------
509 "b"=>"2", "c"=>"3"
510 (1 row)
511
512 select 'a=>null , b=>2, c=>3'::hstore - 'a'::text;
513 ?column?
514 --------------------
515 "b"=>"2", "c"=>"3"
516 (1 row)
517
518 select 'a=>1 , b=>2, c=>3'::hstore - 'b'::text;
519 ?column?
520 --------------------
521 "a"=>"1", "c"=>"3"
522 (1 row)
523
524 select 'a=>1 , b=>2, c=>3'::hstore - 'c'::text;
525 ?column?
526 --------------------
527 "a"=>"1", "b"=>"2"
528 (1 row)
529
530 select 'a=>1 , b=>2, c=>3'::hstore - 'd'::text;
531 ?column?
532 ------------------------------
533 "a"=>"1", "b"=>"2", "c"=>"3"
534 (1 row)
535
536 select pg_column_size('a=>1 , b=>2, c=>3'::hstore - 'b'::text)
537 = pg_column_size('a=>1, b=>2'::hstore);
538 ?column?
539 ----------
540 t
541 (1 row)
542
543 -- delete (array)
544 select delete('a=>1 , b=>2, c=>3'::hstore, ARRAY['d','e']);
545 delete
546 ------------------------------
547 "a"=>"1", "b"=>"2", "c"=>"3"
548 (1 row)
549
550 select delete('a=>1 , b=>2, c=>3'::hstore, ARRAY['d','b']);
551 delete
552 --------------------
553 "a"=>"1", "c"=>"3"
554 (1 row)
555
556 select delete('a=>1 , b=>2, c=>3'::hstore, ARRAY['a','c']);
557 delete
558 ----------
559 "b"=>"2"
560 (1 row)
561
562 select delete('a=>1 , b=>2, c=>3'::hstore, ARRAY[['b'],['c'],['a']]);
563 delete
564 --------
565
566 (1 row)
567
568 select delete('a=>1 , b=>2, c=>3'::hstore, '{}'::text[]);
569 delete
570 ------------------------------
571 "a"=>"1", "b"=>"2", "c"=>"3"
572 (1 row)
573
574 select 'a=>1 , b=>2, c=>3'::hstore - ARRAY['d','e'];
575 ?column?
576 ------------------------------
577 "a"=>"1", "b"=>"2", "c"=>"3"
578 (1 row)
579
580 select 'a=>1 , b=>2, c=>3'::hstore - ARRAY['d','b'];
581 ?column?
582 --------------------
583 "a"=>"1", "c"=>"3"
584 (1 row)
585
586 select 'a=>1 , b=>2, c=>3'::hstore - ARRAY['a','c'];
587 ?column?
588 ----------
589 "b"=>"2"
590 (1 row)
591
592 select 'a=>1 , b=>2, c=>3'::hstore - ARRAY[['b'],['c'],['a']];
593 ?column?
594 ----------
595
596 (1 row)
597
598 select 'a=>1 , b=>2, c=>3'::hstore - '{}'::text[];
599 ?column?
600 ------------------------------
601 "a"=>"1", "b"=>"2", "c"=>"3"
602 (1 row)
603
604 select pg_column_size('a=>1 , b=>2, c=>3'::hstore - ARRAY['a','c'])
605 = pg_column_size('b=>2'::hstore);
606 ?column?
607 ----------
608 t
609 (1 row)
610
611 select pg_column_size('a=>1 , b=>2, c=>3'::hstore - '{}'::text[])
612 = pg_column_size('a=>1, b=>2, c=>3'::hstore);
613 ?column?
614 ----------
615 t
616 (1 row)
617
618 -- delete (hstore)
619 select delete('aa=>1 , b=>2, c=>3'::hstore, 'aa=>4, b=>2'::hstore);
620 delete
621 ---------------------
622 "c"=>"3", "aa"=>"1"
623 (1 row)
624
625 select delete('aa=>1 , b=>2, c=>3'::hstore, 'aa=>NULL, c=>3'::hstore);
626 delete
627 ---------------------
628 "b"=>"2", "aa"=>"1"
629 (1 row)
630
631 select delete('aa=>1 , b=>2, c=>3'::hstore, 'aa=>1, b=>2, c=>3'::hstore);
632 delete
633 --------
634
635 (1 row)
636
637 select delete('aa=>1 , b=>2, c=>3'::hstore, 'b=>2'::hstore);
638 delete
639 ---------------------
640 "c"=>"3", "aa"=>"1"
641 (1 row)
642
643 select delete('aa=>1 , b=>2, c=>3'::hstore, ''::hstore);
644 delete
645 -------------------------------
646 "b"=>"2", "c"=>"3", "aa"=>"1"
647 (1 row)
648
649 select 'aa=>1 , b=>2, c=>3'::hstore - 'aa=>4, b=>2'::hstore;
650 ?column?
651 ---------------------
652 "c"=>"3", "aa"=>"1"
653 (1 row)
654
655 select 'aa=>1 , b=>2, c=>3'::hstore - 'aa=>NULL, c=>3'::hstore;
656 ?column?
657 ---------------------
658 "b"=>"2", "aa"=>"1"
659 (1 row)
660
661 select 'aa=>1 , b=>2, c=>3'::hstore - 'aa=>1, b=>2, c=>3'::hstore;
662 ?column?
663 ----------
664
665 (1 row)
666
667 select 'aa=>1 , b=>2, c=>3'::hstore - 'b=>2'::hstore;
668 ?column?
669 ---------------------
670 "c"=>"3", "aa"=>"1"
671 (1 row)
672
673 select 'aa=>1 , b=>2, c=>3'::hstore - ''::hstore;
674 ?column?
675 -------------------------------
676 "b"=>"2", "c"=>"3", "aa"=>"1"
677 (1 row)
678
679 select pg_column_size('a=>1 , b=>2, c=>3'::hstore - 'b=>2'::hstore)
680 = pg_column_size('a=>1, c=>3'::hstore);
681 ?column?
682 ----------
683 t
684 (1 row)
685
686 select pg_column_size('a=>1 , b=>2, c=>3'::hstore - ''::hstore)
687 = pg_column_size('a=>1, b=>2, c=>3'::hstore);
688 ?column?
689 ----------
690 t
691 (1 row)
692
693 -- ||
694 select 'aa=>1 , b=>2, cq=>3'::hstore || 'cq=>l, b=>g, fg=>f';
695 ?column?
696 -------------------------------------------
697 "b"=>"g", "aa"=>"1", "cq"=>"l", "fg"=>"f"
698 (1 row)
699
700 select 'aa=>1 , b=>2, cq=>3'::hstore || 'aq=>l';
701 ?column?
702 -------------------------------------------
703 "b"=>"2", "aa"=>"1", "aq"=>"l", "cq"=>"3"
704 (1 row)
705
706 select 'aa=>1 , b=>2, cq=>3'::hstore || 'aa=>l';
707 ?column?
708 --------------------------------
709 "b"=>"2", "aa"=>"l", "cq"=>"3"
710 (1 row)
711
712 select 'aa=>1 , b=>2, cq=>3'::hstore || '';
713 ?column?
714 --------------------------------
715 "b"=>"2", "aa"=>"1", "cq"=>"3"
716 (1 row)
717
718 select ''::hstore || 'cq=>l, b=>g, fg=>f';
719 ?column?
720 --------------------------------
721 "b"=>"g", "cq"=>"l", "fg"=>"f"
722 (1 row)
723
724 select pg_column_size(''::hstore || ''::hstore) = pg_column_size(''::hstore);
725 ?column?
726 ----------
727 t
728 (1 row)
729
730 select pg_column_size('aa=>1'::hstore || 'b=>2'::hstore)
731 = pg_column_size('aa=>1, b=>2'::hstore);
732 ?column?
733 ----------
734 t
735 (1 row)
736
737 select pg_column_size('aa=>1, b=>2'::hstore || ''::hstore)
738 = pg_column_size('aa=>1, b=>2'::hstore);
739 ?column?
740 ----------
741 t
742 (1 row)
743
744 select pg_column_size(''::hstore || 'aa=>1, b=>2'::hstore)
745 = pg_column_size('aa=>1, b=>2'::hstore);
746 ?column?
747 ----------
748 t
749 (1 row)
750
751 -- hstore(text,text)
752 select 'a=>g, b=>c'::hstore || hstore('asd', 'gf');
753 ?column?
754 ---------------------------------
755 "a"=>"g", "b"=>"c", "asd"=>"gf"
756 (1 row)
757
758 select 'a=>g, b=>c'::hstore || hstore('b', 'gf');
759 ?column?
760 ---------------------
761 "a"=>"g", "b"=>"gf"
762 (1 row)
763
764 select 'a=>g, b=>c'::hstore || hstore('b', 'NULL');
765 ?column?
766 -----------------------
767 "a"=>"g", "b"=>"NULL"
768 (1 row)
769
770 select 'a=>g, b=>c'::hstore || hstore('b', NULL);
771 ?column?
772 ---------------------
773 "a"=>"g", "b"=>NULL
774 (1 row)
775
776 select ('a=>g, b=>c'::hstore || hstore(NULL, 'b')) is null;
777 ?column?
778 ----------
779 t
780 (1 row)
781
782 select pg_column_size(hstore('b', 'gf'))
783 = pg_column_size('b=>gf'::hstore);
784 ?column?
785 ----------
786 t
787 (1 row)
788
789 select pg_column_size('a=>g, b=>c'::hstore || hstore('b', 'gf'))
790 = pg_column_size('a=>g, b=>gf'::hstore);
791 ?column?
792 ----------
793 t
794 (1 row)
795
796 -- slice()
797 select slice(hstore 'aa=>1, b=>2, c=>3', ARRAY['g','h','i']);
798 slice
799 -------
800
801 (1 row)
802
803 select slice(hstore 'aa=>1, b=>2, c=>3', ARRAY['c','b']);
804 slice
805 --------------------
806 "b"=>"2", "c"=>"3"
807 (1 row)
808
809 select slice(hstore 'aa=>1, b=>2, c=>3', ARRAY['aa','b']);
810 slice
811 ---------------------
812 "b"=>"2", "aa"=>"1"
813 (1 row)
814
815 select slice(hstore 'aa=>1, b=>2, c=>3', ARRAY['c','b','aa']);
816 slice
817 -------------------------------
818 "b"=>"2", "c"=>"3", "aa"=>"1"
819 (1 row)
820
821 select pg_column_size(slice(hstore 'aa=>1, b=>2, c=>3', ARRAY['c','b']))
822 = pg_column_size('b=>2, c=>3'::hstore);
823 ?column?
824 ----------
825 t
826 (1 row)
827
828 select pg_column_size(slice(hstore 'aa=>1, b=>2, c=>3', ARRAY['c','b','aa']))
829 = pg_column_size('aa=>1, b=>2, c=>3'::hstore);
830 ?column?
831 ----------
832 t
833 (1 row)
834
835 -- array input
836 select '{}'::text[]::hstore;
837 hstore
838 --------
839
840 (1 row)
841
842 select ARRAY['a','g','b','h','asd']::hstore;
843 ERROR: array must have even number of elements
844 select ARRAY['a','g','b','h','asd','i']::hstore;
845 array
846 --------------------------------
847 "a"=>"g", "b"=>"h", "asd"=>"i"
848 (1 row)
849
850 select ARRAY[['a','g'],['b','h'],['asd','i']]::hstore;
851 array
852 --------------------------------
853 "a"=>"g", "b"=>"h", "asd"=>"i"
854 (1 row)
855
856 select ARRAY[['a','g','b'],['h','asd','i']]::hstore;
857 ERROR: array must have two columns
858 select ARRAY[[['a','g'],['b','h'],['asd','i']]]::hstore;
859 ERROR: wrong number of array subscripts
860 select hstore('{}'::text[]);
861 hstore
862 --------
863
864 (1 row)
865
866 select hstore(ARRAY['a','g','b','h','asd']);
867 ERROR: array must have even number of elements
868 select hstore(ARRAY['a','g','b','h','asd','i']);
869 hstore
870 --------------------------------
871 "a"=>"g", "b"=>"h", "asd"=>"i"
872 (1 row)
873
874 select hstore(ARRAY[['a','g'],['b','h'],['asd','i']]);
875 hstore
876 --------------------------------
877 "a"=>"g", "b"=>"h", "asd"=>"i"
878 (1 row)
879
880 select hstore(ARRAY[['a','g','b'],['h','asd','i']]);
881 ERROR: array must have two columns
882 select hstore(ARRAY[[['a','g'],['b','h'],['asd','i']]]);
883 ERROR: wrong number of array subscripts
884 select hstore('[0:5]={a,g,b,h,asd,i}'::text[]);
885 hstore
886 --------------------------------
887 "a"=>"g", "b"=>"h", "asd"=>"i"
888 (1 row)
889
890 select hstore('[0:2][1:2]={{a,g},{b,h},{asd,i}}'::text[]);
891 hstore
892 --------------------------------
893 "a"=>"g", "b"=>"h", "asd"=>"i"
894 (1 row)
895
896 -- pairs of arrays
897 select hstore(ARRAY['a','b','asd'], ARRAY['g','h','i']);
898 hstore
899 --------------------------------
900 "a"=>"g", "b"=>"h", "asd"=>"i"
901 (1 row)
902
903 select hstore(ARRAY['a','b','asd'], ARRAY['g','h',NULL]);
904 hstore
905 ---------------------------------
906 "a"=>"g", "b"=>"h", "asd"=>NULL
907 (1 row)
908
909 select hstore(ARRAY['z','y','x'], ARRAY['1','2','3']);
910 hstore
911 ------------------------------
912 "x"=>"3", "y"=>"2", "z"=>"1"
913 (1 row)
914
915 select hstore(ARRAY['aaa','bb','c','d'], ARRAY[null::text,null,null,null]);
916 hstore
917 -----------------------------------------------
918 "c"=>NULL, "d"=>NULL, "bb"=>NULL, "aaa"=>NULL
919 (1 row)
920
921 select hstore(ARRAY['aaa','bb','c','d'], null);
922 hstore
923 -----------------------------------------------
924 "c"=>NULL, "d"=>NULL, "bb"=>NULL, "aaa"=>NULL
925 (1 row)
926
927 select quote_literal(hstore('{}'::text[], '{}'::text[]));
928 quote_literal
929 ---------------
930 ''
931 (1 row)
932
933 select quote_literal(hstore('{}'::text[], null));
934 quote_literal
935 ---------------
936 ''
937 (1 row)
938
939 select hstore(ARRAY['a'], '{}'::text[]); -- error
940 ERROR: arrays must have same bounds
941 select hstore('{}'::text[], ARRAY['a']); -- error
942 ERROR: arrays must have same bounds
943 select pg_column_size(hstore(ARRAY['a','b','asd'], ARRAY['g','h','i']))
944 = pg_column_size('a=>g, b=>h, asd=>i'::hstore);
945 ?column?
946 ----------
947 t
948 (1 row)
949
950 -- records
951 select hstore(v) from (values (1, 'foo', 1.2, 3::float8)) v(a,b,c,d);
952 hstore
953 --------------------------------------------
954 "a"=>"1", "b"=>"foo", "c"=>"1.2", "d"=>"3"
955 (1 row)
956
957 create domain hstestdom1 as integer not null default 0;
958 create table testhstore0 (a integer, b text, c numeric, d float8);
959 create table testhstore1 (a integer, b text, c numeric, d float8, e hstestdom1);
960 insert into testhstore0 values (1, 'foo', 1.2, 3::float8);
961 insert into testhstore1 values (1, 'foo', 1.2, 3::float8);
962 select hstore(v) from testhstore1 v;
963 hstore
964 ------------------------------------------------------
965 "a"=>"1", "b"=>"foo", "c"=>"1.2", "d"=>"3", "e"=>"0"
966 (1 row)
967
968 select hstore(null::testhstore0);
969 hstore
970 --------------------------------------------
971 "a"=>NULL, "b"=>NULL, "c"=>NULL, "d"=>NULL
972 (1 row)
973
974 select hstore(null::testhstore1);
975 hstore
976 -------------------------------------------------------
977 "a"=>NULL, "b"=>NULL, "c"=>NULL, "d"=>NULL, "e"=>NULL
978 (1 row)
979
980 select pg_column_size(hstore(v))
981 = pg_column_size('a=>1, b=>"foo", c=>"1.2", d=>"3", e=>"0"'::hstore)
982 from testhstore1 v;
983 ?column?
984 ----------
985 t
986 (1 row)
987
988 select populate_record(v, hstore('c', '3.45')) from testhstore1 v;
989 populate_record
990 ------------------
991 (1,foo,3.45,3,0)
992 (1 row)
993
994 select populate_record(v, hstore('d', '3.45')) from testhstore1 v;
995 populate_record
996 --------------------
997 (1,foo,1.2,3.45,0)
998 (1 row)
999
1000 select populate_record(v, hstore('e', '123')) from testhstore1 v;
1001 populate_record
1002 -------------------
1003 (1,foo,1.2,3,123)
1004 (1 row)
1005
1006 select populate_record(v, hstore('e', null)) from testhstore1 v;
1007 ERROR: domain hstestdom1 does not allow null values
1008 select populate_record(v, hstore('c', null)) from testhstore1 v;
1009 populate_record
1010 -----------------
1011 (1,foo,,3,0)
1012 (1 row)
1013
1014 select populate_record(v, hstore('b', 'foo') || hstore('a', '123')) from testhstore1 v;
1015 populate_record
1016 -------------------
1017 (123,foo,1.2,3,0)
1018 (1 row)
1019
1020 select populate_record(v, hstore('b', 'foo') || hstore('e', null)) from testhstore0 v;
1021 populate_record
1022 -----------------
1023 (1,foo,1.2,3)
1024 (1 row)
1025
1026 select populate_record(v, hstore('b', 'foo') || hstore('e', null)) from testhstore1 v;
1027 ERROR: domain hstestdom1 does not allow null values
1028 select populate_record(v, '') from testhstore0 v;
1029 populate_record
1030 -----------------
1031 (1,foo,1.2,3)
1032 (1 row)
1033
1034 select populate_record(v, '') from testhstore1 v;
1035 populate_record
1036 -----------------
1037 (1,foo,1.2,3,0)
1038 (1 row)
1039
1040 select populate_record(null::testhstore1, hstore('c', '3.45') || hstore('a', '123'));
1041 ERROR: domain hstestdom1 does not allow null values
1042 select populate_record(null::testhstore1, hstore('c', '3.45') || hstore('e', '123'));
1043 populate_record
1044 -----------------
1045 (,,3.45,,123)
1046 (1 row)
1047
1048 select populate_record(null::testhstore0, '');
1049 populate_record
1050 -----------------
1051 (,,,)
1052 (1 row)
1053
1054 select populate_record(null::testhstore1, '');
1055 ERROR: domain hstestdom1 does not allow null values
1056 select v #= hstore('c', '3.45') from testhstore1 v;
1057 ?column?
1058 ------------------
1059 (1,foo,3.45,3,0)
1060 (1 row)
1061
1062 select v #= hstore('d', '3.45') from testhstore1 v;
1063 ?column?
1064 --------------------
1065 (1,foo,1.2,3.45,0)
1066 (1 row)
1067
1068 select v #= hstore('e', '123') from testhstore1 v;
1069 ?column?
1070 -------------------
1071 (1,foo,1.2,3,123)
1072 (1 row)
1073
1074 select v #= hstore('c', null) from testhstore1 v;
1075 ?column?
1076 --------------
1077 (1,foo,,3,0)
1078 (1 row)
1079
1080 select v #= hstore('e', null) from testhstore0 v;
1081 ?column?
1082 ---------------
1083 (1,foo,1.2,3)
1084 (1 row)
1085
1086 select v #= hstore('e', null) from testhstore1 v;
1087 ERROR: domain hstestdom1 does not allow null values
1088 select v #= (hstore('b', 'foo') || hstore('a', '123')) from testhstore1 v;
1089 ?column?
1090 -------------------
1091 (123,foo,1.2,3,0)
1092 (1 row)
1093
1094 select v #= (hstore('b', 'foo') || hstore('e', '123')) from testhstore1 v;
1095 ?column?
1096 -------------------
1097 (1,foo,1.2,3,123)
1098 (1 row)
1099
1100 select v #= hstore '' from testhstore0 v;
1101 ?column?
1102 ---------------
1103 (1,foo,1.2,3)
1104 (1 row)
1105
1106 select v #= hstore '' from testhstore1 v;
1107 ?column?
1108 -----------------
1109 (1,foo,1.2,3,0)
1110 (1 row)
1111
1112 select null::testhstore1 #= (hstore('c', '3.45') || hstore('a', '123'));
1113 ERROR: domain hstestdom1 does not allow null values
1114 select null::testhstore1 #= (hstore('c', '3.45') || hstore('e', '123'));
1115 ?column?
1116 ---------------
1117 (,,3.45,,123)
1118 (1 row)
1119
1120 select null::testhstore0 #= hstore '';
1121 ?column?
1122 ----------
1123 (,,,)
1124 (1 row)
1125
1126 select null::testhstore1 #= hstore '';
1127 ERROR: domain hstestdom1 does not allow null values
1128 select v #= h from testhstore1 v, (values (hstore 'a=>123',1),('b=>foo,c=>3.21',2),('a=>null',3),('e=>123',4),('f=>blah',5)) x(h,i) order by i;
1129 ?column?
1130 -------------------
1131 (123,foo,1.2,3,0)
1132 (1,foo,3.21,3,0)
1133 (,foo,1.2,3,0)
1134 (1,foo,1.2,3,123)
1135 (1,foo,1.2,3,0)
1136 (5 rows)
1137
1138 -- keys/values
1139 select akeys('aa=>1 , b=>2, cq=>3'::hstore || 'cq=>l, b=>g, fg=>f');
1140 akeys
1141 --------------
1142 {b,aa,cq,fg}
1143 (1 row)
1144
1145 select akeys('""=>1');
1146 akeys
1147 -------
1148 {""}
1149 (1 row)
1150
1151 select akeys('');
1152 akeys
1153 -------
1154 {}
1155 (1 row)
1156
1157 select avals('aa=>1 , b=>2, cq=>3'::hstore || 'cq=>l, b=>g, fg=>f');
1158 avals
1159 -----------
1160 {g,1,l,f}
1161 (1 row)
1162
1163 select avals('aa=>1 , b=>2, cq=>3'::hstore || 'cq=>l, b=>g, fg=>NULL');
1164 avals
1165 --------------
1166 {g,1,l,NULL}
1167 (1 row)
1168
1169 select avals('""=>1');
1170 avals
1171 -------
1172 {1}
1173 (1 row)
1174
1175 select avals('');
1176 avals
1177 -------
1178 {}
1179 (1 row)
1180
1181 select hstore_to_array('aa=>1, cq=>l, b=>g, fg=>NULL'::hstore);
1182 hstore_to_array
1183 -------------------------
1184 {b,g,aa,1,cq,l,fg,NULL}
1185 (1 row)
1186
1187 select %% 'aa=>1, cq=>l, b=>g, fg=>NULL';
1188 ?column?
1189 -------------------------
1190 {b,g,aa,1,cq,l,fg,NULL}
1191 (1 row)
1192
1193 select hstore_to_matrix('aa=>1, cq=>l, b=>g, fg=>NULL'::hstore);
1194 hstore_to_matrix
1195 ---------------------------------
1196 {{b,g},{aa,1},{cq,l},{fg,NULL}}
1197 (1 row)
1198
1199 select %# 'aa=>1, cq=>l, b=>g, fg=>NULL';
1200 ?column?
1201 ---------------------------------
1202 {{b,g},{aa,1},{cq,l},{fg,NULL}}
1203 (1 row)
1204
1205 select * from skeys('aa=>1 , b=>2, cq=>3'::hstore || 'cq=>l, b=>g, fg=>f');
1206 skeys
1207 -------
1208 b
1209 aa
1210 cq
1211 fg
1212 (4 rows)
1213
1214 select * from skeys('""=>1');
1215 skeys
1216 -------
1217
1218 (1 row)
1219
1220 select * from skeys('');
1221 skeys
1222 -------
1223 (0 rows)
1224
1225 select * from svals('aa=>1 , b=>2, cq=>3'::hstore || 'cq=>l, b=>g, fg=>f');
1226 svals
1227 -------
1228 g
1229 1
1230 l
1231 f
1232 (4 rows)
1233
1234 select *, svals is null from svals('aa=>1 , b=>2, cq=>3'::hstore || 'cq=>l, b=>g, fg=>NULL');
1235 svals | ?column?
1236 -------+----------
1237 g | f
1238 1 | f
1239 l | f
1240 | t
1241 (4 rows)
1242
1243 select * from svals('""=>1');
1244 svals
1245 -------
1246 1
1247 (1 row)
1248
1249 select * from svals('');
1250 svals
1251 -------
1252 (0 rows)
1253
1254 select * from each('aaa=>bq, b=>NULL, ""=>1 ');
1255 key | value
1256 -----+-------
1257 | 1
1258 b |
1259 aaa | bq
1260 (3 rows)
1261
1262 -- @>
1263 select 'a=>b, b=>1, c=>NULL'::hstore @> 'a=>b';
1264 ?column?
1265 ----------
1266 t
1267 (1 row)
1268
1269 select 'a=>b, b=>1, c=>NULL'::hstore @> 'a=>b, c=>NULL';
1270 ?column?
1271 ----------
1272 t
1273 (1 row)
1274
1275 select 'a=>b, b=>1, c=>NULL'::hstore @> 'a=>b, g=>NULL';
1276 ?column?
1277 ----------
1278 f
1279 (1 row)
1280
1281 select 'a=>b, b=>1, c=>NULL'::hstore @> 'g=>NULL';
1282 ?column?
1283 ----------
1284 f
1285 (1 row)
1286
1287 select 'a=>b, b=>1, c=>NULL'::hstore @> 'a=>c';
1288 ?column?
1289 ----------
1290 f
1291 (1 row)
1292
1293 select 'a=>b, b=>1, c=>NULL'::hstore @> 'a=>b';
1294 ?column?
1295 ----------
1296 t
1297 (1 row)
1298
1299 select 'a=>b, b=>1, c=>NULL'::hstore @> 'a=>b, c=>q';
1300 ?column?
1301 ----------
1302 f
1303 (1 row)
1304
1305 CREATE TABLE testhstore (h hstore);
1306 \copy testhstore from 'data/hstore.data'
1307 select count(*) from testhstore where h @> 'wait=>NULL';
1308 count
1309 -------
1310 1
1311 (1 row)
1312
1313 select count(*) from testhstore where h @> 'wait=>CC';
1314 count
1315 -------
1316 15
1317 (1 row)
1318
1319 select count(*) from testhstore where h @> 'wait=>CC, public=>t';
1320 count
1321 -------
1322 2
1323 (1 row)
1324
1325 select count(*) from testhstore where h ? 'public';
1326 count
1327 -------
1328 194
1329 (1 row)
1330
1331 select count(*) from testhstore where h ?| ARRAY['public','disabled'];
1332 count
1333 -------
1334 337
1335 (1 row)
1336
1337 select count(*) from testhstore where h ?& ARRAY['public','disabled'];
1338 count
1339 -------
1340 42
1341 (1 row)
1342
1343 create index hidx on testhstore using gist(h);
1344 set enable_seqscan=off;
1345 select count(*) from testhstore where h @> 'wait=>NULL';
1346 count
1347 -------
1348 1
1349 (1 row)
1350
1351 select count(*) from testhstore where h @> 'wait=>CC';
1352 count
1353 -------
1354 15
1355 (1 row)
1356
1357 select count(*) from testhstore where h @> 'wait=>CC, public=>t';
1358 count
1359 -------
1360 2
1361 (1 row)
1362
1363 select count(*) from testhstore where h ? 'public';
1364 count
1365 -------
1366 194
1367 (1 row)
1368
1369 select count(*) from testhstore where h ?| ARRAY['public','disabled'];
1370 count
1371 -------
1372 337
1373 (1 row)
1374
1375 select count(*) from testhstore where h ?& ARRAY['public','disabled'];
1376 count
1377 -------
1378 42
1379 (1 row)
1380
1381 drop index hidx;
1382 create index hidx on testhstore using gist(h gist_hstore_ops(siglen=0));
1383 ERROR: value 0 out of bounds for option "siglen"
1384 DETAIL: Valid values are between "1" and "2024".
1385 create index hidx on testhstore using gist(h gist_hstore_ops(siglen=2025));
1386 ERROR: value 2025 out of bounds for option "siglen"
1387 DETAIL: Valid values are between "1" and "2024".
1388 create index hidx on testhstore using gist(h gist_hstore_ops(siglen=2024));
1389 set enable_seqscan=off;
1390 select count(*) from testhstore where h @> 'wait=>NULL';
1391 count
1392 -------
1393 1
1394 (1 row)
1395
1396 select count(*) from testhstore where h @> 'wait=>CC';
1397 count
1398 -------
1399 15
1400 (1 row)
1401
1402 select count(*) from testhstore where h @> 'wait=>CC, public=>t';
1403 count
1404 -------
1405 2
1406 (1 row)
1407
1408 select count(*) from testhstore where h ? 'public';
1409 count
1410 -------
1411 194
1412 (1 row)
1413
1414 select count(*) from testhstore where h ?| ARRAY['public','disabled'];
1415 count
1416 -------
1417 337
1418 (1 row)
1419
1420 select count(*) from testhstore where h ?& ARRAY['public','disabled'];
1421 count
1422 -------
1423 42
1424 (1 row)
1425
1426 drop index hidx;
1427 create index hidx on testhstore using gin (h);
1428 set enable_seqscan=off;
1429 select count(*) from testhstore where h @> 'wait=>NULL';
1430 count
1431 -------
1432 1
1433 (1 row)
1434
1435 select count(*) from testhstore where h @> 'wait=>CC';
1436 count
1437 -------
1438 15
1439 (1 row)
1440
1441 select count(*) from testhstore where h @> 'wait=>CC, public=>t';
1442 count
1443 -------
1444 2
1445 (1 row)
1446
1447 select count(*) from testhstore where h ? 'public';
1448 count
1449 -------
1450 194
1451 (1 row)
1452
1453 select count(*) from testhstore where h ?| ARRAY['public','disabled'];
1454 count
1455 -------
1456 337
1457 (1 row)
1458
1459 select count(*) from testhstore where h ?& ARRAY['public','disabled'];
1460 count
1461 -------
1462 42
1463 (1 row)
1464
1465 select count(*) from (select (each(h)).key from testhstore) as wow ;
1466 count
1467 -------
1468 4781
1469 (1 row)
1470
1471 select key, count(*) from (select (each(h)).key from testhstore) as wow group by key order by count desc, key;
1472 key | count
1473 -----------+-------
1474 line | 884
1475 query | 207
1476 pos | 203
1477 node | 202
1478 space | 197
1479 status | 195
1480 public | 194
1481 title | 190
1482 wait | 190
1483 org | 189
1484 user | 189
1485 coauthors | 188
1486 disabled | 185
1487 indexed | 184
1488 cleaned | 180
1489 bad | 179
1490 date | 179
1491 world | 176
1492 state | 172
1493 subtitle | 169
1494 auth | 168
1495 abstract | 161
1496 (22 rows)
1497
1498 -- sort/hash
1499 select count(distinct h) from testhstore;
1500 count
1501 -------
1502 885
1503 (1 row)
1504
1505 set enable_hashagg = false;
1506 select count(*) from (select h from (select * from testhstore union all select * from testhstore) hs group by h) hs2;
1507 count
1508 -------
1509 885
1510 (1 row)
1511
1512 set enable_hashagg = true;
1513 set enable_sort = false;
1514 select count(*) from (select h from (select * from testhstore union all select * from testhstore) hs group by h) hs2;
1515 count
1516 -------
1517 885
1518 (1 row)
1519
1520 select distinct * from (values (hstore '' || ''),('')) v(h);
1521 h
1522 ---
1523
1524 (1 row)
1525
1526 set enable_sort = true;
1527 -- btree
1528 drop index hidx;
1529 create index hidx on testhstore using btree (h);
1530 set enable_seqscan=off;
1531 select count(*) from testhstore where h #># 'p=>1';
1532 count
1533 -------
1534 125
1535 (1 row)
1536
1537 select count(*) from testhstore where h = 'pos=>98, line=>371, node=>CBA, indexed=>t';
1538 count
1539 -------
1540 1
1541 (1 row)
1542
1543 -- json and jsonb
1544 select hstore_to_json('"a key" =>1, b => t, c => null, d=> 12345, e => 012345, f=> 1.234, g=> 2.345e+4');
1545 hstore_to_json
1546 -------------------------------------------------------------------------------------------------
1547 {"b": "t", "c": null, "d": "12345", "e": "012345", "f": "1.234", "g": "2.345e+4", "a key": "1"}
1548 (1 row)
1549
1550 select cast( hstore '"a key" =>1, b => t, c => null, d=> 12345, e => 012345, f=> 1.234, g=> 2.345e+4' as json);
1551 json
1552 -------------------------------------------------------------------------------------------------
1553 {"b": "t", "c": null, "d": "12345", "e": "012345", "f": "1.234", "g": "2.345e+4", "a key": "1"}
1554 (1 row)
1555
1556 select hstore_to_json_loose('"a key" =>1, b => t, c => null, d=> 12345, e => 012345, f=> 1.234, g=> 2.345e+4, h=> "2016-01-01"');
1557 hstore_to_json_loose
1558 -------------------------------------------------------------------------------------------------------------
1559 {"b": true, "c": null, "d": 12345, "e": "012345", "f": 1.234, "g": 2.345e+4, "h": "2016-01-01", "a key": 1}
1560 (1 row)
1561
1562 select hstore_to_jsonb('"a key" =>1, b => t, c => null, d=> 12345, e => 012345, f=> 1.234, g=> 2.345e+4');
1563 hstore_to_jsonb
1564 -------------------------------------------------------------------------------------------------
1565 {"b": "t", "c": null, "d": "12345", "e": "012345", "f": "1.234", "g": "2.345e+4", "a key": "1"}
1566 (1 row)
1567
1568 select cast( hstore '"a key" =>1, b => t, c => null, d=> 12345, e => 012345, f=> 1.234, g=> 2.345e+4' as jsonb);
1569 jsonb
1570 -------------------------------------------------------------------------------------------------
1571 {"b": "t", "c": null, "d": "12345", "e": "012345", "f": "1.234", "g": "2.345e+4", "a key": "1"}
1572 (1 row)
1573
1574 select hstore_to_jsonb_loose('"a key" =>1, b => t, c => null, d=> 12345, e => 012345, f=> 1.234, g=> 2.345e+4, h=> "2016-01-01"');
1575 hstore_to_jsonb_loose
1576 ----------------------------------------------------------------------------------------------------------
1577 {"b": true, "c": null, "d": 12345, "e": "012345", "f": 1.234, "g": 23450, "h": "2016-01-01", "a key": 1}
1578 (1 row)
1579
1580 create table test_json_agg (f1 text, f2 hstore);
1581 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'),
1582 ('rec2','"a key" =>2, b => f, c => "null", d=> -12345, e => 012345.6, f=> -1.234, g=> 0.345e-4');
1583 select json_agg(q) from test_json_agg q;
1584 json_agg
1585 ----------------------------------------------------------------------------------------------------------------------------
1586 [{"f1":"rec1","f2":{"b": "t", "c": null, "d": "12345", "e": "012345", "f": "1.234", "g": "2.345e+4", "a key": "1"}}, +
1587 {"f1":"rec2","f2":{"b": "f", "c": "null", "d": "-12345", "e": "012345.6", "f": "-1.234", "g": "0.345e-4", "a key": "2"}}]
1588 (1 row)
1589
1590 select json_agg(q) from (select f1, hstore_to_json_loose(f2) as f2 from test_json_agg) q;
1591 json_agg
1592 ----------------------------------------------------------------------------------------------------------------------
1593 [{"f1":"rec1","f2":{"b": true, "c": null, "d": 12345, "e": "012345", "f": 1.234, "g": 2.345e+4, "a key": 1}}, +
1594 {"f1":"rec2","f2":{"b": false, "c": "null", "d": -12345, "e": "012345.6", "f": -1.234, "g": 0.345e-4, "a key": 2}}]
1595 (1 row)
1596
1597 -- Test subscripting
1598 insert into test_json_agg default values;
1599 select f2['d'], f2['x'] is null as x_isnull from test_json_agg;
1600 f2 | x_isnull
1601 --------+----------
1602 12345 | t
1603 -12345 | t
1604 | t
1605 (3 rows)
1606
1607 select f2['d']['e'] from test_json_agg; -- error
1608 ERROR: hstore allows only one subscript
1609 select f2['d':'e'] from test_json_agg; -- error
1610 ERROR: hstore allows only one subscript
1611 update test_json_agg set f2['d'] = f2['e'], f2['x'] = 'xyzzy';
1612 select f2 from test_json_agg;
1613 f2
1614 ---------------------------------------------------------------------------------------------------------------------
1615 "b"=>"t", "c"=>NULL, "d"=>"012345", "e"=>"012345", "f"=>"1.234", "g"=>"2.345e+4", "x"=>"xyzzy", "a key"=>"1"
1616 "b"=>"f", "c"=>"null", "d"=>"012345.6", "e"=>"012345.6", "f"=>"-1.234", "g"=>"0.345e-4", "x"=>"xyzzy", "a key"=>"2"
1617 "d"=>NULL, "x"=>"xyzzy"
1618 (3 rows)
1619
1620 -- Test subscripting in plpgsql
1621 do $$ declare h hstore;
1622 begin h['a'] := 'b'; raise notice 'h = %, h[a] = %', h, h['a']; end $$;
1623 NOTICE: h = "a"=>"b", h[a] = b
1624 -- Check the hstore_hash() and hstore_hash_extended() function explicitly.
1625 SELECT v as value, hstore_hash(v)::bit(32) as standard,
1626 hstore_hash_extended(v, 0)::bit(32) as extended0,
1627 hstore_hash_extended(v, 1)::bit(32) as extended1
1628 FROM (VALUES (NULL::hstore), (''), ('"a key" =>1'), ('c => null'),
1629 ('e => 012345'), ('g => 2.345e+4')) x(v)
1630 WHERE hstore_hash(v)::bit(32) != hstore_hash_extended(v, 0)::bit(32)
1631 OR hstore_hash(v)::bit(32) = hstore_hash_extended(v, 1)::bit(32);
1632 value | standard | extended0 | extended1
1633 -------+----------+-----------+-----------
1634 (0 rows)
1635