Thread: plperl "set-valued function" problem

plperl "set-valued function" problem

From
"samı"
Date:
Hi

I am using PostgreSQL 8.2.3 on WindowsXP

I am using the PL/Perl regression tests located here:

     http://developer.postgresql.org/cvsweb.cgi/pgsql/src/pl/plperl/test/Attic/test_queries.sql

and comparing them to the expected output located here:

     http://developer.postgresql.org/cvsweb.cgi/pgsql/src/pl/plperl/test/Attic/test.expected

==============================================
The following function call gives an error :

CREATE OR REPLACE FUNCTION perl_set_int(int) RETURNS SETOF INTEGER AS $
$
return undef;
$$ LANGUAGE plperl;

> SELECT perl_set_int(5);
"ERROR:  set-valued function called in context that cannot accept a
set"


The .expected file above for the regression tests indicates that the
test should be successful:

SELECT perl_set_int(5);
 perl_set_int
--------------
(0 rows)

================================================

Did I miss anything? Is this problem known or is this not a problem at
all?

Thanks

Sami


Re: plperl "set-valued function" problem

From
Alvaro Herrera
Date:
samı escribió:
> Hi
>
> I am using PostgreSQL 8.2.3 on WindowsXP
>
> I am using the PL/Perl regression tests located here:
>
>      http://developer.postgresql.org/cvsweb.cgi/pgsql/src/pl/plperl/test/Attic/test_queries.sql

The fact that these files are in the "Attic" means they were deleted.
Try the files that actually exist:

http://developer.postgresql.org/cvsweb.cgi/pgsql/src/pl/plperl/sql/
http://developer.postgresql.org/cvsweb.cgi/pgsql/src/pl/plperl/expected/

--
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

Re: plperl "set-valued function" problem

From
"sami jan"
Date:
Thanks Alvaro

I checked out the files from: pgsql/src/pl/plperl/sql/ and
pgsql/src/pl/plperl/expected and compared the results

I still found a difference in 2 functions :
====================
Function 1 - Expected:
====================
CREATE OR REPLACE FUNCTION perl_spi_prepared(INTEGER) RETURNS INTEGER AS $$
   my $x = spi_prepare('select $1 AS a', 'INTEGER');
   my $q = spi_exec_prepared( $x, $_[0] + 1);
   spi_freeplan($x);
return $q->{rows}->[0]->{a};
$$ LANGUAGE plperl;

SELECT * from perl_spi_prepared(42);

 perl_spi_prepared
-------------------
                43
(1 row)

====================
Function 1 - Actual Output:
====================
ERROR:  error from Perl function: type "integer" does not exist at line 2.

====================
Function 2 - Expected:
====================
CREATE OR REPLACE FUNCTION perl_spi_prepared_double(double precision)
RETURNS double precision AS $$
  my $x = spi_prepare('SELECT 10.0 * $1 AS a', 'DOUBLE PRECISION');
  my $q = spi_query_prepared($x,$_[0]);
  my $result;
  while (defined (my $y = spi_fetchrow($q))) {
      $result = $y->{a};
  }
  spi_freeplan($x);
  return $result;
$$ LANGUAGE plperl;

SELECT perl_spi_prepared_double(4.35) as "double precision";

 double precision
------------------
             43.5
(1 row)

====================
Function 2 - Actual Output:
====================
ERROR:  error from Perl function: invalid name syntax at line 2.


Is this due to a bug? I think this is related - a problem with typename aliases

http://archives.postgresql.org/pgsql-bugs/2007-01/msg00111.php

Even if this is a bug and it has been logged, how did the author of
these files generate the result sets as seen in the .expected files?
Has he been using a newer version of Postgres?

I am using the PG 8.2.3 WinXP installer downloaded on 07 Feb 2007

Thanks

Sami


On 4/10/07, Alvaro Herrera <alvherre@commandprompt.com> wrote:
> samı escribió:
> > Hi
> >
> > I am using PostgreSQL 8.2.3 on WindowsXP
> >
> > I am using the PL/Perl regression tests located here:
> >
> >      http://developer.postgresql.org/cvsweb.cgi/pgsql/src/pl/plperl/test/Attic/test_queries.sql
>
> The fact that these files are in the "Attic" means they were deleted.
> Try the files that actually exist:
>
> http://developer.postgresql.org/cvsweb.cgi/pgsql/src/pl/plperl/sql/
> http://developer.postgresql.org/cvsweb.cgi/pgsql/src/pl/plperl/expected/
>
> --
> Alvaro Herrera                                http://www.CommandPrompt.com/
> PostgreSQL Replication, Consulting, Custom Development, 24x7 support
>

Re: plperl "set-valued function" problem

From
Tom Lane
Date:
"sami jan" <sami.jan@gmail.com> writes:
> I checked out the files from: pgsql/src/pl/plperl/sql/ and
> pgsql/src/pl/plperl/expected and compared the results

> I still found a difference in 2 functions :
> ERROR:  error from Perl function: type "integer" does not exist at line 2.

Apparently you're trying to use test files meant for CVS HEAD with some
prior release of Postgres.  You'd be better off looking at the CVS
histories and noting which version is latest on the branch you want.

> Is this due to a bug? I think this is related - a problem with typename aliases
> http://archives.postgresql.org/pgsql-bugs/2007-01/msg00111.php

Yup.

http://archives.postgresql.org/pgsql-committers/2007-01/msg00336.php

            regards, tom lane