forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commita0558cf
committed
Fix checking of query type in plpgsql's RETURN QUERY command.
Prior to v14, we insisted that the query in RETURN QUERY be of a typethat returns tuples. (For instance, INSERT RETURNING was allowed,but not plain INSERT.) That happened indirectly because we opened acursor for the query, so spi.c checked SPI_is_cursor_plan(). As aconsequence, the error message wasn't terribly on-point, but at leastit was there.Commit2f48ede lost this detail. Instead, plain RETURN QUERYinsisted that the query be a SELECT (by checking for SPI_OK_SELECT)while RETURN QUERY EXECUTE failed to check the query type at all.Neither of these changes was intended.The only convenient place to check this in the EXECUTE case is inside_SPI_execute_plan, because we haven't done parse analysis until then.So we need to pass down a flag saying whether to enforce that thequery returns tuples. Fortunately, we can squeeze another booleaninto struct SPIExecuteOptions without an ABI break, since there'spadding space there. (It's unlikely that any extensions wouldalready be using this new struct, but preserving ABI in v14 seemslike a smart idea anyway.)Within spi.c, it seemed like _SPI_execute_plan's parameter listwas already ridiculously long, and I didn't want to make it longer.So I thought of passing SPIExecuteOptions down as-is, allowing thatparameter list to become much shorter. This makes the patch a bitmore invasive than it might otherwise be, but it's all internal tospi.c, so that seems fine.Per report from Marc Bachmann. Back-patch to v14 where thefaulty code came in.Discussion:https://postgr.es/m/1F2F75F0-27DF-406F-848D-8B50C7EEF06A@gmail.com1 parent2903f14 commita0558cf
File tree
6 files changed
+186
-80
lines changed- doc/src/sgml
- src
- backend/executor
- include/executor
- pl/plpgsql/src
- test/regress
- expected
- sql
6 files changed
+186
-80
lines changedLines changed: 22 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
739 | 739 |
| |
740 | 740 |
| |
741 | 741 |
| |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
742 | 753 |
| |
743 | 754 |
| |
744 | 755 |
| |
| |||
1869 | 1880 |
| |
1870 | 1881 |
| |
1871 | 1882 |
| |
| 1883 | + | |
| 1884 | + | |
| 1885 | + | |
| 1886 | + | |
| 1887 | + | |
| 1888 | + | |
| 1889 | + | |
| 1890 | + | |
| 1891 | + | |
| 1892 | + | |
| 1893 | + | |
1872 | 1894 |
| |
1873 | 1895 |
| |
1874 | 1896 |
| |
|
0 commit comments
Comments
(0)