forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit2812059
committed
Fix pg_sequence_last_value() for unlogged sequences on standbys.
Presently, when this function is called for an unlogged sequence ona standby server, it will error out with a message likeERROR: could not open file "base/5/16388": No such file or directorySince the pg_sequences system view uses pg_sequence_last_value(),it can error similarly. To fix, modify the function to return NULLfor unlogged sequences on standby servers. Since this bug ispresent on all versions since v15, this approach is preferable tomaking the ERROR nicer because we need to repair the pg_sequencesview without modifying its definition on released versions. Forconsistency, this commit also modifies the function to return NULLfor other sessions' temporary sequences. The pg_sequences viewalready appropriately filters out such sequences, so there's no bugthere, but we might as well offer some defense in case someoneinvokes this function directly.Unlogged sequences were first introduced in v15, but temporarysequences are much older, so while the fix for unlogged sequencesis only back-patched to v15, the temporary sequence portion isback-patched to all supported versions.We could also remove the privilege check in the pg_sequences viewdefinition in v18 if we modify this function to return NULL forsequences for which the current user lacks privileges, but that isleft as a future exercise for when v18 development begins.Reviewed-by: Tom Lane, Michael PaquierDiscussion:https://postgr.es/m/20240501005730.GA594666%40nathanxps13Backpatch-through: 121 parent157b1e6 commit2812059
1 file changed
+18
-9
lines changedLines changed: 18 additions & 9 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1857 | 1857 |
| |
1858 | 1858 |
| |
1859 | 1859 |
| |
1860 |
| - | |
1861 |
| - | |
1862 |
| - | |
1863 |
| - | |
1864 |
| - | |
| 1860 | + | |
| 1861 | + | |
1865 | 1862 |
| |
1866 | 1863 |
| |
1867 | 1864 |
| |
| |||
1872 | 1869 |
| |
1873 | 1870 |
| |
1874 | 1871 |
| |
1875 |
| - | |
| 1872 | + | |
| 1873 | + | |
| 1874 | + | |
| 1875 | + | |
| 1876 | + | |
| 1877 | + | |
| 1878 | + | |
| 1879 | + | |
| 1880 | + | |
| 1881 | + | |
1876 | 1882 |
| |
1877 |
| - | |
1878 |
| - | |
| 1883 | + | |
1879 | 1884 |
| |
1880 |
| - | |
| 1885 | + | |
| 1886 | + | |
| 1887 | + | |
| 1888 | + | |
| 1889 | + | |
1881 | 1890 |
| |
1882 | 1891 |
| |
1883 | 1892 |
| |
|
0 commit comments
Comments
(0)