mirror of
https://github.com/postgres/postgres.git
synced 2025-07-26 01:22:12 +03:00
Allow args to spi_prepare to be standard type aliaes as well as those known in pg_type. Fixes bug #2917. Add some regression tests for these cases.
This commit is contained in:
@ -316,7 +316,7 @@ SELECT array_of_text();
|
||||
-- Test spi_prepare/spi_exec_prepared/spi_freeplan
|
||||
--
|
||||
CREATE OR REPLACE FUNCTION perl_spi_prepared(INTEGER) RETURNS INTEGER AS $$
|
||||
my $x = spi_prepare('select $1 AS a', 'INT4');
|
||||
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};
|
||||
@ -337,3 +337,33 @@ CREATE OR REPLACE FUNCTION perl_spi_prepared_set(INTEGER, INTEGER) RETURNS SETOF
|
||||
$$ LANGUAGE plperl;
|
||||
SELECT * from perl_spi_prepared_set(1,2);
|
||||
|
||||
--
|
||||
-- Test prepare with a type with spaces
|
||||
--
|
||||
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";
|
||||
|
||||
--
|
||||
-- Test with a bad type
|
||||
--
|
||||
CREATE OR REPLACE FUNCTION perl_spi_prepared_bad(double precision) RETURNS double precision AS $$
|
||||
my $x = spi_prepare('SELECT 10.0 * $1 AS a', 'does_not_exist');
|
||||
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_bad(4.35) as "double precision";
|
||||
|
||||
|
Reference in New Issue
Block a user