~ubuntu-branches/ubuntu/hardy/postgresql-8.4/hardy-backports

« back to all changes in this revision

Viewing changes to contrib/hstore/expected/hstore.out

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-03-20 12:00:13 UTC
  • Revision ID: james.westby@ubuntu.com-20090320120013-hogj7egc5mjncc5g
Tags: upstream-8.4~0cvs20090328
ImportĀ upstreamĀ versionĀ 8.4~0cvs20090328

Show diffs side-by-side

added added

removed removed

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