binary operators on integers

From: Marko Kreen <marko(at)l-t(dot)ee>
To: pgsql-patches(at)postgresql(dot)org
Subject: binary operators on integers
Date: 2000-09-25 07:21:46
Message-ID: 20000925092146.A12772@l-t.ee
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Here is my next take on binary operators for integers.
It implements the following operators for int2/int4/int8:

~ - not
& - and
^ - xor
| - or
<< - shift left
>> - shift right

Notes:

* My original choice for xor was '#' because the '^' operator conflicts
with power operator on floats but Tom Lane said:

> Well, you *could* use '^' since there's no definition of it for integer
> operands. But that would mean that something like '4^2', which was
> formerly implicitly coerced to float and interpreted as floating
> power function, would suddenly mean something different. Again a
> serious risk of silently breaking applications. This doesn't apply to
> '|' though, since it has no numeric interpretation at all right now.

As the bit-string uses '^' too for xor-ing it would be nice to be
consistent. I am quite unsure on this matter. The patch now seems
otherwise sane to me, this is the only issue left.

* On << and >> the second argument is always int32 as this seems
to be the 'default' int type in PostgreSQL.

* Oids used are 1874 - 1909.

Comments?

Patch is against current CVS.

--
marko

Attachment Content-Type Size
binops2.diff text/plain 11.9 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Zeugswetter Andreas SB 2000-09-25 09:44:01 Q: How to #ifdef for dlopen() or a specific OS Version
Previous Message Philip Warner 2000-09-25 01:48:03 Re: [HACKERS] RFC - change of behaviour of pg_get_userbyid & pg_get_viewdef?

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2000-09-25 12:43:02 Re: Unbreak plperl building
Previous Message James A. Pattie 2000-09-24 00:16:08 Network Patch File for Specifing IP to Bind to