On 6/17/10 2:03 PM, David E. Wheeler wrote:
> On Jun 17, 2010, at 1:50 PM, Josh Berkus wrote:
>
>>> It isn't. || already does what you're saying.
>> So what *does* it do?
>
> It returns an hstore that's effectively a slice of another hstore. From the docs
(http://developer.postgresql.org/pgdocs/postgres/hstore.html):
OK, hammered this out on IRC with several Hstore users, and I think the
best answer here is consistency. Both with the other hstore operators
and with other set types, such as intarray and ltree.
Currently for hstore, %% returns a flattened array and %# returns a
two-dimensional array. That means that it makes sense that the operator
which returns an hstore subset should be something based on %, either
%>, %% or just %.
I vote for % .
Stuff we discussed and discarded includes:
& for two reasons: (a) it looks like a predicate and (b) it's used as
"intersect" for intarray and ltree, and we might want to implement
intersect for hstore someday.
# because it's used as "index" for intarray, and thus should more
properly be a synonym for -> in hstore
+> because it looks like it ought to be some kind of special incrementor.
Using % would also mean that sometime in the future we can implement !%
as "elements NOT in this list" (i.e. ' a => 1, b => 2, c => 5' !% 'a, b'
== 'c => 5' )
-- -- Josh Berkus PostgreSQL Experts Inc.
http://www.pgexperts.com