On Fri, Oct 23, 2015 at 7:20 AM, Alvaro Herrera <alvhe...@2ndquadrant.com> wrote: > Andres Freund wrote: > >> FWIW, adding an <> operator for xid seems like a perfectly good idea.
+1. I have wanted that more than once, but avoided it all the time with some casts. > +1 (two of them actually -- See for example the attached (do we care about commutativity with int = xid and int <> xid?). > (another one for <>(xid,int) which mirrors the =(xid,int) we already have). To which one are you referring here? -- Michael
diff --git a/src/backend/utils/adt/xid.c b/src/backend/utils/adt/xid.c index 6b61765..c93ff4d 100644 --- a/src/backend/utils/adt/xid.c +++ b/src/backend/utils/adt/xid.c @@ -88,6 +88,18 @@ xideq(PG_FUNCTION_ARGS) } /* + * xidneq - are two xids different? + */ +Datum +xidneq(PG_FUNCTION_ARGS) +{ + TransactionId xid1 = PG_GETARG_TRANSACTIONID(0); + TransactionId xid2 = PG_GETARG_TRANSACTIONID(1); + + PG_RETURN_BOOL(!TransactionIdEquals(xid1, xid2)); +} + +/* * xid_age - compute age of an XID (relative to latest stable xid) */ Datum diff --git a/src/include/catalog/pg_operator.h b/src/include/catalog/pg_operator.h index eec9c60..e79ce57 100644 --- a/src/include/catalog/pg_operator.h +++ b/src/include/catalog/pg_operator.h @@ -144,10 +144,14 @@ DESCR("prepend element onto front of array"); DATA(insert OID = 375 ( "||" PGNSP PGUID b f f 2277 2277 2277 0 0 array_cat - - )); DESCR("concatenate"); -DATA(insert OID = 352 ( "=" PGNSP PGUID b f t 28 28 16 352 0 xideq eqsel eqjoinsel )); +DATA(insert OID = 352 ( "=" PGNSP PGUID b f t 28 28 16 352 3315 xideq eqsel eqjoinsel )); DESCR("equal"); -DATA(insert OID = 353 ( "=" PGNSP PGUID b f f 28 23 16 0 0 xideqint4 eqsel eqjoinsel )); +DATA(insert OID = 353 ( "=" PGNSP PGUID b f f 28 23 16 0 3316 xideqint4 eqsel eqjoinsel )); DESCR("equal"); +DATA(insert OID = 3315 ( "<>" PGNSP PGUID b f f 28 28 16 3315 352 xidneq neqsel neqjoinsel )); +DESCR("not equal"); +DATA(insert OID = 3316 ( "<>" PGNSP PGUID b f f 28 23 16 0 353 xidneqint4 neqsel neqjoinsel )); +DESCR("not equal"); DATA(insert OID = 388 ( "!" PGNSP PGUID r f f 20 0 1700 0 0 numeric_fac - - )); DESCR("factorial"); DATA(insert OID = 389 ( "!!" PGNSP PGUID l f f 0 20 1700 0 0 numeric_fac - - )); diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h index f688454..cf36f06 100644 --- a/src/include/catalog/pg_proc.h +++ b/src/include/catalog/pg_proc.h @@ -212,6 +212,7 @@ DATA(insert OID = 65 ( int4eq PGNSP PGUID 12 1 0 0 0 f f f t t f i s 2 0 DATA(insert OID = 66 ( int4lt PGNSP PGUID 12 1 0 0 0 f f f t t f i s 2 0 16 "23 23" _null_ _null_ _null_ _null_ _null_ int4lt _null_ _null_ _null_ )); DATA(insert OID = 67 ( texteq PGNSP PGUID 12 1 0 0 0 f f f t t f i s 2 0 16 "25 25" _null_ _null_ _null_ _null_ _null_ texteq _null_ _null_ _null_ )); DATA(insert OID = 68 ( xideq PGNSP PGUID 12 1 0 0 0 f f f t t f i s 2 0 16 "28 28" _null_ _null_ _null_ _null_ _null_ xideq _null_ _null_ _null_ )); +DATA(insert OID = 3308 ( xidneq PGNSP PGUID 12 1 0 0 0 f f f t t f i s 2 0 16 "28 28" _null_ _null_ _null_ _null_ _null_ xidneq _null_ _null_ _null_ )); DATA(insert OID = 69 ( cideq PGNSP PGUID 12 1 0 0 0 f f f t t f i s 2 0 16 "29 29" _null_ _null_ _null_ _null_ _null_ cideq _null_ _null_ _null_ )); DATA(insert OID = 70 ( charne PGNSP PGUID 12 1 0 0 0 f f f t t f i s 2 0 16 "18 18" _null_ _null_ _null_ _null_ _null_ charne _null_ _null_ _null_ )); DATA(insert OID = 1246 ( charlt PGNSP PGUID 12 1 0 0 0 f f f t t f i s 2 0 16 "18 18" _null_ _null_ _null_ _null_ _null_ charlt _null_ _null_ _null_ )); @@ -1516,6 +1517,8 @@ DESCR("character length"); DATA(insert OID = 1319 ( xideqint4 PGNSP PGUID 12 1 0 0 0 f f f t t f i s 2 0 16 "28 23" _null_ _null_ _null_ _null_ _null_ xideq _null_ _null_ _null_ )); +DATA(insert OID = 3309 ( xidneqint4 PGNSP PGUID 12 1 0 0 0 f f f t t f i s 2 0 16 "28 23" _null_ _null_ _null_ _null_ _null_ xidneq _null_ _null_ _null_ )); + DATA(insert OID = 1326 ( interval_div PGNSP PGUID 12 1 0 0 0 f f f f t f i s 2 0 1186 "1186 701" _null_ _null_ _null_ _null_ _null_ interval_div _null_ _null_ _null_ )); DATA(insert OID = 1339 ( dlog10 PGNSP PGUID 12 1 0 0 0 f f f f t f i s 1 0 701 "701" _null_ _null_ _null_ _null_ _null_ dlog10 _null_ _null_ _null_ )); diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h index fc1679e..77074a0 100644 --- a/src/include/utils/builtins.h +++ b/src/include/utils/builtins.h @@ -860,6 +860,7 @@ extern Datum xidout(PG_FUNCTION_ARGS); extern Datum xidrecv(PG_FUNCTION_ARGS); extern Datum xidsend(PG_FUNCTION_ARGS); extern Datum xideq(PG_FUNCTION_ARGS); +extern Datum xidneq(PG_FUNCTION_ARGS); extern Datum xid_age(PG_FUNCTION_ARGS); extern Datum mxid_age(PG_FUNCTION_ARGS); extern int xidComparator(const void *arg1, const void *arg2); diff --git a/src/test/regress/expected/opr_sanity.out b/src/test/regress/expected/opr_sanity.out index df29fe5..7c93b3b 100644 --- a/src/test/regress/expected/opr_sanity.out +++ b/src/test/regress/expected/opr_sanity.out @@ -641,6 +641,8 @@ uuid_eq(uuid,uuid) uuid_ge(uuid,uuid) uuid_gt(uuid,uuid) uuid_ne(uuid,uuid) +xidneq(xid,xid) +xidneqint4(xid,integer) -- restore normal output mode \a\t -- List of functions used by libpq's fe-lobj.c
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers