Hey Alex,

Thanks for answering.

"Alex Pilosov" <[EMAIL PROTECTED]> writes:

> The thing is, arrays are not extremely well supported in PostgreSQL
> itself, and there are all sorts of what you can do and can't do with
> them, you are not encouraged to use arrays in first place.

Hmmm.. Not easy to know that given that the documentation for arrays
is as complete as for any of the other data types. Are there any
issues you can point out? I went searching in the archives, but didn't
find anything obvious.

> None of other postgresql interfaces (JDBC, libpq) provide any kind
> of support dealing with arrays, and I think it probably will be
> misplaced to do it in DBD::Pg.

They presumably support exactly what Perl currently does: arrays look
like strings. Or do they not support that at all?

> To work around it, its fairly easy. Make a function to
> serialize/deserialize array ref, and call it at appropriate moment.

True. I just wanted to have a way to do it in C so that it would be
fast. I want to access arrays of 6 floats in tables with a million
rows, doing that using perl's split() and join() is going to be slow. 

> If you really want to get it in DBD::Pg, write a patch :)

That's what I'm offering ;-)

I was just hoping that someone could tell me if there is some
fundamental obstruction in the DBI C API that prohibits using RV's. In
Pg's dbbimp.c it wants to convert all the bind variables into
char*'s. 

I'm hoping that this is because that's what Pg wants and not what DBI
forces you to do.

> Oh, and you might want to consider DBD::PgSPI and plperlu on server end,
> this way you can serialize complex structures and pass them to a
> server-side perl program  :)

Thanks for pointing that out. I was disappointed that PL/Perl didn't
allow access to the DB, so I never used it. I grabbed your module and
the latest beta and dug around in the code. But I couldn't figure some
stuff out.

Am I forced to serialize them into strings? Or can I return arbitrary
SV's from the functions? 

in plperl.c, plperl_func_handler() does:

        retval = FunctionCall3(&prodesc->result_in_func,
                                   PointerGetDatum(SvPV(perlret, PL_na)),
                                   ObjectIdGetDatum(prodesc->result_in_elem),
                                   Int32GetDatum(-1));

which rips a string out of the perlret SV. So my guess is you have to
return a string from your function. What about using
bind_param_inout()? The DBD::Pg man page says this isn't supported,
but would implementing this enable me to pass back RV's?

Cheers,
jas.

Reply via email to