From: | Curt Kolovson <ckolovson(at)gmail(dot)com> |
---|---|
To: | pgsql-docs(at)lists(dot)postgresql(dot)org |
Subject: | Bug in documentation: https://www.postgresql.org/docs/current/spi-examples.html |
Date: | 2023-07-17 23:52:53 |
Message-ID: | CANhYJV6HWtgz_qjx_APfK0PAgLUzY-2vjLuj7i_o=TZF1LAQew@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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)
From | Date | Subject | |
---|---|---|---|
Next Message | David G. Johnston | 2023-07-18 00:26:26 | Re: Bug in documentation: https://www.postgresql.org/docs/current/spi-examples.html |
Previous Message | Michael Paquier | 2023-07-17 08:27:43 | Re: Improvement of clarity in pg_ctl command docummentation |