Обсуждение: What does # mean in plpgsql?

Поиск
Список
Период
Сортировка

What does # mean in plpgsql?

От
Stephen Cook
Дата:
What does the hash mark (#) mean in plpgsql?

I saw it used in the pseudo_encrypt function @
http://wiki.postgresql.org/wiki/Pseudo_encrypt, on the line:

r2 := l1 # ((((1366.0 * r1 + 150889) % 714025) / 714025.0) * 32767)::int;

My google-fu has failed me on this one, and I needs to know.

Thanks!


-- Stephen

Re: What does # mean in plpgsql?

От
Pavel Stehule
Дата:
hello

try:

postgres=# select oprcode, oprleft::regtype, oprright::regtype from
pg_operator where oprname = '#';
    oprcode    | oprleft  | oprright
---------------+----------+----------
 path_npoints  | -        | path
 box_intersect | box      | box
 poly_npoints  | -        | polygon
 lseg_interpt  | lseg     | lseg
 line_interpt  | line     | line
 bitxor        | bit      | bit
 int2xor       | smallint | smallint
 int4xor       | integer  | integer
 int8xor       | bigint   | bigint
(9 rows)

so this means a xor operation

regards

Pavel Stehule

2010/8/12 Stephen Cook <sclists@gmail.com>:
> What does the hash mark (#) mean in plpgsql?
>
> I saw it used in the pseudo_encrypt function @
> http://wiki.postgresql.org/wiki/Pseudo_encrypt, on the line:
>
> r2 := l1 # ((((1366.0 * r1 + 150889) % 714025) / 714025.0) * 32767)::int;
>
> My google-fu has failed me on this one, and I needs to know.
>
> Thanks!
>
>
> -- Stephen
>
> --
> Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

Re: What does # mean in plpgsql?

От
Adrian Klaver
Дата:
On Thursday 12 August 2010 7:51:39 am Stephen Cook wrote:
> What does the hash mark (#) mean in plpgsql?
>
> I saw it used in the pseudo_encrypt function @
> http://wiki.postgresql.org/wiki/Pseudo_encrypt, on the line:
>
> r2 := l1 # ((((1366.0 * r1 + 150889) % 714025) / 714025.0) * 32767)::int;
>
> My google-fu has failed me on this one, and I needs to know.
>
> Thanks!
>
>
> -- Stephen

From here:
http://www.postgresql.org/docs/8.4/interactive/functions-math.html
bitwise XOR

--
Adrian Klaver
adrian.klaver@gmail.com

Re: What does # mean in plpgsql?

От
"Daniel Verite"
Дата:
    Stephen Cook wrote:

> What does the hash mark (#) mean in plpgsql?
>
> I saw it used in the pseudo_encrypt function @
> http://wiki.postgresql.org/wiki/Pseudo_encrypt, on the line:
>
> r2 := l1 # ((((1366.0 * r1 + 150889) % 714025) / 714025.0) * 32767)::int;
>
> My google-fu has failed me on this one, and I needs to know.

It's a bitwise exclusive OR (XOR)

Best regards,
--
Daniel
PostgreSQL-powered mail user agent and storage: http://www.manitou-mail.org

Re: What does # mean in plpgsql?

От
Tom Lane
Дата:
Pavel Stehule <pavel.stehule@gmail.com> writes:
> try:

> postgres=# select oprcode, oprleft::regtype, oprright::regtype from
> pg_operator where oprname = '#';

Or even easier:

regression=# \do+ #
                                         List of operators
   Schema   | Name | Left arg type | Right arg type | Result type |          Description
------------+------+---------------+----------------+-------------+--------------------------------
 pg_catalog | #    | bigint        | bigint         | bigint      | bitwise xor
 pg_catalog | #    | bit           | bit            | bit         | bitwise exclusive or
...

            regards, tom lane

Re: What does # mean in plpgsql?

От
Stephen Cook
Дата:
On 8/12/2010 10:56 AM, Pavel Stehule wrote:
> so this means a xor operation
>
> 2010/8/12 Stephen Cook<sclists@gmail.com>:
>> What does the hash mark (#) mean in plpgsql?
>>
>> I saw it used in the pseudo_encrypt function @
>> http://wiki.postgresql.org/wiki/Pseudo_encrypt, on the line:
>>
>> r2 := l1 # ((((1366.0 * r1 + 150889) % 714025) / 714025.0) * 32767)::int;
>>
>> My google-fu has failed me on this one, and I needs to know.
>>
>> Thanks!

Thanks (and also to everyone else who said the same thing almost
instantly). That's not one I have used yet (at least not in a database).

I should have known it was an operator and looked it up that way... what
threw me off was that when I paste that line in pgAdmin it changes the
font and formatting for that line. So I thought it must be something
special.

Sorry for the noise.


-- Stephen