Use the function call form. According to the system catalogs, the hstore ?
operator uses the exist
function:
regress=# select oprname, oprcode from pg_operator where oprname="?";
oprname | oprcode
---------+---------
? | exist
(1 row)
so you can write:
SELECT * FROM tbl WHERE exist(hst,'foo');
(Personally I’m not a big fan of hstore’s operator-centric design and documentation, I think it discards the useful self-documenting properties of a function based interface without any real benefit and I usually use its function calls rather than its operators. Just because you can define operators doesn’t mean you should.)