> Dmitry, > > please supply documentation (i.e. a patch to the SGML) to accompany this > patch, or at the very least a description of how it works, with the > promise of proper documentation to follow.
I am willing to write a proper documentation, but I haven't found the place where to add descriptions for the new functions, and neither the SGML document you're referring to, but I can submit a patch to it if you tell me where it is. If you take this as a promise of proper documentation, I'll explain in short how it works here: I added the following functions: * spi_prepare( $QUERY, @ARGUMENT_TYPES) : $PREPARED_QUERY - prepares a query with typed parameters, returns a prepared query token. * spi_exec_prepared( $PREPARED_QUERY, [%ATTRIBUTES], @ARGUMENTS) : $RESULT - executes a prepared query, returns the result in the same format as spi_exec_query() does. %ATTRIBUTES currently recognizes the only integer 'limit', which is the same as limit in spi_exec_query(). * spi_query_prepared( $PREPARED_QUERY, @ARGUMENTS) : $CURSOR - same as spi_query(), but instead of a text query statement, expects a result of spi_prepare() as the first parameter. * spi_freeplan( $PREPARED_QUERY) - frees the prepared query, must be called explicitly. * spi_cursor_close($CURSOR) - a wrapper around SPI_cursor_close(), to cancel a query session early, which would normally be freed after the last spi_fetchrow() is called. $CURSOR is returned either by spi_query() or spi_query_prepared(). There are also the following fixes to the existing code: - A fix to memory leaks in spi_fetchrow(), by replacing newSV(0) that is intended to signal an error but was never freed, to PL_sv_undef that is safe to return as a non-mortal scalar. - Replace (pointer_type*) SvIV(pointer) to INT2PTR( pointer_type*, SvUV(pointer)), to extinguish warnings. - Changed logic in plperl_spi_query() which I don't think correctly handled the case when SPI_prepare() fails. -- Sincerely, Dmitry Karasik --- catpipe Systems ApS *BSD solutions, consulting, development www.catpipe.net +45 7021 0050 ---------------------------(end of broadcast)--------------------------- TIP 2: Don't 'kill -9' the postmaster