Search Postgresql Archives

Re: Perl function leading to out of memory error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 21.02.2013 01:02, Jeff Janes wrote:
CREATE DOMAIN isin AS char(12) CHECK (isin_ok(value));
Could you give some example values that meet this criteria?  Trying to
reverse engineer your helper functions is no fun.
A valid example is "DE0007100000". The same with another check digit is of course invalid (e.g. "DE0007100001").
CREATE OR REPLACE FUNCTION foo(isin char(12)) RETURNS void AS $$
my ($isin) = @_;

my $stmt = spi_prepare('
     INSERT INTO foo (isin)
     VALUES ($1)', 'isin');
spi_exec_prepared($stmt, $isin);
spi_freeplan($stmt);
$$ LANGUAGE plperl VOLATILE STRICT;
That should be easy enough to re-write as plpgsql.  If you do, does it
still leak?
I have no idea how to create a prepared statement in plpgsql. I have tested the following function:

CREATE OR REPLACE FUNCTION foo(isin char(12)) RETURNS void AS $$
BEGIN
    INSERT INTO foo (isin) VALUES (isin);
END;
$$ LANGUAGE plpgsql VOLATILE STRICT;

This works without any problem.

Regards,
Christian

--
Deriva GmbH                         Tel.: +49 551 489500-42
Financial IT and Consulting         Fax:  +49 551 489500-91
Hans-Böckler-Straße 2                  http://www.deriva.de
D-37079 Göttingen

Amtsgericht Göttingen | HRB 3240
Geschäftsführer: Dirk Baule, Christian Schröder
Deriva CA Certificate: http://www.deriva.de/deriva-ca.cer



--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux