summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* ICU: check for U_STRING_NOT_TERMINATED_WARNING.HEADmasterJeff Davis2023-05-172-29/+15
| | | | | | | | | | | | | Fixes memory error in cases where the length of the language name returned by uloc_getLanguage() is exactly ULOC_LANG_CAPACITY, in which case the status is set to U_STRING_NOT_TERMINATED_WARNING. Also check in call sites for other ICU functions that are expected to return a C string to be safe (no bug is known at these other call sites). Reported-by: Alexander Lakhin Discussion: https://postgr.es/m/2098874d-c111-41e4-9063-30bcf135226b@gmail.com
* Reduce icu_validation_level default to WARNING.Jeff Davis2023-05-176-8/+8
| | | | Discussion: https://postgr.es/m/daa9f060aa2349ebc84444515efece49e7b32c5d.camel@j-davis.com
* Fix error message wordingsPeter Eisentraut2023-05-171-3/+3
| | | | | | The original patch for percentrepl.c c96de2ce17 adopted the error messages from basebackup_to_shell, but that uses terminology that doesn't really fit with the new API naming.
* Add writeback to pg_stat_ioAndres Freund2023-05-1712-25/+82
| | | | | | | | | | | | | | | 28e626bde00 added the concept of IOOps but neglected to include writeback operations. ac8d53dae5 added time spent doing these I/O operations. Without counting writeback, checkpointer write time in the log often differed substantially from that in pg_stat_io. To fix this, add IOOp IOOP_WRITEBACK and track writeback in pg_stat_io. Bumps catversion. Author: Melanie Plageman <melanieplageman@gmail.com> Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com> Reported-by: Andres Freund <andres@anarazel.de> Discussion: https://postgr.es/m/20230419172326.dhgyo4wrrhulovt6%40awork3.anarazel.de
* Update parameter name context to wb_contextAndres Freund2023-05-172-16/+17
| | | | | | | | | | For clarity of review, renaming the function parameter "context" in ScheduleBufferTagForWriteback() and IssuePendingWritebacks() to "wb_context" is a separate commit. The next commit adds an "io_context" parameter and "wb_context" makes it more clear which is which. Author: Melanie Plageman <melanieplageman@gmail.com> Discussion: https://postgr.es/m/CAAKRu_acc6iL4M3hvOTeztf_ZPpsB3Pqio5aVHgZ5q=Pi3BZKg@mail.gmail.com
* Use BUFFER_USAGE_LIMIT to reduce needed test table sizeAndres Freund2023-05-172-4/+8
| | | | | | | | Using the minimum BUFFER_USAGE_LIMIT value, we can make one of the pg_stat_io test tables smaller while still causing reuses. Author: Melanie Plageman <melanieplageman@gmail.com> Discussion: https://postgr.es/m/CAAKRu_acc6iL4M3hvOTeztf_ZPpsB3Pqio5aVHgZ5q=Pi3BZKg@mail.gmail.com
* Revert "Add USER SET parameter values for pg_db_role_setting"Alexander Korotkov2023-05-1734-677/+51
| | | | | | | | | This reverts commit 096dd80f3ccc and its fixups beecbe8e5001, afdd9f7f0e00, 529da086ba, db93e739ac61. Catversion is bumped. Discussion: https://postgr.es/m/d46f9265-ff3c-6743-2278-6772598233c2%40pgmasters.net
* pg_dump: Error message improvementsAlvaro Herrera2023-05-171-2/+2
| | | | | Remove spurious semicolon from one error message, and print the offending value of a parameter reported as invalid in another.
* pg_dump: Have _EndLO report errno after CFH->write_func() failureAlvaro Herrera2023-05-171-1/+7
| | | | | Other callers of that function do things this way, but this one didn't get the memo.
* Track tlist_vinfo.varnullingrels even in non-Assert builds.Tom Lane2023-05-171-6/+0
| | | | | Oversight in commit 867be9c07 (which should get reverted along with that, if we ever do revert it). Per buildfarm.
* Fix some issues with improper placement of outer join clauses.Tom Lane2023-05-1714-86/+450
| | | | | | | | | | | | | | | | | | | | | | | | | | After applying outer-join identity 3 in the forward direction, it was possible for the planner to mistakenly apply a qual clause from above the two outer joins at the now-lower join level. This can give the wrong answer, since a value that would get nulled by the now-upper join might not yet be null. To fix, when we perform such a transformation, consider that the now-lower join hasn't really completed the outer join it's nominally responsible for and thus its relid set should not include that OJ's relid (nor should its output Vars have that nullingrel bit set). Instead we add those bits when the now-upper join is performed. The existing rules for qual placement then suffice to prevent higher qual clauses from dropping below the now-upper join. There are a few complications from needing to consider transitive closures in case multiple pushdowns have happened, but all in all it's not a very complex patch. This is all new logic (from 2489d76c4) so no need to back-patch. The added test cases all have the same results as in v15. Tom Lane and Richard Guo Discussion: https://postgr.es/m/0b819232-4b50-f245-1c7d-c8c61bf41827@postgrespro.ru
* Convert nullingrels match checks from Asserts to test-and-elog.Tom Lane2023-05-171-13/+21
| | | | | | | | | | | | It seems like the code that these checks are backstopping may have a few bugs left in it. Use a test-and-elog so that the tests are performed even in non-assert builds, and so that we get something more informative than "server closed the connection" on failure. Committed separately with the idea that eventually we'll revert this. It might be awhile though. Discussion: https://postgr.es/m/3014965.1684293045@sss.pgh.pa.us
* Advance input pointer when LZ4 compressing dataTomas Vondra2023-05-173-1/+55
| | | | | | | | | | | | | | | | | LZ4File_write() did not advance the input pointer on subsequent invocations of LZ4F_compressUpdate(). As a result the generated compressed output would be a compressed version of the same input chunk. Tests failed to catch this error because the data would comfortably fit within the default buffer size, as a single chunk. Tests have been added to provide adequate coverage of multi-chunk compression. WriteDataToArchiveLZ4() which is also using LZ4F_compressUpdate() did not suffer from this omission. Author: Georgios Kokolatos <gkokolatos@pm.me> Reported-by: Michael Paquier <michael@paquier.xyz> Discussion: https://postgr.es/m/ZFhCyn4Gm2eu60rB%40paquier.xyz
* Null-terminate the output buffer of LZ4Stream_getsTomas Vondra2023-05-171-1/+11
| | | | | | | | | | LZ4Stream_gets did not null-terminate its output buffer. The callers expected the buffer to be null-terminated and passed it around to functions such as sscanf with unintended consequences. Author: Georgios Kokolatos <gkokolatos@pm.me> Reported-by: Alexander Lakhin <exclusion@gmail.com> Discussion: https://postgr.es/m/94ae9bca-5ebb-1e68-bb7b-4f32e89fefbe@gmail.com
* Add back SQLValueFunction for SQL keywordsMichael Paquier2023-05-1723-270/+473
| | | | | | | | | | | | | | | | | | | | | | | | This is equivalent to a revert of f193883 and fb32748, with the addition that the declaration of the SQLValueFunction node needs to gain a couple of node_attr for query jumbling. The performance impact of removing the function call inlining is proving to be too huge for some workloads where these are used. A worst-case test case of involving only simple SELECT queries with a SQL keyword is proving to lead to a reduction of 10% in TPS via pgbench and prepared queries on a high-end machine. None of the tests I ran back for this set of changes saw such a huge gap, but Alexander Lakhin and Andres Freund have found that this can be noticeable. Keeping the older performance would mean to do more inlining in the executor when using COERCE_SQL_SYNTAX for a function expression, similarly to what SQLValueFunction does. This requires more redesign work and there is little time until 16beta1 is released, so for now reverting the change is the best way forward, bringing back the previous performance. Bump catalog version. Reported-by: Alexander Lakhin Discussion: https://postgr.es/m/b32bed1b-0746-9b20-1472-4bdc9ca66d52@gmail.com
* Ensure Soundex difference() function handles empty input sanely.Tom Lane2023-05-163-7/+15
| | | | | | | | | | | | | | | | fuzzystrmatch's difference() function assumes that _soundex() always initializes its output buffer fully. This was not so for the case of a string containing no alphabetic characters, resulting in unstable output and Valgrind complaints. Fix by using memset() to fill the whole buffer in the early-exit case. Also make some cosmetic improvements (I didn't care for the random switches between "instr[0]" and "*instr" notation). Report and diagnosis by Alexander Lakhin (bug #17935). Back-patch to all supported branches. Discussion: https://postgr.es/m/17935-b99316aa79c18513@postgresql.org
* libpq: Error message improvementAlvaro Herrera2023-05-161-2/+2
| | | | | Move a variable name out of the translatable message, to make it identical to others.
* Mark internal messages as no longer translatableAlvaro Herrera2023-05-161-6/+6
| | | | | | | | | | | The problem that these messages protect against can only occur because a corrupted hash spill file was written, i.e., a Postgres bug. There's no reason to have them as translatable. Backpatch to 15, where these messages were changed by commit c4649cce39a4. Reviewed-by: Daniel Gustafsson <daniel@yesql.se> Discussion: https://postgr.es/m/20230510175407.dwa5v477pw62ikyx@alvherre.pgsql
* Fix reported runtime for single tests in pg_regressDaniel Gustafsson2023-05-161-2/+2
| | | | | | | | | Commit 558fff0adf got the order of the parameters to test_status_failed mixed up which resulted in the runtime being reported as 0 ms. Fix by changing the order to the correct one. No backpatching is needed since this has not been shipped in a release yet. Discussion: https://postgr.es/m/0134C9EC-5F6B-4EAC-B2D5-BB4249BEBD4D@yesql.se
* doc: Fix ordering of entries in wait event table for I/O typeMichael Paquier2023-05-161-4/+4
| | | | | | Issue spotted while reviewing a different patch touching this area. Discussion: https://postgr.es/m/ZGM1U5D5EuBUbasi@paquier.xyz
* libpq: Error message improvementPeter Eisentraut2023-05-164-23/+23
|
* psql: Adjust capitalization of table headingPeter Eisentraut2023-05-162-20/+20
| | | | for consistency with surrounding headings
* doc: Fix incorrect version list for Windows SDKMichael Paquier2023-05-151-2/+2
| | | | | | | | References to SDK 8.1a should have been cleaned up in 495ed0e, as only version 10 and above are supported with Windows 10 and newer versions. Reported-by: Thomas Munro Discussion: https://postgr.es/m/CA+hUKG++qE9uVjQaTTD7oaC8a2T3h8K50=Eqyx9uUZvOHa__ww@mail.gmail.com
* Fix incorrect TAP test orderingPeter Eisentraut2023-05-151-1/+1
| | | | | | | | | | | | Using a test function before a possible skip_all is incorrect. If the skip_all is called, the test output will become incorrect and the test file will fail. a4f23f9b3c introduced a new test before skip_all. After discussion, this doesn't really need to be a test. Instead, we just bail out if the condition is not satisfied. Discussion: https://www.postgresql.org/message-id/af5567a1-aea6-fbdb-7e4b-d1e23a43c43b@enterprisedb.com
* Fix whitespace inconsistenciesPeter Eisentraut2023-05-151-2/+2
|
* Fix wal_writer_flush_after initializer value.Thomas Munro2023-05-153-2/+4
| | | | | | | | | | Commit a73952b7956 (new in 16) required default values in guc_table.c and C variable initializers to match. This one only matched when XLOG_BLCKSZ == 8kB. Fix by using the same expression in both places with a new DEFAULT_XXX macro, as done for other GUCs. Reviewed-by: Andres Freund <andres@anarazel.de> Discussion: https://postgr.es/m/CA+hUKGLNmLV=VrT==5MqnbARgx2ifRSFtdd8ofdfrdSLL3yv5A@mail.gmail.com
* Rename io_direct to debug_io_direct.Thomas Munro2023-05-154-38/+38
| | | | | | | | | | | | | | | | | | Give the new GUC introduced by d4e71df6 a name that is clearly not intended for mainstream use quite yet. Future proposals would drop the prefix only after adding infrastructure to make it efficient. Having the switch in the tree sooner is good because it might lead to new discoveries about the hazards awaiting us on a wide range of systems, but that name was too enticing and could lead to cross-version confusion in future, per complaints from Noah and Justin. Suggested-by: Noah Misch <noah@leadboat.com> Reviewed-by: Noah Misch <noah@leadboat.com> Reviewed-by: Justin Pryzby <pryzby@telsasoft.com> (the idea, not the patch) Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> (ditto) Discussion: https://postgr.es/m/20230430041106.GA2268796%40rfd.leadboat.com
* Improve error message for pg_create_subscription.Nathan Bossart2023-05-122-2/+5
| | | | | | | | c3afe8cf5a updated this error message, but it didn't use the new style established in de4d456b40. Reviewed-by: Tom Lane Discussion: https://postgr.es/m/20230512203721.GA2644063%40nathanxps13.home
* Tighten usage of PSQL_WATCH_PAGER.Tom Lane2023-05-122-19/+26
| | | | | | | | | | | | | | | | | | | | | | Don't use PSQL_WATCH_PAGER when stdin/stdout are not a terminal. This corresponds to the restrictions on when other commands will use [PSQL_]PAGER. There isn't a lot of sense in trying to use a pager in non-interactive cases, and doing so allows an environment setting to break our tests. Also, ignore PSQL_WATCH_PAGER if it is set but empty or all-blank, for the same reasons we ignore such settings of [PSQL_]PAGER (see commit 18f8f784c). No documentation change is really needed, since there is nothing suggesting that these constraints on [PSQL_]PAGER didn't already apply to PSQL_WATCH_PAGER too. But I rearranged the text a little to make it read more naturally (IMHO anyway). Per report from Pavel Stehule. Back-patch to v15 where PSQL_WATCH_PAGER was introduced. Discussion: https://postgr.es/m/CAFj8pRDTwFzmEWdA-gdAcUh0ZnxUioSfTMre71WyB_wNJy-8gw@mail.gmail.com
* initdb: Set collversion for standard collation UNICODEPeter Eisentraut2023-05-122-1/+8
| | | | | | | | | | Since the behavior of the UNICODE collation can change with new ICU/Unicode versions, we need to apply the versioning mechanism to it. We do this with an UPDATE command in initdb; this is similar to how we put the collation version into pg_database already. Reported-by: Daniel Verite <daniel@manitou-mail.org> Discussion: https://www.postgresql.org/message-id/49417853-7bdd-4b23-a4e9-04c7aff33821@manitou-mail.org
* Undo faulty attempt at not relying on RINFO_IS_PUSHED_DOWN.Tom Lane2023-05-113-6/+23
| | | | | | | | | | | | | | I've had a bee in my bonnet for some time about getting rid of RestrictInfo.is_pushed_down, because it's squishily defined and requires not-inexpensive extra tests to use (cf RINFO_IS_PUSHED_DOWN). In commit 2489d76c4, I tried to make remove_rel_from_query() not depend on that macro; but the replacement test is buggy, as exposed by a report from Rushabh Lathia and Robert Haas. That change was pretty incidental to the main goal of 2489d76c4, so let's just revert it for now. (Getting rid of is_pushed_down is still far away, anyway.) Discussion: https://postgr.es/m/CA+TgmoYco=hmg+iX1CW9Y1_CzNoSL81J03wUG-d2_3=rue+L2A@mail.gmail.com
* Doc: Fix link to fillfactor reloption.Peter Geoghegan2023-05-101-1/+1
| | | | | | | | | | | | Fix a link from the "Heap-Only Tuples" documentation section. Previously, its "fillfactor" link pointed to the "CREATE TABLE" command's documentation. Now the link directly points to the fillfactor storage parameter documentation (which is about half way into the "CREATE TABLE" sect1). Oversight in commit 115464bb. Backpatch: 12-, the first version with a usable reloption link.
* Fix publication syntax error messageAlvaro Herrera2023-05-103-2/+15
| | | | | | | | | | | | There was some odd wording in corner-case gram.y error messages "some error ... at or near", which appears to have been modeled after "syntax error" messages. However, they don't work that way, and they're just wrong. They're also uncovered by tests. Remove the trailing words, and also add tests. They were introduced with 5a2832465fd8; backpatch to 15. Author: Álvaro Herrera <alvherre@alvh.no-ip.org>
* Add missing gettext triggersPeter Eisentraut2023-05-101-0/+3
| | | | due to the changes in commit dac048f71e
* Fix assertion failure when updating stats_fetch_consistency in a transactionMichael Paquier2023-05-106-5/+118
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | An update of the GUC stats_fetch_consistency in a transaction would be able to trigger an assertion when doing cache->snapshot. In this case, when retrieving a pgstat entry after the switch, a new snapshot would be rebuilt, confusing pgstat_build_snapshot() because a snapshot is already cached with an unexpected mode ("cache"). In order to fix this problem, this commit adds a flag to force a snapshot clear each time this GUC is changed. Some tests are added to check, while on it. Some optimizations in avoiding the snapshot clear should be possible depending on what is cached and the current GUC value, I guess, but this solution is simple, and ensures that the state of the cache is updated each time a new pgstat entry is fetched, hence being consistent with the level wanted by the client that has set the GUC. Note that cache->none and snapshot->none would not cause issues, as fetching a pgstat entry would be retrieved from shared memory on the second attempt, however a snapshot would still be cached. Similarly, none->snapshot and none->cache would build a new snapshot on the second fetch attempt. Finally, snapshot->cache would cache a new snapshot on the second attempt. Reported-by: Alexander Lakhin Author: Kyotaro Horiguchi Discussion: https://postgr.es/m/17804-2a118cd046f2d0e5@postgresql.org backpatch-through: 15
* Document values of stats_fetch_consistency in postgresql.conf.sampleMichael Paquier2023-05-101-1/+1
| | | | | | Issue noted while looking at a patch related to that. Discussion: https://postgr.es/m/ZE9LiFc7JdNHokz/@paquier.xyz
* Fix the race condition in the test case added by commit a6e04b1d20.Amit Kapila2023-05-091-18/+18
| | | | | | | | | | | | | | | The commit a6e04b1d20 added a test to ensure that the invalidated logical slots don't retain WAL. The test was ensuring that the checkpoint removes the WAL files corresponding to invalidated logical slots on the standby node but missed the point that the standby node also had a physical slot which led to the prevention of WAL file removal. Move the creation of physical slot on the standby and initialization of cascading standby closer to the test case that actually required it so that other tests don't get affected by the presence of the physical slot on standby. Author: Bertrand Drouvot Reviewed-by: Amit Kapila Discussion: https://postgr.es/m/2fefa454-5a70-2174-ddbf-4a0e41537139@gmail.com
* Fix invalid memory access during the shutdown of the parallel apply worker.Amit Kapila2023-05-093-18/+38
| | | | | | | | | | | | | | | | | | | | | | | The callback function pa_shutdown() accesses MyLogicalRepWorker which may not be initialized if there is an error during the initialization of the parallel apply worker. The other problem is that by the time it is invoked even after the initialization of the worker, the MyLogicalRepWorker will be reset by another callback logicalrep_worker_onexit. So, it won't have the required information. To fix this, register the shutdown callback after we are attached to the worker slot. After this fix, we observed another issue which is that sometimes the leader apply worker tries to receive the message from the error queue that might already be detached by the parallel apply worker leading to an error. To prevent such an error, we ensure that the leader apply worker detaches from the parallel apply worker's error queue before stopping it. Reported-by: Sawada Masahiko Author: Hou Zhijie Reviewed-by: Sawada Masahiko, Amit Kapila Discussion: https://postgr.es/m/CAD21AoDo+yUwNq6nTrvE2h9bB2vZfcag=jxWc7QxuWCmkDAqcA@mail.gmail.com
* Revert "ICU: do not convert locale 'C' to 'en-US-u-va-posix'."Jeff Davis2023-05-084-14/+34
| | | | | | This reverts commit f7faa9976cc0504c027a20ed66ceca9018041dd4. Discussion: https://postgr.es/m/483826.1683582475@sss.pgh.pa.us
* Doc: update VACUUM FREEZE query conflict guidance.Peter Geoghegan2023-05-081-4/+10
| | | | | | | | | | | | | | | Commit 1de58df4, which added page-level freezing, taught VACUUM to reuse each page's "set-visibility-map" snapshotConflictHorizon for freezing (at least in the vast majority of cases where freezing went ahead). This made VACUUM FREEZE much less prone to generating recovery conflicts on standbys; VACUUM FREEZE became only slightly more likely to cause recovery conflicts than an equivalent VACUUM. Update old documentation that specifically warned of the likelihood of recovery conflicts from VACUUM FREEZE. Explain the same general issue (the issue of VACUUM generating recovery conflicts even in the absence of dead row cleanup) using the example of conflicts caused by VISIBLE WAL records.
* ICU: do not convert locale 'C' to 'en-US-u-va-posix'.Jeff Davis2023-05-084-34/+14
| | | | | | | | | | The conversion was intended to be for convenience, but it's more likely to be confusing than useful. The user can still directly specify 'en-US-u-va-posix' if desired. Discussion: https://postgr.es/m/f83f089ee1e9acd5dbbbf3353294d24e1f196e95.camel@j-davis.com Discussion: https://postgr.es/m/37520ec1ae9591f83132f82dbd625f3fc2d69c16.camel@j-davis.com
* Adjust sepgsql expected output for 681d9e462 et al.Tom Lane2023-05-081-1/+0
| | | | Security: CVE-2023-2454
* Handle RLS dependencies in inlined set-returning functions properly.Tom Lane2023-05-083-0/+54
| | | | | | | | | | | | | | | If an SRF in the FROM clause references a table having row-level security policies, and we inline that SRF into the calling query, we neglected to mark the plan as potentially dependent on which role is executing it. This could lead to later executions in the same session returning or hiding rows that should have been hidden or returned instead. Our thanks to Wolfgang Walther for reporting this problem. Stephen Frost and Tom Lane Security: CVE-2023-2455
* Replace last PushOverrideSearchPath() call with set_config_option().Noah Misch2023-05-087-11/+165
| | | | | | | | | | | | | | | | | | | | | The two methods don't cooperate, so set_config_option("search_path", ...) has been ineffective under non-empty overrideStack. This defect enabled an attacker having database-level CREATE privilege to execute arbitrary code as the bootstrap superuser. While that particular attack requires v13+ for the trusted extension attribute, other attacks are feasible in all supported versions. Standardize on the combination of NewGUCNestLevel() and set_config_option("search_path", ...). It is newer than PushOverrideSearchPath(), more-prevalent, and has no known disadvantages. The "override" mechanism remains for now, for compatibility with out-of-tree code. Users should update such code, which likely suffers from the same sort of vulnerability closed here. Back-patch to v11 (all supported versions). Alexander Lakhin. Reported by Alexander Lakhin. Security: CVE-2023-2454
* Add missing source file to nls.mkPeter Eisentraut2023-05-081-0/+1
|
* pg_dump: Restore lost translation markerPeter Eisentraut2023-05-081-1/+1
| | | | The refactoring in 03d02f54a6 lost a translation marker.
* doc: Fix some markups in logical replication sectionMichael Paquier2023-05-081-6/+6
| | | | | | Author: Peter Smith Reviewed-by: David Zhang Discussion: https://postgr.es/m/CAHut+Pst11ac2hcmePt1=oTmBwTT=DAssRR1nsdoy4BT+68=Mg@mail.gmail.com
* pg_basebackup: Restore lost translation markersPeter Eisentraut2023-05-082-13/+13
| | | | The refactoring in ebfb814f7c lost some translation markers.
* Add ruleutils support for decompiling MERGE commands.Tom Lane2023-05-073-0/+262
| | | | | | | | | This was overlooked when MERGE was added, but it's essential support for MERGE in new-style SQL functions. Alvaro Herrera Discussion: https://postgr.es/m/3579737.1683293801@sss.pgh.pa.us
* Fix typo with wait event for SLRU buffer of commit timestampsMichael Paquier2023-05-051-1/+1
| | | | | | | | | | | | | This wait event was documented as "CommitTsBuffer" since its introduction, but the code named it "CommitTSBuffer". This commit fixes the code to follow the term documented, which is also more consistent with the naming of the other wait events used for commit timestamps. Introduced by 5da1493. Author: Alexander Lakhin Discussion: https://postgr.es/m/e8c38840-596a-83d6-bd8d-cebc51111572@gmail.com Backpatch-through: 13