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 default hash or btree opclass before > the composite-type logic will accept it as the thing to use for > comparing that column.
Ah, okay. Just need more stuff, I guess: CREATE OR REPLACE FUNCTION json_cmp( json, json ) RETURNS INTEGER LANGUAGE SQL STRICT IMMUTABLE AS $$ SELECT bttextcmp($1::text, $2::text); $$; CREATE OR REPLACE FUNCTION json_eq( json, json ) RETURNS BOOLEAN LANGUAGE SQL STRICT IMMUTABLE AS $$ SELECT bttextcmp($1::text, $2::text) = 0; $$; CREATE OPERATOR = ( LEFTARG = json, RIGHTARG = json, PROCEDURE = json_eq ); CREATE OPERATOR CLASS json_ops DEFAULT FOR TYPE JSON USING btree AS OPERATOR 3 = (json, json), FUNCTION 1 json_cmp(json, json); This seems to work. Best, David -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers