Skip site navigation (1) Skip section navigation (2)

Typed hstore proposal

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: (view raw, whole thread or download thread mbox)
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;
 text: "a"
(1 row)

# select 'integer: 17'::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'; 
 text: "a"
(1 row)

All comments are welcome.  As the project matures, I'm sure other
needed functions will crop up.

   Johann Oskarsson          |[]
   PostgreSQL Development, 24x7 Support, Training and Services  --+--


pgsql-hackers by date

Next:From: Christopher BrowneDate: 2011-12-22 03:40:02
Subject: Re: Typed hstore proposal
Previous:From: Robert HaasDate: 2011-12-22 00:45:19
Subject: Re: Page Checksums + Double Writes

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group