Bug in documentation: https://www.postgresql.org/docs/current/spi-examples.html - Mailing list pgsql-docs

From Curt Kolovson
Subject Bug in documentation: https://www.postgresql.org/docs/current/spi-examples.html
Date
Msg-id CANhYJV6HWtgz_qjx_APfK0PAgLUzY-2vjLuj7i_o=TZF1LAQew@mail.gmail.com
Whole thread Raw
Responses Re: Bug in documentation: https://www.postgresql.org/docs/current/spi-examples.html
List pgsql-docs
The actual results (shown below) are different than shown on this doc
page. The reason is because the second parameter to the UDF that is
passed to SPI_exec is the maximum number of rows to return, or 0 for
no limit. It is not the maximum number of rows to process. In the case
of "SELECT execq('INSERT INTO a SELECT x + 2 FROM a', 1)", it returned
0 rows, but it inserted (processed) 2 rows. This example should be
corrected.

Curt

db=# SELECT execq('CREATE TABLE a (x integer)', 0);
 execq
-------
     0
(1 row)

db=# INSERT INTO a VALUES (execq('INSERT INTO a VALUES (0)', 0));
INSERT 0 1
db=# SELECT execq('SELECT * FROM a', 0);
INFO:  EXECQ:  0
INFO:  EXECQ:  1
 execq
-------
     2
(1 row)

db=# SELECT execq('INSERT INTO a SELECT x + 2 FROM a', 1);
 execq
-------
     2
(1 row)

db=# SELECT execq('SELECT * FROM a', 10);
INFO:  EXECQ:  0
INFO:  EXECQ:  1
INFO:  EXECQ:  2
INFO:  EXECQ:  3
 execq
-------
     4
(1 row)



pgsql-docs by date:

Previous
From: Michael Paquier
Date:
Subject: Re: Improvement of clarity in pg_ctl command docummentation
Next
From: "David G. Johnston"
Date:
Subject: Re: Bug in documentation: https://www.postgresql.org/docs/current/spi-examples.html