Initial revision
[hstore.git] / expected / hstore.out
1 \set ECHO none
2 psql:hstore.sql:8: NOTICE:  type "hstore" is not yet defined
3 DETAIL:  Creating a shell type definition.
4 psql:hstore.sql:13: NOTICE:  argument type hstore is only a shell
5 psql:hstore.sql:132: NOTICE:  type "ghstore" is not yet defined
6 DETAIL:  Creating a shell type definition.
7 psql:hstore.sql:137: NOTICE:  argument type ghstore is only a shell
8 --hstore;
9 select ''::hstore;
10  hstore 
11 --------
12  
13 (1 row)
14
15 select 'a=>b'::hstore;
16   hstore  
17 ----------
18  "a"=>"b"
19 (1 row)
20
21 select ' a=>b'::hstore;
22   hstore  
23 ----------
24  "a"=>"b"
25 (1 row)
26
27 select 'a =>b'::hstore;
28   hstore  
29 ----------
30  "a"=>"b"
31 (1 row)
32
33 select 'a=>b '::hstore;
34   hstore  
35 ----------
36  "a"=>"b"
37 (1 row)
38
39 select 'a=> b'::hstore;
40   hstore  
41 ----------
42  "a"=>"b"
43 (1 row)
44
45 select '"a"=>"b"'::hstore;
46   hstore  
47 ----------
48  "a"=>"b"
49 (1 row)
50
51 select ' "a"=>"b"'::hstore;
52   hstore  
53 ----------
54  "a"=>"b"
55 (1 row)
56
57 select '"a" =>"b"'::hstore;
58   hstore  
59 ----------
60  "a"=>"b"
61 (1 row)
62
63 select '"a"=>"b" '::hstore;
64   hstore  
65 ----------
66  "a"=>"b"
67 (1 row)
68
69 select '"a"=> "b"'::hstore;
70   hstore  
71 ----------
72  "a"=>"b"
73 (1 row)
74
75 select 'aa=>bb'::hstore;
76    hstore   
77 ------------
78  "aa"=>"bb"
79 (1 row)
80
81 select ' aa=>bb'::hstore;
82    hstore   
83 ------------
84  "aa"=>"bb"
85 (1 row)
86
87 select 'aa =>bb'::hstore;
88    hstore   
89 ------------
90  "aa"=>"bb"
91 (1 row)
92
93 select 'aa=>bb '::hstore;
94    hstore   
95 ------------
96  "aa"=>"bb"
97 (1 row)
98
99 select 'aa=> bb'::hstore;
100    hstore   
101 ------------
102  "aa"=>"bb"
103 (1 row)
104
105 select '"aa"=>"bb"'::hstore;
106    hstore   
107 ------------
108  "aa"=>"bb"
109 (1 row)
110
111 select ' "aa"=>"bb"'::hstore;
112    hstore   
113 ------------
114  "aa"=>"bb"
115 (1 row)
116
117 select '"aa" =>"bb"'::hstore;
118    hstore   
119 ------------
120  "aa"=>"bb"
121 (1 row)
122
123 select '"aa"=>"bb" '::hstore;
124    hstore   
125 ------------
126  "aa"=>"bb"
127 (1 row)
128
129 select '"aa"=> "bb"'::hstore;
130    hstore   
131 ------------
132  "aa"=>"bb"
133 (1 row)
134
135 select 'aa=>bb, cc=>dd'::hstore;
136          hstore         
137 ------------------------
138  "aa"=>"bb", "cc"=>"dd"
139 (1 row)
140
141 select 'aa=>bb , cc=>dd'::hstore;
142          hstore         
143 ------------------------
144  "aa"=>"bb", "cc"=>"dd"
145 (1 row)
146
147 select 'aa=>bb ,cc=>dd'::hstore;
148          hstore         
149 ------------------------
150  "aa"=>"bb", "cc"=>"dd"
151 (1 row)
152
153 select 'aa=>bb, "cc"=>dd'::hstore;
154          hstore         
155 ------------------------
156  "aa"=>"bb", "cc"=>"dd"
157 (1 row)
158
159 select 'aa=>bb , "cc"=>dd'::hstore;
160          hstore         
161 ------------------------
162  "aa"=>"bb", "cc"=>"dd"
163 (1 row)
164
165 select 'aa=>bb ,"cc"=>dd'::hstore;
166          hstore         
167 ------------------------
168  "aa"=>"bb", "cc"=>"dd"
169 (1 row)
170
171 select 'aa=>"bb", cc=>dd'::hstore;
172          hstore         
173 ------------------------
174  "aa"=>"bb", "cc"=>"dd"
175 (1 row)
176
177 select 'aa=>"bb" , cc=>dd'::hstore;
178          hstore         
179 ------------------------
180  "aa"=>"bb", "cc"=>"dd"
181 (1 row)
182
183 select 'aa=>"bb" ,cc=>dd'::hstore;
184          hstore         
185 ------------------------
186  "aa"=>"bb", "cc"=>"dd"
187 (1 row)
188
189 select 'aa=>null'::hstore;
190    hstore   
191 ------------
192  "aa"=>NULL
193 (1 row)
194
195 select 'aa=>NuLl'::hstore;
196    hstore   
197 ------------
198  "aa"=>NULL
199 (1 row)
200
201 select 'aa=>"NuLl"'::hstore;
202     hstore    
203 --------------
204  "aa"=>"NuLl"
205 (1 row)
206
207 select '\\=a=>q=w'::hstore;
208    hstore    
209 -------------
210  "=a"=>"q=w"
211 (1 row)
212
213 select '"=a"=>q\\=w'::hstore;
214    hstore    
215 -------------
216  "=a"=>"q=w"
217 (1 row)
218
219 select '"\\"a"=>q>w'::hstore;
220     hstore    
221 --------------
222  "\"a"=>"q>w"
223 (1 row)
224
225 select '\\"a=>q"w'::hstore;
226     hstore     
227 ---------------
228  "\"a"=>"q\"w"
229 (1 row)
230
231 select ''::hstore;
232  hstore 
233 --------
234  
235 (1 row)
236
237 select '        '::hstore;
238  hstore 
239 --------
240  
241 (1 row)
242
243 -- -> operator
244 select 'aa=>b, c=>d , b=>16'::hstore->'c';
245  ?column? 
246 ----------
247  d
248 (1 row)
249
250 select 'aa=>b, c=>d , b=>16'::hstore->'b';
251  ?column? 
252 ----------
253  16
254 (1 row)
255
256 select 'aa=>b, c=>d , b=>16'::hstore->'aa';
257  ?column? 
258 ----------
259  b
260 (1 row)
261
262 select ('aa=>b, c=>d , b=>16'::hstore->'gg') is null;
263  ?column? 
264 ----------
265  t
266 (1 row)
267
268 select ('aa=>NULL, c=>d , b=>16'::hstore->'aa') is null;
269  ?column? 
270 ----------
271  t
272 (1 row)
273
274 -- exists/defined
275 select isexists('a=>NULL, b=>qq', 'a');
276  isexists 
277 ----------
278  t
279 (1 row)
280
281 select isexists('a=>NULL, b=>qq', 'b');
282  isexists 
283 ----------
284  t
285 (1 row)
286
287 select isexists('a=>NULL, b=>qq', 'c');
288  isexists 
289 ----------
290  f
291 (1 row)
292
293 select isdefined('a=>NULL, b=>qq', 'a');
294  isdefined 
295 -----------
296  f
297 (1 row)
298
299 select isdefined('a=>NULL, b=>qq', 'b');
300  isdefined 
301 -----------
302  t
303 (1 row)
304
305 select isdefined('a=>NULL, b=>qq', 'c');
306  isdefined 
307 -----------
308  f
309 (1 row)
310
311 -- delete 
312 select delete('a=>1 , b=>2, c=>3'::hstore, 'a');
313        delete       
314 --------------------
315  "b"=>"2", "c"=>"3"
316 (1 row)
317
318 select delete('a=>null , b=>2, c=>3'::hstore, 'a');
319        delete       
320 --------------------
321  "b"=>"2", "c"=>"3"
322 (1 row)
323
324 select delete('a=>1 , b=>2, c=>3'::hstore, 'b');
325        delete       
326 --------------------
327  "a"=>"1", "c"=>"3"
328 (1 row)
329
330 select delete('a=>1 , b=>2, c=>3'::hstore, 'c');
331        delete       
332 --------------------
333  "a"=>"1", "b"=>"2"
334 (1 row)
335
336 select delete('a=>1 , b=>2, c=>3'::hstore, 'd');
337             delete            
338 ------------------------------
339  "a"=>"1", "b"=>"2", "c"=>"3"
340 (1 row)
341
342 -- ||
343 select 'aa=>1 , b=>2, cq=>3'::hstore || 'cq=>l, b=>g, fg=>f';
344                  ?column?                  
345 -------------------------------------------
346  "b"=>"g", "aa"=>"1", "cq"=>"l", "fg"=>"f"
347 (1 row)
348
349 select 'aa=>1 , b=>2, cq=>3'::hstore || 'aq=>l';
350                  ?column?                  
351 -------------------------------------------
352  "b"=>"2", "aa"=>"1", "aq"=>"l", "cq"=>"3"
353 (1 row)
354
355 select 'aa=>1 , b=>2, cq=>3'::hstore || 'aa=>l';
356             ?column?            
357 --------------------------------
358  "b"=>"2", "aa"=>"l", "cq"=>"3"
359 (1 row)
360
361 select 'aa=>1 , b=>2, cq=>3'::hstore || '';
362             ?column?            
363 --------------------------------
364  "b"=>"2", "aa"=>"1", "cq"=>"3"
365 (1 row)
366
367 select ''::hstore || 'cq=>l, b=>g, fg=>f';
368             ?column?            
369 --------------------------------
370  "b"=>"g", "cq"=>"l", "fg"=>"f"
371 (1 row)
372
373 -- =>
374 select 'a=>g, b=>c'::hstore || ( 'asd'=>'gf' );
375             ?column?             
376 ---------------------------------
377  "a"=>"g", "b"=>"c", "asd"=>"gf"
378 (1 row)
379
380 select 'a=>g, b=>c'::hstore || ( 'b'=>'gf' );
381       ?column?       
382 ---------------------
383  "a"=>"g", "b"=>"gf"
384 (1 row)
385
386 -- keys/values
387 select akeys('aa=>1 , b=>2, cq=>3'::hstore || 'cq=>l, b=>g, fg=>f');
388     akeys     
389 --------------
390  {b,aa,cq,fg}
391 (1 row)
392
393 select akeys('""=>1');
394  akeys 
395 -------
396  {""}
397 (1 row)
398
399 select akeys('');
400  akeys 
401 -------
402  {}
403 (1 row)
404
405 select avals('aa=>1 , b=>2, cq=>3'::hstore || 'cq=>l, b=>g, fg=>f');
406    avals   
407 -----------
408  {g,1,l,f}
409 (1 row)
410
411 select avals('aa=>1 , b=>2, cq=>3'::hstore || 'cq=>l, b=>g, fg=>NULL');
412    avals    
413 ------------
414  {g,1,l,""}
415 (1 row)
416
417 select avals('""=>1');
418  avals 
419 -------
420  {1}
421 (1 row)
422
423 select avals('');
424  avals 
425 -------
426  {}
427 (1 row)
428
429 select * from skeys('aa=>1 , b=>2, cq=>3'::hstore || 'cq=>l, b=>g, fg=>f');
430  skeys 
431 -------
432  b
433  aa
434  cq
435  fg
436 (4 rows)
437
438 select * from skeys('""=>1');
439  skeys 
440 -------
441  
442 (1 row)
443
444 select * from skeys('');
445  skeys 
446 -------
447 (0 rows)
448
449 select * from svals('aa=>1 , b=>2, cq=>3'::hstore || 'cq=>l, b=>g, fg=>f');
450  svals 
451 -------
452  g
453  1
454  l
455  f
456 (4 rows)
457
458 select *, svals is null from svals('aa=>1 , b=>2, cq=>3'::hstore || 'cq=>l, b=>g, fg=>NULL');
459  svals | ?column? 
460 -------+----------
461  g     | f
462  1     | f
463  l     | f
464        | t
465 (4 rows)
466
467 select * from svals('""=>1');
468  svals 
469 -------
470  1
471 (1 row)
472
473 select * from svals('');
474  svals 
475 -------
476 (0 rows)
477
478 select * from each('aaa=>bq, b=>NULL, ""=>1 ');
479  key | value 
480 -----+-------
481      | 1
482  b   | 
483  aaa | bq
484 (3 rows)
485
486 -- @
487 select 'a=>b, b=>1, c=>NULL'::hstore @ 'a=>NULL';
488  ?column? 
489 ----------
490  t
491 (1 row)
492
493 select 'a=>b, b=>1, c=>NULL'::hstore @ 'a=>NULL, c=>NULL';
494  ?column? 
495 ----------
496  t
497 (1 row)
498
499 select 'a=>b, b=>1, c=>NULL'::hstore @ 'a=>NULL, g=>NULL';
500  ?column? 
501 ----------
502  f
503 (1 row)
504
505 select 'a=>b, b=>1, c=>NULL'::hstore @ 'g=>NULL';
506  ?column? 
507 ----------
508  f
509 (1 row)
510
511 select 'a=>b, b=>1, c=>NULL'::hstore @ 'a=>c';
512  ?column? 
513 ----------
514  f
515 (1 row)
516
517 select 'a=>b, b=>1, c=>NULL'::hstore @ 'a=>b';
518  ?column? 
519 ----------
520  t
521 (1 row)
522
523 select 'a=>b, b=>1, c=>NULL'::hstore @ 'a=>b, c=>NULL';
524  ?column? 
525 ----------
526  t
527 (1 row)
528
529 select 'a=>b, b=>1, c=>NULL'::hstore @ 'a=>b, c=>q';
530  ?column? 
531 ----------
532  f
533 (1 row)
534
535 CREATE TABLE testhstore (h hstore);
536 \copy testhstore from 'data/hstore.data'
537 select count(*) from testhstore where h @ 'wait=>NULL';
538  count 
539 -------
540    189
541 (1 row)
542
543 select count(*) from testhstore where h @ 'wait=>CC';
544  count 
545 -------
546     15
547 (1 row)
548
549 select count(*) from testhstore where h @ 'wait=>CC, public=>t';
550  count 
551 -------
552      2
553 (1 row)
554
555 create index hidx on testhstore using gist(h);
556 set enable_seqscan=off;
557 select count(*) from testhstore where h @ 'wait=>NULL';
558  count 
559 -------
560    189
561 (1 row)
562
563 select count(*) from testhstore where h @ 'wait=>CC';
564  count 
565 -------
566     15
567 (1 row)
568
569 select count(*) from testhstore where h @ 'wait=>CC, public=>t';
570  count 
571 -------
572      2
573 (1 row)
574
575 select count(*) from (select (each(h)).key from testhstore) as wow ;
576  count 
577 -------
578   4779
579 (1 row)
580
581 select key, count(*) from (select (each(h)).key from testhstore) as wow group by key order by count desc, key;
582     key    | count 
583 -----------+-------
584  line      |   883
585  query     |   207
586  pos       |   203
587  node      |   202
588  space     |   197
589  status    |   195
590  public    |   194
591  title     |   190
592  org       |   189
593  user      |   189
594  wait      |   189
595  coauthors |   188
596  disabled  |   185
597  indexed   |   184
598  cleaned   |   180
599  bad       |   179
600  date      |   179
601  world     |   176
602  state     |   172
603  subtitle  |   169
604  auth      |   168
605  abstract  |   161
606 (22 rows)
607