plperl spi_prepare and arrays

From: Nathan Jahnke <njahnke(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: plperl spi_prepare and arrays
Date: 2009-07-22 22:30:12
Message-ID: 89e8c360907221530i44766d1dn9f0c2cef904d001f@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi all,

Spent the last few hours searching but was unable to get a
satisfactory answer. Basically, if I do this:

my $arr = [1,2,3,4];
$_SHARED{test} = spi_prepare('update users set interest=$1 where
uid=2', 'int[]');
spi_exec_prepared($_SHARED{test}, $arr);

I get:

DBD::Pg::st execute failed: ERROR: error from Perl function "view":
array value must start with "{" or dimension information

Okay, so I can pass the arrayref to spi_exec_prepared by making a
string out of it, with join() and string concatenation with curlies
and all that jazz, but this is an inefficient pain, especially if I
happened to have more than a 1D array. Shouldn't I be able to pass an
arrayref directly?

Also, what about going the other way - getting postgres arrays in
plperl as arrayrefs instead of as strings with curlies? In searching I
found this old message:

http://archives.postgresql.org/pgsql-general/2006-08/msg01472.php

... which suggests to me that it is indeed possible, but I would like
more details.

Thank you very much.

Nathan

Browse pgsql-general by date

  From Date Subject
Next Message Sam Mason 2009-07-22 22:39:42 Re: How would I get information regarding update when running for a long time?
Previous Message Robert James 2009-07-22 22:22:40 Re: Can LIKE under utf8 use INDEXes?