From: | Richard Huxton <dev(at)archonet(dot)com> |
---|---|
To: | "Andrey Y(dot) Mosienko" <feo(at)ttn(dot)ru> |
Cc: | Postgres <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Strange behaviour of PL/Perl |
Date: | 2001-02-25 08:44:47 |
Message-ID: | 3A98C5FE.A7C9274F@archonet.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
"Andrey Y. Mosienko" wrote:
>
> Hello All!
>
> I just included PL/Perl language in my database.
> Created function:
>
> CREATE FUNCTION and_with_mask(int2, int2) RETURNS int2 AS
> '
> return $_[0] &
> $_[1]
> ' LANGUAGE 'plperl';
> select and_with_mask(32,1);
> and_with_mask
> ---------------
> 1
> #!/usr/bin/perl
> $val = 32 & 1;
> print("val = $val\n");
>
> val = 0
>
> Where am I mistaken or something is in PL/Perl?
perl -e 'print ("32" & "1"),"\n"'
Values are being passed in as strings so perl is doing bitwise string
operation (perldoc perlop). Convert to numbers by doing +0 or similar.
- Richard Huxton
From | Date | Subject | |
---|---|---|---|
Next Message | Mathieu Arnold | 2001-02-25 12:37:15 | strange behaviour |
Previous Message | Richard Huxton | 2001-02-25 08:29:03 | Re: Request for thoughts... |