Re: [HACKERS] Custom Operators Cannot be Found for Composite Type Values

2012-03-08 Thread David E. Wheeler
On Mar 8, 2012, at 11:27 AM, Andrew Dunstan wrote: > Yeah. Note too that this is at best dubious: > >CREATE OR REPLACE FUNCTION json_cmp( >json, >json >) RETURNS INTEGER LANGUAGE SQL STRICT IMMUTABLE AS $$ >SELECT bttextcmp($1::text, $2::text); >$$; > > > Two

Re: [HACKERS] Custom Operators Cannot be Found for Composite Type Values

2012-03-08 Thread David E. Wheeler
On Mar 8, 2012, at 11:16 AM, Tom Lane wrote: >> This seems to work. > > Urk. You really ought to provide the whole opclass (all 5 operators). > I'm not sure what will blow up if you leave it like that, but it won't > be pretty. Yes, I expect to have to fill in gaps as I go. These are just for u

Re: [HACKERS] Custom Operators Cannot be Found for Composite Type Values

2012-03-08 Thread Andrew Dunstan
On 03/08/2012 02:16 PM, Tom Lane wrote: "David E. Wheeler" writes: CREATE OPERATOR CLASS json_ops DEFAULT FOR TYPE JSON USING btree AS OPERATOR3 = (json, json), FUNCTION1 json_cmp(json, json); This seems to work. Urk. You really ought to provide the whole op

Re: [HACKERS] Custom Operators Cannot be Found for Composite Type Values

2012-03-08 Thread Tom Lane
"David E. Wheeler" writes: > CREATE OPERATOR CLASS json_ops > DEFAULT FOR TYPE JSON USING btree AS > OPERATOR3 = (json, json), > FUNCTION1 json_cmp(json, json); > This seems to work. Urk. You really ought to provide the whole opclass (all 5 operators). I'm not sure

Re: [HACKERS] Custom Operators Cannot be Found for Composite Type Values

2012-03-08 Thread David E. Wheeler
On Mar 7, 2012, at 8:23 PM, Tom Lane wrote: > You have not told the system that your operator is equality for the > datatype. It's just a random operator that happens to be named "=". > We try to avoid depending on operator names as cues to semantics. > > You need to incorporate it into a defaul

Re: [HACKERS] Custom Operators Cannot be Found for Composite Type Values

2012-03-07 Thread Tom Lane
"David E. Wheeler" writes: > I’m doing some development with the new JSON type (actually, Andrew’s > backport to 9.1) and needed to do some very basic equivalence testing. So I > created a custom operator: > CREATE OR REPLACE FUNCTION json_eq( > json, > json > ) RETURNS

[HACKERS] Custom Operators Cannot be Found for Composite Type Values

2012-03-07 Thread David E. Wheeler
Hackers, I’m doing some development with the new JSON type (actually, Andrew’s backport to 9.1) and needed to do some very basic equivalence testing. So I created a custom operator: CREATE OR REPLACE FUNCTION json_eq( json, json ) RETURNS BOOLEAN LANGUAGE SQL STRICT IMMU