From: | "Johann 'Myrkraverk' Oskarsson" <johann(at)2ndquadrant(dot)com> |
---|---|
To: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Typed hstore proposal |
Date: | 2011-12-22 01:32:43 |
Message-ID: | x6ehvx1jd0.fsf@2ndquadrant.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi all,
I mean to create a typed hstore, called tstore for now. I'm open to
name suggestions. It'll only support a subset of core Postgres types
to begin with. Keys are always text, it's the value that's typed.
Usage is very similar to hstore; this is not a complete reference.
tstore( text, text) Creates a text key-value pair.
tstore( text, int4 ) Creates an integer key-value pair.
tstore -> text Returns a tvalue, which is basically an
oid-value pair.
typeof( tvalue ) Returns the oid.
tvalue::int4 The integer value.
tvalue::text The text value.
each_int( tstore ) Set of all keys and values where the value
is int4.
each_text( tstore ) Set of all keys and values where the value
is text.
each( tstore ) Set of all keys and values as tvalues.
Some examples:
# select 'text: "a"'::tvalue;
tvalue
----------
text: "a"
(1 row)
# select 'integer: 17'::tvalue;
tvalue
----------
int4: 17
(1 row)
# select each_int( '"a" -> text: "b", "b" -> int: 17'::tstore );
?column? | ?column?
----------+----------
"b" | 17
(1 row)
#select '"a" -> text: "b", "b" -> int: 17'::tstore -> 'a';
?column?
-----------
text: "a"
(1 row)
All comments are welcome. As the project matures, I'm sure other
needed functions will crop up.
--
Johann Oskarsson http://www.2ndquadrant.com/ |[]
PostgreSQL Development, 24x7 Support, Training and Services --+--
|
Blog: http://my.opera.com/myrkraverk/blog/
From | Date | Subject | |
---|---|---|---|
Next Message | Christopher Browne | 2011-12-22 03:40:02 | Re: Typed hstore proposal |
Previous Message | Robert Haas | 2011-12-22 00:45:19 | Re: Page Checksums + Double Writes |