pgsql: Fix overread in JSON parsing errors for incomplete byte sequence

2024-05-08 Thread Michael Paquier
Fix overread in JSON parsing errors for incomplete byte sequences json_lex_string() relies on pg_encoding_mblen_bounded() to point to the end of a JSON string when generating an error message, and the input it uses is not guaranteed to be null-terminated. It was possible to walk off the end of

pgsql: Fix overread in JSON parsing errors for incomplete byte sequence

2024-05-08 Thread Michael Paquier
Fix overread in JSON parsing errors for incomplete byte sequences json_lex_string() relies on pg_encoding_mblen_bounded() to point to the end of a JSON string when generating an error message, and the input it uses is not guaranteed to be null-terminated. It was possible to walk off the end of

pgsql: Fix overread in JSON parsing errors for incomplete byte sequence

2024-05-08 Thread Michael Paquier
Fix overread in JSON parsing errors for incomplete byte sequences json_lex_string() relies on pg_encoding_mblen_bounded() to point to the end of a JSON string when generating an error message, and the input it uses is not guaranteed to be null-terminated. It was possible to walk off the end of

pgsql: Fix overread in JSON parsing errors for incomplete byte sequence

2024-05-08 Thread Michael Paquier
Fix overread in JSON parsing errors for incomplete byte sequences json_lex_string() relies on pg_encoding_mblen_bounded() to point to the end of a JSON string when generating an error message, and the input it uses is not guaranteed to be null-terminated. It was possible to walk off the end of

pgsql: Fix overread in JSON parsing errors for incomplete byte sequence

2024-05-08 Thread Michael Paquier
Fix overread in JSON parsing errors for incomplete byte sequences json_lex_string() relies on pg_encoding_mblen_bounded() to point to the end of a JSON string when generating an error message, and the input it uses is not guaranteed to be null-terminated. It was possible to walk off the end of

pgsql: injection_points: Fix incorrect spinlock acquisition

2024-05-05 Thread Michael Paquier
injection_points: Fix incorrect spinlock acquisition Injection points created under injection_points_set_local() are cleaned up by a shmem_exit() callback. The spinlock used by the module would be hold while calling InjectionPointDetach(), which is incorrect as spinlocks should avoid external

pgsql: Add tab completion for EXPLAIN (MEMORY|SERIALIZE)

2024-04-30 Thread Michael Paquier
Add tab completion for EXPLAIN (MEMORY|SERIALIZE) SERIALIZE has been added in 06286709ee06, and MEMORY in 5de890e3610d. Author: Jian He Discussion: https://postgr.es/m/cacjufxh5ubhbcg-omt7phomvnabf2x48jfefu24fexsqvgz...@mail.gmail.com Branch -- master Details ---

pgsql: doc: Remove one example related to pg_input_error_info()

2024-04-30 Thread Michael Paquier
doc: Remove one example related to pg_input_error_info() This slightly bloated the contents of the function table for this entry, without really bringing extra value. Per discussion with Jian He and David G. Johnston. Discussion:

pgsql: Make two-phase tests of ECPG and main suite more concurrent-proo

2024-04-29 Thread Michael Paquier
Make two-phase tests of ECPG and main suite more concurrent-proof The ECPG and main 2PC tests have been using rather-generic names for the prepared transactions they generate. This commit switches the 2PC transactions to use more complex GIDs, reducing the risk of naming conflicts. The main 2PC

pgsql: Improve comment of DeallocateStmt->isall

2024-04-24 Thread Michael Paquier
Improve comment of DeallocateStmt->isall This field is not used directly in the code, but it is important for query jumbling to be able to make a difference between a named DEALLOCATE and DEALLOCATE ALL (see bb45156f342c). This behavior is tracked in the regression tests of pg_stat_statements,

pgsql: Fix dumps of partitioned tables with table AMs

2024-04-22 Thread Michael Paquier
, with some tweaks for the table AMs of the partitions to make the output more readable. Issue introduced by 374c7a229042, that has added support for table AMs in partitioned tables. Author: Michael Paquier Reviewed-by: Álvaro Herrera Discussion: https://postgr.es/m/zh4jlsvvtqgbj...@paquier.xyz Branch

pgsql: Remove resowner_private.h

2024-04-20 Thread Michael Paquier
Remove resowner_private.h This header is not used since the refactoring of resource owners done in b8bff07daa85, and all the functions declared in it became (well, mostly) static inline local to each resowner kind's code path. Author: Xing Guo Discussion:

pgsql: Fix typos with function name in event_trigger.c

2024-04-17 Thread Michael Paquier
Fix typos with function name in event_trigger.c Databases exist, contrary to datatabases. Oversight in e83d1b0c40cc. Author: Japin Li Discussion: https://postgr.es/m/me3p282mb316611a2f7bf43919f695228b6...@me3p282mb3166.ausp282.prod.outlook.com Branch -- master Details ---

pgsql: xml2: Replace deprecated routines with recommended ones

2024-04-15 Thread Michael Paquier
xml2: Replace deprecated routines with recommended ones Some functions are used in the tree and are currently marked as deprecated by upstream. This commit refreshes the code to use the recommended functions, leading to the following changes: - xmlSubstituteEntitiesDefault() is gone, and needs

pgsql: xml2: Replace deprecated routines with recommended ones

2024-04-15 Thread Michael Paquier
xml2: Replace deprecated routines with recommended ones Some functions are used in the tree and are currently marked as deprecated by upstream. This commit refreshes the code to use the recommended functions, leading to the following changes: - xmlSubstituteEntitiesDefault() is gone, and needs

pgsql: xml2: Replace deprecated routines with recommended ones

2024-04-15 Thread Michael Paquier
xml2: Replace deprecated routines with recommended ones Some functions are used in the tree and are currently marked as deprecated by upstream. This commit refreshes the code to use the recommended functions, leading to the following changes: - xmlSubstituteEntitiesDefault() is gone, and needs

pgsql: xml2: Replace deprecated routines with recommended ones

2024-04-15 Thread Michael Paquier
xml2: Replace deprecated routines with recommended ones Some functions are used in the tree and are currently marked as deprecated by upstream. This commit refreshes the code to use the recommended functions, leading to the following changes: - xmlSubstituteEntitiesDefault() is gone, and needs

pgsql: xml2: Replace deprecated routines with recommended ones

2024-04-15 Thread Michael Paquier
xml2: Replace deprecated routines with recommended ones Some functions are used in the tree and are currently marked as deprecated by upstream. This commit refreshes the code to use the recommended functions, leading to the following changes: - xmlSubstituteEntitiesDefault() is gone, and needs

Re: pgsql: Move code for backend startup to separate file

2024-04-15 Thread Michael Paquier
On Mon, Apr 15, 2024 at 05:24:39PM +0900, Michael Paquier wrote: > extern PGDLLIMPORT const char *progname; > > +extern bool LoadedSSL; > > This variable is missing a PGDLLIMPORT, it seems. > > aafc05de1bf5 has missed a second one with MyClientSocket. Both are >

pgsql: Add missing PGDLLIMPORT markings

2024-04-15 Thread Michael Paquier
Add missing PGDLLIMPORT markings All backend-side variables should be marked with PGDLLIMPORT, as per policy introduced in 8ec569479f. aafc05de1bf5 has forgotten MyClientSocket, and 05c3980e7f47 LoadedSSL. These can be spotted with a command like this one (be careful of not switching

Re: pgsql: Move code for backend startup to separate file

2024-04-15 Thread Michael Paquier
Hi Heikki, (Peter E. in CC.) On Mon, Mar 18, 2024 at 09:40:36AM +, Heikki Linnakangas wrote: > Move code for backend startup to separate file > > This is code that runs in the backend process after forking, rather > than postmaster. Move it out of postmaster.c for clarity. > > Reviewed-by:

pgsql: Use correct datatype for xmin variables in slot.c

2024-04-11 Thread Michael Paquier
Use correct datatype for xmin variables in slot.c Two variables storing a slot's effective_xmin and effective_catalog_xmin were saved as XLogRecPtr, which is incorrect as these should be TransactionIds. Oversight in 818fefd8fd44. Author: Bharath Rupireddy Discussion:

pgsql: Use correct datatype for xmin variables in slot.c

2024-04-11 Thread Michael Paquier
Use correct datatype for xmin variables in slot.c Two variables storing a slot's effective_xmin and effective_catalog_xmin were saved as XLogRecPtr, which is incorrect as these should be TransactionIds. Oversight in 818fefd8fd44. Author: Bharath Rupireddy Discussion:

Re: pgsql: Fix race leading to incorrect conflict cause in InvalidatePossib

2024-04-11 Thread Michael Paquier
On Thu, Apr 11, 2024 at 12:38:06PM +0530, Bharath Rupireddy wrote: > I found a typo with the code added by this commit - we've used > XLogRecPtr/InvalidXLogRecPtr for xmins in place of > TransactionId/InvalidTransactionId. Attached a patch to fix this. Thanks for the report. Will fix. -- Michael

Re: pgsql: Fix potential stack overflow in incremental backup.

2024-04-10 Thread Michael Paquier
Hi Thomas, On Thu, Apr 11, 2024 at 01:53:24AM +, Thomas Munro wrote: > Fix potential stack overflow in incremental backup. > > The user can set RELSEG_SIZE to a high number at compile time, so we > can't use it to control the size of an array on the stack: it could be > many gigabytes in

pgsql: Fix inconsistency with replay of hash squeeze record for clean b

2024-04-10 Thread Michael Paquier
regression test suite covers. As this is an oversight in aa5edbe379d6, no backpatch is required. Reported-by: Zubeyr Eryilmaz Author: Hayato Kuroda Reviewed-by: Amit Kapila, Michael Paquier Discussion: https://postgr.es/m/zbyvvg_7ew3yd...@paquier.xyz Branch -- master Details --- https://git.

pgsql: Make GIN tests using injection points concurrent-safe

2024-04-09 Thread Michael Paquier
Make GIN tests using injection points concurrent-safe f587338dec87 has introduced in the test module injection_points a SQL function called injection_points_set_local(), that can be used to make all the injection points linked to the process where they are attached, discarded automatically if any

pgsql: Add missing set_pglocale_pgservice() for pg_walsummary and pg_co

2024-04-08 Thread Michael Paquier
Add missing set_pglocale_pgservice() for pg_walsummary and pg_combinebackup These calls are required to make both tools work with NLS. Author: Kyotaro Horiguchi Discussion: https://postgr.es/m/20240408.162702.183779935636035593.horikyota@gmail.com Branch -- master Details ---

pgsql: injection_points: Fix race condition with local injection point

2024-04-08 Thread Michael Paquier
injection_points: Fix race condition with local injection point tests The module relies on a shmem exit callback to clean up any injection points linked to a specific process. One of the tests checks for the case of an injection point name reused in a second connection where the first connection

pgsql: injection_points: Introduce runtime conditions

2024-04-07 Thread Michael Paquier
injection_points: Introduce runtime conditions This adds a new SQL function injection_points_set_local() that can be used to force injection points to be run only in the process where they are attached. This is handy for SQL tests to: - Detach automatically injection points when the process

pgsql: Make GIN test using injection points repeatable

2024-04-07 Thread Michael Paquier
Make GIN test using injection points repeatable As written, the test would fail when run repeatedly because one of the injection points attached was not detached. This would not matter if the test is rewritten to be concurrently safe, but let's be clean and it is a good practice. Oversight in

pgsql: Add "ABI_compatibility" regions to wait_event_names.txt

2024-04-04 Thread Michael Paquier
oo; New wait events added in stable branches should be added at the end of each ABI_compatibility region, and ABI_compatibility should remain empty on HEAD and unreleased stable branches. This design has been suggested by Noah Misch and me. Reported-by: Noah Misch Author: Bertrand Drouvot Reviewed-by: Mi

pgsql: Coordinate emit_log_hook and all log destinations to share the s

2024-04-03 Thread Michael Paquier
where the JSON was not mentioned. Oversight in dc686681e079, that I have noticed while reviewing this patch. Author: Kambam Vinay, Michael Paquier Discussion: https://postgr.es/m/canirfmsk36a0i8mnqtzaxhsm3cucimpwjpp4wqnq53odsnk...@mail.gmail.com Branch -- master Details --- https

pgsql: pg_regress: Save errno in emit_tap_output_v() and switch to %m

2024-04-03 Thread Michael Paquier
, and that will avoid future mistakes if new logs that include %m are added. Author: Dagfinn Ilmari Mannsåker Reviewed-by: Peter Eisentraunt, Michael Paquier Discussion: https://postgr.es/m/87sf13jhuw@wibble.ilmari.org Branch -- master Details --- https://git.postgresql.org/pg/commitdiff

pgsql: Remove references to backup_fs_hot() in Cluster.pm

2024-03-17 Thread Michael Paquier
Remove references to backup_fs_hot() in Cluster.pm This routine has been removed in 39969e2a1e4d with the exclusive backup mode but there were still references to it. Issue noticed while working on 071e3ad59d6f. Branch -- master Details ---

Re: pgsql: Add TAP tests for timeouts

2024-03-15 Thread Michael Paquier
On Fri, Mar 15, 2024 at 11:20:49AM +0500, Andrey M. Borodin wrote: > And hachi sometimes pass this test too [0]. > > I’ll look more on this. Do I understand right that we have only 2 buildfarm > members with injection points? I have added --enable-injection-points to three of them: hachi,

Re: pgsql: Add TAP tests for timeouts

2024-03-14 Thread Michael Paquier
On Fri, Mar 15, 2024 at 10:42:35AM +0900, Kyotaro Horiguchi wrote: > In 005_timeouts.pl, I found the following comment. Note also that the test is not stable, one of my machines with injection points enabled has complained twice in its last three runs:

pgsql: Add basic TAP tests for the low-level backup method, take two

2024-03-14 Thread Michael Paquier
Add basic TAP tests for the low-level backup method, take two There are currently no tests for the low-level backup method where pg_backup_start() and pg_backup_stop() are involved while taking a file-system backup. The tests introduced in this commit rely on a background psql process to make

pgsql: Refactor initial hash lookup in dynahash.c

2024-03-14 Thread Michael Paquier
that hash_search_with_hash_value() does not need the bucket number, just the hash bucket. Author: Teodor Sigaev Reviewed-by: Aleksander Alekseev, Michael Paquier Discussion: https://postgr.es/m/5812a6e5-68ae-4d84-9d85-b44317696...@sigaev.ru Branch -- master Details --- https://git.postgresql.org

pgsql: Revert "Add basic TAP tests for the low-level backup method"

2024-03-13 Thread Michael Paquier
Revert "Add basic TAP tests for the low-level backup method" This reverts commit 99b4a63bef94. The test is proving to be unstable, so revert it for now. One of the failures seen involves the cluster started without the backup_label, where the archives of the primary are overwritten, causing

pgsql: Add basic TAP tests for the low-level backup method

2024-03-13 Thread Michael Paquier
Add basic TAP tests for the low-level backup method There are currently no tests for the low-level backup method where pg_backup_start() and pg_backup_stop() are involved while taking a file-system backup. The tests introduced in this commit rely on a background psql process to make sure that

pgsql: Add tests for more row patterns with COPY FROM .. (ON_ERROR igno

2024-03-12 Thread Michael Paquier
Add tests for more row patterns with COPY FROM .. (ON_ERROR ignore) While digging into the code of this feature, I got confused by the fact that a line is skipped when a value cannot be converted to its expected attribute even if the line has fewer attributes than the target relation. The tests

pgsql: Add some asserts based on LWLockHeldByMe() for replication slot

2024-03-12 Thread Michael Paquier
Add some asserts based on LWLockHeldByMe() for replication slot statistics Two assertions checking that ReplicationSlotAllocationLock is acquired are added to pgstat_create_replslot() and pgstat_drop_replslot(), corresponding to the routines in charge of the creation and the drop of replication

pgsql: Keep replication slot statistics on invalidation

2024-03-11 Thread Michael Paquier
Keep replication slot statistics on invalidation The code path in charge of invalidating a replication slot includes a call to pgstat_drop_replslot(), which would result in removing the statistics of the slot once invalidated. However, there is no need to remove the statistics of an invalidated

pgsql: Use printf's %m format instead of strerror(errno) in more places

2024-03-11 Thread Michael Paquier
Use printf's %m format instead of strerror(errno) in more places Most callers of strerror() are removed from the backend code. The remaining callers require special handling with a saved errno from a previous system call. The frontend code still needs strerror() where error states need to be

pgsql: Improve consistency of replication slot statistics

2024-03-10 Thread Michael Paquier
. The issue should unlikely be a problem in practice, causing the report of inconsistent stats or or the stats reset of an incorrect slot, so no backpatch is done. Author: Bertrand Drouvot Reviewed-by: Heikki Linnakangas, Shveta Malik, Michael Paquier Discussion: https://postgr.es/m/zegq1hdwfflkj

pgsql: Add some checkpoint and redo LSNs to a couple of recovery errors

2024-03-10 Thread Michael Paquier
Add some checkpoint and redo LSNs to a couple of recovery errors Two FATALs and one PANIC gain details about the LSNs they fail at: - When restoring from a backup_label, the FATAL log generated when not finding the checkpoint record now reports its LSN. - When restoring from a backup_label, the

pgsql: Improve support for ExplainOneQuery() hook

2024-03-10 Thread Michael Paquier
Improve support for ExplainOneQuery() hook There is a hook called ExplainOneQuery_hook that gives modules the possibility to plug into this code path, but, like utility.c for utility statement execution, there is no corresponding "standard" routine in the case of EXPLAIN executed for one Query.

pgsql: Document units of "timeout" in ConditionVariableTimedSleep()

2024-03-08 Thread Michael Paquier
Document units of "timeout" in ConditionVariableTimedSleep() The timeout is passed down to WaitLatch() as milliseconds. Author: Shveta Malik Discussion: https://postgr.es/m/CAJpy0uC=xibqd1wapgyyvoiytap6uljaakld867zzxqu9ty...@mail.gmail.com Branch -- master Details ---

pgsql: Add support for DEFAULT in ALTER TABLE .. SET ACCESS METHOD

2024-03-07 Thread Michael Paquier
(left out here as future work), while being useful on its own for relations with physical storage as these must have an access method set. Per suggestion from Justin Pryzby. Author: Michael Paquier Reviewed-by: Justin Pryzby Discussion: https://postgr.es/m/ZeCZ89xAVFeOmrQC@pryzbyj2023 Branch

pgsql: Update comment of AlterTableCmd->name in parsenodes.h

2024-03-07 Thread Michael Paquier
Update comment of AlterTableCmd->name in parsenodes.h Since b0483263dda0, this field can be used to store an access method name for ALTER TABLE, but access methods were not mentioned in the field's description. Issue noticed while working on the area. Discussion:

pgsql: Revert "Add recovery TAP test for race condition with slot inval

2024-03-06 Thread Michael Paquier
Revert "Add recovery TAP test for race condition with slot invalidations" This reverts commit 08a52ab151ca, due to some sporadic instability in the test. Getting the test right should require some redesign with a second injection point, but let's revert it for now to avoid these issues in the CI

pgsql: Revert "Fix parallel-safety check of expressions and predicate f

2024-03-06 Thread Michael Paquier
Revert "Fix parallel-safety check of expressions and predicate for index builds" This reverts commit eae7be600be7, following a discussion with Tom Lane, due to concerns that this impacts the decisions made by the planner for the number of workers spawned based on the inlining and const-folding of

pgsql: Revert "Fix parallel-safety check of expressions and predicate f

2024-03-06 Thread Michael Paquier
Revert "Fix parallel-safety check of expressions and predicate for index builds" This reverts commit eae7be600be7, following a discussion with Tom Lane, due to concerns that this impacts the decisions made by the planner for the number of workers spawned based on the inlining and const-folding of

pgsql: Revert "Fix parallel-safety check of expressions and predicate f

2024-03-06 Thread Michael Paquier
Revert "Fix parallel-safety check of expressions and predicate for index builds" This reverts commit eae7be600be7, following a discussion with Tom Lane, due to concerns that this impacts the decisions made by the planner for the number of workers spawned based on the inlining and const-folding of

pgsql: Revert "Fix parallel-safety check of expressions and predicate f

2024-03-06 Thread Michael Paquier
Revert "Fix parallel-safety check of expressions and predicate for index builds" This reverts commit eae7be600be7, following a discussion with Tom Lane, due to concerns that this impacts the decisions made by the planner for the number of workers spawned based on the inlining and const-folding of

pgsql: Revert "Fix parallel-safety check of expressions and predicate f

2024-03-06 Thread Michael Paquier
Revert "Fix parallel-safety check of expressions and predicate for index builds" This reverts commit eae7be600be7, following a discussion with Tom Lane, due to concerns that this impacts the decisions made by the planner for the number of workers spawned based on the inlining and const-folding of

pgsql: Revert "Fix parallel-safety check of expressions and predicate f

2024-03-06 Thread Michael Paquier
Revert "Fix parallel-safety check of expressions and predicate for index builds" This reverts commit eae7be600be7, following a discussion with Tom Lane, due to concerns that this impacts the decisions made by the planner for the number of workers spawned based on the inlining and const-folding of

pgsql: Fix parallel-safety check of expressions and predicate for index

2024-03-06 Thread Michael Paquier
Lakhin Author: Tender Wang Reviewed-by: Jian He, Michael Paquier Discussion: https://postgr.es/m/CAHewXN=UaAaNn9ruHDH3Os8kxLVmtWqbssnf=dZN_s9=evh...@mail.gmail.com Backpatch-through: 12 Branch -- REL_16_STABLE Details --- https://git.postgresql.org/pg/commitdiff

pgsql: Fix parallel-safety check of expressions and predicate for index

2024-03-06 Thread Michael Paquier
Lakhin Author: Tender Wang Reviewed-by: Jian He, Michael Paquier Discussion: https://postgr.es/m/CAHewXN=UaAaNn9ruHDH3Os8kxLVmtWqbssnf=dZN_s9=evh...@mail.gmail.com Backpatch-through: 12 Branch -- REL_14_STABLE Details --- https://git.postgresql.org/pg/commitdiff

pgsql: Fix parallel-safety check of expressions and predicate for index

2024-03-06 Thread Michael Paquier
Lakhin Author: Tender Wang Reviewed-by: Jian He, Michael Paquier Discussion: https://postgr.es/m/CAHewXN=UaAaNn9ruHDH3Os8kxLVmtWqbssnf=dZN_s9=evh...@mail.gmail.com Backpatch-through: 12 Branch -- REL_12_STABLE Details --- https://git.postgresql.org/pg/commitdiff

pgsql: Fix parallel-safety check of expressions and predicate for index

2024-03-06 Thread Michael Paquier
Lakhin Author: Tender Wang Reviewed-by: Jian He, Michael Paquier Discussion: https://postgr.es/m/CAHewXN=UaAaNn9ruHDH3Os8kxLVmtWqbssnf=dZN_s9=evh...@mail.gmail.com Backpatch-through: 12 Branch -- REL_13_STABLE Details --- https://git.postgresql.org/pg/commitdiff

pgsql: Fix parallel-safety check of expressions and predicate for index

2024-03-06 Thread Michael Paquier
Lakhin Author: Tender Wang Reviewed-by: Jian He, Michael Paquier Discussion: https://postgr.es/m/CAHewXN=UaAaNn9ruHDH3Os8kxLVmtWqbssnf=dZN_s9=evh...@mail.gmail.com Backpatch-through: 12 Branch -- master Details --- https://git.postgresql.org/pg/commitdiff

pgsql: Fix parallel-safety check of expressions and predicate for index

2024-03-06 Thread Michael Paquier
Lakhin Author: Tender Wang Reviewed-by: Jian He, Michael Paquier Discussion: https://postgr.es/m/CAHewXN=UaAaNn9ruHDH3Os8kxLVmtWqbssnf=dZN_s9=evh...@mail.gmail.com Backpatch-through: 12 Branch -- REL_15_STABLE Details --- https://git.postgresql.org/pg/commitdiff

pgsql: Add recovery TAP test for race condition with slot invalidations

2024-03-05 Thread Michael Paquier
Add recovery TAP test for race condition with slot invalidations This commit adds a recovery test to provide coverage for the bug fixed in 818fefd8fd, using an injection point to wait just after the process of an active slot is killed. The trick is to give enough time for effective_xmin and

pgsql: Add PostgreSQL::Test::Cluster::wait_for_event()

2024-03-03 Thread Michael Paquier
Add PostgreSQL::Test::Cluster::wait_for_event() Per a demand from the author and the reviewer of this commit, this adds to Cluster.pm a helper routine that can be used to monitor when a process reaches a wanted wait event. This can be used in combination with the module injection_points for the

pgsql: Add regression test for restart points during promotion

2024-03-03 Thread Michael Paquier
ion_points. Author: Kyotaro Horiguchi, Michael Paquier Reviewed-by: Andrey Borodin, Bertrand Drouvot Discussion: https://postgr.es/m/zdluxbk5hgpol...@paquier.xyz Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/6782709df81f6c68450172605907fa9ff2b7f2b1 Modified Files

pgsql: injection_points: Add wait and wakeup of processes

2024-03-03 Thread Michael Paquier
ustom wait event under the "Extension" category. The shared memory state used by the module is registered using the DSM registry, and is optional, so there is no need to load the module with shared_preload_libraries to be able to use these features. Author: Michael Paquier Reviewed-by: Andr

pgsql: Simplify pg_enc2gettext_tbl[] with C99-designated initializer sy

2024-03-01 Thread Michael Paquier
Simplify pg_enc2gettext_tbl[] with C99-designated initializer syntax This commit switches pg_enc2gettext_tbl[] in encnames.c to use a C99-designated initializer syntax. pg_bind_textdomain_codeset() is simplified so as it is possible to do a direct lookup at the gettext() array with a value of

pgsql: Use C99-designated initializer syntax for arrays related to enco

2024-02-28 Thread Michael Paquier
Use C99-designated initializer syntax for arrays related to encodings This updates the following lookup arrays to use C99-designated initializer syntax, indexed based on the enum pg_enc: pg_enc2icu_tbl[] pg_enc2name_tbl[] pg_wchar_table[] This is more readable, and removes problems with ordering

Re: pgsql: Mop-up for AIX-ectomy: remove now-dead test code.

2024-02-28 Thread Michael Paquier
On Wed, Feb 28, 2024 at 07:34:25PM +, Tom Lane wrote: > Mop-up for AIX-ectomy: remove now-dead test code. > > Commit 0b16bb877 removed the test query added by commit 79b716cfb, > but not the C-language support function used by that query. I don't > see any plausible reason why we'd need that

pgsql: Remove last NULL element in config_group_names[]

2024-02-27 Thread Michael Paquier
Remove last NULL element in config_group_names[] This has not been needed since 9d77708d83ee where there was a loop to print all the possible GUC groups, relying on the last element to be NULL. Author: Japin Li Reviewed-By: Jelte Fennema-Nio Discussion:

pgsql: Use C99-designated initializer syntax for more arrays

2024-02-27 Thread Michael Paquier
Use C99-designated initializer syntax for more arrays This is in the same spirit as ef5e2e90859a, updating this time some arrays in parser.c, relpath.c, guc_tables.c and pg_dump_sort.c so as the order of their elements has no need to match the enum structures they are based on anymore. Author:

pgsql: Remove unnecessary array object_classes[] in dependency.c

2024-02-26 Thread Michael Paquier
to maintain the enum ObjectClass and the array in sync when adding new object types. Reported-by: Jeff Davis Author: Jelte Fennema-Nio Reviewed-by: Jian He, Michael Paquier Discussion: https://postgr.es/m/cageczqt3caubcccsznewccmmbcuyp7xnam60j3ybd6pn5kh...@mail.gmail.com Branch -- master

pgsql: Fix comment thinko in sequence.c

2024-02-26 Thread Michael Paquier
Fix comment thinko in sequence.c One comment mentioned indexes, but the relation opened should be sequences. Reported-by: Matthias van de Meent Discussion: https://postgr.es/m/CAEze2WiMGNG9XK3NSUen-5BARhCnP=u=fxnf8pvpl2qdkeo...@mail.gmail.com Branch -- master Details ---

pgsql: Group more closely cache updates for backends in sequence.c

2024-02-26 Thread Michael Paquier
noticed while doing some refactoring of the sequence code. Author: Michael Paquier Reviewed-by: Tomas Vondra Discussion: https://postgr.es/m/zwlohtkas0uvv...@paquier.xyz Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/6e951bf98e2e0230ed95db2fafc244536bd7502f Modified

pgsql: Introduce sequence_*() access functions

2024-02-25 Thread Michael Paquier
error detail about the relkind of the relation used in the DDL query. Author: Michael Paquier Reviewed-by: Tomas Vondra Discussion: https://postgr.es/m/zwlohtkas0uvv...@paquier.xyz Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/449e798c77ed9a03f8bb04e5d324d4e3cfbbae8e

pgsql: Make GetSlotInvalidationCause() return RS_INVAL_NONE on unexpect

2024-02-22 Thread Michael Paquier
Make GetSlotInvalidationCause() return RS_INVAL_NONE on unexpected input 943f7ae1c869 has changed GetSlotInvalidationCause() so as it would return the last element of SlotInvalidationCauses[] when an incorrect conflict reason name is given by a caller, but this should return RS_INVAL_NONE in such

pgsql: Speed up uuid_out() by not relying on a StringInfo

2024-02-21 Thread Michael Paquier
when the data is fully in shared buffers or the OS cache. Author: Laurenz Albe Reviewed-by: Andres Freund, Michael Paquier Description: https://postgr.es/m/679d5455cbbb0af667ccb753da51a475bae1eaed.ca...@cybertec.at Branch -- master Details --- https://git.postgresql.org/pg/commitdiff

pgsql: Add lookup table for replication slot conflict reasons

2024-02-21 Thread Michael Paquier
Add lookup table for replication slot conflict reasons This commit switches the handling of the conflict cause strings for replication slots to use a table rather than being explicitly listed, using a C99-designated initializer syntax for the array elements. This makes the whole more readable

pgsql: Add option force_initdb to PostgreSQL::Test::Cluster:init()

2024-02-20 Thread Michael Paquier
less efficient. Author: Amul Sul Reviewed-by: Robert Haas, Michael Paquier Discussion: https://postgr.es/m/zc1tx9llonlgu...@paquier.xyz Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/ff9e1e764fcce9a34467d614611a34d4d2a91b50 Modified Files -- src/bin

pgsql: Fix race leading to incorrect conflict cause in InvalidatePossib

2024-02-19 Thread Michael Paquier
. Holding the mutex longer is not an option, so this commit changes the code to record the LSNs stored in the slot during the termination of the process owning the slot. Bonus thanks to Alexander Lakhin for the various tests and the analysis. Author: Bertrand Drouvot Reviewed-by: Michael Paquier

pgsql: Fix race leading to incorrect conflict cause in InvalidatePossib

2024-02-19 Thread Michael Paquier
. Holding the mutex longer is not an option, so this commit changes the code to record the LSNs stored in the slot during the termination of the process owning the slot. Bonus thanks to Alexander Lakhin for the various tests and the analysis. Author: Bertrand Drouvot Reviewed-by: Michael Paquier

pgsql: doc: Use system-username instead of system-user

2024-02-19 Thread Michael Paquier
doc: Use system-username instead of system-user This inconsistency has been introduced in efb6f4a4f9b6. Reported-by: Julien Rouhaud Author: Bertrand Drouvot Discussion: https://postgr.es/m/zdmwux1hpiebk...@ip-10-97-1-34.eu-west-3.compute.internal Backpatch-through: 16 Branch -- master

pgsql: doc: Use system-username instead of system-user

2024-02-19 Thread Michael Paquier
doc: Use system-username instead of system-user This inconsistency has been introduced in efb6f4a4f9b6. Reported-by: Julien Rouhaud Author: Bertrand Drouvot Discussion: https://postgr.es/m/zdmwux1hpiebk...@ip-10-97-1-34.eu-west-3.compute.internal Backpatch-through: 16 Branch --

pgsql: ecpg: Fix zero-termination of string generated by intoasc()

2024-02-18 Thread Michael Paquier
ecpg: Fix zero-termination of string generated by intoasc() intoasc(), a wrapper for PGTYPESinterval_to_asc that converts an interval to its textual representation, used a plain memcpy() when copying its result. This could miss a zero-termination in the result string, leading to an incorrect

pgsql: ecpg: Fix zero-termination of string generated by intoasc()

2024-02-18 Thread Michael Paquier
ecpg: Fix zero-termination of string generated by intoasc() intoasc(), a wrapper for PGTYPESinterval_to_asc that converts an interval to its textual representation, used a plain memcpy() when copying its result. This could miss a zero-termination in the result string, leading to an incorrect

pgsql: ecpg: Fix zero-termination of string generated by intoasc()

2024-02-18 Thread Michael Paquier
ecpg: Fix zero-termination of string generated by intoasc() intoasc(), a wrapper for PGTYPESinterval_to_asc that converts an interval to its textual representation, used a plain memcpy() when copying its result. This could miss a zero-termination in the result string, leading to an incorrect

pgsql: ecpg: Fix zero-termination of string generated by intoasc()

2024-02-18 Thread Michael Paquier
ecpg: Fix zero-termination of string generated by intoasc() intoasc(), a wrapper for PGTYPESinterval_to_asc that converts an interval to its textual representation, used a plain memcpy() when copying its result. This could miss a zero-termination in the result string, leading to an incorrect

pgsql: ecpg: Fix zero-termination of string generated by intoasc()

2024-02-18 Thread Michael Paquier
ecpg: Fix zero-termination of string generated by intoasc() intoasc(), a wrapper for PGTYPESinterval_to_asc that converts an interval to its textual representation, used a plain memcpy() when copying its result. This could miss a zero-termination in the result string, leading to an incorrect

pgsql: ecpg: Fix zero-termination of string generated by intoasc()

2024-02-18 Thread Michael Paquier
ecpg: Fix zero-termination of string generated by intoasc() intoasc(), a wrapper for PGTYPESinterval_to_asc that converts an interval to its textual representation, used a plain memcpy() when copying its result. This could miss a zero-termination in the result string, leading to an incorrect

pgsql: ecpg: Fix error handling on OOMs when parsing timestamps

2024-02-18 Thread Michael Paquier
ecpg: Fix error handling on OOMs when parsing timestamps pgtypes_alloc() can return NULL when failing an allocation, which is something that PGTYPEStimestamp_defmt_asc() has forgotten about when translating a timestamp for 'D', 'r', 'R' and 'T' as these require a temporary allocation. This is

pgsql: Revert "Refactor CopyReadAttributes{CSV,Text}() to use a callbac

2024-02-13 Thread Michael Paquier
Revert "Refactor CopyReadAttributes{CSV,Text}() to use a callback in COPY FROM" This reverts commit 95fb5b49024, for reasons similar to what led to 1aa8324b81fa. In this case, the callback was called once per row, which is less worse than the previous callback introduced for COPY TO called once

pgsql: pgcrypto: Fix incorrect argument vs PG_GETARG*() mappings

2024-02-13 Thread Michael Paquier
pgcrypto: Fix incorrect argument vs PG_GETARG*() mappings The following functions use a mix of bytea and text arguments, but their C internals always used PG_GETARG_BYTEA_PP(), creating an incorrect mix with the argument types expected by encrypt_internal(): -

pgsql: Improve comment about query_id_enabled in queryjumblefuncs.c

2024-02-13 Thread Michael Paquier
Improve comment about query_id_enabled in queryjumblefuncs.c The comment was inexact because query_id_enabled will not be switched to "true" even if compute_query_id is "on", unless a module requests for it. While on it, this adds a comment to mention that IsQueryIdEnabled() should be used to

pgsql: Add previous commit to .git-blame-ignore-revs

2024-02-08 Thread Michael Paquier
Add previous commit to .git-blame-ignore-revs Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/3c44746fdb5d5603f6bc4645c78bca6c702fc920 Modified Files -- .git-blame-ignore-revs | 3 +++ 1 file changed, 3 insertions(+)

pgsql: Fix indentation of copyto.c

2024-02-08 Thread Michael Paquier
Fix indentation of copyto.c Issue introduced by b619852086ed. Per buildfarm member koel. Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/49e7c6f78ed608c5d5454080ae19c0e7f1b09a04 Modified Files -- src/backend/commands/copyto.c | 4 ++-- 1 file changed,

pgsql: Improve COPY TO performance when server and client encodings mat

2024-02-08 Thread Michael Paquier
ion. Reported-by: Andres Freund Analyzed-by: Andres Freund Author: Michael Paquier Reviewed-by: Heikki Linnakangas Discussion: https://postgr.es/m/20240206020504.edijzczkgd25e...@awork3.anarazel.de Branch -- master Details --- https://git.postgresql.org/pg/commitd

pgsql: Simplify signature of CopyAttributeOutCSV() in copyto.c

2024-02-06 Thread Michael Paquier
Simplify signature of CopyAttributeOutCSV() in copyto.c This has come up in 2889fd23be56, reverted later on, and is still useful on its own to reduce a bit the differences between the code paths dedicated to CSV and text. Discussion: https://postgr.es/m/zcckwaefrloqp...@paquier.xyz Branch

pgsql: Revert "Refactor CopyAttributeOut{CSV,Text}() to use a callback

2024-02-06 Thread Michael Paquier
Revert "Refactor CopyAttributeOut{CSV,Text}() to use a callback in COPY TO" This reverts commit 2889fd23be56, following a discussion with Andres Freund as this callback, being called once per attribute when sending a relation's row, can involve a lot of indirect function calls (more attributes to

  1   2   3   4   5   6   7   8   9   10   >