On Fri, Nov 19, 2004 at 05:29:20AM -0600, Andrew Dunstan wrote: > Tom Lane said: > > Josh Berkus <[EMAIL PROTECTED]> writes: > >>> I would agree that seems a little odd ;). Would this be something we > >>> want done for 8.0? > > > >> I think we'd better. Otherwise, people will get used to the broken > >> syntax. > > > > Agreed. Someone's going to step up and patch this, no? > > > > (Not me --- I've already wasted more hours than I could afford this > > week on plperl.) > > > > I knew I should have looked at this closer when Peter made his complaint - > it sounded familiar. IIRC it was actually a point I raised about the > original code, and it was fixed. At any rate, last night Abhijit Menon-Sen > and I looked at the code and got confused becuse it appears to have been > fixed ;-). "rows" only contains data and only exists if the result is from a > successful select. "processed" is the row count, and is always present. > > So it's a case of bad documentation, which we will fix very shortly. Sorry > for the noise.
Please find attached a patch that fixes this. Cheers, D -- David Fetter [EMAIL PROTECTED] http://fetter.org/ phone: +1 510 893 6100 mobile: +1 415 235 3778 Remember to vote!
Index: doc/src/sgml/plperl.sgml =================================================================== RCS file: /projects/cvsroot/pgsql/doc/src/sgml/plperl.sgml,v retrieving revision 2.30 diff -c -r2.30 plperl.sgml *** doc/src/sgml/plperl.sgml 6 Nov 2004 14:32:10 -0000 2.30 --- doc/src/sgml/plperl.sgml 19 Nov 2004 18:52:34 -0000 *************** *** 174,189 **** <programlisting> $rv = spi_exec_query('SELECT * FROM my_table', 5); </programlisting> ! This returns up to 5 rows from the table ! <literal>my_table</literal>. If <literal>my_table</literal> ! has a column <literal>my_column</literal>, it could be accessed ! like this: <programlisting> $foo = $rv->{rows}[$i]->{my_column}; </programlisting> ! The total number of rows returned can be accessed like this: <programlisting> ! $nrows = @{$rv->{rows}}; </programlisting> </para> --- 174,190 ---- <programlisting> $rv = spi_exec_query('SELECT * FROM my_table', 5); </programlisting> ! This returns up to 5 rows from the table ! <literal>my_table</literal>. If <literal>my_table</literal> ! has a column <literal>my_column</literal>, you can get the value that ! value from row <literal>$i</literal> from a ! <command>SELECT</command> like this: <programlisting> $foo = $rv->{rows}[$i]->{my_column}; </programlisting> ! The total number of rows returned from a <command>SELECT</command> query can be accessed like this: <programlisting> ! $nrows = $rv->{processed} </programlisting> </para> *************** *** 200,206 **** </programlisting> To get the number of rows affected, do: <programlisting> ! $nrows = $rv->{rows}; </programlisting> </para> </listitem> --- 201,207 ---- </programlisting> To get the number of rows affected, do: <programlisting> ! $nrows = $rv->{processed}; </programlisting> </para> </listitem>
---------------------------(end of broadcast)--------------------------- TIP 8: explain analyze is your friend