Initial revision
authorteodor <teodor>
Tue, 16 May 2006 11:38:52 +0000 (11:38 +0000)
committerteodor <teodor>
Tue, 16 May 2006 11:38:52 +0000 (11:38 +0000)
12 files changed:
Makefile [new file with mode: 0644]
README.hstore [new file with mode: 0644]
crc32.c [new file with mode: 0644]
crc32.h [new file with mode: 0644]
data/hstore.data [new file with mode: 0644]
expected/hstore.out [new file with mode: 0644]
hstore.h [new file with mode: 0644]
hstore.sql.in [new file with mode: 0644]
hstore_gist.c [new file with mode: 0644]
hstore_io.c [new file with mode: 0644]
hstore_op.c [new file with mode: 0644]
sql/hstore.sql [new file with mode: 0644]

diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..b037234
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,17 @@
+subdir = contrib/hstore
+top_builddir = ../..
+include $(top_builddir)/src/Makefile.global
+
+
+override CPPFLAGS := -I. $(CPPFLAGS)
+
+MODULE_big = hstore
+OBJS = hstore_io.o hstore_op.o hstore_gist.o crc32.o
+
+DATA_built = hstore.sql
+DOCS = README.hstore
+REGRESS = hstore
+
+include $(top_srcdir)/contrib/contrib-global.mk
+# DO NOT DELETE
+
diff --git a/README.hstore b/README.hstore
new file mode 100644 (file)
index 0000000..89c67bf
--- /dev/null
@@ -0,0 +1,175 @@
+Hstore - contrib module for storing (key,value) pairs
+
+[Online version] (http://www.sai.msu.su/~megera/oddmuse/index.cgi?Hstore)
+
+Motivation
+
+Many attributes rarely searched, semistructural data, lazy DBA
+
+Authors
+
+    * Oleg Bartunov <oleg@sai.msu.su>, Moscow, Moscow University, Russia
+    * Teodor Sigaev <teodor@sigaev.ru>, Moscow, Delta-Soft Ltd.,Russia
+
+License
+
+Stable version, included into PostgreSQL distribution, released under BSD license. Development version, available from this site, released under the GNU General Public License, version 2 (June 1991).
+
+Operations
+
+    * hstore -> text - get value , perl analogy $h{key} 
+
+select 'a=>q, b=>g'->'a';
+  ?
+------
+  q
+
+    * hstore || hstore - concatenation, perl analogy %a=( %b, %c ); 
+
+regression=# select 'a=>b'::hstore || 'c=>d'::hstore;
+      ?column?      
+--------------------
+ "a"=>"b", "c"=>"d"
+(1 row)
+
+but, notice
+
+regression=# select 'a=>b'::hstore || 'a=>d'::hstore;
+ ?column? 
+----------
+ "a"=>"d"
+(1 row)
+
+    * text => text - creates hstore type from two text strings 
+
+select 'a'=>'b';
+  ?column?
+----------
+  "a"=>"b"
+
+    * hstore @ hstore - contains operation, check if left operand contains right. 
+
+regression=# select 'a=>b, b=>1, c=>NULL'::hstore @ 'a=>c';
+ ?column? 
+----------
+ f
+(1 row)
+
+regression=# select 'a=>b, b=>1, c=>NULL'::hstore @ 'b=>1';
+ ?column? 
+----------
+ t
+(1 row)
+
+    * hstore ~ hstore - contained operation, check if left operand is contained in right
+
+Functions
+
+    * akeys(hstore) - returns all keys from hstore as array 
+
+regression=# select akeys('a=>1,b=>2');
+ akeys 
+-------
+ {a,b}
+
+    * skeys(hstore) - returns all keys from hstore as strings 
+
+regression=# select skeys('a=>1,b=>2');
+ skeys 
+-------
+ a
+ b
+
+    * avals(hstore) - returns all values from hstore as array 
+
+regression=# select avals('a=>1,b=>2');
+ avals 
+-------
+ {1,2}
+
+    * svals(hstore) - returns all values from hstore as strings 
+
+regression=# select svals('a=>1,b=>2');
+ svals 
+-------
+ 1
+ 2
+
+    * delete (hstore,text) - delete (key,value) from hstore if key matches argument. 
+
+regression=# select delete('a=>1,b=>2','b');
+  delete  
+----------
+ "a"=>"1"
+
+    * each(hstore) return (key, value) pairs 
+
+regression=# select * from each('a=>1,b=>2');
+ key | value 
+-----+-------
+ a   | 1
+ b   | 2
+
+    * isexists (hstore,text) - returns 'true if key is exists in hstore and false otherwise. 
+
+regression=# select isexists('a=>1','a');
+ isexists 
+----------
+ t
+
+    * isdefined (hstore,text) - returns true if key is exists in hstore and its value is not NULL. 
+
+regression=# select isdefined('a=>NULL','a');
+ isdefined 
+-----------
+ f
+
+Indices
+
+Module provides index support for '@' and '~' operations.
+
+create index hidx on testhstore using gist(h);
+
+Note
+
+Use parenthesis in select below, because priority of 'is' is higher than that of '->'
+
+select id from entrants where (info->'education_period') is not null;
+
+Examples
+
+    * add key 
+
+update tt set h=h||'c=>3';
+
+    * delete key 
+
+update tt set h=delete(h,'k1');
+
+    * Statistics
+
+hstore type, because of its intrinsic liberality, could contain a lot of different keys. Checking for valid keys is the task of application. Examples below demonstrate several techniques how to check keys statistics.
+
+          o simple example 
+
+select * from each('aaa=>bq, b=>NULL, ""=>1 ');
+
+          o using table 
+
+select (each(h)).key, (each(h)).value into stat from testhstore ;
+
+          o online stat 
+
+select key, count(*) from (select (each(h)).key from testhstore) as stat group by key order by count desc, key;
+    key    | count 
+-----------+-------
+ line      |   883
+ query     |   207
+ pos       |   203
+ node      |   202
+ space     |   197
+ status    |   195
+ public    |   194
+ title     |   190
+ org       |   189
+...................
\ No newline at end of file
diff --git a/crc32.c b/crc32.c
new file mode 100644 (file)
index 0000000..dc93db7
--- /dev/null
+++ b/crc32.c
@@ -0,0 +1,103 @@
+/* Both POSIX and CRC32 checksums */
+
+#include <sys/types.h>
+#include <stdio.h>
+#include <sys/types.h>
+
+#include "crc32.h"
+
+/*
+ * This code implements the AUTODIN II polynomial
+ * The variable corresponding to the macro argument "crc" should
+ * be an unsigned long.
+ * Oroginal code  by Spencer Garrett <srg@quick.com>
+ */
+
+#define _CRC32_(crc, ch)        (crc = (crc >> 8) ^ crc32tab[(crc ^ (ch)) & 0xff])
+
+/* generated using the AUTODIN II polynomial
+ *     x^32 + x^26 + x^23 + x^22 + x^16 +
+ *     x^12 + x^11 + x^10 + x^8 + x^7 + x^5 + x^4 + x^2 + x^1 + 1
+ */
+
+static const unsigned int crc32tab[256] = {
+       0x00000000, 0x77073096, 0xee0e612c, 0x990951ba,
+       0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
+       0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
+       0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
+       0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
+       0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
+       0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec,
+       0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5,
+       0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
+       0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
+       0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940,
+       0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
+       0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116,
+       0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f,
+       0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
+       0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d,
+       0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a,
+       0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
+       0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818,
+       0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
+       0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
+       0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457,
+       0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c,
+       0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
+       0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
+       0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb,
+       0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
+       0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9,
+       0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086,
+       0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
+       0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4,
+       0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad,
+       0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
+       0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683,
+       0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
+       0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
+       0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe,
+       0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7,
+       0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
+       0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
+       0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252,
+       0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
+       0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60,
+       0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79,
+       0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
+       0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f,
+       0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04,
+       0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
+       0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a,
+       0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
+       0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
+       0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21,
+       0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e,
+       0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
+       0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
+       0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45,
+       0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
+       0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db,
+       0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0,
+       0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
+       0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6,
+       0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,
+       0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
+       0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d,
+};
+
+unsigned int
+crc32_sz(char *buf, int size)
+{
+       unsigned int crc = ~0;
+       char       *p;
+       int                     len,
+                               nr;
+
+       len = 0;
+       nr = size;
+       for (len += nr, p = buf; nr--; ++p)
+               _CRC32_(crc, *p);
+       return ~crc;
+}
diff --git a/crc32.h b/crc32.h
new file mode 100644 (file)
index 0000000..97254a4
--- /dev/null
+++ b/crc32.h
@@ -0,0 +1,10 @@
+#ifndef _CRC32_H
+#define _CRC32_H
+
+/* Returns crc32 of data block */
+extern unsigned int crc32_sz(char *buf, int size);
+
+/* Returns crc32 of null-terminated string */
+#define crc32(buf) crc32_sz((buf),strlen(buf))
+
+#endif
diff --git a/data/hstore.data b/data/hstore.data
new file mode 100644 (file)
index 0000000..7651a10
--- /dev/null
@@ -0,0 +1,1000 @@
+line=>1, date=>CB, node=>AA
+cleaned=>f, status=>59, line=>2, disabled=>f, node=>CBB
+indexed=>t, status=>35, line=>3, disabled=>f, wait=>CAA, subtitle=>BA, user=>CCA
+line=>4, disabled=>t, space=>BB
+cleaned=>f, line=>5, wait=>BB, query=>CAC, coauthors=>ACA, node=>CBA
+world=>CB, query=>CBC, indexed=>f, line=>6, pos=>92, date=>AAB, space=>CB, coauthors=>ACA, node=>CBC
+state=>98, org=>43, line=>7, pos=>97
+auth=>BB, title=>CAC, query=>BA, status=>94, line=>8, coauthors=>BBB
+auth=>BAC, title=>CAA, wait=>CA, bad=>t, query=>AA, indexed=>t, line=>9, pos=>56
+title=>AAC, bad=>t, user=>AAB, query=>AC, line=>10, node=>AB
+world=>CAC, user=>AB, query=>ACA, indexed=>t, line=>11, space=>CB
+line=>12, pos=>72, abstract=>BBA, space=>AAC
+
+world=>CC, query=>AA, line=>14, disabled=>f, date=>CAC, coauthors=>AB
+org=>68, title=>BBB, query=>BAC, line=>15, public=>f
+org=>73, user=>AA, indexed=>t, line=>16, date=>CCC, public=>t, coauthors=>AB
+indexed=>f, line=>17
+state=>23, auth=>BCC, org=>38, status=>28, line=>18, disabled=>f, abstract=>CB
+state=>99, auth=>CA, indexed=>t, line=>19, date=>BA
+wait=>CBA, user=>BBA, indexed=>t, line=>20, disabled=>f, abstract=>BA, date=>ABA
+org=>10, query=>AC, indexed=>f, line=>21, disabled=>t, abstract=>CA, pos=>44
+state=>65, title=>AC, user=>AAC, cleaned=>t, status=>93, line=>22, abstract=>ABC, node=>CCC
+subtitle=>AC, user=>CCC, line=>23
+state=>67, world=>ACB, bad=>t, user=>CB, line=>24, disabled=>t
+
+state=>65, title=>CBC, wait=>AAC, bad=>t, query=>ACA, line=>26, disabled=>f, space=>CA
+auth=>BAA, state=>68, indexed=>t, line=>27, space=>BA
+indexed=>f, line=>28, disabled=>t, space=>CC, node=>BB
+auth=>BAB, org=>80, title=>BBA, query=>BBC, status=>3, line=>29
+title=>AC, status=>16, cleaned=>t, line=>30
+state=>39, world=>AAB, user=>BB, line=>31, disabled=>t
+wait=>BC, bad=>f, query=>AA, line=>32, coauthors=>CAC
+line=>33, pos=>97
+title=>AA, world=>CCA, wait=>CC, bad=>t, status=>86, line=>34, disabled=>t, node=>ACA
+
+world=>BCC, title=>ACB, org=>61, status=>99, cleaned=>t, line=>36, pos=>76, space=>ACC, coauthors=>AA, node=>CB
+title=>CAA, cleaned=>f, line=>37, abstract=>ACA, node=>BC
+auth=>BC, title=>BA, world=>ACA, indexed=>t, line=>38, abstract=>AAA, public=>t
+org=>90, line=>39, public=>f
+state=>16, indexed=>t, line=>40, pos=>53
+auth=>AAB, wait=>CAC, status=>44, line=>41
+subtitle=>ACA, bad=>t, line=>42
+org=>19, world=>BC, user=>ABA, indexed=>f, line=>43, disabled=>t, pos=>48, abstract=>CAB, space=>CCB
+indexed=>f, line=>44
+indexed=>t, line=>45
+status=>84, line=>46, date=>CCC
+state=>94, title=>BAB, bad=>t, user=>BBB, indexed=>t, line=>47, public=>f
+org=>90, subtitle=>BAC, query=>CAC, cleaned=>f, line=>48, disabled=>t, abstract=>CC, pos=>17, space=>BCA
+world=>CBC, line=>49
+org=>24, line=>50, date=>CA, public=>f
+world=>BC, indexed=>t, status=>44, line=>51, pos=>59, date=>BA, public=>t
+org=>98, line=>52
+title=>CA, world=>ABC, subtitle=>CBB, line=>53, abstract=>BBA, date=>ACB, node=>CA
+user=>BAB, cleaned=>t, line=>54
+subtitle=>CAA, line=>55, disabled=>f, pos=>55, abstract=>AB, public=>f, coauthors=>AA
+wait=>CC, user=>CC, cleaned=>t, line=>56, pos=>73, node=>ABC
+title=>BCC, wait=>ABC, indexed=>t, line=>57, disabled=>f
+org=>42, title=>BB, line=>58, disabled=>t, public=>t, coauthors=>BCC
+wait=>CAB, title=>CCB, query=>BAC, status=>66, line=>59, disabled=>t
+user=>CAC, line=>60
+user=>BBB, line=>61, disabled=>f, pos=>31
+org=>18, line=>62, coauthors=>CCC, node=>CA
+line=>63, coauthors=>AB
+org=>25, wait=>CA, line=>64, abstract=>BA, date=>BBB
+title=>CB, wait=>CC, bad=>f, user=>BBB, line=>65, abstract=>ACA, public=>t
+line=>66, coauthors=>AC
+state=>20, wait=>CCB, bad=>t, line=>67, abstract=>CB
+state=>79, wait=>BAC, bad=>f, status=>11, line=>68, abstract=>BC, public=>t, coauthors=>CBA
+state=>39, title=>CCA, bad=>f, query=>BBA, line=>69, pos=>42, public=>f
+title=>BC, subtitle=>CA, query=>BC, line=>70
+
+bad=>t, query=>BBB, line=>72
+state=>35, world=>CC, bad=>f, line=>73, space=>BB, public=>f
+title=>ACC, wait=>CAB, subtitle=>CB, status=>19, line=>74, disabled=>f, space=>BAA, coauthors=>CBC, node=>AC
+subtitle=>BCB, indexed=>f, status=>83, line=>75, public=>t
+state=>32, line=>76, disabled=>f, pos=>66, space=>CC
+state=>43, cleaned=>t, line=>77
+
+state=>97, wait=>CBA, indexed=>f, cleaned=>f, line=>79, abstract=>CB, date=>ACC, public=>f
+user=>AAB, line=>80, pos=>85, date=>AC
+world=>AC, wait=>CC, subtitle=>AAB, bad=>f, cleaned=>f, line=>81, pos=>91, node=>CCC
+
+org=>87, bad=>f, user=>AAC, query=>CCC, line=>83, disabled=>f, abstract=>AC, date=>CCA, public=>f
+state=>50, line=>84
+wait=>AA, subtitle=>AA, query=>BB, status=>97, line=>85, disabled=>t, abstract=>CB
+
+subtitle=>CA, query=>BC, line=>87
+
+title=>CC, line=>89, disabled=>f, pos=>49, date=>CCB, space=>CB, node=>BB
+auth=>CC, wait=>AA, title=>BC, bad=>t, line=>90
+state=>37, org=>85, indexed=>f, line=>91, space=>CAA, public=>t, coauthors=>BA
+wait=>BBB, title=>BBC, org=>95, subtitle=>AC, line=>92, pos=>23, date=>AC, public=>t, space=>BBC
+org=>48, user=>AC, line=>93, space=>CCC
+
+state=>77, wait=>ABA, subtitle=>AC, user=>BA, status=>43, line=>95, public=>f
+title=>CA, indexed=>t, status=>26, line=>96
+auth=>BCA, subtitle=>ACC, user=>CA, line=>97, disabled=>f, node=>ACB
+query=>BB, line=>98, coauthors=>AB
+
+auth=>AA, title=>ACB, org=>58, subtitle=>AC, bad=>f, cleaned=>f, line=>100, space=>ACC, public=>t
+subtitle=>AAB, bad=>f, line=>101, public=>t
+subtitle=>AAA, indexed=>f, cleaned=>f, line=>102, disabled=>t, pos=>35
+
+world=>CAC, org=>10, query=>AAA, cleaned=>t, status=>79, indexed=>t, line=>104, pos=>65, public=>f, node=>BAB
+bad=>f, line=>105, abstract=>BA, node=>CBB
+world=>BB, wait=>BAA, title=>ACA, line=>106, date=>CBC, space=>BA
+state=>92, wait=>CAC, title=>AAA, bad=>f, line=>107, abstract=>CBC, date=>BCC, public=>f
+title=>CCC, indexed=>t, line=>108, abstract=>ACB, public=>f, coauthors=>ABB
+auth=>BB, query=>ACC, status=>68, line=>109
+user=>CC, cleaned=>f, indexed=>t, line=>110, date=>BAA, space=>BCB
+auth=>CC, org=>4, wait=>BAC, bad=>f, indexed=>f, line=>111, pos=>55, node=>BBC
+line=>112, disabled=>t
+org=>66, cleaned=>t, indexed=>f, line=>113, pos=>96
+world=>CA, title=>ACA, org=>83, query=>BAC, user=>BBC, indexed=>f, line=>114
+subtitle=>BCC, line=>115, space=>AA, public=>t, node=>CBA
+state=>77, status=>23, line=>116
+bad=>f, status=>4, line=>117, node=>CC
+state=>99, title=>BCC, query=>AC, status=>98, line=>118, date=>BA
+status=>55, line=>119, public=>f, coauthors=>BBA, node=>BCA
+query=>CAA, status=>40, indexed=>f, line=>120, disabled=>f, coauthors=>CA
+title=>BBC, org=>82, subtitle=>ACB, line=>121, abstract=>BB, node=>CC
+state=>66, world=>AB, subtitle=>BA, query=>CB, line=>122, abstract=>BBC, pos=>65, date=>BAB
+state=>96, title=>CBC, status=>44, line=>123, abstract=>BA, space=>ACA, node=>AAC
+auth=>CA, state=>59, bad=>f, cleaned=>f, line=>124, pos=>41, date=>BBA, coauthors=>ABB
+wait=>ACC, line=>125
+org=>30, wait=>CBB, subtitle=>CCA, cleaned=>t, line=>126, date=>AC, node=>ABC
+
+auth=>BBA, org=>66, subtitle=>CCB, bad=>t, cleaned=>f, line=>128, abstract=>BB, public=>t, coauthors=>BA
+subtitle=>AC, bad=>f, user=>BAA, line=>129, date=>BCB, node=>BAC
+wait=>CC, subtitle=>CA, line=>130, disabled=>f, pos=>49, node=>BA
+indexed=>f, line=>131, pos=>79, date=>AAA, node=>CAC
+wait=>AC, world=>CB, title=>AAA, user=>ABC, indexed=>f, status=>15, line=>132, coauthors=>BA
+state=>96, bad=>t, line=>133, disabled=>f, space=>BAC, coauthors=>ABA
+world=>BAC, line=>134
+title=>CCC, line=>135, coauthors=>CC
+cleaned=>t, line=>136
+bad=>t, query=>CCA, user=>CA, cleaned=>f, line=>137, disabled=>t
+
+world=>CC, subtitle=>BBB, line=>139
+wait=>CA, status=>2, line=>140
+world=>BC, bad=>f, user=>BBC, query=>ACB, line=>141, pos=>33, space=>ACA
+state=>92, title=>CA, bad=>t, query=>AB, line=>142, abstract=>BA, date=>ABB, space=>BC, coauthors=>CAA
+state=>79, query=>AB, user=>CCA, indexed=>t, cleaned=>t, line=>143, public=>t
+org=>37, query=>CA, cleaned=>t, line=>144, disabled=>t, date=>CC
+wait=>AC, title=>CBA, user=>AAA, status=>24, line=>145, date=>CBC, public=>f, coauthors=>BAC, node=>ACC
+user=>CA, indexed=>t, line=>146, disabled=>f, coauthors=>BA
+wait=>BC, org=>35, bad=>f, query=>CBB, line=>147, date=>AAA, public=>f, space=>BBB
+org=>56, user=>AB, indexed=>t, line=>148
+
+title=>CBB, org=>78, subtitle=>CBA, bad=>t, user=>AAB, line=>150, disabled=>t, abstract=>BAC
+world=>CCA, query=>BC, cleaned=>t, indexed=>f, line=>151, abstract=>BC, pos=>43, coauthors=>AB, node=>CBA
+auth=>ABA, status=>13, line=>152, date=>AA
+world=>CA, line=>153, space=>CBC
+world=>BA, user=>BBB, status=>72, line=>154
+auth=>ABB, line=>155, disabled=>t, node=>BBC
+world=>BBB, bad=>f, line=>156, abstract=>CBC
+line=>157, pos=>60, node=>ACC
+line=>158, node=>CC
+line=>159, public=>t
+
+query=>BA, status=>53, cleaned=>f, line=>161, public=>t
+line=>162, date=>CC
+
+title=>BC, bad=>f, query=>CC, line=>164, abstract=>CCB, date=>BA
+status=>36, line=>165
+title=>AB, bad=>f, status=>64, line=>166, abstract=>AB, coauthors=>AA, node=>AA
+wait=>AA, line=>167
+subtitle=>CBC, user=>AC, cleaned=>f, line=>168, disabled=>t, coauthors=>BAB, node=>CC
+state=>34, status=>73, cleaned=>t, line=>169, abstract=>BC, public=>f, space=>BBC, node=>BAA
+state=>10, auth=>BBB, bad=>t, indexed=>f, status=>34, line=>170, abstract=>BC
+subtitle=>AAA, bad=>f, user=>ACA, status=>53, line=>171, disabled=>f, date=>AAA
+subtitle=>CB, query=>CC, indexed=>t, line=>172, node=>BBC
+state=>5, world=>ABC, bad=>f, line=>173, public=>f
+subtitle=>AC, line=>174
+auth=>AC, org=>72, query=>CA, indexed=>f, cleaned=>t, line=>175, disabled=>t, pos=>54
+title=>BCB, bad=>f, line=>176, pos=>35, coauthors=>AAC, node=>ABB
+title=>BB, cleaned=>t, status=>26, line=>177
+state=>61, wait=>BB, world=>CB, query=>BAB, line=>178, abstract=>BB, date=>CBB, space=>CA, node=>AB
+wait=>CA, cleaned=>f, indexed=>t, line=>179, space=>CBC
+org=>68, line=>180
+wait=>ABB, subtitle=>CCC, cleaned=>t, line=>181, abstract=>BC, coauthors=>BA
+title=>ACA, subtitle=>AAB, line=>182, node=>BAC
+
+
+subtitle=>BA, query=>BBB, indexed=>t, cleaned=>t, line=>185, node=>BCC
+org=>6, title=>BCC, user=>BA, line=>186, pos=>67, abstract=>CBA, coauthors=>CBB, node=>CBC
+org=>50, title=>CAB, subtitle=>CB, query=>CBB, line=>187, coauthors=>CA, node=>CC
+bad=>f, line=>188, node=>CCB
+org=>4, world=>AAC, query=>CAC, line=>189, pos=>90, node=>AC
+state=>86, line=>190, pos=>79
+org=>98, title=>AAC, cleaned=>t, line=>191, space=>BC, coauthors=>AA
+wait=>CAA, bad=>f, user=>BC, status=>23, line=>192, disabled=>t, date=>CA, coauthors=>BBB
+status=>26, line=>193, disabled=>t
+world=>CA, subtitle=>CCC, query=>ABB, status=>86, line=>194, pos=>97, space=>CAC
+cleaned=>t, line=>195
+state=>53, org=>84, wait=>BC, query=>BCC, line=>196, disabled=>t, abstract=>AAC, node=>CAC
+state=>25, status=>70, cleaned=>f, line=>197, disabled=>t, space=>AA, public=>f
+org=>82, subtitle=>AAC, line=>198
+org=>87, bad=>t, status=>69, line=>199, public=>f
+wait=>CC, org=>60, subtitle=>BCA, bad=>t, cleaned=>f, indexed=>t, line=>200, date=>BA
+state=>9, world=>CAA, org=>78, user=>ACB, cleaned=>t, line=>201, disabled=>t, abstract=>ACC, public=>f
+state=>50, world=>AAA, title=>CAA, user=>AB, status=>37, line=>202, disabled=>f
+org=>36, subtitle=>CB, query=>BAA, status=>35, line=>203, abstract=>CC
+auth=>CCC, bad=>t, query=>CB, status=>84, line=>204, disabled=>f, date=>BB
+auth=>AC, query=>BA, indexed=>f, line=>205, date=>AAB, space=>ABB
+state=>30, world=>CCA, query=>CC, user=>BAA, line=>206
+title=>CAB, wait=>BAB, bad=>t, query=>BCB, indexed=>t, status=>48, cleaned=>t, line=>207, node=>ACB
+state=>97, subtitle=>BC, status=>99, line=>208, abstract=>CB
+title=>CA, world=>BBA, bad=>t, indexed=>f, cleaned=>f, status=>82, line=>209, disabled=>f, pos=>44, space=>ACA
+line=>210, public=>t
+line=>211, space=>BBC, node=>AAA
+wait=>BAA, org=>50, line=>212, abstract=>BB, public=>t, space=>AB
+line=>213, pos=>57, date=>CC, space=>AC
+state=>23, user=>BAB, query=>BCB, line=>214, abstract=>BAB
+world=>ACB, org=>21, line=>215, abstract=>AC, public=>f
+state=>14, wait=>ACB, org=>79, title=>BB, subtitle=>BA, line=>216
+wait=>BC, line=>217, date=>BB
+wait=>AC, user=>BB, indexed=>f, status=>83, line=>218
+auth=>BC, org=>9, user=>BA, status=>31, line=>219, disabled=>f
+state=>80, world=>BA, wait=>CA, line=>220, pos=>65, node=>CAC
+wait=>AC, subtitle=>ABB, status=>79, indexed=>t, line=>221, abstract=>AC, pos=>33, space=>BA
+state=>69, org=>83, world=>CBC, subtitle=>CAC, cleaned=>f, line=>222, space=>BC, node=>CCA
+line=>223, abstract=>BC
+
+world=>BB, title=>BC, bad=>f, query=>BBC, cleaned=>f, line=>225, disabled=>f, public=>t
+line=>226, date=>AC
+auth=>CB, subtitle=>AB, indexed=>f, status=>2, line=>227, pos=>53, space=>AB, coauthors=>BCA
+title=>ABA, org=>36, line=>228, space=>AA
+world=>AB, line=>229, pos=>78, date=>BC, space=>CC
+wait=>BBC, org=>47, cleaned=>t, status=>5, line=>230, pos=>2, date=>CCA
+line=>231, coauthors=>CB
+state=>1, user=>CAA, cleaned=>f, line=>232, date=>BA, public=>t, coauthors=>AAA, node=>BCC
+auth=>AB, world=>CAC, query=>BC, cleaned=>t, line=>233, pos=>47, space=>AB, node=>AB
+title=>CAA, line=>234, pos=>9, public=>t, node=>AB
+auth=>CCA, title=>AA, org=>6, subtitle=>CA, cleaned=>t, status=>12, indexed=>f, line=>235, space=>ABB
+auth=>CA, bad=>f, query=>BC, status=>61, cleaned=>f, line=>236, disabled=>t, public=>t
+user=>BCB, line=>237, pos=>70, node=>CBA
+query=>CCB, line=>238, disabled=>t, coauthors=>BAB, node=>BC
+auth=>AC, org=>73, title=>CA, bad=>f, status=>94, line=>239, abstract=>CC
+subtitle=>BC, indexed=>f, line=>240, disabled=>t
+auth=>AAC, org=>73, title=>CB, bad=>t, query=>CA, cleaned=>t, line=>241, disabled=>f, public=>f
+line=>242, public=>f
+auth=>AC, title=>BC, status=>61, line=>243, disabled=>f
+auth=>ABB, bad=>f, indexed=>f, line=>244, abstract=>BAB, date=>ABC, coauthors=>BC
+query=>BA, line=>245, disabled=>f, space=>BAB
+world=>BCC, bad=>f, indexed=>f, line=>246, disabled=>t, pos=>80, public=>f, coauthors=>BC
+indexed=>t, line=>247
+wait=>CCA, subtitle=>CBB, bad=>f, line=>248, pos=>83, public=>f, space=>BA
+
+auth=>ABA, org=>13, title=>BA, bad=>f, indexed=>t, line=>250, disabled=>f, abstract=>BBA, date=>AB
+state=>37, title=>AAA, bad=>f, line=>251, disabled=>f, coauthors=>CBC
+auth=>ACB, world=>AC, title=>CAA, subtitle=>BCA, bad=>f, status=>32, line=>252, pos=>84
+query=>BA, indexed=>f, status=>0, line=>253, abstract=>CCB, pos=>48, date=>AC, space=>AAC
+subtitle=>BBA, line=>254, node=>AAA
+query=>AC, user=>CAA, status=>13, line=>255, public=>t, coauthors=>BCC
+auth=>AAA, state=>31, line=>256
+
+
+wait=>AC, query=>AAA, cleaned=>t, indexed=>f, line=>259, pos=>89, coauthors=>BCA, node=>BC
+world=>CC, query=>BB, line=>260
+
+org=>99, bad=>f, user=>ABA, line=>262, abstract=>BA, coauthors=>BCC
+auth=>CAC, world=>CBC, subtitle=>CA, bad=>f, status=>22, line=>263, pos=>4, public=>t, node=>BB
+wait=>BB, subtitle=>BCC, indexed=>t, line=>264, node=>CAC
+subtitle=>BB, query=>CBB, line=>265
+state=>35, query=>AA, line=>266, coauthors=>AAA
+status=>6, line=>267, pos=>66
+auth=>BAA, subtitle=>CCA, bad=>f, query=>CCB, line=>268, public=>t, space=>CAB, node=>CAC
+world=>AC, org=>58, user=>AC, line=>269, node=>AB
+auth=>BCB, org=>36, title=>AB, line=>270, abstract=>CAB, date=>CAB, public=>t, coauthors=>CB, node=>AB
+cleaned=>t, line=>271
+world=>ACC, cleaned=>t, status=>11, line=>272, disabled=>f, abstract=>AA, space=>BCA, node=>BA
+cleaned=>t, line=>273, pos=>50, public=>t
+status=>95, line=>274, abstract=>BB, coauthors=>AC
+auth=>BCC, state=>80, cleaned=>t, line=>275, abstract=>AC
+wait=>BA, line=>276
+org=>62, subtitle=>CAA, query=>BA, user=>BCC, indexed=>f, line=>277, disabled=>f, abstract=>ACA, date=>AB
+org=>63, bad=>t, line=>278, pos=>26, coauthors=>BA
+auth=>CBB, indexed=>f, line=>279, pos=>40, space=>CA, coauthors=>CC
+auth=>BA, line=>280, abstract=>AAA, public=>t, coauthors=>CAC
+org=>10, status=>16, line=>281, date=>CCC, space=>AC
+org=>76, user=>BBC, indexed=>f, line=>282, pos=>56, node=>CBA
+auth=>CA, subtitle=>AB, query=>AA, indexed=>t, line=>283, disabled=>f, coauthors=>ABC, node=>CAA
+title=>BA, status=>91, line=>284, pos=>7, coauthors=>BB
+wait=>CCA, line=>285, public=>t
+world=>AC, line=>286, disabled=>t
+line=>287, abstract=>AAA
+user=>CCB, status=>50, line=>288, public=>f
+state=>41, world=>CCC, query=>AA, line=>289, disabled=>t, pos=>49, public=>f
+wait=>CBC, line=>290, abstract=>CCA, space=>BBC
+auth=>CCB, world=>BAB, user=>CCC, status=>93, line=>291, pos=>77, node=>BAC
+wait=>BCC, org=>8, user=>AC, cleaned=>t, line=>292, disabled=>t, pos=>67, date=>AA
+org=>56, query=>BCA, line=>293, pos=>81, coauthors=>AAA, node=>CAB
+world=>CB, subtitle=>CBC, bad=>t, query=>ACB, indexed=>f, line=>294, pos=>58, date=>BC, node=>CB
+wait=>BC, user=>CA, line=>295
+world=>ABA, wait=>BA, user=>BB, status=>65, line=>296, pos=>45, date=>BB
+
+
+auth=>BA, user=>AA, indexed=>f, line=>299, space=>ABA, public=>f, coauthors=>BC
+line=>300, space=>ABA
+state=>36, org=>16, world=>BBC, status=>13, line=>301, public=>f
+subtitle=>CB, user=>BC, line=>302, date=>AA, coauthors=>CAC
+wait=>CBC, indexed=>t, cleaned=>t, line=>303, date=>ACC, public=>t
+user=>CAC, status=>81, line=>304, node=>CAB
+title=>CBB, org=>89, subtitle=>CAA, user=>CCA, indexed=>t, line=>305
+state=>10, title=>CBA, org=>66, cleaned=>t, line=>306, pos=>59, coauthors=>CAC
+
+auth=>AAA, world=>AC, wait=>ACA, subtitle=>BAA, status=>64, line=>308, node=>CCA
+state=>31, world=>CCC, title=>BCB, cleaned=>f, status=>11, line=>309, disabled=>t, date=>AA
+title=>BC, subtitle=>CB, indexed=>f, line=>310, disabled=>t, abstract=>BA, space=>ACA
+wait=>ABB, cleaned=>t, indexed=>f, line=>311, space=>CAB
+
+subtitle=>CA, line=>313
+org=>91, title=>CAB, line=>314, date=>CA
+
+state=>65, line=>316, node=>CC
+line=>317, space=>AA
+
+wait=>AA, indexed=>t, line=>319
+wait=>BB, org=>42, world=>AC, subtitle=>ACC, indexed=>t, line=>320, disabled=>t
+
+auth=>CAC, line=>322
+
+line=>324, pos=>38, space=>CC, node=>BBC
+title=>CC, line=>325, public=>t, coauthors=>BAC, node=>ACC
+world=>CC, subtitle=>BBC, bad=>f, user=>BA, line=>326, date=>AAA, space=>AA
+state=>81, title=>BC, wait=>BA, indexed=>f, status=>48, line=>327, coauthors=>AB
+line=>328, space=>ABB
+line=>329, date=>CCA
+
+auth=>BB, world=>BAB, subtitle=>BA, query=>ABB, line=>331, disabled=>t, date=>AAA, node=>BC
+auth=>ABA, title=>CC, user=>CBA, line=>332, disabled=>t, space=>ACC
+org=>98, subtitle=>ACB, line=>333, abstract=>BC, public=>f, coauthors=>BC, node=>ABA
+
+world=>BC, subtitle=>BAC, user=>AB, query=>BAA, cleaned=>t, line=>335, space=>AC, node=>BAA
+state=>76, indexed=>t, cleaned=>f, line=>336, node=>CAC
+org=>95, status=>84, line=>337
+
+world=>BBA, title=>BCC, subtitle=>ACB, query=>BA, line=>339, space=>ABC, node=>AC
+title=>CBB, user=>CBA, cleaned=>t, line=>340, public=>t, space=>CB, coauthors=>CAB
+wait=>AA, status=>82, line=>341
+world=>CC, line=>342
+auth=>BAB, title=>CAC, query=>BCC, indexed=>t, line=>343
+org=>77, world=>BAC, subtitle=>AA, user=>ABA, line=>344
+state=>99, org=>56, world=>CC, title=>CAB, wait=>CB, subtitle=>BCC, line=>345, pos=>65
+state=>68, org=>97, title=>AA, indexed=>t, line=>346, node=>CC
+state=>3, title=>CBC, user=>BAA, status=>98, line=>347, disabled=>t, pos=>96, date=>BBA
+auth=>BAA, world=>ABB, line=>348, disabled=>f, abstract=>ACA, pos=>66, space=>CCC, coauthors=>CBB, node=>BC
+
+status=>54, line=>350
+wait=>CC, query=>ABA, user=>AB, status=>76, cleaned=>f, line=>351, abstract=>CBA
+line=>352, disabled=>t, public=>f
+state=>93, org=>92, status=>88, line=>353, space=>AB, coauthors=>CB
+org=>34, wait=>ABC, world=>CBA, bad=>f, query=>BB, indexed=>f, line=>354, date=>CB, public=>t
+wait=>CBA, title=>CAC, cleaned=>t, indexed=>t, line=>355, pos=>9, date=>CAA
+user=>BC, indexed=>f, cleaned=>t, status=>73, line=>356, disabled=>t, space=>CB
+state=>20, cleaned=>f, line=>357, pos=>28, abstract=>CCB, space=>BC
+state=>17, wait=>ABC, query=>CB, cleaned=>f, status=>4, line=>358, disabled=>f
+
+state=>83, world=>CC, org=>53, cleaned=>f, status=>64, line=>360, abstract=>CBC, coauthors=>BC
+title=>BB, indexed=>f, line=>361
+state=>49, wait=>BCA, line=>362
+world=>CCC, title=>CA, query=>CCC, cleaned=>t, line=>363, space=>AA, coauthors=>AAC
+state=>8, wait=>BBB, line=>364, pos=>70, public=>f, space=>BAA, coauthors=>AB
+state=>20, indexed=>f, status=>87, cleaned=>t, line=>365, public=>t
+
+state=>92, title=>CCC, subtitle=>CAB, status=>39, line=>367
+state=>54, org=>38, line=>368
+
+auth=>ACA, subtitle=>CBC, status=>52, line=>370, date=>ACC, public=>t
+indexed=>t, line=>371, pos=>98, node=>CBA
+world=>BA, status=>40, line=>372, coauthors=>AA
+
+query=>BA, indexed=>f, cleaned=>t, line=>374, date=>BCC
+query=>CA, indexed=>t, line=>375, public=>f
+auth=>CCA, wait=>BBC, bad=>f, status=>91, line=>376, abstract=>BBC, date=>ABA
+user=>BA, query=>CB, status=>86, indexed=>f, line=>377, pos=>83, abstract=>BCC, space=>CBC, public=>t
+title=>ACA, org=>15, wait=>CBC, status=>85, line=>378
+state=>57, bad=>t, line=>379, abstract=>BC, date=>CAC
+world=>CC, cleaned=>t, line=>380
+title=>CB, subtitle=>AC, line=>381, public=>f
+
+
+status=>12, line=>384, coauthors=>CC
+auth=>BAC, bad=>f, line=>385, abstract=>CBB, public=>f, space=>BBC
+
+
+world=>BBC, bad=>t, status=>71, cleaned=>f, line=>388, node=>BB
+cleaned=>f, line=>389
+state=>73, line=>390
+wait=>BB, org=>5, subtitle=>BAA, bad=>f, indexed=>f, line=>391, public=>f, node=>BAA
+auth=>CCC, org=>51, bad=>f, cleaned=>t, line=>392, space=>AC, node=>CC
+
+line=>394, abstract=>ACC, public=>t
+org=>44, subtitle=>BAC, query=>BAC, line=>395
+wait=>BC, line=>396
+state=>68, world=>AB, title=>ABB, user=>CBC, cleaned=>f, indexed=>t, line=>397, abstract=>BA, pos=>11
+world=>CA, title=>AB, subtitle=>BC, user=>BCB, line=>398
+bad=>t, query=>BCC, line=>399
+wait=>BB, user=>BB, cleaned=>t, indexed=>f, line=>400, date=>BC, public=>f
+
+wait=>BA, line=>402
+title=>AC, subtitle=>BCB, query=>BA, line=>403
+
+auth=>BA, org=>19, query=>CCB, line=>405, pos=>82, date=>CAA
+state=>26, world=>CB, subtitle=>AB, cleaned=>f, line=>406, disabled=>t, date=>AC
+
+state=>11, bad=>t, indexed=>t, line=>408, pos=>79, abstract=>BA, date=>CB, space=>BBA
+auth=>AC, status=>59, line=>409
+org=>15, line=>410, disabled=>t, date=>BAC, space=>CCA
+
+
+state=>65, world=>AB, status=>69, line=>413, space=>BA
+
+title=>CCB, line=>415
+title=>BAB, subtitle=>CA, indexed=>f, line=>416, public=>t
+wait=>CAB, user=>CAB, cleaned=>t, line=>417, date=>BC, coauthors=>BBA
+subtitle=>ABA, user=>BB, query=>AA, indexed=>t, line=>418, pos=>8, space=>BB, coauthors=>CBA
+state=>11, indexed=>t, line=>419, node=>AA
+state=>86, cleaned=>f, line=>420, pos=>2, node=>CBC
+org=>73, line=>421, disabled=>f
+query=>BAC, user=>CB, status=>69, line=>422
+status=>22, line=>423
+auth=>CB, wait=>CCA, world=>AAB, line=>424, disabled=>f, space=>BA, public=>f
+state=>81, world=>AC, subtitle=>CBA, bad=>t, cleaned=>f, indexed=>t, line=>425, date=>AAB, coauthors=>BC, node=>BAC
+wait=>CB, query=>BCC, status=>97, line=>426
+org=>47, query=>CB, cleaned=>t, line=>427, date=>CC
+org=>33, query=>AC, status=>48, indexed=>f, line=>428, disabled=>t, abstract=>BC, space=>ACC
+org=>10, query=>AB, line=>429, pos=>77, date=>BC
+line=>430, pos=>7, abstract=>CCA, space=>AA
+bad=>f, user=>CA, query=>CAB, line=>431, node=>AC
+auth=>CA, bad=>f, line=>432
+
+auth=>BAA, org=>98, title=>CCC, world=>BAC, line=>434, public=>t
+state=>54, wait=>AA, user=>BBA, indexed=>f, line=>435, disabled=>t, pos=>12, space=>AB
+world=>AC, title=>CA, query=>AAA, line=>436, space=>AB, coauthors=>AA
+auth=>CB, wait=>CCC, bad=>f, line=>437, pos=>42, date=>ABC, space=>AB, coauthors=>ABC
+auth=>CBB, title=>BB, query=>CB, line=>438, pos=>15, abstract=>BC, node=>BBB
+title=>CC, line=>439, disabled=>f
+title=>AB, line=>440, disabled=>f
+org=>3, bad=>t, user=>BCB, query=>AB, indexed=>f, cleaned=>t, line=>441, disabled=>f, space=>BA, node=>BB
+state=>62, user=>BCC, status=>12, line=>442, pos=>58, date=>CC, node=>CB
+world=>BCB, bad=>t, line=>443, space=>AAB
+state=>56, bad=>f, cleaned=>f, line=>444, disabled=>f, date=>CA, space=>BBB, public=>t
+
+org=>31, world=>ABC, cleaned=>t, line=>446, disabled=>t, public=>t, coauthors=>CB
+state=>54, indexed=>t, line=>447
+state=>98, title=>AC, wait=>AAC, world=>BC, bad=>f, line=>448, disabled=>t, public=>t, node=>ABB
+world=>AAC, indexed=>t, line=>449, disabled=>t, pos=>61
+org=>56, title=>CA, line=>450
+auth=>BBB, line=>451, pos=>58, date=>BB, space=>ABA
+auth=>AB, world=>CA, cleaned=>t, line=>452
+bad=>t, line=>453, disabled=>t, abstract=>AC, pos=>20, date=>ABB, node=>CAB
+
+state=>91, wait=>AC, org=>96, world=>AA, subtitle=>BBC, query=>AA, cleaned=>t, line=>455, public=>f
+status=>99, line=>456, disabled=>t
+org=>86, line=>457, public=>t, coauthors=>AC
+status=>14, cleaned=>t, line=>458, disabled=>t
+world=>AB, user=>CB, query=>AAB, line=>459, pos=>66, public=>f, node=>BBA
+state=>58, world=>BB, wait=>CBA, title=>BCA, line=>460, pos=>95, abstract=>CCA, space=>BC, coauthors=>CB
+
+auth=>CAC, title=>AB, query=>BBA, user=>CB, line=>462, abstract=>BCC, pos=>89, coauthors=>ABB
+org=>13, bad=>f, query=>AA, status=>49, line=>463, disabled=>f
+bad=>t, cleaned=>f, line=>464, coauthors=>BB
+org=>14, query=>BA, line=>465, pos=>25, abstract=>BBA, space=>AAA, node=>CAC
+org=>63, title=>CA, subtitle=>ACC, query=>BAC, status=>76, line=>466, abstract=>ACA
+wait=>BA, subtitle=>BC, line=>467, disabled=>f, abstract=>AC
+org=>76, title=>CA, query=>AB, line=>468, public=>f
+state=>95, world=>AC, bad=>f, status=>65, cleaned=>f, line=>469, disabled=>f
+wait=>AB, subtitle=>AA, bad=>f, user=>CC, query=>BBC, status=>6, line=>470, date=>CCC
+state=>82, bad=>t, indexed=>t, line=>471, date=>BB, coauthors=>AAA
+
+state=>12, auth=>ACB, world=>CBC, bad=>f, indexed=>t, line=>473, date=>CA, space=>ABB, coauthors=>CC
+subtitle=>AA, bad=>f, user=>ACC, line=>474, pos=>86, abstract=>CAC, space=>BBA
+cleaned=>t, line=>475
+title=>CC, wait=>BB, status=>6, line=>476, abstract=>ACC, date=>CB, space=>BA, public=>t
+state=>96, wait=>BA, org=>30, subtitle=>BB, user=>CBB, status=>19, line=>477
+state=>78, org=>99, title=>CC, line=>478, node=>BAB
+world=>CBC, bad=>f, line=>479, date=>ACB, public=>t, node=>CB
+state=>0, query=>ABC, status=>65, line=>480, disabled=>t, space=>CBA, node=>BA
+auth=>BAC, org=>24, subtitle=>BBC, bad=>f, user=>CAC, line=>481, date=>BBB, public=>t, coauthors=>CBA
+org=>18, bad=>t, cleaned=>f, status=>3, indexed=>t, line=>482, date=>BB, coauthors=>ACC
+wait=>CB, user=>AC, line=>483, disabled=>f
+world=>AC, subtitle=>AA, query=>AAB, line=>484, disabled=>t, space=>CAA
+line=>485, pos=>2, space=>CA
+org=>42, indexed=>f, line=>486, date=>CB
+org=>3, wait=>CAA, subtitle=>CA, cleaned=>t, line=>487, disabled=>t
+org=>68, subtitle=>CCB, query=>CAA, cleaned=>f, status=>46, line=>488, pos=>87, public=>f, node=>BC
+
+status=>60, cleaned=>f, line=>490, space=>CC, node=>BCB
+state=>42, org=>9, subtitle=>CBA, user=>BA, status=>96, line=>491, pos=>36
+state=>16, title=>BCC, user=>ABC, indexed=>f, status=>24, line=>492, disabled=>t, node=>CBC
+auth=>CC, wait=>BBB, line=>493, disabled=>f, public=>f, coauthors=>AB
+
+wait=>BB, title=>BBC, subtitle=>BA, status=>3, cleaned=>f, line=>495, disabled=>f, coauthors=>AB, node=>BAC
+
+query=>CC, indexed=>f, line=>497, coauthors=>CAC, node=>BC
+auth=>BBA, state=>68, line=>498
+state=>21, title=>CCB, wait=>AAA, subtitle=>CCC, user=>BAA, indexed=>t, line=>499, coauthors=>BB
+auth=>AAA, subtitle=>CC, bad=>t, user=>CC, indexed=>t, line=>500, disabled=>t, date=>AB, node=>AC
+auth=>BB, title=>CCA, user=>BA, cleaned=>t, line=>501, pos=>37, space=>BA, public=>f
+auth=>BCA, line=>502, date=>BA
+world=>ABA, bad=>t, indexed=>f, line=>503, disabled=>t, abstract=>AC, pos=>1, public=>f
+auth=>BBB, subtitle=>ACB, line=>504, space=>AC, node=>BB
+auth=>CAC, state=>19, title=>ACA, wait=>BA, query=>CC, line=>505
+subtitle=>BC, cleaned=>f, indexed=>f, line=>506, date=>CAB, public=>f, node=>ABC
+state=>87, wait=>CCC, query=>CAC, user=>CBB, line=>507, abstract=>BBC, date=>AA, coauthors=>CA
+auth=>AC, subtitle=>BC, bad=>f, query=>ABA, user=>CBB, indexed=>t, cleaned=>f, line=>508, coauthors=>BA
+auth=>AA, title=>ABA, subtitle=>CCA, query=>CC, line=>509, pos=>27, node=>CBB
+org=>5, title=>CAC, subtitle=>BBB, line=>510, pos=>76, abstract=>AAB, space=>AA
+bad=>t, line=>511
+wait=>ACB, indexed=>f, line=>512
+auth=>CBA, world=>BA, bad=>t, user=>CBA, query=>CC, line=>513, public=>f, coauthors=>CC
+
+state=>97, wait=>BB, line=>515, date=>CBC, space=>CA
+auth=>CBC, line=>516, disabled=>t
+state=>91, user=>CCA, line=>517, coauthors=>BA, node=>CBA
+bad=>f, cleaned=>t, line=>518, space=>AAB
+
+title=>CA, cleaned=>f, status=>38, line=>520
+auth=>BCA, world=>AC, org=>71, user=>CA, line=>521, abstract=>AAB
+bad=>t, line=>522, pos=>28, abstract=>BAA
+line=>523, coauthors=>CBC, node=>AAB
+status=>51, cleaned=>f, line=>524
+query=>AAB, line=>525, disabled=>t, date=>AA, public=>t, coauthors=>CA
+org=>15, user=>AC, cleaned=>f, line=>526, coauthors=>CAC, node=>BAB
+world=>ABA, line=>527, disabled=>t, public=>t
+auth=>BBC, state=>48, bad=>f, line=>528, abstract=>BB, date=>BAC, space=>BA, public=>t
+auth=>BA, wait=>CAC, subtitle=>ABC, query=>CB, indexed=>f, cleaned=>f, line=>529, disabled=>t, date=>CA
+wait=>AC, world=>ABA, org=>55, bad=>t, indexed=>t, line=>530, pos=>32, space=>BCA, public=>t
+title=>CBC, wait=>BAA, line=>531
+world=>AA, line=>532, pos=>35, space=>AAB, public=>t
+line=>533, space=>AB, coauthors=>BA
+auth=>CBC, world=>BB, line=>534, space=>ACA, coauthors=>CBB
+wait=>ACA, status=>47, line=>535, public=>t, node=>BAA
+org=>16, subtitle=>BBB, line=>536, abstract=>AC, space=>CB, coauthors=>CC, node=>CBC
+wait=>AAB, line=>537, abstract=>AB, space=>CAC
+query=>CAC, line=>538
+world=>AC, query=>AAA, indexed=>f, status=>18, line=>539, pos=>62, space=>BC, coauthors=>BAC
+org=>30, world=>AA, query=>BC, user=>BAC, status=>12, cleaned=>t, line=>540, space=>AB
+org=>30, user=>CCB, query=>BB, cleaned=>f, line=>541, disabled=>t, public=>t, node=>CBA
+
+subtitle=>ABB, bad=>t, line=>543
+subtitle=>BBB, bad=>t, line=>544, pos=>43, coauthors=>ABB
+
+subtitle=>AB, user=>BA, line=>546, node=>CB
+title=>BBB, user=>AA, line=>547, abstract=>CBB, pos=>45
+wait=>CCB, title=>AC, world=>AAA, line=>548, abstract=>BBC, pos=>23, coauthors=>ACC
+org=>55, subtitle=>BA, line=>549, disabled=>t, date=>CB, space=>AA
+org=>39, cleaned=>t, line=>550, public=>f
+state=>41, auth=>CC, world=>CB, line=>551, space=>AAB
+
+state=>26, bad=>f, query=>BAA, status=>84, indexed=>t, line=>553, disabled=>f, coauthors=>CC, node=>CBB
+world=>ABA, user=>CCC, query=>ABB, line=>554, space=>ABC, node=>AAA
+state=>18, wait=>CCB, bad=>t, user=>BA, line=>555, space=>CC, coauthors=>BB, node=>BBB
+auth=>AA, state=>71, subtitle=>AA, query=>ACC, indexed=>t, line=>556, space=>BAB, public=>f
+indexed=>t, cleaned=>t, line=>557, disabled=>f, abstract=>AB
+auth=>BCC, title=>ACB, world=>BCA, user=>BAB, cleaned=>f, line=>558, space=>BB, coauthors=>CBC
+
+auth=>ACC, org=>18, wait=>AB, status=>1, indexed=>t, line=>560
+status=>8, line=>561, abstract=>BA, public=>f
+state=>27, title=>ABA, bad=>t, query=>AAB, indexed=>f, line=>562, pos=>86, public=>t, coauthors=>BA
+
+title=>BAC, wait=>CCC, user=>BA, line=>564, disabled=>f, date=>BB, public=>t, space=>CB, coauthors=>CCB
+wait=>CAA, line=>565, pos=>80, space=>AB
+auth=>CBB, subtitle=>BCA, user=>CB, line=>566, abstract=>BC, date=>AB
+title=>CCB, status=>78, line=>567, pos=>68, node=>BA
+auth=>BC, query=>AB, line=>568, space=>AB, node=>BB
+
+line=>570, pos=>54
+world=>BBB, user=>CC, indexed=>t, line=>571, abstract=>CC, coauthors=>BA, node=>ABB
+state=>41, line=>572
+subtitle=>CBC, cleaned=>t, line=>573, node=>BCB
+title=>ABA, line=>574, pos=>27, space=>CC
+status=>29, indexed=>f, cleaned=>f, line=>575, pos=>52, public=>f, coauthors=>ACC
+title=>BBB, org=>86, wait=>AAA, user=>CC, query=>CA, line=>576, disabled=>f, date=>AB, node=>BC
+line=>577, abstract=>CAA, date=>BB
+auth=>CCC, subtitle=>BBB, query=>ABA, line=>578, pos=>99, space=>CCB, public=>t, coauthors=>ACA, node=>ACB
+wait=>BCC, line=>579
+state=>99, world=>BAC, user=>CA, line=>580
+state=>55, world=>AAA, title=>AAA, cleaned=>f, line=>581, date=>AC, public=>t, node=>AA
+query=>ACC, cleaned=>t, line=>582, disabled=>f
+auth=>AAB, query=>BAC, line=>583
+auth=>AA, user=>BAC, line=>584
+
+org=>96, wait=>BC, bad=>f, cleaned=>f, status=>96, line=>586, pos=>95
+auth=>BC, subtitle=>BCB, bad=>t, user=>BBC, line=>587, pos=>79, node=>BA
+state=>55, line=>588
+title=>ABC, world=>AB, subtitle=>CBC, user=>BA, query=>BAB, line=>589, date=>AC, node=>CB
+world=>BAA, bad=>f, user=>AAB, cleaned=>f, indexed=>f, line=>590
+title=>CB, wait=>BC, subtitle=>BAC, cleaned=>t, line=>591, disabled=>f, abstract=>CBB, public=>f, node=>ACC
+user=>BC, line=>592, public=>f
+
+wait=>CC, org=>57, title=>BAC, line=>594, abstract=>AA
+auth=>BBC, state=>3, world=>AAC, query=>BA, line=>595, coauthors=>BB
+
+subtitle=>CC, user=>CC, line=>597
+wait=>BBA, user=>AAA, line=>598, space=>ACB, node=>AA
+auth=>BB, user=>ABA, line=>599, abstract=>AB, node=>BA
+
+world=>AAA, user=>BB, cleaned=>f, line=>601, space=>AC, coauthors=>ABB
+title=>CAB, bad=>f, line=>602, coauthors=>ABB
+
+world=>CCC, org=>79, line=>604
+org=>56, query=>AB, cleaned=>t, indexed=>t, status=>20, line=>605, public=>t, coauthors=>ACA
+auth=>BBC, org=>13, subtitle=>CC, bad=>t, user=>ABC, line=>606, date=>CA, public=>f
+query=>BA, line=>607
+bad=>t, line=>608, pos=>12, coauthors=>CB
+bad=>f, status=>42, line=>609
+
+bad=>t, line=>611
+auth=>CCA, subtitle=>BC, bad=>t, query=>CAA, cleaned=>f, line=>612, public=>f, node=>CBA
+org=>65, query=>BC, line=>613
+
+wait=>BAC, title=>AAB, user=>CAC, line=>615, pos=>69, space=>CC, node=>AAC
+bad=>f, line=>616, abstract=>AB, pos=>65, coauthors=>BBB
+
+org=>38, world=>BA, line=>618, coauthors=>AA, node=>BC
+cleaned=>f, line=>619, disabled=>f
+auth=>BC, line=>620, pos=>79, date=>AB, coauthors=>BAA, node=>CB
+auth=>CAA, title=>CB, user=>BAC, cleaned=>f, line=>621, public=>f, space=>CBA
+
+bad=>f, status=>12, line=>623
+auth=>BBB, wait=>BAC, org=>36, title=>AB, indexed=>f, cleaned=>f, line=>624, date=>AB, coauthors=>CB
+wait=>AA, subtitle=>AB, query=>CCB, line=>625, node=>CBB
+wait=>BC, subtitle=>BA, bad=>t, user=>AA, line=>626, pos=>3, date=>BB
+org=>28, user=>BC, query=>AC, status=>63, line=>627, pos=>45, public=>t, node=>BC
+query=>BC, status=>47, line=>628, disabled=>f, date=>CA, public=>f
+
+wait=>CB, line=>630, pos=>67, coauthors=>AC
+org=>33, world=>BBB, query=>BB, status=>92, line=>631
+state=>65, title=>AC, world=>CBC, query=>CBC, line=>632, date=>CAC, space=>CC, coauthors=>CC
+
+auth=>CC, query=>BCA, status=>46, line=>634, disabled=>f, pos=>69
+wait=>CB, line=>635, pos=>34
+state=>9, wait=>CC, status=>23, line=>636, disabled=>t, date=>BB, space=>AC
+user=>CCB, indexed=>f, cleaned=>t, line=>637, pos=>65, date=>AA, public=>t
+auth=>BC, wait=>AB, title=>BB, bad=>t, line=>638, abstract=>ACC, date=>BC, public=>f
+state=>44, auth=>BC, world=>CBC, line=>639, disabled=>f, date=>CAA
+world=>CB, title=>ACB, user=>BA, query=>AA, line=>640, disabled=>t, space=>AC
+state=>37, line=>641, disabled=>t, pos=>66
+world=>AAA, bad=>t, user=>AAA, query=>BA, line=>642, disabled=>t, coauthors=>CBC
+world=>BA, title=>ABB, org=>96, bad=>f, query=>AAA, status=>75, cleaned=>f, line=>643, space=>BA
+state=>36, org=>66, subtitle=>AA, query=>CA, cleaned=>t, status=>79, line=>644, date=>CB
+wait=>BC, line=>645, date=>CBA, space=>BCB, public=>t, node=>ABA
+auth=>BB, org=>37, query=>CAA, indexed=>t, line=>646, abstract=>CBA, coauthors=>CBA
+
+
+state=>58, world=>BAB, org=>11, user=>CC, line=>649
+title=>CB, status=>19, line=>650, disabled=>f, public=>f, coauthors=>AA
+user=>BBC, indexed=>t, line=>651, disabled=>t, pos=>8
+query=>CC, cleaned=>t, indexed=>f, line=>652, pos=>67, date=>AA
+auth=>AAC, line=>653, disabled=>t, public=>f, coauthors=>AAA, node=>CBB
+bad=>t, query=>AC, line=>654, disabled=>f
+world=>CCA, org=>15, bad=>f, user=>CCC, line=>655, public=>t, space=>CC
+line=>656, coauthors=>BBB
+title=>BA, line=>657, date=>ACB
+user=>BC, query=>CC, cleaned=>t, line=>658, pos=>51, abstract=>BA
+subtitle=>CCA, user=>CCA, cleaned=>f, line=>659, abstract=>BA, pos=>95, date=>CA
+auth=>CA, state=>23, org=>19, bad=>f, user=>BCB, indexed=>f, line=>660, date=>ABA
+state=>64, org=>97, bad=>f, indexed=>f, line=>661, space=>BAB, coauthors=>BB, node=>BA
+status=>11, line=>662
+title=>BCC, org=>44, subtitle=>ACB, cleaned=>f, line=>663, pos=>58
+auth=>ABB, bad=>t, line=>664, pos=>82, coauthors=>CC, node=>AB
+bad=>f, cleaned=>t, status=>25, line=>665, disabled=>f, abstract=>BB, public=>t
+wait=>AC, user=>CB, line=>666, pos=>71, abstract=>ACA, coauthors=>CBB
+title=>AA, bad=>t, user=>BB, line=>667, date=>CA, space=>BC, node=>CC
+
+auth=>AAB, line=>669
+wait=>AAC, query=>ABA, status=>35, line=>670, disabled=>f, pos=>56
+org=>3, line=>671
+state=>46, bad=>f, cleaned=>t, line=>672
+state=>30, org=>9, status=>72, line=>673, abstract=>ACA, coauthors=>CB
+auth=>BB, wait=>CA, title=>BBB, bad=>t, user=>AAA, status=>86, indexed=>f, line=>674, node=>BCC
+indexed=>t, line=>675, pos=>63
+bad=>t, query=>CBB, status=>5, line=>676, abstract=>CCC, public=>f, space=>BB
+title=>BBB, org=>60, bad=>t, cleaned=>f, line=>677, pos=>82, date=>BAA, space=>BB, coauthors=>CAA
+
+
+state=>73, bad=>f, cleaned=>f, line=>680, abstract=>CA, date=>CCA, space=>CB
+state=>92, query=>CC, line=>681, abstract=>AB, date=>BBB, public=>t, coauthors=>CBA
+subtitle=>CCA, line=>682
+world=>BAC, subtitle=>AC, line=>683, disabled=>t, abstract=>AA, pos=>55, space=>AC, node=>CA
+state=>75, world=>ACA, query=>BC, line=>684, coauthors=>AAC
+status=>21, line=>685
+state=>39, wait=>CB, title=>CBC, query=>BB, cleaned=>t, line=>686, disabled=>f
+world=>CCA, wait=>AB, user=>CC, query=>BB, cleaned=>t, line=>687
+auth=>CAC, state=>94, wait=>ACC, title=>BBC, user=>BB, line=>688, disabled=>f, pos=>16, coauthors=>AAC
+
+org=>43, line=>690
+
+state=>4, title=>CA, subtitle=>AA, query=>BC, line=>692, pos=>57, date=>BCA, public=>f, coauthors=>ABB
+wait=>BBA, line=>693
+auth=>BCA, bad=>f, user=>BBA, line=>694, disabled=>f, date=>CC, public=>t, coauthors=>CB
+state=>66, wait=>BB, user=>CC, indexed=>t, line=>695, pos=>99, space=>BCA
+org=>1, line=>696, disabled=>f, space=>BCC, coauthors=>BC
+auth=>BC, cleaned=>t, indexed=>f, line=>697, space=>CBB
+wait=>AC, indexed=>f, line=>698, pos=>44
+wait=>AA, title=>BBB, org=>31, indexed=>t, line=>699, disabled=>f
+auth=>BB, world=>ACC, bad=>t, indexed=>f, line=>700, abstract=>CB, pos=>5, space=>ACB, node=>CC
+cleaned=>f, line=>701, space=>CB
+line=>702, space=>CCC
+world=>CA, subtitle=>ABA, line=>703, pos=>5, date=>BA, coauthors=>AB
+
+line=>705, date=>BBB
+state=>10, query=>CB, status=>70, line=>706, abstract=>ABA, date=>BC
+auth=>CB, line=>707
+wait=>BBA, cleaned=>t, line=>708, pos=>94, date=>CBC
+state=>86, org=>5, world=>BB, indexed=>f, line=>709, date=>BBB, space=>CA, public=>t
+world=>ACA, query=>ABC, status=>40, line=>710, disabled=>t, public=>t, node=>CA
+bad=>t, line=>711
+query=>AB, line=>712, coauthors=>BBC, node=>AA
+user=>ABB, line=>713, public=>f, space=>AAA, node=>BBA
+auth=>AC, wait=>BAC, bad=>t, line=>714, public=>f
+line=>715, abstract=>CA, public=>f
+user=>AC, indexed=>t, line=>716, coauthors=>CB
+state=>4, title=>ABB, org=>26, indexed=>t, line=>717, public=>t, coauthors=>CCA, node=>AC
+wait=>CA, title=>CCA, world=>CCC, line=>718, abstract=>ACA
+auth=>ACA, org=>29, subtitle=>AA, user=>CA, status=>24, indexed=>t, line=>719, public=>f, node=>CA
+
+line=>721, disabled=>t, abstract=>BAC
+world=>BC, line=>722
+state=>27, auth=>AA, title=>BC, world=>CC, query=>BCC, line=>723, disabled=>t, pos=>9, public=>f, node=>BCC
+org=>78, wait=>ABA, cleaned=>t, indexed=>t, line=>724, date=>ACB, space=>AA
+state=>60, line=>725
+
+
+wait=>ABA, title=>CAC, user=>CCC, line=>728
+wait=>CC, indexed=>t, status=>39, line=>729, disabled=>t, public=>f
+auth=>CB, subtitle=>BBA, line=>730, coauthors=>CAC
+world=>CBB, line=>731, space=>BCB
+cleaned=>t, line=>732
+org=>67, bad=>t, line=>733, pos=>9, node=>ACC
+world=>BC, wait=>CAC, org=>58, subtitle=>ACC, bad=>t, query=>CAA, line=>734, abstract=>BCA, pos=>1, public=>t
+state=>45, query=>AB, indexed=>f, line=>735, pos=>82, date=>BC, public=>f, coauthors=>BA
+state=>68, title=>BC, cleaned=>t, status=>34, line=>736, disabled=>t, node=>BBB
+auth=>AC, line=>737
+line=>738, date=>BA, space=>CCC, public=>f
+line=>739, node=>BAA
+org=>72, title=>BC, line=>740, pos=>51, coauthors=>CA
+state=>72, user=>CCB, query=>ACA, line=>741
+org=>80, subtitle=>BBA, bad=>t, user=>BC, line=>742, pos=>52, coauthors=>BCA
+
+query=>BC, line=>744, abstract=>AB, public=>f, node=>BAC
+world=>CAC, line=>745
+auth=>CBB, title=>AA, user=>AB, line=>746, pos=>35, public=>f, space=>AAB
+state=>69, world=>AB, org=>78, subtitle=>BA, bad=>f, line=>747, node=>AAA
+bad=>t, line=>748, public=>t
+wait=>BC, org=>47, query=>BBB, line=>749
+title=>BBB, line=>750
+org=>33, query=>CB, line=>751, disabled=>t
+subtitle=>BB, line=>752, space=>CC
+org=>89, line=>753
+auth=>ABA, line=>754, coauthors=>ACC
+subtitle=>BA, line=>755, pos=>47
+state=>81, subtitle=>CB, query=>AB, status=>25, cleaned=>f, line=>756, pos=>72, date=>BA, coauthors=>BCA
+state=>46, status=>88, line=>757, disabled=>f, public=>t
+world=>AB, line=>758, disabled=>t, abstract=>BB, coauthors=>AAA
+query=>AC, line=>759, abstract=>AAB
+auth=>BC, indexed=>f, line=>760, abstract=>BA, node=>CAA
+state=>10, auth=>BAC, title=>BC, query=>BCA, cleaned=>t, line=>761, disabled=>t, space=>ACC, coauthors=>ABA
+line=>762, disabled=>t, pos=>43
+world=>CBA, user=>BBC, indexed=>t, line=>763
+wait=>ACB, query=>BA, status=>22, line=>764, pos=>70, abstract=>BAC, public=>f, space=>BC
+
+line=>766, disabled=>f, abstract=>CBC, date=>CA
+title=>CC, bad=>t, user=>BCC, indexed=>f, line=>767, date=>BCB, node=>AAA
+title=>CB, line=>768, abstract=>AA, node=>ABB
+org=>21, user=>ABC, line=>769, abstract=>BB, date=>CBB, space=>CC
+auth=>AC, org=>66, user=>CC, line=>770, public=>f, space=>CA, coauthors=>AA
+org=>58, line=>771, coauthors=>BCC, node=>AC
+
+auth=>BC, wait=>CC, line=>773, abstract=>ACC, pos=>98, date=>CCC, space=>ABB, node=>CB
+
+query=>BC, user=>AC, indexed=>t, line=>775, abstract=>AAA
+subtitle=>BAA, indexed=>f, line=>776
+line=>777, pos=>33, date=>CCB, public=>t
+world=>BCA, bad=>t, line=>778
+auth=>CA, line=>779, date=>AC, space=>CAC
+title=>BB, bad=>f, cleaned=>t, line=>780, disabled=>f, date=>BAB, space=>ACB
+auth=>CAC, title=>AAB, subtitle=>CA, bad=>f, line=>781, disabled=>f, space=>CB
+state=>78, auth=>AC, bad=>t, status=>46, line=>782, abstract=>CCA, pos=>97, public=>t
+user=>BBA, line=>783
+
+state=>63, title=>CA, cleaned=>t, line=>785, abstract=>BA, space=>BCC
+line=>786, node=>CAC
+line=>787, pos=>65
+line=>788, space=>ABB
+
+org=>14, line=>790, abstract=>CAB, coauthors=>BBC
+subtitle=>CBA, cleaned=>f, line=>791, disabled=>f, pos=>57, node=>CB
+auth=>CAA, org=>84, wait=>AB, indexed=>t, status=>51, line=>792, abstract=>CC
+org=>72, bad=>t, line=>793, space=>ACA
+
+auth=>BC, state=>76, wait=>CC, user=>ABB, cleaned=>f, line=>795, pos=>99, abstract=>CA
+wait=>CCA, world=>CBC, line=>796, date=>CB, public=>f
+state=>49, line=>797, coauthors=>CC
+wait=>BBB, title=>ABB, org=>74, line=>798, disabled=>f, pos=>34, space=>BB
+line=>799, abstract=>CB
+state=>84, user=>ABB, cleaned=>f, status=>18, line=>800, disabled=>t, date=>CCA, node=>BA
+state=>81, auth=>CB, world=>CA, user=>CAA, line=>801, date=>AC, space=>CBC, coauthors=>BCB
+org=>4, line=>802, disabled=>f, abstract=>ABA, public=>f
+auth=>CBC, state=>99, cleaned=>t, line=>803, disabled=>t, space=>BC, node=>BBC
+auth=>AC, wait=>CA, cleaned=>f, line=>804, pos=>54, date=>BAA, public=>t, space=>AB
+
+auth=>BCB, wait=>BCC, subtitle=>AAA, line=>806
+line=>807, disabled=>f, space=>ACA
+org=>96, query=>CBA, line=>808, disabled=>f, pos=>74, space=>CA, public=>f
+
+state=>12, title=>AA, bad=>f, status=>20, line=>810, disabled=>t, coauthors=>CAC, node=>AB
+auth=>ABC, line=>811, date=>CA
+title=>AB, indexed=>f, line=>812, disabled=>f, node=>AAC
+
+world=>CBA, status=>15, line=>814, abstract=>CBA
+status=>49, line=>815, pos=>49
+subtitle=>CAB, line=>816
+
+
+world=>CAC, title=>CB, wait=>AA, query=>CA, indexed=>t, line=>819, disabled=>t
+auth=>ABB, wait=>AC, query=>CC, cleaned=>t, indexed=>f, line=>820, abstract=>AA, public=>f, node=>AB
+org=>5, wait=>BA, indexed=>t, line=>821, node=>AB
+title=>CC, wait=>CC, bad=>f, query=>BCC, indexed=>f, line=>822, pos=>27, date=>CB, node=>CBA
+query=>BC, status=>28, line=>823, public=>f
+status=>1, line=>824, abstract=>BB
+
+auth=>AA, title=>BC, query=>CA, status=>33, line=>826
+state=>9, title=>BB, subtitle=>ACC, bad=>t, query=>BA, status=>41, line=>827, abstract=>ACB, public=>f
+auth=>AB, subtitle=>CAB, line=>828, public=>f, coauthors=>AB, node=>BAC
+line=>829, disabled=>f, public=>t, node=>CBC
+auth=>BAB, line=>830
+wait=>BBA, bad=>t, indexed=>f, line=>831, space=>BB
+org=>70, wait=>BC, world=>AC, indexed=>t, status=>96, line=>832, disabled=>t, space=>AB
+state=>8, world=>BAB, bad=>t, indexed=>t, status=>18, line=>833, date=>BA, space=>BA
+query=>AB, line=>834
+bad=>t, status=>5, line=>835
+world=>BAC, subtitle=>BB, bad=>f, user=>AB, indexed=>f, cleaned=>t, line=>836
+line=>837, public=>f
+line=>838, pos=>7
+auth=>CA, query=>ABB, indexed=>t, line=>839, public=>t
+wait=>CC, bad=>f, line=>840, date=>AAB, public=>f, coauthors=>BCB
+auth=>AB, state=>97, org=>24, line=>841, pos=>41, node=>BC
+wait=>BB, world=>CBA, user=>BAA, status=>18, line=>842, date=>BAB, public=>t
+title=>BA, subtitle=>CA, query=>CCB, line=>843, space=>BB
+auth=>BB, world=>ACA, line=>844, pos=>29
+state=>65, org=>40, query=>CAA, user=>AB, indexed=>f, cleaned=>f, line=>845
+title=>CB, cleaned=>f, indexed=>f, line=>846
+wait=>CAA, indexed=>f, line=>847, disabled=>f
+
+title=>CB, query=>CC, line=>849, abstract=>CB, pos=>10, public=>t
+auth=>CB, subtitle=>BA, cleaned=>t, line=>850, disabled=>t, pos=>84
+org=>45, wait=>BA, query=>CCC, line=>851, date=>BCA, coauthors=>CAB
+state=>84, title=>CB, line=>852, pos=>71, space=>CA
+line=>853, public=>t, node=>AA
+subtitle=>BC, user=>AB, cleaned=>t, line=>854, public=>t
+state=>26, wait=>BA, world=>BBB, user=>BB, status=>53, line=>855, abstract=>ABA, pos=>72, space=>AC
+line=>856, public=>f, coauthors=>CA
+wait=>ABB, subtitle=>CBA, line=>857, pos=>44
+auth=>ABA, wait=>CC, org=>0, bad=>t, query=>BB, line=>858, disabled=>f, public=>t
+bad=>f, user=>AA, line=>859, pos=>90
+world=>BCC, title=>BAA, bad=>f, user=>CAA, query=>BBC, line=>860, date=>CAA, space=>BCB, public=>t, coauthors=>CB
+title=>BAB, world=>BC, subtitle=>AA, cleaned=>f, status=>9, line=>861, pos=>95
+title=>AC, line=>862
+wait=>CB, bad=>f, status=>89, line=>863, coauthors=>AB
+subtitle=>ACC, indexed=>t, cleaned=>t, line=>864
+title=>AB, subtitle=>CBB, query=>ACA, indexed=>t, line=>865, disabled=>t
+title=>BC, world=>BB, query=>AA, user=>ACB, status=>43, cleaned=>f, line=>866, coauthors=>CBC, node=>ACB
+
+org=>25, wait=>AC, indexed=>f, line=>868, disabled=>f, abstract=>CA, pos=>48
+bad=>t, status=>34, line=>869, pos=>32, date=>AC, public=>t, node=>AA
+state=>33, wait=>AAC, indexed=>t, status=>20, line=>870, abstract=>BA
+wait=>CCC, subtitle=>AC, line=>871, disabled=>f, space=>BA, public=>t, coauthors=>BCC
+status=>49, line=>872
+state=>90, title=>ACC, world=>CBB, subtitle=>BAB, bad=>f, status=>94, line=>873, abstract=>CB
+title=>BCB, line=>874
+cleaned=>f, line=>875
+wait=>BAA, subtitle=>BBC, line=>876
+auth=>AB, org=>35, bad=>f, indexed=>f, line=>877, coauthors=>BBA
+line=>878, public=>f
+
+auth=>CB, wait=>CBC, indexed=>f, line=>880, public=>t
+query=>CC, status=>4, line=>881, disabled=>t, node=>CA
+title=>BB, line=>882
+state=>53, bad=>f, cleaned=>f, status=>63, line=>883, coauthors=>BAA
+auth=>ACA, world=>AC, user=>CBC, line=>884, date=>BCA, node=>BBC
+auth=>BAB, state=>11, world=>CB, org=>77, query=>BA, cleaned=>f, line=>885, space=>AC
+world=>CA, user=>CA, line=>886, node=>CB
+state=>32, org=>50, wait=>AA, line=>887, disabled=>f, space=>BBA, public=>f
+cleaned=>t, line=>888, pos=>70, node=>ABC
+org=>63, user=>AAB, query=>BB, line=>889, date=>BC, space=>CBB, node=>ABC
+wait=>BB, user=>BB, query=>CB, line=>890, space=>BB, coauthors=>BA, node=>ABC
+auth=>BC, world=>CC, subtitle=>CB, line=>891, public=>f, coauthors=>BC
+state=>13, org=>38, line=>892, coauthors=>BC, node=>ABC
+auth=>CC, world=>CAC, line=>893, date=>BBA, node=>CBC
+
+auth=>AA, line=>895, coauthors=>BB
+auth=>AA, state=>76, status=>85, line=>896, date=>CCC, public=>t, coauthors=>AB
+auth=>AB, indexed=>t, cleaned=>f, line=>897
+line=>898, coauthors=>CBB
+
+wait=>ACC, line=>900, abstract=>BBA
+auth=>AA, wait=>BCB, cleaned=>f, line=>901, abstract=>AAC
+state=>68, title=>AC, subtitle=>BB, line=>902
+state=>41, wait=>ABA, bad=>f, user=>BBA, status=>46, line=>903, node=>AAB
+
+cleaned=>f, line=>905, pos=>33
+bad=>f, query=>BA, line=>906, pos=>48, space=>CB, public=>t
+query=>CB, indexed=>t, line=>907, pos=>41, abstract=>CBB, space=>BA, public=>f, node=>BC
+title=>AB, line=>908
+auth=>BC, title=>CB, line=>909, disabled=>f, space=>CA, public=>t, coauthors=>BC
+world=>AA, user=>ABA, indexed=>f, line=>910, abstract=>CC
+auth=>CCA, indexed=>f, line=>911, date=>AC, public=>f
+world=>AAB, bad=>t, line=>912
+subtitle=>CBB, line=>913, public=>t
+wait=>CB, line=>914, disabled=>f, pos=>71, date=>BA, space=>CBA, public=>f, coauthors=>BB
+org=>67, wait=>CA, bad=>f, line=>915, disabled=>f, public=>t
+
+line=>917, date=>CB
+auth=>CBB, world=>AAA, status=>83, indexed=>f, line=>918, disabled=>t, date=>CBA, coauthors=>ACC
+wait=>AB, title=>BA, status=>33, line=>919, disabled=>f
+wait=>ACB, cleaned=>f, line=>920, abstract=>AA, coauthors=>BCB
+wait=>ABB, org=>40, world=>BC, subtitle=>CA, user=>AAC, status=>14, indexed=>t, line=>921, pos=>66
+auth=>BA, org=>22, wait=>BAB, bad=>t, user=>ACC, status=>32, line=>922
+world=>BA, query=>CAB, status=>0, line=>923
+org=>84, bad=>t, line=>924, coauthors=>BAB
+auth=>ACC, subtitle=>AAA, query=>CCA, cleaned=>f, line=>925, pos=>60, space=>BC
+wait=>BC, subtitle=>CCC, bad=>f, cleaned=>f, indexed=>f, line=>926, public=>f, coauthors=>AC
+auth=>CA, state=>91, org=>6, world=>AA, wait=>ABB, query=>AAC, line=>927, date=>CA, node=>BAC
+world=>BCA, query=>AA, user=>BBC, line=>928, disabled=>f
+world=>CBC, user=>CBC, line=>929, date=>CAC
+world=>BCB, bad=>f, user=>BB, line=>930
+auth=>CA, world=>AA, query=>ABA, user=>AA, indexed=>t, line=>931, coauthors=>BBC
+auth=>BAA, bad=>t, line=>932, disabled=>f, pos=>93, abstract=>CCA, date=>BBA, coauthors=>AA
+line=>933, space=>CAB, node=>AB
+
+status=>60, cleaned=>t, indexed=>t, line=>935, pos=>35, space=>CAB, node=>BBB
+wait=>AAA, bad=>t, status=>26, line=>936, abstract=>ACB, space=>BBA, coauthors=>CCC
+title=>BA, bad=>t, line=>937, date=>BBA, public=>t
+
+query=>BA, user=>BA, line=>939, disabled=>t
+line=>940, date=>CC
+wait=>CAB, query=>BCA, user=>BC, line=>941, pos=>8, coauthors=>ACC
+line=>942, space=>BA
+auth=>CA, org=>11, line=>943, pos=>99
+org=>83, line=>944, disabled=>f, date=>BBA, space=>AC, node=>AC
+world=>CCA, line=>945, node=>BC
+org=>95, title=>CA, world=>BA, line=>946, pos=>36, coauthors=>CA
+state=>93, line=>947
+cleaned=>f, status=>5, line=>948, abstract=>BB, public=>f, coauthors=>ABC
+world=>CA, org=>61, bad=>f, query=>CC, cleaned=>t, line=>949, pos=>14, space=>CC
+state=>91, line=>950, abstract=>BA, date=>AB
+auth=>BBC, line=>951, date=>BB
+auth=>BAB, line=>952, disabled=>t, node=>AAA
+auth=>CAA, subtitle=>ABA, bad=>t, line=>953
+auth=>CA, wait=>BB, org=>12, user=>BCC, cleaned=>f, line=>954, public=>f, coauthors=>AA
+org=>93, cleaned=>t, line=>955, disabled=>t, public=>t, node=>ACA
+line=>956, pos=>10
+org=>74, world=>CCC, subtitle=>AB, user=>AAA, cleaned=>t, line=>957, pos=>70, public=>t, node=>CC
+state=>51, line=>958
+world=>CCA, title=>BCB, user=>AB, indexed=>t, line=>959, disabled=>t, pos=>21, date=>CBC
+org=>86, wait=>BC, query=>BB, user=>AA, indexed=>t, line=>960, pos=>58, date=>AB
+line=>961, node=>CC
+auth=>BCB, world=>ACC, subtitle=>CA, bad=>t, user=>BA, indexed=>f, line=>962, public=>f
+
+status=>37, line=>964
+state=>70, status=>76, indexed=>f, line=>965, disabled=>t, space=>BB
+
+state=>67, world=>CA, title=>AA, line=>967, abstract=>BA, space=>BAA
+auth=>CA, world=>AA, bad=>t, query=>BC, status=>53, indexed=>f, line=>968, date=>AB, node=>BAA
+query=>AC, cleaned=>t, line=>969, abstract=>BC, space=>CAB, coauthors=>BAA
+wait=>BCA, world=>CB, title=>BC, indexed=>f, line=>970, disabled=>t, pos=>70, date=>AB
+
+subtitle=>BC, query=>AA, line=>972
+line=>973, public=>t
+org=>75, world=>AAB, subtitle=>BB, user=>CC, line=>974, space=>CA
+auth=>BCB, cleaned=>t, line=>975
+title=>BAC, user=>CB, line=>976, public=>f
+subtitle=>BAC, indexed=>f, cleaned=>f, line=>977, disabled=>f, abstract=>ABC, space=>ABA
+state=>63, bad=>f, line=>978, pos=>93, node=>AAC
+
+cleaned=>f, line=>980, abstract=>CCB
+state=>40, title=>ABA, subtitle=>CAB, query=>BC, line=>981, date=>CA, coauthors=>AB
+
+auth=>ABA, subtitle=>ACC, user=>AA, query=>AC, cleaned=>t, line=>983, date=>ACB, node=>CB
+state=>32, title=>ABC, org=>58, status=>95, line=>984, disabled=>t, pos=>6, space=>CBB
+title=>BCC, subtitle=>CCC, user=>BBC, line=>985, public=>f, coauthors=>CCB, node=>AA
+subtitle=>ACA, query=>BCC, status=>43, cleaned=>t, indexed=>t, line=>986, abstract=>CAC
+
+world=>CAB, org=>21, indexed=>t, line=>988, abstract=>ABC
+title=>CBC, status=>66, line=>989
+
+line=>991, abstract=>BA, node=>BBB
+line=>992, disabled=>t, pos=>29, public=>f
+state=>53, wait=>CB, subtitle=>CCC, line=>993, date=>CAC, public=>f, coauthors=>BB
+wait=>CBA, title=>CA, subtitle=>BB, user=>BAA, line=>994, disabled=>t, date=>BB, coauthors=>CCC, node=>CC
+title=>BB, user=>AA, query=>CAA, status=>43, line=>995, pos=>6, abstract=>CC, public=>t
+wait=>AC, query=>BA, line=>996, coauthors=>BB, node=>CCC
+auth=>BC, title=>CAC, subtitle=>BA, line=>997, date=>BAA
+wait=>AB, user=>ABC, line=>998, pos=>41, node=>CAC
+state=>4, title=>AC, bad=>t, status=>59, line=>999, disabled=>t
+user=>BC, line=>1000
diff --git a/expected/hstore.out b/expected/hstore.out
new file mode 100644 (file)
index 0000000..06605e1
--- /dev/null
@@ -0,0 +1,607 @@
+\set ECHO none
+psql:hstore.sql:8: NOTICE:  type "hstore" is not yet defined
+DETAIL:  Creating a shell type definition.
+psql:hstore.sql:13: NOTICE:  argument type hstore is only a shell
+psql:hstore.sql:132: NOTICE:  type "ghstore" is not yet defined
+DETAIL:  Creating a shell type definition.
+psql:hstore.sql:137: NOTICE:  argument type ghstore is only a shell
+--hstore;
+select ''::hstore;
+ hstore 
+--------
+(1 row)
+
+select 'a=>b'::hstore;
+  hstore  
+----------
+ "a"=>"b"
+(1 row)
+
+select ' a=>b'::hstore;
+  hstore  
+----------
+ "a"=>"b"
+(1 row)
+
+select 'a =>b'::hstore;
+  hstore  
+----------
+ "a"=>"b"
+(1 row)
+
+select 'a=>b '::hstore;
+  hstore  
+----------
+ "a"=>"b"
+(1 row)
+
+select 'a=> b'::hstore;
+  hstore  
+----------
+ "a"=>"b"
+(1 row)
+
+select '"a"=>"b"'::hstore;
+  hstore  
+----------
+ "a"=>"b"
+(1 row)
+
+select ' "a"=>"b"'::hstore;
+  hstore  
+----------
+ "a"=>"b"
+(1 row)
+
+select '"a" =>"b"'::hstore;
+  hstore  
+----------
+ "a"=>"b"
+(1 row)
+
+select '"a"=>"b" '::hstore;
+  hstore  
+----------
+ "a"=>"b"
+(1 row)
+
+select '"a"=> "b"'::hstore;
+  hstore  
+----------
+ "a"=>"b"
+(1 row)
+
+select 'aa=>bb'::hstore;
+   hstore   
+------------
+ "aa"=>"bb"
+(1 row)
+
+select ' aa=>bb'::hstore;
+   hstore   
+------------
+ "aa"=>"bb"
+(1 row)
+
+select 'aa =>bb'::hstore;
+   hstore   
+------------
+ "aa"=>"bb"
+(1 row)
+
+select 'aa=>bb '::hstore;
+   hstore   
+------------
+ "aa"=>"bb"
+(1 row)
+
+select 'aa=> bb'::hstore;
+   hstore   
+------------
+ "aa"=>"bb"
+(1 row)
+
+select '"aa"=>"bb"'::hstore;
+   hstore   
+------------
+ "aa"=>"bb"
+(1 row)
+
+select ' "aa"=>"bb"'::hstore;
+   hstore   
+------------
+ "aa"=>"bb"
+(1 row)
+
+select '"aa" =>"bb"'::hstore;
+   hstore   
+------------
+ "aa"=>"bb"
+(1 row)
+
+select '"aa"=>"bb" '::hstore;
+   hstore   
+------------
+ "aa"=>"bb"
+(1 row)
+
+select '"aa"=> "bb"'::hstore;
+   hstore   
+------------
+ "aa"=>"bb"
+(1 row)
+
+select 'aa=>bb, cc=>dd'::hstore;
+         hstore         
+------------------------
+ "aa"=>"bb", "cc"=>"dd"
+(1 row)
+
+select 'aa=>bb , cc=>dd'::hstore;
+         hstore         
+------------------------
+ "aa"=>"bb", "cc"=>"dd"
+(1 row)
+
+select 'aa=>bb ,cc=>dd'::hstore;
+         hstore         
+------------------------
+ "aa"=>"bb", "cc"=>"dd"
+(1 row)
+
+select 'aa=>bb, "cc"=>dd'::hstore;
+         hstore         
+------------------------
+ "aa"=>"bb", "cc"=>"dd"
+(1 row)
+
+select 'aa=>bb , "cc"=>dd'::hstore;
+         hstore         
+------------------------
+ "aa"=>"bb", "cc"=>"dd"
+(1 row)
+
+select 'aa=>bb ,"cc"=>dd'::hstore;
+         hstore         
+------------------------
+ "aa"=>"bb", "cc"=>"dd"
+(1 row)
+
+select 'aa=>"bb", cc=>dd'::hstore;
+         hstore         
+------------------------
+ "aa"=>"bb", "cc"=>"dd"
+(1 row)
+
+select 'aa=>"bb" , cc=>dd'::hstore;
+         hstore         
+------------------------
+ "aa"=>"bb", "cc"=>"dd"
+(1 row)
+
+select 'aa=>"bb" ,cc=>dd'::hstore;
+         hstore         
+------------------------
+ "aa"=>"bb", "cc"=>"dd"
+(1 row)
+
+select 'aa=>null'::hstore;
+   hstore   
+------------
+ "aa"=>NULL
+(1 row)
+
+select 'aa=>NuLl'::hstore;
+   hstore   
+------------
+ "aa"=>NULL
+(1 row)
+
+select 'aa=>"NuLl"'::hstore;
+    hstore    
+--------------
+ "aa"=>"NuLl"
+(1 row)
+
+select '\\=a=>q=w'::hstore;
+   hstore    
+-------------
+ "=a"=>"q=w"
+(1 row)
+
+select '"=a"=>q\\=w'::hstore;
+   hstore    
+-------------
+ "=a"=>"q=w"
+(1 row)
+
+select '"\\"a"=>q>w'::hstore;
+    hstore    
+--------------
+ "\"a"=>"q>w"
+(1 row)
+
+select '\\"a=>q"w'::hstore;
+    hstore     
+---------------
+ "\"a"=>"q\"w"
+(1 row)
+
+select ''::hstore;
+ hstore 
+--------
+(1 row)
+
+select '       '::hstore;
+ hstore 
+--------
+(1 row)
+
+-- -> operator
+select 'aa=>b, c=>d , b=>16'::hstore->'c';
+ ?column? 
+----------
+ d
+(1 row)
+
+select 'aa=>b, c=>d , b=>16'::hstore->'b';
+ ?column? 
+----------
+ 16
+(1 row)
+
+select 'aa=>b, c=>d , b=>16'::hstore->'aa';
+ ?column? 
+----------
+ b
+(1 row)
+
+select ('aa=>b, c=>d , b=>16'::hstore->'gg') is null;
+ ?column? 
+----------
+ t
+(1 row)
+
+select ('aa=>NULL, c=>d , b=>16'::hstore->'aa') is null;
+ ?column? 
+----------
+ t
+(1 row)
+
+-- exists/defined
+select isexists('a=>NULL, b=>qq', 'a');
+ isexists 
+----------
+ t
+(1 row)
+
+select isexists('a=>NULL, b=>qq', 'b');
+ isexists 
+----------
+ t
+(1 row)
+
+select isexists('a=>NULL, b=>qq', 'c');
+ isexists 
+----------
+ f
+(1 row)
+
+select isdefined('a=>NULL, b=>qq', 'a');
+ isdefined 
+-----------
+ f
+(1 row)
+
+select isdefined('a=>NULL, b=>qq', 'b');
+ isdefined 
+-----------
+ t
+(1 row)
+
+select isdefined('a=>NULL, b=>qq', 'c');
+ isdefined 
+-----------
+ f
+(1 row)
+
+-- delete 
+select delete('a=>1 , b=>2, c=>3'::hstore, 'a');
+       delete       
+--------------------
+ "b"=>"2", "c"=>"3"
+(1 row)
+
+select delete('a=>null , b=>2, c=>3'::hstore, 'a');
+       delete       
+--------------------
+ "b"=>"2", "c"=>"3"
+(1 row)
+
+select delete('a=>1 , b=>2, c=>3'::hstore, 'b');
+       delete       
+--------------------
+ "a"=>"1", "c"=>"3"
+(1 row)
+
+select delete('a=>1 , b=>2, c=>3'::hstore, 'c');
+       delete       
+--------------------
+ "a"=>"1", "b"=>"2"
+(1 row)
+
+select delete('a=>1 , b=>2, c=>3'::hstore, 'd');
+            delete            
+------------------------------
+ "a"=>"1", "b"=>"2", "c"=>"3"
+(1 row)
+
+-- ||
+select 'aa=>1 , b=>2, cq=>3'::hstore || 'cq=>l, b=>g, 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"
+(1 row)
+
+select 'aa=>1 , b=>2, cq=>3'::hstore || 'aa=>l';
+            ?column?            
+--------------------------------
+ "b"=>"2", "aa"=>"l", "cq"=>"3"
+(1 row)
+
+select 'aa=>1 , b=>2, cq=>3'::hstore || '';
+            ?column?            
+--------------------------------
+ "b"=>"2", "aa"=>"1", "cq"=>"3"
+(1 row)
+
+select ''::hstore || 'cq=>l, b=>g, fg=>f';
+            ?column?            
+--------------------------------
+ "b"=>"g", "cq"=>"l", "fg"=>"f"
+(1 row)
+
+-- =>
+select 'a=>g, b=>c'::hstore || ( 'asd'=>'gf' );
+            ?column?             
+---------------------------------
+ "a"=>"g", "b"=>"c", "asd"=>"gf"
+(1 row)
+
+select 'a=>g, b=>c'::hstore || ( 'b'=>'gf' );
+      ?column?       
+---------------------
+ "a"=>"g", "b"=>"gf"
+(1 row)
+
+-- keys/values
+select akeys('aa=>1 , b=>2, cq=>3'::hstore || 'cq=>l, b=>g, fg=>f');
+    akeys     
+--------------
+ {b,aa,cq,fg}
+(1 row)
+
+select akeys('""=>1');
+ akeys 
+-------
+ {""}
+(1 row)
+
+select akeys('');
+ akeys 
+-------
+ {}
+(1 row)
+
+select avals('aa=>1 , b=>2, cq=>3'::hstore || 'cq=>l, b=>g, fg=>f');
+   avals   
+-----------
+ {g,1,l,f}
+(1 row)
+
+select avals('aa=>1 , b=>2, cq=>3'::hstore || 'cq=>l, b=>g, fg=>NULL');
+   avals    
+------------
+ {g,1,l,""}
+(1 row)
+
+select avals('""=>1');
+ avals 
+-------
+ {1}
+(1 row)
+
+select avals('');
+ avals 
+-------
+ {}
+(1 row)
+
+select * from skeys('aa=>1 , b=>2, cq=>3'::hstore || 'cq=>l, b=>g, fg=>f');
+ skeys 
+-------
+ b
+ aa
+ cq
+ fg
+(4 rows)
+
+select * from skeys('""=>1');
+ skeys 
+-------
+(1 row)
+
+select * from skeys('');
+ skeys 
+-------
+(0 rows)
+
+select * from svals('aa=>1 , b=>2, cq=>3'::hstore || 'cq=>l, b=>g, fg=>f');
+ svals 
+-------
+ g
+ 1
+ l
+ f
+(4 rows)
+
+select *, svals is null from svals('aa=>1 , b=>2, cq=>3'::hstore || 'cq=>l, b=>g, fg=>NULL');
+ svals | ?column? 
+-------+----------
+ g     | f
+ 1     | f
+ l     | f
+       | t
+(4 rows)
+
+select * from svals('""=>1');
+ svals 
+-------
+ 1
+(1 row)
+
+select * from svals('');
+ svals 
+-------
+(0 rows)
+
+select * from each('aaa=>bq, b=>NULL, ""=>1 ');
+ key | value 
+-----+-------
+     | 1
+ b   | 
+ aaa | bq
+(3 rows)
+
+-- @
+select 'a=>b, b=>1, c=>NULL'::hstore @ 'a=>NULL';
+ ?column? 
+----------
+ t
+(1 row)
+
+select 'a=>b, b=>1, c=>NULL'::hstore @ 'a=>NULL, c=>NULL';
+ ?column? 
+----------
+ t
+(1 row)
+
+select 'a=>b, b=>1, c=>NULL'::hstore @ 'a=>NULL, g=>NULL';
+ ?column? 
+----------
+ f
+(1 row)
+
+select 'a=>b, b=>1, c=>NULL'::hstore @ 'g=>NULL';
+ ?column? 
+----------
+ f
+(1 row)
+
+select 'a=>b, b=>1, c=>NULL'::hstore @ 'a=>c';
+ ?column? 
+----------
+ f
+(1 row)
+
+select 'a=>b, b=>1, c=>NULL'::hstore @ 'a=>b';
+ ?column? 
+----------
+ t
+(1 row)
+
+select 'a=>b, b=>1, c=>NULL'::hstore @ 'a=>b, c=>NULL';
+ ?column? 
+----------
+ t
+(1 row)
+
+select 'a=>b, b=>1, c=>NULL'::hstore @ 'a=>b, c=>q';
+ ?column? 
+----------
+ f
+(1 row)
+
+CREATE TABLE testhstore (h hstore);
+\copy testhstore from 'data/hstore.data'
+select count(*) from testhstore where h @ 'wait=>NULL';
+ count 
+-------
+   189
+(1 row)
+
+select count(*) from testhstore where h @ 'wait=>CC';
+ count 
+-------
+    15
+(1 row)
+
+select count(*) from testhstore where h @ 'wait=>CC, public=>t';
+ count 
+-------
+     2
+(1 row)
+
+create index hidx on testhstore using gist(h);
+set enable_seqscan=off;
+select count(*) from testhstore where h @ 'wait=>NULL';
+ count 
+-------
+   189
+(1 row)
+
+select count(*) from testhstore where h @ 'wait=>CC';
+ count 
+-------
+    15
+(1 row)
+
+select count(*) from testhstore where h @ 'wait=>CC, public=>t';
+ count 
+-------
+     2
+(1 row)
+
+select count(*) from (select (each(h)).key from testhstore) as wow ;
+ count 
+-------
+  4779
+(1 row)
+
+select key, count(*) from (select (each(h)).key from testhstore) as wow group by key order by count desc, key;
+    key    | count 
+-----------+-------
+ line      |   883
+ query     |   207
+ pos       |   203
+ node      |   202
+ space     |   197
+ status    |   195
+ public    |   194
+ title     |   190
+ org       |   189
+ user      |   189
+ wait      |   189
+ coauthors |   188
+ disabled  |   185
+ indexed   |   184
+ cleaned   |   180
+ bad       |   179
+ date      |   179
+ world     |   176
+ state     |   172
+ subtitle  |   169
+ auth      |   168
+ abstract  |   161
+(22 rows)
+
diff --git a/hstore.h b/hstore.h
new file mode 100644 (file)
index 0000000..b6c8a81
--- /dev/null
+++ b/hstore.h
@@ -0,0 +1,49 @@
+#ifndef __HSTORE_H__
+#define __HSTORE_H__
+
+#include "postgres.h"
+
+#include "access/gist.h"
+#include "access/itup.h"
+#include "utils/elog.h"
+#include "utils/palloc.h"
+#include "utils/builtins.h"
+#include "storage/bufpage.h"
+
+
+typedef struct {
+       uint16  keylen;
+       uint16  vallen;
+       uint32  
+               valisnull:1,
+               pos:31;
+} HEntry; 
+
+
+typedef struct {
+       int4    len;
+       int4    size;
+       char    data[1];
+} HStore;
+
+#define HSHRDSIZE      (2*sizeof(int4))
+#define CALCDATASIZE(x, lenstr) ( (x) * sizeof(HEntry) + HSHRDSIZE + (lenstr) )
+#define ARRPTR(x)       ( (HEntry*) ( (char*)(x) + HSHRDSIZE ) )
+#define STRPTR(x)       ( (char*)(x) + HSHRDSIZE + ( sizeof(HEntry) * ((HStore*)x)->size ) )
+
+
+#define PG_GETARG_HS(x)        ((HStore*)PG_DETOAST_DATUM(PG_GETARG_DATUM(x)))
+
+typedef struct {
+        char    *key;
+        char    *val;
+        uint16  keylen;
+        uint16  vallen;
+        bool    isnull;  
+        bool    needfree;  
+} Pairs;
+
+int comparePairs(const void *a, const void *b);
+int uniquePairs(Pairs * a, int4 l, int4 *buflen);
+
+#endif
diff --git a/hstore.sql.in b/hstore.sql.in
new file mode 100644 (file)
index 0000000..98ca9cf
--- /dev/null
@@ -0,0 +1,195 @@
+SET search_path = public;
+
+BEGIN;
+
+CREATE FUNCTION hstore_in(cstring)
+RETURNS hstore
+AS 'MODULE_PATHNAME'
+LANGUAGE 'C' with (isstrict);
+
+CREATE FUNCTION hstore_out(hstore)
+RETURNS cstring
+AS 'MODULE_PATHNAME'
+LANGUAGE 'C' with (isstrict);
+
+CREATE TYPE hstore (
+        INTERNALLENGTH = -1,
+        INPUT = hstore_in,
+        OUTPUT = hstore_out,
+        STORAGE = extended
+);
+
+CREATE FUNCTION fetchval(hstore,text)
+RETURNS text
+AS 'MODULE_PATHNAME'
+LANGUAGE 'C' with (isstrict,iscachable);
+
+CREATE OPERATOR -> (
+       LEFTARG = hstore,
+       RIGHTARG = text,
+       PROCEDURE = fetchval
+);
+
+CREATE FUNCTION isexists(hstore,text)
+RETURNS bool
+AS 'MODULE_PATHNAME','exists'
+LANGUAGE 'C' with (isstrict,iscachable);
+
+CREATE FUNCTION isdefined(hstore,text)
+RETURNS bool
+AS 'MODULE_PATHNAME','defined'
+LANGUAGE 'C' with (isstrict,iscachable);
+
+CREATE FUNCTION delete(hstore,text)
+RETURNS hstore
+AS 'MODULE_PATHNAME','delete'
+LANGUAGE 'C' with (isstrict,iscachable);
+
+CREATE FUNCTION hs_concat(hstore,hstore)
+RETURNS hstore
+AS 'MODULE_PATHNAME'
+LANGUAGE 'C' with (isstrict,iscachable);
+
+CREATE OPERATOR || (
+       LEFTARG = hstore,
+       RIGHTARG = hstore,
+       PROCEDURE = hs_concat
+);
+
+CREATE FUNCTION hs_contains(hstore,hstore)
+RETURNS bool
+AS 'MODULE_PATHNAME'
+LANGUAGE 'C' with (isstrict,iscachable);
+
+CREATE OPERATOR @ (
+       LEFTARG = hstore,
+       RIGHTARG = hstore,
+       PROCEDURE = hs_contains,
+       COMMUTATOR = '~',
+       RESTRICT = contsel,
+       JOIN = contjoinsel
+);
+
+CREATE FUNCTION hs_contained(hstore,hstore)
+RETURNS bool
+AS 'MODULE_PATHNAME'
+LANGUAGE 'C' with (isstrict,iscachable);
+
+CREATE OPERATOR ~ (
+       LEFTARG = hstore,
+       RIGHTARG = hstore,
+       PROCEDURE = hs_contained,
+       COMMUTATOR = '@',
+       RESTRICT = contsel,
+       JOIN = contjoinsel
+);
+
+CREATE FUNCTION tconvert(text,text)
+RETURNS hstore
+AS 'MODULE_PATHNAME'
+LANGUAGE 'C' with (isstrict,iscachable);
+
+CREATE OPERATOR => (
+       LEFTARG = text,
+       RIGHTARG = text,
+       PROCEDURE = tconvert
+);
+
+CREATE FUNCTION akeys(hstore)
+RETURNS _text
+AS 'MODULE_PATHNAME'
+LANGUAGE 'C' with (isstrict,iscachable);
+
+CREATE FUNCTION avals(hstore)
+RETURNS _text
+AS 'MODULE_PATHNAME'
+LANGUAGE 'C' with (isstrict,iscachable);
+
+CREATE FUNCTION skeys(hstore)
+RETURNS setof text
+AS 'MODULE_PATHNAME'
+LANGUAGE 'C' with (isstrict,iscachable);
+
+CREATE FUNCTION svals(hstore)
+RETURNS setof text
+AS 'MODULE_PATHNAME'
+LANGUAGE 'C' with (isstrict,iscachable);
+
+create type hs_each as (key text, value text);
+
+CREATE FUNCTION each(hstore)
+RETURNS setof hs_each
+AS 'MODULE_PATHNAME'
+LANGUAGE 'C' with (isstrict,iscachable);
+
+
+
+-- define the GiST support methods
+
+CREATE FUNCTION ghstore_in(cstring)
+RETURNS ghstore
+AS 'MODULE_PATHNAME'
+LANGUAGE 'C' with (isstrict);
+
+CREATE FUNCTION ghstore_out(ghstore)
+RETURNS cstring
+AS 'MODULE_PATHNAME'
+LANGUAGE 'C' with (isstrict);
+
+CREATE TYPE ghstore (
+        INTERNALLENGTH = -1,
+        INPUT = ghstore_in,
+        OUTPUT = ghstore_out
+);
+
+CREATE FUNCTION ghstore_compress(internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE 'C';
+
+CREATE FUNCTION ghstore_decompress(internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE 'C';
+
+CREATE FUNCTION ghstore_penalty(internal,internal,internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE 'C' WITH (isstrict);
+
+CREATE FUNCTION ghstore_picksplit(internal, internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE 'C';
+
+CREATE FUNCTION ghstore_union(internal, internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE 'C';
+
+CREATE FUNCTION ghstore_same(internal, internal, internal)
+RETURNS internal
+AS 'MODULE_PATHNAME'
+LANGUAGE 'C';
+
+CREATE FUNCTION ghstore_consistent(internal,internal,int4)
+RETURNS bool
+AS 'MODULE_PATHNAME'
+LANGUAGE 'C';
+
+-- register the opclass for indexing (not as default)
+CREATE OPERATOR CLASS gist_hstore_ops
+DEFAULT FOR TYPE hstore USING gist
+AS
+        OPERATOR        7       @       RECHECK,
+        --OPERATOR        8       ~       RECHECK,
+        FUNCTION        1       ghstore_consistent (internal, internal, int4),
+        FUNCTION        2       ghstore_union (internal, internal),
+        FUNCTION        3       ghstore_compress (internal),
+        FUNCTION        4       ghstore_decompress (internal),
+        FUNCTION        5       ghstore_penalty (internal, internal, internal),
+        FUNCTION        6       ghstore_picksplit (internal, internal),
+        FUNCTION        7       ghstore_same (internal, internal, internal),
+        STORAGE         ghstore;
+
+END;
diff --git a/hstore_gist.c b/hstore_gist.c
new file mode 100644 (file)
index 0000000..f6ecc78
--- /dev/null
@@ -0,0 +1,481 @@
+#include "hstore.h"
+
+#include "access/gist.h"
+#include "access/itup.h"
+/*#include "access/rtree.h"*/
+#include "crc32.h"
+
+/* bigint defines */
+#define BITBYTE 8
+#define SIGLENINT  4              /* >122 => key will toast, so very slow!!! */
+#define SIGLEN  ( sizeof(int)*SIGLENINT )
+#define SIGLENBIT (SIGLEN*BITBYTE)
+
+typedef char BITVEC[SIGLEN];
+typedef char *BITVECP;
+
+#define SIGPTR(x)  ( (BITVECP) ARR_DATA_PTR(x) )
+
+
+#define LOOPBYTE(a) \
+               for(i=0;i<SIGLEN;i++) {\
+                               a;\
+               }
+
+#define LOOPBIT(a) \
+               for(i=0;i<SIGLENBIT;i++) {\
+                               a;\
+               }
+
+/* beware of multiple evaluation of arguments to these macros! */
+#define GETBYTE(x,i) ( *( (BITVECP)(x) + (int)( (i) / BITBYTE ) ) )
+#define GETBITBYTE(x,i) ( (*((char*)(x)) >> (i)) & 0x01 )
+#define CLRBIT(x,i)   GETBYTE(x,i) &= ~( 0x01 << ( (i) % BITBYTE ) )
+#define SETBIT(x,i)   GETBYTE(x,i) |=  ( 0x01 << ( (i) % BITBYTE ) )
+#define GETBIT(x,i) ( (GETBYTE(x,i) >> ( (i) % BITBYTE )) & 0x01 )
+#define HASHVAL(val) (((unsigned int)(val)) % SIGLENBIT)
+#define HASH(sign, val) SETBIT((sign), HASHVAL(val))
+
+typedef struct {
+       int4        len;
+       int4        flag;
+       char        data[1];
+}       GISTTYPE;
+
+#define ALLISTRUE       0x04
+
+#define ISALLTRUE(x)    ( ((GISTTYPE*)x)->flag & ALLISTRUE )
+
+#define GTHDRSIZE       ( sizeof(int4)*2  )
+#define CALCGTSIZE(flag) ( GTHDRSIZE+(((flag) & ALLISTRUE) ? 0 : SIGLEN) )
+  
+#define GETSIGN(x)      ( (BITVECP)( (char*)x+GTHDRSIZE ) )
+
+#define SUMBIT(val) (       \
+       GETBITBYTE((val),0) + \
+       GETBITBYTE((val),1) + \
+       GETBITBYTE((val),2) + \
+       GETBITBYTE((val),3) + \
+       GETBITBYTE((val),4) + \
+       GETBITBYTE((val),5) + \
+       GETBITBYTE((val),6) + \
+       GETBITBYTE((val),7)   \
+)
+
+#ifdef GEVHDRSZ
+#define GETENTRY(vec,pos) ((GISTTYPE *) DatumGetPointer((vec)->vector[(pos)].key))
+#else
+#define GETENTRY(vec,pos) ((GISTTYPE *) DatumGetPointer(((GISTENTRY *) VARDATA(vec))[(pos)].key))
+#endif
+
+#define WISH_F(a,b,c) (double)( -(double)(((a)-(b))*((a)-(b))*((a)-(b)))*(c) )
+
+PG_FUNCTION_INFO_V1(ghstore_in);
+Datum     ghstore_in(PG_FUNCTION_ARGS);
+
+PG_FUNCTION_INFO_V1(ghstore_out);
+Datum     ghstore_out(PG_FUNCTION_ARGS);
+  
+
+Datum
+ghstore_in(PG_FUNCTION_ARGS) {
+       elog(ERROR, "Not implemented");
+       PG_RETURN_DATUM(0);
+}
+
+Datum
+ghstore_out(PG_FUNCTION_ARGS) {
+       elog(ERROR, "Not implemented");
+       PG_RETURN_DATUM(0);
+}
+
+PG_FUNCTION_INFO_V1(ghstore_consistent);
+PG_FUNCTION_INFO_V1(ghstore_compress);
+PG_FUNCTION_INFO_V1(ghstore_decompress);
+PG_FUNCTION_INFO_V1(ghstore_penalty);
+PG_FUNCTION_INFO_V1(ghstore_picksplit);
+PG_FUNCTION_INFO_V1(ghstore_union);
+PG_FUNCTION_INFO_V1(ghstore_same);
+
+Datum     ghstore_consistent(PG_FUNCTION_ARGS);
+Datum     ghstore_compress(PG_FUNCTION_ARGS);
+Datum     ghstore_decompress(PG_FUNCTION_ARGS);
+Datum     ghstore_penalty(PG_FUNCTION_ARGS);
+Datum     ghstore_picksplit(PG_FUNCTION_ARGS);
+Datum     ghstore_union(PG_FUNCTION_ARGS);
+Datum     ghstore_same(PG_FUNCTION_ARGS);
+
+Datum
+ghstore_compress(PG_FUNCTION_ARGS) {
+       GISTENTRY  *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
+       GISTENTRY  *retval = entry;
+        
+       if (entry->leafkey) {                                                  
+               GISTTYPE   *res = (GISTTYPE*)palloc(CALCGTSIZE(0));
+               HStore     *toastedval = (HStore *) DatumGetPointer(entry->key);
+               HStore     *val = (HStore *) DatumGetPointer(PG_DETOAST_DATUM(entry->key));
+               HEntry     *ptr = ARRPTR(val);
+               char       *words = STRPTR(val);
+
+               memset(res,0,CALCGTSIZE(0));
+               res->len=CALCGTSIZE(0);
+       
+               while(ptr-ARRPTR(val) < val->size) {
+                       int h;
+                       h = crc32_sz((char*)(words+ptr->pos), ptr->keylen);
+                       HASH( GETSIGN(res), h);
+                       if ( !ptr->valisnull ) {
+                               h = crc32_sz((char *)(words+ptr->pos+ptr->keylen), ptr->vallen);
+                               HASH( GETSIGN(res), h);
+                       }
+                       ptr++;
+               }
+
+               if (val != toastedval)
+                       pfree(val);
+
+               retval = (GISTENTRY *) palloc(sizeof(GISTENTRY));
+               gistentryinit(*retval, PointerGetDatum(res),
+                                         entry->rel, entry->page,
+                                         entry->offset, res->len, FALSE);
+       } else if ( !ISALLTRUE(DatumGetPointer(entry->key)) ) {
+               int4        i;
+               GISTTYPE   *res;
+               BITVECP  sign = GETSIGN(DatumGetPointer(entry->key));
+               
+               LOOPBYTE(
+                       if ((sign[i] & 0xff) != 0xff)
+                               PG_RETURN_POINTER(retval);
+               );
+
+               res = (GISTTYPE *) palloc(CALCGTSIZE(ALLISTRUE));
+               res->len = CALCGTSIZE(ALLISTRUE);
+               res->flag = ALLISTRUE;
+
+               retval = (GISTENTRY *) palloc(sizeof(GISTENTRY));
+               gistentryinit(*retval, PointerGetDatum(res),
+                                         entry->rel, entry->page,
+                                         entry->offset, res->len, FALSE);
+       }
+
+       PG_RETURN_POINTER(retval);
+}
+
+Datum
+ghstore_decompress(PG_FUNCTION_ARGS) {
+       PG_RETURN_DATUM(PG_GETARG_DATUM(0));
+}
+
+Datum
+ghstore_same(PG_FUNCTION_ARGS) {
+       GISTTYPE   *a = (GISTTYPE *) PG_GETARG_POINTER(0);
+       GISTTYPE   *b = (GISTTYPE *) PG_GETARG_POINTER(1);
+       bool       *result = (bool *) PG_GETARG_POINTER(2);
+
+       if (ISALLTRUE(a) && ISALLTRUE(b))
+               *result = true;
+       else if (ISALLTRUE(a))
+               *result = false;
+       else if (ISALLTRUE(b))
+               *result = false;
+       else {
+               int4            i;
+               BITVECP         sa = GETSIGN(a),
+                               sb = GETSIGN(b);
+               *result = true;
+               LOOPBYTE(
+                       if (sa[i] != sb[i]) {
+                               *result = false;
+                               break;
+                       }
+               );
+       }
+       PG_RETURN_POINTER(result);
+}
+
+static int4
+sizebitvec(BITVECP sign) {
+       int4        size = 0, i;
+       LOOPBYTE(
+               size += SUMBIT(sign);
+               sign = (BITVECP) (((char *) sign) + 1);
+       );
+       return size;
+}
+static int
+hemdistsign(BITVECP  a, BITVECP b) {
+       int i,dist=0;
+
+       LOOPBIT(
+               if ( GETBIT(a,i) != GETBIT(b,i) )
+                       dist++;
+       );
+       return dist;
+}
+
+static int
+hemdist(GISTTYPE   *a, GISTTYPE   *b) {
+       if ( ISALLTRUE(a) ) {
+               if (ISALLTRUE(b))
+                       return 0;
+               else
+                       return SIGLENBIT-sizebitvec(GETSIGN(b));
+       } else if (ISALLTRUE(b))
+               return SIGLENBIT-sizebitvec(GETSIGN(a));
+
+       return hemdistsign( GETSIGN(a), GETSIGN(b) );
+}
+
+static int4
+unionkey(BITVECP sbase, GISTTYPE * add)
+{
+       int4        i;
+       BITVECP  sadd = GETSIGN(add);
+
+       if (ISALLTRUE(add))
+               return 1;
+       LOOPBYTE(
+               sbase[i] |= sadd[i];
+       );
+       return 0;
+}
+
+Datum
+ghstore_union(PG_FUNCTION_ARGS) {
+#ifdef GEVHDRSZ
+       GistEntryVector      *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0);
+       int4        len = entryvec->n;
+#else
+       bytea      *entryvec = (bytea *) PG_GETARG_POINTER(0);
+       int4        len = (VARSIZE(entryvec) - VARHDRSZ) / sizeof(GISTENTRY);
+#endif
+       int             *size = (int *) PG_GETARG_POINTER(1);
+       BITVEC    base;
+       int4        i;
+       int4        flag = 0;
+       GISTTYPE   *result;
+
+       MemSet((void *) base, 0, sizeof(BITVEC));
+       for (i = 0; i < len; i++) {
+               if (unionkey(base, GETENTRY(entryvec, i))) {
+                       flag = ALLISTRUE;
+                       break;
+               }
+       }
+
+       len = CALCGTSIZE(flag);
+       result = (GISTTYPE *) palloc(len);
+       *size = result->len = len;
+       result->flag = flag;
+       if (!ISALLTRUE(result))
+               memcpy((void *) GETSIGN(result), (void *) base, sizeof(BITVEC));
+
+       PG_RETURN_POINTER(result);
+}
+
+Datum
+ghstore_penalty(PG_FUNCTION_ARGS) {
+       GISTENTRY  *origentry = (GISTENTRY *) PG_GETARG_POINTER(0); /* always ISSIGNKEY */
+       GISTENTRY  *newentry = (GISTENTRY *) PG_GETARG_POINTER(1);
+       float      *penalty = (float *) PG_GETARG_POINTER(2);
+       GISTTYPE   *origval = (GISTTYPE *) DatumGetPointer(origentry->key);
+       GISTTYPE   *newval = (GISTTYPE *) DatumGetPointer(newentry->key);
+
+       *penalty=hemdist(origval,newval);
+       PG_RETURN_POINTER(penalty);
+}
+
+
+typedef struct {
+       OffsetNumber pos;
+       int4        cost;
+} SPLITCOST;
+
+static int
+comparecost(const void *a, const void *b) {
+       return ((SPLITCOST *) a)->cost - ((SPLITCOST *) b)->cost;
+}
+
+
+Datum
+ghstore_picksplit(PG_FUNCTION_ARGS) {
+#ifdef GEVHDRSZ
+       GistEntryVector      *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0);
+       OffsetNumber maxoff = entryvec->n - 2;
+#else
+       bytea      *entryvec = (bytea *) PG_GETARG_POINTER(0);
+       OffsetNumber maxoff = ((VARSIZE(entryvec) - VARHDRSZ) / sizeof(GISTENTRY)) - 2;
+#endif
+       GIST_SPLITVEC *v = (GIST_SPLITVEC *) PG_GETARG_POINTER(1);
+       OffsetNumber k,
+                               j;
+       GISTTYPE *datum_l,
+                          *datum_r;
+       BITVECP  union_l,
+                               union_r;
+       int4        size_alpha, size_beta;
+       int4        size_waste,
+                               waste = -1;
+       int4        nbytes;
+       OffsetNumber seed_1 = 0,
+                               seed_2 = 0;
+       OffsetNumber *left,
+                          *right;
+       BITVECP  ptr;
+       int                  i;
+       SPLITCOST  *costvector;
+       GISTTYPE *_k,
+                          *_j;
+
+       nbytes = (maxoff + 2) * sizeof(OffsetNumber);
+       v->spl_left = (OffsetNumber *) palloc(nbytes);
+       v->spl_right = (OffsetNumber *) palloc(nbytes);
+
+       for (k = FirstOffsetNumber; k < maxoff; k = OffsetNumberNext(k)) {
+               _k = GETENTRY(entryvec, k);
+               for (j = OffsetNumberNext(k); j <= maxoff; j = OffsetNumberNext(j)) {
+                       size_waste=hemdist(_k, GETENTRY(entryvec, j));
+                       if (size_waste > waste ) {
+                               waste = size_waste;
+                               seed_1 = k;
+                               seed_2 = j;
+                       }
+               }
+       }
+
+       left = v->spl_left;
+       v->spl_nleft = 0;
+       right = v->spl_right;
+       v->spl_nright = 0;
+
+       if (seed_1 == 0 || seed_2 == 0)
+       {
+               seed_1 = 1;
+               seed_2 = 2;
+       }
+
+       /* form initial .. */
+       if (ISALLTRUE(GETENTRY(entryvec, seed_1))) {
+               datum_l = (GISTTYPE *) palloc(GTHDRSIZE);
+               datum_l->len = GTHDRSIZE;
+               datum_l->flag = ALLISTRUE;
+       } else {
+               datum_l = (GISTTYPE *) palloc(GTHDRSIZE + SIGLEN);
+               datum_l->len = GTHDRSIZE + SIGLEN;
+               datum_l->flag = 0;
+               memcpy((void *) GETSIGN(datum_l), (void *) GETSIGN(GETENTRY(entryvec, seed_1)), sizeof(BITVEC))
+;
+       }
+       if (ISALLTRUE(GETENTRY(entryvec, seed_2))) {
+               datum_r = (GISTTYPE *) palloc(GTHDRSIZE);
+               datum_r->len = GTHDRSIZE;
+               datum_r->flag = ALLISTRUE;
+       } else {
+               datum_r = (GISTTYPE *) palloc(GTHDRSIZE + SIGLEN);
+               datum_r->len = GTHDRSIZE + SIGLEN;
+               datum_r->flag = 0;
+               memcpy((void *) GETSIGN(datum_r), (void *) GETSIGN(GETENTRY(entryvec, seed_2)), sizeof(BITVEC)) ;
+       }
+
+       maxoff = OffsetNumberNext(maxoff);
+       /* sort before ... */
+       costvector = (SPLITCOST *) palloc(sizeof(SPLITCOST) * maxoff);
+       for (j = FirstOffsetNumber; j <= maxoff; j = OffsetNumberNext(j))
+       {
+               costvector[j - 1].pos = j;
+               _j = GETENTRY(entryvec, j);
+               size_alpha = hemdist(datum_l,_j);
+               size_beta  = hemdist(datum_r,_j);
+               costvector[j - 1].cost = abs(size_alpha - size_beta);
+       }
+       qsort((void *) costvector, maxoff, sizeof(SPLITCOST), comparecost);
+
+       union_l=GETSIGN(datum_l);
+       union_r=GETSIGN(datum_r);
+
+       for (k = 0; k < maxoff; k++) {
+               j = costvector[k].pos;
+               if (j == seed_1) {
+                       *left++ = j;
+                       v->spl_nleft++;
+                       continue;
+               } else if (j == seed_2) {
+                       *right++ = j;
+                       v->spl_nright++;
+                       continue;
+               }
+               _j = GETENTRY(entryvec, j);
+               size_alpha = hemdist(datum_l,_j);
+               size_beta  = hemdist(datum_r,_j);
+
+               if (size_alpha < size_beta  + WISH_F(v->spl_nleft, v->spl_nright, 0.0001)) {
+                       if (ISALLTRUE(datum_l) || ISALLTRUE(_j) ) {
+                               if (!ISALLTRUE(datum_l))
+                                       MemSet((void *) union_l, 0xff, sizeof(BITVEC));
+                       } else {
+                               ptr=GETSIGN(_j);
+                               LOOPBYTE(
+                                       union_l[i] |= ptr[i];
+                               );
+                       }
+                       *left++ = j;
+                       v->spl_nleft++;
+               } else {
+                       if (ISALLTRUE(datum_r) || ISALLTRUE(_j) ) {
+                               if (!ISALLTRUE(datum_r))
+                                       MemSet((void *) union_r, 0xff, sizeof(BITVEC));
+                       } else {
+                               ptr=GETSIGN(_j);
+                               LOOPBYTE(
+                                       union_r[i] |= ptr[i];
+                               );
+                       }
+                       *right++ = j;
+                       v->spl_nright++;
+               }
+       }
+
+       *right = *left = FirstOffsetNumber;
+       pfree(costvector);
+
+       v->spl_ldatum = PointerGetDatum(datum_l);
+       v->spl_rdatum = PointerGetDatum(datum_r);
+
+       PG_RETURN_POINTER(v);
+}
+
+
+Datum     
+ghstore_consistent(PG_FUNCTION_ARGS) {
+       GISTTYPE  *entry = (GISTTYPE*) DatumGetPointer( ((GISTENTRY *) PG_GETARG_POINTER(0))->key );
+       HStore *query=PG_GETARG_HS(1);
+       bool res=true;
+       HEntry  *qe = ARRPTR(query);
+       char    *qv = STRPTR(query);
+       BITVECP sign;
+
+       if ( ISALLTRUE(entry) ) {
+               PG_FREE_IF_COPY(query,1);
+               PG_RETURN_BOOL(true);
+       }
+
+       sign=GETSIGN(entry); 
+       while(res && qe-ARRPTR(query) < query->size) {
+               int crc = crc32_sz((char *)(qv + qe->pos), qe->keylen);
+               if (GETBIT(sign,HASHVAL(crc))) {
+                       if ( !qe->valisnull ) {
+                               crc = crc32_sz((char *)(qv + qe->pos + qe->keylen), qe->vallen);
+                               if ( !GETBIT(sign,HASHVAL(crc)) )
+                                       res=false;
+                       }
+               } else
+                       res=false;
+               qe++;
+       }
+
+       PG_FREE_IF_COPY(query,1);
+       PG_RETURN_BOOL(res);
+}
+
+
diff --git a/hstore_io.c b/hstore_io.c
new file mode 100644 (file)
index 0000000..c372a64
--- /dev/null
@@ -0,0 +1,368 @@
+#include "hstore.h"
+#include <ctype.h>
+
+typedef struct {
+       char *begin;
+       char *ptr;
+       char *cur;
+       char *word;
+       int wordlen;
+
+       Pairs   *pairs;
+       int     pcur;
+       int     plen;
+} HSParser;
+
+#define RESIZEPRSBUF \
+do { \
+        if ( state->cur - state->word + 1 >= state->wordlen ) \
+        { \
+                int4 clen = state->cur - state->word; \
+                state->wordlen *= 2; \
+                state->word = (char*)repalloc( (void*)state->word, state->wordlen ); \
+                state->cur = state->word + clen; \
+        } \
+} while (0)
+
+
+#define GV_WAITVAL 0 
+#define GV_INVAL 1 
+#define GV_INESCVAL 2 
+#define GV_WAITESCIN 3 
+#define GV_WAITESCESCIN 4 
+
+static bool
+get_val( HSParser *state, bool ignoreeq, bool *escaped ) {
+       int st = GV_WAITVAL;
+       state->wordlen=32;
+       state->cur = state->word = palloc( state->wordlen );
+       *escaped=false;
+
+       while(1) {
+               if ( st == GV_WAITVAL ) {
+                       if ( *(state->ptr) == '"' ) {
+                               *escaped=true;
+                               st = GV_INESCVAL;
+                       } else if ( *(state->ptr) == '\0' ) {
+                               return false;
+                       } else if (  *(state->ptr) == '=' && !ignoreeq ) {
+                               elog(ERROR,"Syntax error near '%c' at postion %d", *(state->ptr), state->ptr-state->begin);
+                       } else if ( *(state->ptr) == '\\' ) {
+                               st = GV_WAITESCIN;
+                       } else if ( !isspace(*(state->ptr)) ) {
+                               *(state->cur) = *(state->ptr);
+                               state->cur++;
+                               st = GV_INVAL;
+                       }
+               } else if ( st == GV_INVAL ) {
+                       if ( *(state->ptr) == '\\' ) {
+                               st = GV_WAITESCIN;
+                       } else if ( *(state->ptr) == '=' && !ignoreeq ) {
+                               state->ptr--;
+                               return true;
+                       } else if ( *(state->ptr) == ',' && ignoreeq ) {
+                               state->ptr--;
+                               return true;
+                       } else if ( isspace(*(state->ptr)) ) {
+                               return true;
+                       } else if ( *(state->ptr) == '\0' ) {
+                               state->ptr--;
+                               return true;
+                       } else {
+                               RESIZEPRSBUF;
+                               *(state->cur) = *(state->ptr);
+                               state->cur++;
+                       }
+               } else if ( st == GV_INESCVAL ) {
+                       if ( *(state->ptr) == '\\' ) {
+                               st = GV_WAITESCESCIN;
+                       } else if ( *(state->ptr) == '"' ) {
+                               return true;
+                       } else if ( *(state->ptr) == '\0' ) {
+                               elog(ERROR,"Unexpected end of string");
+                       } else {
+                               RESIZEPRSBUF;
+                               *(state->cur) = *(state->ptr);
+                               state->cur++;
+                       }
+               } else if ( st == GV_WAITESCIN ) {
+                       if ( *(state->ptr) == '\0' )
+                               elog(ERROR,"Unexpected end of string");
+                       RESIZEPRSBUF;
+                       *(state->cur) = *(state->ptr);
+                       state->cur++;
+                       st = GV_INVAL; 
+               } else if ( st == GV_WAITESCESCIN ) {
+                       if ( *(state->ptr) == '\0' )
+                               elog(ERROR,"Unexpected end of string");
+                       RESIZEPRSBUF;
+                       *(state->cur) = *(state->ptr);
+                       state->cur++;
+                       st = GV_INESCVAL;
+               } else
+                       elog(ERROR,"Unknown state %d at postion line %d in file '%s'", st, __LINE__, __FILE__); 
+
+               state->ptr++;
+       } 
+
+       return false;
+}
+
+#define WKEY   0
+#define WVAL   1
+#define WEQ    2
+#define WGT    3
+#define WDEL   4
+
+
+static void
+parse_hstore( HSParser *state ) {
+       int st = WKEY;
+       bool escaped=false;
+
+       state->plen=16;
+       state->pairs = (Pairs*)palloc( sizeof(Pairs) * state->plen );
+       state->pcur=0;
+       state->ptr = state->begin;
+       state->word=NULL;
+
+       while(1) {
+               if (st == WKEY) {
+                       if ( !get_val(state, false, &escaped) )
+                               return;
+                       if ( state->pcur >= state->plen ) {
+                               state->plen *= 2;
+                               state->pairs = (Pairs*)repalloc( state->pairs, sizeof(Pairs) * state->plen );
+                       }
+                       state->pairs[ state->pcur ].key = state->word; 
+                       state->pairs[ state->pcur ].keylen = state->cur - state->word;
+                       state->pairs[ state->pcur ].val=NULL;
+                       state->word=NULL;
+                       st = WEQ;
+               } else if ( st == WEQ ) {
+                       if ( *(state->ptr) == '=' ) {
+                               st = WGT;
+                       } else if ( *(state->ptr) == '\0' ) {
+                               elog(ERROR,"Unexpectd end of string");
+                       } else if (!isspace(*(state->ptr))) {
+                               elog(ERROR,"Syntax error near '%c' at postion %d", *(state->ptr), state->ptr-state->begin);
+                       }
+               } else if ( st == WGT ) {
+                       if ( *(state->ptr) == '>' ) {
+                               st = WVAL;
+                       } else if ( *(state->ptr) == '\0' ) {
+                               elog(ERROR,"Unexpectd end of string");
+                       } else { 
+                               elog(ERROR,"Syntax error near '%c' at postion %d", *(state->ptr), state->ptr-state->begin);
+                       }
+               } else if ( st == WVAL ) {
+                       if ( !get_val(state, true, &escaped) )
+                               elog(ERROR,"Unexpected end of string");
+                       state->pairs[ state->pcur ].val = state->word;
+                       state->pairs[ state->pcur ].vallen = state->cur - state->word;
+                       state->pairs[ state->pcur ].isnull = false;
+                       state->pairs[ state->pcur ].needfree = true;
+                       if ( state->cur - state->word == 4 && !escaped) {
+                               state->word[4] = '\0';
+                               if ( 0==strcasecmp(state->word, "null") ) 
+                                       state->pairs[ state->pcur ].isnull=true;
+                       } 
+                       state->word=NULL;
+                       state->pcur++;
+                       st = WDEL;
+               } else if ( st == WDEL ) {
+                       if (  *(state->ptr) == ',' ) {
+                               st = WKEY;
+                       } else if ( *(state->ptr) == '\0' ) {
+                               return;
+                       } else if (!isspace(*(state->ptr))) {
+                               elog(ERROR,"Syntax error near '%c' at postion %d", *(state->ptr), state->ptr-state->begin);
+                       }
+               } else 
+                       elog(ERROR,"Unknown state %d at line %d in file '%s'", st, __LINE__, __FILE__);
+
+               state->ptr++;
+       }
+} 
+
+int
+comparePairs(const void *a, const void *b) {
+       if ( ((Pairs*)a)->keylen == ((Pairs*)b)->keylen ) { 
+               int res =  strncmp(
+                               ((Pairs*)a)->key,
+                               ((Pairs*)b)->key,
+                               ((Pairs*)a)->keylen
+                       );
+               if ( res )
+                       return res;
+
+               /* guarantee that neddfree willl be later */
+               if ( ((Pairs*)b)->needfree == ((Pairs*)a)->needfree )
+                       return 0;
+               else if ( ((Pairs*)a)->needfree )
+                       return 1;
+               else
+                       return -1;  
+       }
+       return ( ((Pairs*)a)->keylen > ((Pairs*)b)->keylen ) ? 1 : -1;
+}
+
+int
+uniquePairs(Pairs * a, int4 l, int4 *buflen) {
+       Pairs *ptr, *res;
+
+       *buflen=0;
+       if ( l < 2 ) {
+               if ( l==1 )
+                       *buflen = a->keylen + ((a->isnull) ? 0 : a->vallen) ;
+               return l;
+       }
+
+       qsort((void *) a, l, sizeof(Pairs), comparePairs);
+       ptr=a+1;
+       res=a;  
+       while( ptr - a < l ) {
+               if ( ptr->keylen == res->keylen && strncmp( ptr->key, res->key, res->keylen )==0 ) {
+                       if ( ptr->needfree ) {
+                               pfree(ptr->key);
+                               pfree(ptr->val);
+                       }
+               } else {
+                       *buflen += res->keylen + (( res->isnull ) ? 0 : res->vallen);
+                       res++;
+                       memcpy(res,ptr,sizeof(Pairs));
+               }
+
+               ptr++;
+       }
+
+       *buflen += res->keylen + (( res->isnull ) ? 0 : res->vallen);
+       return res + 1 - a;
+}
+
+static void
+freeHSParse(HSParser *state) {
+       int i;
+
+       if ( state->word ) pfree( state->word );
+       for (i=0;i<state->pcur;i++)
+               if ( state->pairs[i].needfree ) {
+                       if (state->pairs[i].key) pfree(state->pairs[i].key);
+                       if (state->pairs[i].val) pfree(state->pairs[i].val);
+               }
+       pfree( state->pairs );
+}
+
+PG_FUNCTION_INFO_V1(hstore_in);
+Datum           hstore_in(PG_FUNCTION_ARGS);
+Datum
+hstore_in(PG_FUNCTION_ARGS) {
+       HSParser   state;
+       int4 len,buflen,i;
+       HStore  *out;
+       HEntry  *entries;
+       char *ptr;
+
+       state.begin =  PG_GETARG_CSTRING(0);
+
+       parse_hstore(&state);
+
+       if ( state.pcur == 0 ) {
+               freeHSParse(&state);
+               len = CALCDATASIZE(0,0);
+               out = palloc(len);
+               out->len=len;
+               out->size=0;
+               PG_RETURN_POINTER(out);
+       }
+
+       state.pcur = uniquePairs(state.pairs, state.pcur, &buflen);
+
+       len=CALCDATASIZE(state.pcur, buflen);
+       out = palloc(len);
+       out->len=len;
+       out->size=state.pcur;
+
+       entries=ARRPTR(out);
+       ptr = STRPTR(out);
+
+       for(i=0;i<out->size;i++) {
+               entries[i].keylen = state.pairs[i].keylen;
+               entries[i].pos = ptr - STRPTR(out);
+               memcpy(ptr, state.pairs[i].key, state.pairs[i].keylen);
+               ptr+=entries[i].keylen;
+
+               entries[i].valisnull = state.pairs[i].isnull;
+               if ( entries[i].valisnull )
+                       entries[i].vallen=4; /* null */
+               else {
+                       entries[i].vallen = state.pairs[i].vallen;
+                       memcpy(ptr, state.pairs[i].val,state.pairs[i].vallen);
+                       ptr+=entries[i].vallen;
+               }
+       }
+
+       freeHSParse(&state);
+       PG_RETURN_POINTER(out);
+}
+
+static char*
+cpw(char *dst, char *src, int len) {
+       char *ptr = src;
+
+       while(ptr-src<len) {
+               if ( *ptr == '"' || *ptr == '\\' )
+                       *dst++='\\';
+               *dst++ = *ptr++;
+       }
+       return dst;
+}
+
+PG_FUNCTION_INFO_V1(hstore_out);
+Datum           hstore_out(PG_FUNCTION_ARGS);
+Datum
+hstore_out(PG_FUNCTION_ARGS) {
+       HStore *in = PG_GETARG_HS(0);
+       int buflen,i;
+       char *out,*ptr;
+       char *base = STRPTR(in);
+       HEntry  *entries = ARRPTR(in);
+
+       if ( in->size==0 ) {
+               out=palloc(1);
+               *out='\0';
+               PG_FREE_IF_COPY(in,0);
+               PG_RETURN_CSTRING(out);
+       }
+
+       buflen = ( 4 /* " */ + 2 /* => */ + 2 /*, */ )*in->size + 
+               2 /* esc */ * ( in->len - CALCDATASIZE(in->size,0) );
+
+       out=ptr=palloc(buflen);
+       for(i=0;i<in->size;i++) {
+               *ptr++='"';
+               ptr = cpw( ptr, base + entries[i].pos, entries[i].keylen );
+               *ptr++='"';
+               *ptr++='=';
+               *ptr++='>';
+               if ( entries[i].valisnull ) {
+                       *ptr++='N';
+                       *ptr++='U';
+                       *ptr++='L';
+                       *ptr++='L';
+               } else {
+                       *ptr++='"';
+                       ptr = cpw( ptr, base + entries[i].pos + entries[i].keylen, entries[i].vallen );
+                       *ptr++='"';
+               }
+
+               if ( i+1 != in->size ) {
+                       *ptr++=',';
+                       *ptr++=' ';
+               }
+       }
+       *ptr='\0';
+
+       PG_FREE_IF_COPY(in,0);
+       PG_RETURN_CSTRING(out);
+}
diff --git a/hstore_op.c b/hstore_op.c
new file mode 100644 (file)
index 0000000..12f783c
--- /dev/null
@@ -0,0 +1,567 @@
+#include "hstore.h"
+#include "utils/array.h"
+#include "catalog/pg_type.h"
+#include "funcapi.h"
+#include <access/heapam.h>
+#include <fmgr.h>
+
+
+static HEntry *
+findkey(HStore *hs, char *key, int keylen) {
+       HEntry *StopLow  = ARRPTR(hs);
+       HEntry *StopHigh = StopLow + hs->size;
+       HEntry  *StopMiddle;
+       int    difference;
+       char *base = STRPTR(hs);
+
+       while (StopLow < StopHigh) {
+               StopMiddle = StopLow + (StopHigh - StopLow) / 2;
+
+               if ( StopMiddle->keylen == keylen )
+                       difference=strncmp(base+StopMiddle->pos, key, StopMiddle->keylen);
+               else
+                       difference=(StopMiddle->keylen > keylen) ? 1 : -1;
+
+               if (difference == 0)
+                       return StopMiddle;
+               else if (difference < 0)
+                       StopLow = StopMiddle + 1;
+               else
+                       StopHigh = StopMiddle;
+       }
+               
+       return NULL;
+}
+
+PG_FUNCTION_INFO_V1(fetchval);
+Datum           fetchval(PG_FUNCTION_ARGS);
+Datum
+fetchval(PG_FUNCTION_ARGS) {
+       HStore *hs  = PG_GETARG_HS(0);
+       text   *key = PG_GETARG_TEXT_P(1);
+       HEntry  *entry;
+       text *out;
+
+       if ((entry=findkey(hs,VARDATA(key), VARSIZE(key)-VARHDRSZ))==NULL || entry->valisnull) {
+               PG_FREE_IF_COPY(hs,0);
+               PG_FREE_IF_COPY(key,1);
+               PG_RETURN_NULL();
+       }
+
+       out=palloc(VARHDRSZ+entry->vallen);
+       memcpy(VARDATA(out),STRPTR(hs) + entry->pos + entry->keylen, entry->vallen);
+       VARATT_SIZEP(out) = VARHDRSZ+entry->vallen;
+
+       PG_FREE_IF_COPY(hs,0);
+       PG_FREE_IF_COPY(key,1);
+       PG_RETURN_POINTER(out);
+}
+
+PG_FUNCTION_INFO_V1(exists);
+Datum           exists(PG_FUNCTION_ARGS);
+Datum
+exists(PG_FUNCTION_ARGS) {
+       HStore *hs  = PG_GETARG_HS(0);
+       text   *key = PG_GETARG_TEXT_P(1);
+       HEntry  *entry;
+
+       entry=findkey(hs,VARDATA(key), VARSIZE(key)-VARHDRSZ);
+
+       PG_FREE_IF_COPY(hs,0);
+       PG_FREE_IF_COPY(key,1);
+
+       PG_RETURN_BOOL(entry);
+}
+
+PG_FUNCTION_INFO_V1(defined);
+Datum           defined(PG_FUNCTION_ARGS);
+Datum
+defined(PG_FUNCTION_ARGS) {
+       HStore *hs  = PG_GETARG_HS(0);
+       text   *key = PG_GETARG_TEXT_P(1);
+       HEntry  *entry;
+       bool res;
+
+       entry=findkey(hs,VARDATA(key), VARSIZE(key)-VARHDRSZ);
+
+       res = ( entry && !entry->valisnull ) ? true : false;
+
+       PG_FREE_IF_COPY(hs,0);
+       PG_FREE_IF_COPY(key,1);
+
+       PG_RETURN_BOOL(res);
+}
+
+PG_FUNCTION_INFO_V1(delete);
+Datum           delete(PG_FUNCTION_ARGS);
+Datum
+delete(PG_FUNCTION_ARGS) {
+       HStore *hs  = PG_GETARG_HS(0);
+       text   *key = PG_GETARG_TEXT_P(1);
+       HStore *out = palloc(hs->len);
+       char *ptrs, *ptrd;
+       HEntry  *es, *ed;
+
+       out->len=hs->len;
+       out->size=hs->size; /* temprorary! */
+
+       ptrs=STRPTR(hs);
+       es  =ARRPTR(hs);
+       ptrd=STRPTR(out);
+       ed  =ARRPTR(out);
+
+       while( es - ARRPTR(hs) < hs->size ) { 
+               if ( !(es->keylen == VARSIZE(key) - VARHDRSZ && strncmp(ptrs, VARDATA(key), es->keylen)==0) ) {
+                       memcpy( ed, es, sizeof(HEntry) );
+                       memcpy( ptrd, ptrs, es->keylen + ( (es->valisnull) ? 0 : es->vallen ) );
+                       ed->pos = ptrd - STRPTR(out);
+                       ptrd += es->keylen + ( (es->valisnull) ? 0 : es->vallen );
+                       ed++;
+               }
+               ptrs += es->keylen + ( (es->valisnull) ? 0 : es->vallen );
+               es++;
+       }
+
+       if ( ed - ARRPTR(out) != out->size ) {
+               int buflen=ptrd-STRPTR(out);
+               ptrd = STRPTR(out);
+
+               out->size = ed - ARRPTR(out);
+
+               memmove( STRPTR(out), ptrd, buflen);
+               out->len = CALCDATASIZE(out->size, buflen);
+       }
+               
+
+       PG_FREE_IF_COPY(hs,0);
+       PG_FREE_IF_COPY(key,1);
+
+       PG_RETURN_POINTER(out);
+}
+
+PG_FUNCTION_INFO_V1(hs_concat);
+Datum           hs_concat(PG_FUNCTION_ARGS);
+Datum
+hs_concat(PG_FUNCTION_ARGS) {
+       HStore *s1  = PG_GETARG_HS(0);
+       HStore *s2  = PG_GETARG_HS(1);
+       HStore *out = palloc( s1->len + s2->len );
+       char *ps1, *ps2, *pd;
+       HEntry *es1, *es2, *ed;
+
+       out->len = s1->len + s2->len;
+       out->size = s1->size + s2->size;
+
+       ps1=STRPTR(s1);
+       ps2=STRPTR(s2);
+       pd=STRPTR(out);
+       es1=ARRPTR(s1);
+       es2=ARRPTR(s2);
+       ed=ARRPTR(out);
+
+       while( es1 - ARRPTR(s1) < s1->size && es2 - ARRPTR(s2) < s2->size ) {
+               int difference;
+               if ( es1->keylen == es2->keylen )
+                       difference=strncmp(ps1, ps2, es1->keylen);
+               else
+                       difference=(es1->keylen > es2->keylen) ? 1 : -1;
+
+               if ( difference == 0 ) {
+                       memcpy( ed, es2, sizeof(HEntry) );
+                       memcpy( pd, ps2, es2->keylen + ( (es2->valisnull) ? 0 : es2->vallen ) );
+                       ed->pos = pd - STRPTR(out);
+                       pd += es2->keylen + ( (es2->valisnull) ? 0 : es2->vallen );
+                       ed++;
+                       
+                       ps1 += es1->keylen + ( (es1->valisnull) ? 0 : es1->vallen );
+                       es1++;
+                       ps2 += es2->keylen + ( (es2->valisnull) ? 0 : es2->vallen );
+                       es2++;
+               } else if ( difference > 0 ) {
+                       memcpy( ed, es2, sizeof(HEntry) );
+                       memcpy( pd, ps2, es2->keylen + ( (es2->valisnull) ? 0 : es2->vallen ) );
+                       ed->pos = pd - STRPTR(out);
+                       pd += es2->keylen + ( (es2->valisnull) ? 0 : es2->vallen );
+                       ed++;
+                       
+                       ps2 += es2->keylen + ( (es2->valisnull) ? 0 : es2->vallen );
+                       es2++;
+               } else {
+                       memcpy( ed, es1, sizeof(HEntry) );
+                       memcpy( pd, ps1, es1->keylen + ( (es1->valisnull) ? 0 : es1->vallen ) );
+                       ed->pos = pd - STRPTR(out);
+                       pd += es1->keylen + ( (es1->valisnull) ? 0 : es1->vallen );
+                       ed++;
+                       
+                       ps1 += es1->keylen + ( (es1->valisnull) ? 0 : es1->vallen );
+                       es1++;
+               }
+       }
+
+       while( es1 - ARRPTR(s1) < s1->size ) {
+               memcpy( ed, es1, sizeof(HEntry) );
+               memcpy( pd, ps1, es1->keylen + ( (es1->valisnull) ? 0 : es1->vallen ) );
+               ed->pos = pd - STRPTR(out);
+               pd += es1->keylen + ( (es1->valisnull) ? 0 : es1->vallen );
+               ed++;
+                       
+               ps1 += es1->keylen + ( (es1->valisnull) ? 0 : es1->vallen );
+               es1++;
+       }
+
+       while( es2 - ARRPTR(s2) < s2->size ) {
+               memcpy( ed, es2, sizeof(HEntry) );
+               memcpy( pd, ps2, es2->keylen + ( (es2->valisnull) ? 0 : es2->vallen ) );
+               ed->pos = pd - STRPTR(out);
+               pd += es2->keylen + ( (es2->valisnull) ? 0 : es2->vallen );
+               ed++;
+               
+               ps2 += es2->keylen + ( (es2->valisnull) ? 0 : es2->vallen );
+               es2++;
+       }
+
+       if ( ed - ARRPTR(out) != out->size ) {
+               int buflen=pd-STRPTR(out);
+               pd = STRPTR(out);
+
+               out->size = ed - ARRPTR(out);
+
+               memmove( STRPTR(out), pd, buflen);
+               out->len = CALCDATASIZE(out->size, buflen);
+       }
+               
+       PG_FREE_IF_COPY(s1,0);
+       PG_FREE_IF_COPY(s2,1);
+
+       PG_RETURN_POINTER(out);
+}
+
+PG_FUNCTION_INFO_V1(tconvert);
+Datum           tconvert(PG_FUNCTION_ARGS);
+Datum
+tconvert(PG_FUNCTION_ARGS) {
+       text   *key = PG_GETARG_TEXT_P(0);
+       text   *val = PG_GETARG_TEXT_P(1);
+       int len;
+       HStore  *out;
+
+       len=CALCDATASIZE(1, VARSIZE(key) + VARSIZE(val) - 2*VARHDRSZ);
+       out = palloc(len);
+       out->len=len;
+       out->size=1;
+
+       ARRPTR(out)->keylen = VARSIZE(key) - VARHDRSZ;
+       ARRPTR(out)->vallen = VARSIZE(val) - VARHDRSZ;
+       ARRPTR(out)->valisnull = false;
+       ARRPTR(out)->pos=0;
+
+       memcpy( STRPTR(out), VARDATA(key), ARRPTR(out)->keylen );
+       memcpy( STRPTR(out) + ARRPTR(out)->keylen, VARDATA(val), ARRPTR(out)->vallen );
+               
+       PG_FREE_IF_COPY(key,0);
+       PG_FREE_IF_COPY(val,1);
+
+       PG_RETURN_POINTER(out);
+}
+
+PG_FUNCTION_INFO_V1(akeys);
+Datum           akeys(PG_FUNCTION_ARGS);
+Datum
+akeys(PG_FUNCTION_ARGS) { 
+       HStore *hs  = PG_GETARG_HS(0);
+       Datum   *d;
+       ArrayType *a;
+       HEntry *ptr=ARRPTR(hs);
+       char *base=STRPTR(hs);
+
+       d=(Datum*)palloc(sizeof(Datum)*(hs->size+1));
+       while( ptr-ARRPTR(hs) < hs->size ) {
+               text *item=(text*)palloc(VARHDRSZ + ptr->keylen);
+               VARATT_SIZEP(item) = VARHDRSZ+ptr->keylen;
+               memcpy(VARDATA(item), base + ptr->pos, ptr->keylen);
+               d[ ptr-ARRPTR(hs) ] = PointerGetDatum(item);
+               ptr++;
+       }
+       
+       a = construct_array(
+               d,
+               hs->size,
+               TEXTOID,
+               -1,
+               false,
+               'i'
+       );
+
+       ptr=ARRPTR(hs);
+       while( ptr-ARRPTR(hs) < hs->size ) {
+               pfree(DatumGetPointer(d[ ptr-ARRPTR(hs) ]));
+               ptr++;
+       }
+
+       pfree(d);
+       PG_FREE_IF_COPY(hs,0);
+
+       PG_RETURN_POINTER(a);
+}
+
+PG_FUNCTION_INFO_V1(avals);
+Datum           avals(PG_FUNCTION_ARGS);
+Datum
+avals(PG_FUNCTION_ARGS) { 
+       HStore *hs  = PG_GETARG_HS(0);
+       Datum   *d;
+       ArrayType *a;
+       HEntry *ptr=ARRPTR(hs);
+       char *base=STRPTR(hs);
+
+       d=(Datum*)palloc(sizeof(Datum)*(hs->size+1));
+       while( ptr-ARRPTR(hs) < hs->size ) {
+               int vallen = (ptr->valisnull) ? 0 : ptr->vallen; 
+               text *item=(text*)palloc(VARHDRSZ + vallen);
+               VARATT_SIZEP(item) = VARHDRSZ+vallen;
+               memcpy(VARDATA(item), base + ptr->pos + ptr->keylen, vallen);
+               d[ ptr-ARRPTR(hs) ] = PointerGetDatum(item);
+               ptr++;
+       }
+       
+       a = construct_array(
+               d,
+               hs->size,
+               TEXTOID,
+               -1,
+               false,
+               'i'
+       );
+
+       ptr=ARRPTR(hs);
+       while( ptr-ARRPTR(hs) < hs->size ) {
+               pfree(DatumGetPointer(d[ ptr-ARRPTR(hs) ]));
+               ptr++;
+       }
+
+       pfree(d);
+       PG_FREE_IF_COPY(hs,0);
+
+       PG_RETURN_POINTER(a);
+}
+
+typedef struct {
+       HStore  *hs;
+       int     i;
+} AKStore;
+
+static void
+setup_firstcall(FuncCallContext  *funcctx, HStore *hs) {
+       MemoryContext     oldcontext;
+       AKStore     *st;
+
+       oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
+
+       st=(AKStore*)palloc( sizeof(AKStore) );
+       st->i=0;
+       st->hs = (HStore*)palloc(hs->len);
+       memcpy( st->hs, hs, hs->len );
+
+       funcctx->user_fctx = (void*)st;
+       MemoryContextSwitchTo(oldcontext);
+}
+
+PG_FUNCTION_INFO_V1(skeys);
+Datum           skeys(PG_FUNCTION_ARGS);
+Datum
+skeys(PG_FUNCTION_ARGS) {
+       FuncCallContext  *funcctx;
+       AKStore *st;
+
+       if (SRF_IS_FIRSTCALL()) {
+               HStore *hs = PG_GETARG_HS(0);
+               funcctx = SRF_FIRSTCALL_INIT();
+               setup_firstcall(funcctx, hs);
+               PG_FREE_IF_COPY(hs,0);
+       }
+
+       funcctx = SRF_PERCALL_SETUP();
+       st = (AKStore*)funcctx->user_fctx;
+       
+       if ( st->i < st->hs->size ) {
+               HEntry *ptr = &(ARRPTR(st->hs)[st->i]);
+               text *item=(text*)palloc(VARHDRSZ + ptr->keylen);
+
+               VARATT_SIZEP(item) = VARHDRSZ+ptr->keylen;
+               memcpy(VARDATA(item), STRPTR(st->hs) + ptr->pos, ptr->keylen);
+               st->i++;
+
+               SRF_RETURN_NEXT(funcctx, PointerGetDatum(item));
+       }
+       
+       pfree( st->hs );
+       pfree( st );
+
+       SRF_RETURN_DONE(funcctx); 
+}
+
+PG_FUNCTION_INFO_V1(svals);
+Datum           svals(PG_FUNCTION_ARGS);
+Datum
+svals(PG_FUNCTION_ARGS) {
+       FuncCallContext  *funcctx;
+       AKStore *st;
+
+       if (SRF_IS_FIRSTCALL()) {
+               HStore *hs = PG_GETARG_HS(0);
+               funcctx = SRF_FIRSTCALL_INIT();
+               setup_firstcall(funcctx, hs);
+               PG_FREE_IF_COPY(hs,0);
+       }
+
+       funcctx = SRF_PERCALL_SETUP();
+       st = (AKStore*)funcctx->user_fctx;
+       
+       if ( st->i < st->hs->size ) {
+               HEntry *ptr = &(ARRPTR(st->hs)[st->i]);
+
+               if ( ptr->valisnull ) {
+                       ReturnSetInfo      *rsi;
+
+                       st->i++;
+                       (funcctx)->call_cntr++;
+                       rsi = (ReturnSetInfo *) fcinfo->resultinfo;
+                       rsi->isDone = ExprMultipleResult;
+                       PG_RETURN_NULL();
+               } else {
+                       int vallen = ptr->vallen; 
+                       text *item=(text*)palloc(VARHDRSZ + vallen);
+
+                       VARATT_SIZEP(item) = VARHDRSZ+vallen;
+                       memcpy(VARDATA(item), STRPTR(st->hs) + ptr->pos + ptr->keylen, vallen);
+                       st->i++;
+
+                       SRF_RETURN_NEXT(funcctx, PointerGetDatum(item));
+               }
+       }
+       
+       pfree( st->hs );
+       pfree( st );
+
+       SRF_RETURN_DONE(funcctx); 
+}
+
+PG_FUNCTION_INFO_V1(hs_contains);
+Datum           hs_contains(PG_FUNCTION_ARGS);
+Datum
+hs_contains(PG_FUNCTION_ARGS) {
+       HStore *val   = PG_GETARG_HS(0);
+       HStore *tmpl  = PG_GETARG_HS(1);
+       bool res = true;
+       HEntry  *te = ARRPTR(tmpl);
+       char    *vv = STRPTR(val);
+       char    *tv = STRPTR(tmpl);
+
+       while(res && te-ARRPTR(tmpl) < tmpl->size) {
+               HEntry *entry = findkey(val, tv + te->pos, te->keylen);
+               if ( entry ) {
+                       if ( ! te->valisnull ) {
+                               if ( entry->valisnull || !(
+                                               te->vallen==entry->vallen && 
+                                               strncmp( 
+                                                       vv + entry->pos + entry->keylen, 
+                                                       tv + te->pos + te->keylen, 
+                                               te->vallen ) == 0
+                                       ) )
+                                       res=false;
+                       }
+               } else
+                       res = false;
+               te++;
+       }
+
+       PG_FREE_IF_COPY(val,0);
+       PG_FREE_IF_COPY(tmpl,1);
+
+       PG_RETURN_BOOL(res);
+}
+       
+PG_FUNCTION_INFO_V1(hs_contained);
+Datum           hs_contained(PG_FUNCTION_ARGS);
+Datum
+hs_contained(PG_FUNCTION_ARGS) {
+       PG_RETURN_DATUM( DirectFunctionCall2(
+               hs_contains,
+               PG_GETARG_DATUM(1),
+               PG_GETARG_DATUM(0)
+       ));
+}
+
+PG_FUNCTION_INFO_V1(each);
+Datum           each(PG_FUNCTION_ARGS);
+Datum
+each(PG_FUNCTION_ARGS) {
+       FuncCallContext  *funcctx;
+       AKStore *st;
+
+       if (SRF_IS_FIRSTCALL()) {
+               TupleDesc            tupdesc;
+               MemoryContext     oldcontext;
+               HStore *hs = PG_GETARG_HS(0);
+
+               funcctx = SRF_FIRSTCALL_INIT();
+               oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
+               st=(AKStore*)palloc( sizeof(AKStore) );
+               st->i=0;
+               st->hs = (HStore*)palloc(hs->len);
+               memcpy( st->hs, hs, hs->len );
+               funcctx->user_fctx = (void*)st;         
+                       
+               tupdesc = RelationNameGetTupleDesc("hs_each");
+               funcctx->slot = TupleDescGetSlot(tupdesc);
+               funcctx->attinmeta = TupleDescGetAttInMetadata(tupdesc);
+
+               MemoryContextSwitchTo(oldcontext);
+               PG_FREE_IF_COPY(hs,0);
+       }
+
+       funcctx = SRF_PERCALL_SETUP();
+       st = (AKStore*)funcctx->user_fctx;
+       
+       if ( st->i < st->hs->size ) {
+               HEntry *ptr = &(ARRPTR(st->hs)[st->i]);
+               Datum res, dvalues[2];
+               char       nulls[] = {' ', ' '};
+               text *item;
+               HeapTuple       tuple;
+
+               item=(text*)palloc(VARHDRSZ + ptr->keylen);
+               VARATT_SIZEP(item) = VARHDRSZ+ptr->keylen;
+               memcpy(VARDATA(item), STRPTR(st->hs) + ptr->pos, ptr->keylen);
+               dvalues[0] = PointerGetDatum(item);
+
+               if ( ptr->valisnull ) {
+                       dvalues[1]=(Datum)0;
+                       nulls[1]='n';
+               } else {
+                       int vallen = ptr->vallen; 
+
+                       item=(text*)palloc(VARHDRSZ + vallen);
+                       VARATT_SIZEP(item) = VARHDRSZ+vallen;
+                       memcpy(VARDATA(item), STRPTR(st->hs) + ptr->pos + ptr->keylen, vallen);
+                       dvalues[1] = PointerGetDatum(item);
+               }
+               st->i++;
+
+               tuple = heap_formtuple(funcctx->attinmeta->tupdesc, dvalues, nulls);
+               res = TupleGetDatum(funcctx->slot, tuple);
+
+               pfree( DatumGetPointer(dvalues[0]) );
+               if ( nulls[1] != 'n' ) 
+                       pfree( DatumGetPointer(dvalues[1]) );
+
+               SRF_RETURN_NEXT(funcctx, PointerGetDatum(res));
+       }
+       
+       pfree( st->hs );
+       pfree( st );
+
+       SRF_RETURN_DONE(funcctx); 
+}
+
+
diff --git a/sql/hstore.sql b/sql/hstore.sql
new file mode 100644 (file)
index 0000000..298ffb0
--- /dev/null
@@ -0,0 +1,131 @@
+\set ECHO none
+\i hstore.sql
+set escape_string_warning=off;
+\set ECHO all
+--hstore;
+
+select ''::hstore;
+select 'a=>b'::hstore;
+select ' a=>b'::hstore;
+select 'a =>b'::hstore;
+select 'a=>b '::hstore;
+select 'a=> b'::hstore;
+select '"a"=>"b"'::hstore;
+select ' "a"=>"b"'::hstore;
+select '"a" =>"b"'::hstore;
+select '"a"=>"b" '::hstore;
+select '"a"=> "b"'::hstore;
+select 'aa=>bb'::hstore;
+select ' aa=>bb'::hstore;
+select 'aa =>bb'::hstore;
+select 'aa=>bb '::hstore;
+select 'aa=> bb'::hstore;
+select '"aa"=>"bb"'::hstore;
+select ' "aa"=>"bb"'::hstore;
+select '"aa" =>"bb"'::hstore;
+select '"aa"=>"bb" '::hstore;
+select '"aa"=> "bb"'::hstore;
+
+select 'aa=>bb, cc=>dd'::hstore;
+select 'aa=>bb , cc=>dd'::hstore;
+select 'aa=>bb ,cc=>dd'::hstore;
+select 'aa=>bb, "cc"=>dd'::hstore;
+select 'aa=>bb , "cc"=>dd'::hstore;
+select 'aa=>bb ,"cc"=>dd'::hstore;
+select 'aa=>"bb", cc=>dd'::hstore;
+select 'aa=>"bb" , cc=>dd'::hstore;
+select 'aa=>"bb" ,cc=>dd'::hstore;
+
+select 'aa=>null'::hstore;
+select 'aa=>NuLl'::hstore;
+select 'aa=>"NuLl"'::hstore;
+
+select '\\=a=>q=w'::hstore;
+select '"=a"=>q\\=w'::hstore;
+select '"\\"a"=>q>w'::hstore;
+select '\\"a=>q"w'::hstore;
+
+select ''::hstore;
+select '       '::hstore;
+
+-- -> operator
+
+select 'aa=>b, c=>d , b=>16'::hstore->'c';
+select 'aa=>b, c=>d , b=>16'::hstore->'b';
+select 'aa=>b, c=>d , b=>16'::hstore->'aa';
+select ('aa=>b, c=>d , b=>16'::hstore->'gg') is null;
+select ('aa=>NULL, c=>d , b=>16'::hstore->'aa') is null;
+
+-- exists/defined
+
+select isexists('a=>NULL, b=>qq', 'a');
+select isexists('a=>NULL, b=>qq', 'b');
+select isexists('a=>NULL, b=>qq', 'c');
+select isdefined('a=>NULL, b=>qq', 'a');
+select isdefined('a=>NULL, b=>qq', 'b');
+select isdefined('a=>NULL, b=>qq', 'c');
+
+-- delete 
+
+select delete('a=>1 , b=>2, c=>3'::hstore, 'a');
+select delete('a=>null , b=>2, c=>3'::hstore, 'a');
+select delete('a=>1 , b=>2, c=>3'::hstore, 'b');
+select delete('a=>1 , b=>2, c=>3'::hstore, 'c');
+select delete('a=>1 , b=>2, c=>3'::hstore, 'd');
+
+-- ||
+select 'aa=>1 , b=>2, cq=>3'::hstore || 'cq=>l, b=>g, fg=>f';
+select 'aa=>1 , b=>2, cq=>3'::hstore || 'aq=>l';
+select 'aa=>1 , b=>2, cq=>3'::hstore || 'aa=>l';
+select 'aa=>1 , b=>2, cq=>3'::hstore || '';
+select ''::hstore || 'cq=>l, b=>g, fg=>f';
+
+-- =>
+select 'a=>g, b=>c'::hstore || ( 'asd'=>'gf' );
+select 'a=>g, b=>c'::hstore || ( 'b'=>'gf' );
+
+-- keys/values
+select akeys('aa=>1 , b=>2, cq=>3'::hstore || 'cq=>l, b=>g, fg=>f');
+select akeys('""=>1');
+select akeys('');
+select avals('aa=>1 , b=>2, cq=>3'::hstore || 'cq=>l, b=>g, fg=>f');
+select avals('aa=>1 , b=>2, cq=>3'::hstore || 'cq=>l, b=>g, fg=>NULL');
+select avals('""=>1');
+select avals('');
+
+select * from skeys('aa=>1 , b=>2, cq=>3'::hstore || 'cq=>l, b=>g, fg=>f');
+select * from skeys('""=>1');
+select * from skeys('');
+select * from svals('aa=>1 , b=>2, cq=>3'::hstore || 'cq=>l, b=>g, fg=>f');
+select *, svals is null from svals('aa=>1 , b=>2, cq=>3'::hstore || 'cq=>l, b=>g, fg=>NULL');
+select * from svals('""=>1');
+select * from svals('');
+
+select * from each('aaa=>bq, b=>NULL, ""=>1 ');
+
+-- @
+select 'a=>b, b=>1, c=>NULL'::hstore @ 'a=>NULL';
+select 'a=>b, b=>1, c=>NULL'::hstore @ 'a=>NULL, c=>NULL';
+select 'a=>b, b=>1, c=>NULL'::hstore @ 'a=>NULL, g=>NULL';
+select 'a=>b, b=>1, c=>NULL'::hstore @ 'g=>NULL';
+select 'a=>b, b=>1, c=>NULL'::hstore @ 'a=>c';
+select 'a=>b, b=>1, c=>NULL'::hstore @ 'a=>b';
+select 'a=>b, b=>1, c=>NULL'::hstore @ 'a=>b, c=>NULL';
+select 'a=>b, b=>1, c=>NULL'::hstore @ 'a=>b, c=>q';
+
+CREATE TABLE testhstore (h hstore);
+\copy testhstore from 'data/hstore.data'
+
+select count(*) from testhstore where h @ 'wait=>NULL';
+select count(*) from testhstore where h @ 'wait=>CC';
+select count(*) from testhstore where h @ 'wait=>CC, public=>t';
+
+create index hidx on testhstore using gist(h);
+set enable_seqscan=off;
+
+select count(*) from testhstore where h @ 'wait=>NULL';
+select count(*) from testhstore where h @ 'wait=>CC';
+select count(*) from testhstore where h @ 'wait=>CC, public=>t';
+
+select count(*) from (select (each(h)).key from testhstore) as wow ;
+select key, count(*) from (select (each(h)).key from testhstore) as wow group by key order by count desc, key;