pgsql: Add missing initializations of p_perminfo

2023-07-13 Thread Amit Langote
Add missing initializations of p_perminfo In a61b1f74823, we failed to update transformFromClauseItem() and buildNSItemFromLists() to set ParseNamespaceItem.p_perminfo causing it to point to garbage. Pointed out by Tom Lane. Reported-by: Farias de Oliveira Discussion: https://postgr.es/m/317347

pgsql: Add missing initializations of p_perminfo

2023-07-13 Thread Amit Langote
Add missing initializations of p_perminfo In a61b1f74823, we failed to update transformFromClauseItem() and buildNSItemFromLists() to set ParseNamespaceItem.p_perminfo causing it to point to garbage. Pointed out by Tom Lane. Reported-by: Farias de Oliveira Discussion: https://postgr.es/m/317347

pgsql: Move privilege check for SET SESSION AUTHORIZATION.

2023-07-13 Thread Nathan Bossart
Move privilege check for SET SESSION AUTHORIZATION. Presently, the privilege check for SET SESSION AUTHORIZATION is performed in session_authorization's assign_hook. A relevant comment states, "It's OK because the check does not require catalog access and can't fail during an end-of-transaction G

pgsql: Fix privilege check for SET SESSION AUTHORIZATION.

2023-07-13 Thread Nathan Bossart
Fix privilege check for SET SESSION AUTHORIZATION. Presently, the privilege check for SET SESSION AUTHORIZATION checks whether the original authenticated role was a superuser at connection start time. Even if the role loses the superuser attribute, its existing sessions are permitted to change se

pgsql: Allow the use of a hash index on the subscriber during replicati

2023-07-13 Thread Amit Kapila
Allow the use of a hash index on the subscriber during replication. Commit 89e46da5e5 allowed using BTREE indexes that are neither PRIMARY KEY nor REPLICA IDENTITY on the subscriber during apply of update/delete. This patch extends that functionality to also allow HASH indexes. We explored suppor

pgsql: Add indisreplident to fields refreshed by RelationReloadIndexInf

2023-07-13 Thread Michael Paquier
Add indisreplident to fields refreshed by RelationReloadIndexInfo() RelationReloadIndexInfo() is a fast-path used for index reloads in the relation cache, and it has always forgotten about updating indisreplident, which is something that would happen after an index is selected for a replica identi

pgsql: Add indisreplident to fields refreshed by RelationReloadIndexInf

2023-07-13 Thread Michael Paquier
Add indisreplident to fields refreshed by RelationReloadIndexInfo() RelationReloadIndexInfo() is a fast-path used for index reloads in the relation cache, and it has always forgotten about updating indisreplident, which is something that would happen after an index is selected for a replica identi

pgsql: Add indisreplident to fields refreshed by RelationReloadIndexInf

2023-07-13 Thread Michael Paquier
Add indisreplident to fields refreshed by RelationReloadIndexInfo() RelationReloadIndexInfo() is a fast-path used for index reloads in the relation cache, and it has always forgotten about updating indisreplident, which is something that would happen after an index is selected for a replica identi

pgsql: Add indisreplident to fields refreshed by RelationReloadIndexInf

2023-07-13 Thread Michael Paquier
Add indisreplident to fields refreshed by RelationReloadIndexInfo() RelationReloadIndexInfo() is a fast-path used for index reloads in the relation cache, and it has always forgotten about updating indisreplident, which is something that would happen after an index is selected for a replica identi

pgsql: Add indisreplident to fields refreshed by RelationReloadIndexInf

2023-07-13 Thread Michael Paquier
Add indisreplident to fields refreshed by RelationReloadIndexInfo() RelationReloadIndexInfo() is a fast-path used for index reloads in the relation cache, and it has always forgotten about updating indisreplident, which is something that would happen after an index is selected for a replica identi

pgsql: Add indisreplident to fields refreshed by RelationReloadIndexInf

2023-07-13 Thread Michael Paquier
Add indisreplident to fields refreshed by RelationReloadIndexInfo() RelationReloadIndexInfo() is a fast-path used for index reloads in the relation cache, and it has always forgotten about updating indisreplident, which is something that would happen after an index is selected for a replica identi

pgsql: Add indisreplident to fields refreshed by RelationReloadIndexInf

2023-07-13 Thread Michael Paquier
Add indisreplident to fields refreshed by RelationReloadIndexInfo() RelationReloadIndexInfo() is a fast-path used for index reloads in the relation cache, and it has always forgotten about updating indisreplident, which is something that would happen after an index is selected for a replica identi

pgsql: Fix updates of indisvalid for partitioned indexes

2023-07-13 Thread Michael Paquier
Fix updates of indisvalid for partitioned indexes indisvalid is switched to true for partitioned indexes when all its partitions have valid indexes when attaching a new partition, up to the top-most parent if all its leaves are themselves valid when dealing with multiple layers of partitions. The

pgsql: Fix updates of indisvalid for partitioned indexes

2023-07-13 Thread Michael Paquier
Fix updates of indisvalid for partitioned indexes indisvalid is switched to true for partitioned indexes when all its partitions have valid indexes when attaching a new partition, up to the top-most parent if all its leaves are themselves valid when dealing with multiple layers of partitions. The

pgsql: Fix updates of indisvalid for partitioned indexes

2023-07-13 Thread Michael Paquier
Fix updates of indisvalid for partitioned indexes indisvalid is switched to true for partitioned indexes when all its partitions have valid indexes when attaching a new partition, up to the top-most parent if all its leaves are themselves valid when dealing with multiple layers of partitions. The

pgsql: Fix updates of indisvalid for partitioned indexes

2023-07-13 Thread Michael Paquier
Fix updates of indisvalid for partitioned indexes indisvalid is switched to true for partitioned indexes when all its partitions have valid indexes when attaching a new partition, up to the top-most parent if all its leaves are themselves valid when dealing with multiple layers of partitions. The

pgsql: Fix updates of indisvalid for partitioned indexes

2023-07-13 Thread Michael Paquier
Fix updates of indisvalid for partitioned indexes indisvalid is switched to true for partitioned indexes when all its partitions have valid indexes when attaching a new partition, up to the top-most parent if all its leaves are themselves valid when dealing with multiple layers of partitions. The

pgsql: Fix updates of indisvalid for partitioned indexes

2023-07-13 Thread Michael Paquier
Fix updates of indisvalid for partitioned indexes indisvalid is switched to true for partitioned indexes when all its partitions have valid indexes when attaching a new partition, up to the top-most parent if all its leaves are themselves valid when dealing with multiple layers of partitions. The

pgsql: Fix updates of indisvalid for partitioned indexes

2023-07-13 Thread Michael Paquier
Fix updates of indisvalid for partitioned indexes indisvalid is switched to true for partitioned indexes when all its partitions have valid indexes when attaching a new partition, up to the top-most parent if all its leaves are themselves valid when dealing with multiple layers of partitions. The

pgsql: Remove wal_sync_method=fsync_writethrough on Windows.

2023-07-13 Thread Thomas Munro
Remove wal_sync_method=fsync_writethrough on Windows. The "fsync" level already flushes drive write caches on Windows (as does "fdatasync"), so it only confuses matters to have an apparently higher level that isn't actually different at all. That leaves "fsync_writethrough" only for macOS, where

pgsql: Add information about line contents on parsing failure of wait_e

2023-07-13 Thread Michael Paquier
Add information about line contents on parsing failure of wait_event_names.txt The contents of the line whose parsing failed was not reported in the error message produced by generate-wait_event_types.pl, making harder than necessary the debugging of incorrectly-shaped entries in the file. Report

pgsql: Remove double quotes from the second column of wait_event_names.

2023-07-13 Thread Michael Paquier
Remove double quotes from the second column of wait_event_names.txt The double quotes used for the wait event names are not required, as the values quoted are made of single words. The files generated by generate-wait_event_types.pl (pgstat_wait_event.c, wait_event_types.h and wait_event_types.sg

pgsql: Release lock after encountering bogs row in vac_truncate_clog()

2023-07-13 Thread Andres Freund
Release lock after encountering bogs row in vac_truncate_clog() When vac_truncate_clog() encounters bogus datfrozenxid / datminmxid values, it returns early. Unfortunately, until now, it did not release WrapLimitsVacuumLock. If the backend later tries to acquire WrapLimitsVacuumLock, the session /

pgsql: Release lock after encountering bogs row in vac_truncate_clog()

2023-07-13 Thread Andres Freund
Release lock after encountering bogs row in vac_truncate_clog() When vac_truncate_clog() encounters bogus datfrozenxid / datminmxid values, it returns early. Unfortunately, until now, it did not release WrapLimitsVacuumLock. If the backend later tries to acquire WrapLimitsVacuumLock, the session /

pgsql: Handle DROP DATABASE getting interrupted

2023-07-13 Thread Andres Freund
Handle DROP DATABASE getting interrupted Until now, when DROP DATABASE got interrupted in the wrong moment, the removal of the pg_database row would also roll back, even though some irreversible steps have already been taken. E.g. DropDatabaseBuffers() might have thrown out dirty buffers, or files

pgsql: Handle DROP DATABASE getting interrupted

2023-07-13 Thread Andres Freund
Handle DROP DATABASE getting interrupted Until now, when DROP DATABASE got interrupted in the wrong moment, the removal of the pg_database row would also roll back, even though some irreversible steps have already been taken. E.g. DropDatabaseBuffers() might have thrown out dirty buffers, or files

pgsql: Handle DROP DATABASE getting interrupted

2023-07-13 Thread Andres Freund
Handle DROP DATABASE getting interrupted Until now, when DROP DATABASE got interrupted in the wrong moment, the removal of the pg_database row would also roll back, even though some irreversible steps have already been taken. E.g. DropDatabaseBuffers() might have thrown out dirty buffers, or files

pgsql: Release lock after encountering bogs row in vac_truncate_clog()

2023-07-13 Thread Andres Freund
Release lock after encountering bogs row in vac_truncate_clog() When vac_truncate_clog() encounters bogus datfrozenxid / datminmxid values, it returns early. Unfortunately, until now, it did not release WrapLimitsVacuumLock. If the backend later tries to acquire WrapLimitsVacuumLock, the session /

pgsql: Handle DROP DATABASE getting interrupted

2023-07-13 Thread Andres Freund
Handle DROP DATABASE getting interrupted Until now, when DROP DATABASE got interrupted in the wrong moment, the removal of the pg_database row would also roll back, even though some irreversible steps have already been taken. E.g. DropDatabaseBuffers() might have thrown out dirty buffers, or files

pgsql: Release lock after encountering bogs row in vac_truncate_clog()

2023-07-13 Thread Andres Freund
Release lock after encountering bogs row in vac_truncate_clog() When vac_truncate_clog() encounters bogus datfrozenxid / datminmxid values, it returns early. Unfortunately, until now, it did not release WrapLimitsVacuumLock. If the backend later tries to acquire WrapLimitsVacuumLock, the session /

pgsql: Handle DROP DATABASE getting interrupted

2023-07-13 Thread Andres Freund
Handle DROP DATABASE getting interrupted Until now, when DROP DATABASE got interrupted in the wrong moment, the removal of the pg_database row would also roll back, even though some irreversible steps have already been taken. E.g. DropDatabaseBuffers() might have thrown out dirty buffers, or files

pgsql: Handle DROP DATABASE getting interrupted

2023-07-13 Thread Andres Freund
Handle DROP DATABASE getting interrupted Until now, when DROP DATABASE got interrupted in the wrong moment, the removal of the pg_database row would also roll back, even though some irreversible steps have already been taken. E.g. DropDatabaseBuffers() might have thrown out dirty buffers, or files

pgsql: Release lock after encountering bogs row in vac_truncate_clog()

2023-07-13 Thread Andres Freund
Release lock after encountering bogs row in vac_truncate_clog() When vac_truncate_clog() encounters bogus datfrozenxid / datminmxid values, it returns early. Unfortunately, until now, it did not release WrapLimitsVacuumLock. If the backend later tries to acquire WrapLimitsVacuumLock, the session /

pgsql: Release lock after encountering bogs row in vac_truncate_clog()

2023-07-13 Thread Andres Freund
Release lock after encountering bogs row in vac_truncate_clog() When vac_truncate_clog() encounters bogus datfrozenxid / datminmxid values, it returns early. Unfortunately, until now, it did not release WrapLimitsVacuumLock. If the backend later tries to acquire WrapLimitsVacuumLock, the session /

pgsql: Handle DROP DATABASE getting interrupted

2023-07-13 Thread Andres Freund
Handle DROP DATABASE getting interrupted Until now, when DROP DATABASE got interrupted in the wrong moment, the removal of the pg_database row would also roll back, even though some irreversible steps have already been taken. E.g. DropDatabaseBuffers() might have thrown out dirty buffers, or files

pgsql: Release lock after encountering bogs row in vac_truncate_clog()

2023-07-13 Thread Andres Freund
Release lock after encountering bogs row in vac_truncate_clog() When vac_truncate_clog() encounters bogus datfrozenxid / datminmxid values, it returns early. Unfortunately, until now, it did not release WrapLimitsVacuumLock. If the backend later tries to acquire WrapLimitsVacuumLock, the session /

pgsql: Remove unnecessary pfree() in g_intbig_compress().

2023-07-13 Thread Tom Lane
Remove unnecessary pfree() in g_intbig_compress(). GiST compress functions (like all GiST opclass functions) are supposed to be called in short-lived memory contexts, so that minor memory leaks in them are not of concern, and indeed explicit pfree's are likely slightly counterproductive. But this

pgsql: Remove unnecessary pfree() in g_intbig_compress().

2023-07-13 Thread Tom Lane
Remove unnecessary pfree() in g_intbig_compress(). GiST compress functions (like all GiST opclass functions) are supposed to be called in short-lived memory contexts, so that minor memory leaks in them are not of concern, and indeed explicit pfree's are likely slightly counterproductive. But this

pgsql: Remove unnecessary pfree() in g_intbig_compress().

2023-07-13 Thread Tom Lane
Remove unnecessary pfree() in g_intbig_compress(). GiST compress functions (like all GiST opclass functions) are supposed to be called in short-lived memory contexts, so that minor memory leaks in them are not of concern, and indeed explicit pfree's are likely slightly counterproductive. But this

pgsql: Remove unnecessary pfree() in g_intbig_compress().

2023-07-13 Thread Tom Lane
Remove unnecessary pfree() in g_intbig_compress(). GiST compress functions (like all GiST opclass functions) are supposed to be called in short-lived memory contexts, so that minor memory leaks in them are not of concern, and indeed explicit pfree's are likely slightly counterproductive. But this

pgsql: Remove unnecessary pfree() in g_intbig_compress().

2023-07-13 Thread Tom Lane
Remove unnecessary pfree() in g_intbig_compress(). GiST compress functions (like all GiST opclass functions) are supposed to be called in short-lived memory contexts, so that minor memory leaks in them are not of concern, and indeed explicit pfree's are likely slightly counterproductive. But this

pgsql: Remove unnecessary pfree() in g_intbig_compress().

2023-07-13 Thread Tom Lane
Remove unnecessary pfree() in g_intbig_compress(). GiST compress functions (like all GiST opclass functions) are supposed to be called in short-lived memory contexts, so that minor memory leaks in them are not of concern, and indeed explicit pfree's are likely slightly counterproductive. But this

pgsql: Remove unnecessary pfree() in g_intbig_compress().

2023-07-13 Thread Tom Lane
Remove unnecessary pfree() in g_intbig_compress(). GiST compress functions (like all GiST opclass functions) are supposed to be called in short-lived memory contexts, so that minor memory leaks in them are not of concern, and indeed explicit pfree's are likely slightly counterproductive. But this

Re: pgsql: Pass constructName to transformJsonValueExpr()

2023-07-13 Thread Amit Langote
On Thu, Jul 13, 2023 at 1:08 PM Tom Lane wrote: > Amit Langote writes: > > Pass constructName to transformJsonValueExpr() > > Surely "char *constructName" should be "const char *constructName"? Right you are. Fixed. -- Thanks, Amit Langote EDB: http://www.enterprisedb.com

pgsql: Add missing const qualifier

2023-07-13 Thread Amit Langote
Add missing const qualifier Missed in commit 785480c9533d9. Pointed out by Tom Lane. Discussion: https://postgr.es/m/2795364.1689221300%40sss.pgh.pa.us Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/40b3af72a787e5c7c842651a2e04e3f856b9460c Modified Files ---

Re: pgsql: Don't include CaseTestExpr in JsonValueExpr.formatted_expr

2023-07-13 Thread Amit Langote
On Thu, Jul 13, 2023 at 5:12 PM Michael Paquier wrote: > > Hi Amit, > > On Thu, Jul 13, 2023 at 03:33:07AM +, Amit Langote wrote: > > Don't include CaseTestExpr in JsonValueExpr.formatted_expr > > > > A CaseTestExpr is currently being put into > > JsonValueExpr.formatted_expr as placeholder fo

pgsql: Fix code indentation violation in commit b6e1157e7d

2023-07-13 Thread Amit Langote
Fix code indentation violation in commit b6e1157e7d Per buildfarm member koel via Andrew Dunstan. Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/328f492d2565cfbe383f13a69425d751fd79415f Modified Files -- src/backend/parser/parse_expr.c | 7 --- 1 fi

pgsql: Fix untranslatable log message assembly

2023-07-13 Thread Peter Eisentraut
Fix untranslatable log message assembly We can't inject the name of the logical replication worker into a log message like that. But for these messages we don't really need the precision of knowing what kind of worker it was, so just write "logical replication worker" and keep the message in one

pgsql: Fix untranslatable log message assembly

2023-07-13 Thread Peter Eisentraut
Fix untranslatable log message assembly We can't inject the name of the logical replication worker into a log message like that. But for these messages we don't really need the precision of knowing what kind of worker it was, so just write "logical replication worker" and keep the message in one

Re: pgsql: Don't include CaseTestExpr in JsonValueExpr.formatted_expr

2023-07-13 Thread Michael Paquier
Hi Amit, On Thu, Jul 13, 2023 at 03:33:07AM +, Amit Langote wrote: > Don't include CaseTestExpr in JsonValueExpr.formatted_expr > > A CaseTestExpr is currently being put into > JsonValueExpr.formatted_expr as placeholder for the result of > evaluating JsonValueExpr.raw_expr, which in turn is

pgsql: Remove duplicated assignment of LLVMJitHandle->lljit

2023-07-13 Thread Michael Paquier
Remove duplicated assignment of LLVMJitHandle->lljit This duplicated assignment when emiting some code not yet compiled. Oversight in 6c57f2e. Author: Matheus Alcantara Reviewed-by: Gurjeet Singh Discussion: https://postgr.es/m/La1Tfi7wirg9uGbCx_y7Qb9kl2T15mYouDXjCKAFuDqzQWnTRwH7KNLGigLLcxRs91V