Re: [BUG] Fix DETACH with FK pointing to a partitioned table fails

2023-08-02 Thread tender wang
I think old "sub-FK" should not be dropped, that will be violates foreign key constraint. For example : postgres=# insert into r values(1,1); INSERT 0 1 postgres=# ALTER TABLE r DETACH PARTITION r_1; ALTER TABLE postgres=# delete from p_1 where id = 1; DELETE 1 postgres=# select * from r_1; id |

Re: Faster "SET search_path"

2023-08-02 Thread Jeff Davis
On Tue, 2023-08-01 at 21:52 -0700, Nathan Bossart wrote: > I > typically see this done with two ѕeparate lists and forboth(). Agreed, done. > > Any reason not to use hash_combine() here? Thank you, fixed. > > I changed it to move the hook so that it's called after retrieving > > from > > the c

Re: Fix incorrect start up costs for WindowAgg paths (bug #17862)

2023-08-02 Thread Andy Fan
Hi David: Sorry for feedback at the last minute! I study the patch and find the following cases. 1. ORDER BY or PARTITION BY select *, count(two) over (order by unique1) from tenk1 limit 1; DEBUG: startup_tuples = 1 DEBUG: startup_tuples = 1 select *, count(two) over (partition by unique1) f

Re: [PoC] pg_upgrade: allow to upgrade publisher node

2023-08-02 Thread Amit Kapila
On Wed, Aug 2, 2023 at 1:43 PM Hayato Kuroda (Fujitsu) wrote: > > Thank you for giving comments! PSA new version patchset. > > > 3. > > + /* > > + * Get replication slots. > > + * > > + * XXX: Which information must be extracted from old node? Currently three > > + * attributes are extracted becau

Re: ALTER COLUMN ... SET EXPRESSION to alter stored generated column's expression

2023-08-02 Thread jian he
On Thu, Aug 3, 2023 at 1:23 PM Amul Sul wrote: > > > That is not expected & acceptable. But, somehow, I am not able to reproduce > this behavior. Could you please retry this experiment by adding "table_schema" > in your output query? > > Thank you. > > Regards, > Amul > sorry. my mistake. I creat

Re: Exposing the lock manager's WaitForLockers() to SQL

2023-08-02 Thread Will Mortensen
Updated docs a bit. I'll see about adding this to the next CF in hopes of attracting a reviewer. :-) v3-0001-Add-WAIT-ONLY-option-to-LOCK-command.patch Description: Binary data

Re: [PATCH] Reuse Workers and Replication Slots during Logical Replication

2023-08-02 Thread Amit Kapila
On Thu, Aug 3, 2023 at 9:35 AM Peter Smith wrote: > > On Wed, Aug 2, 2023 at 11:19 PM Amit Kapila wrote: > > > > On Wed, Aug 2, 2023 at 4:09 PM Melih Mutlu wrote: > > > > > > PFA an updated version with some of the earlier reviews addressed. > > > Forgot to include them in the previous email. >

Re: [PoC] Reducing planning time when tables have many partitions

2023-08-02 Thread Yuya Watari
Hello, On Wed, Aug 2, 2023 at 6:43 PM Andrey Lepikhov wrote: > You introduced list_ptr_cmp as an extern function of a List, but use it > the only under USE_ASSERT_CHECKING ifdef. > Maybe you hide it under USE_ASSERT_CHECKING or remove all the stuff? Thank you for your quick reply and for pointin

Re: Use of additional index columns in rows filtering

2023-08-02 Thread Peter Geoghegan
On Wed, Aug 2, 2023 at 6:32 PM Peter Geoghegan wrote: > I don't dispute the fact that this can only happen when the planner > believes (with good reason) that the expected cost will be lower. But > I maintain that there is a novel risk to be concerned about, which is > meaningfully distinct from t

Re: ALTER COLUMN ... SET EXPRESSION to alter stored generated column's expression

2023-08-02 Thread Amul Sul
On Wed, Aug 2, 2023 at 9:16 PM jian he wrote: > On Wed, Aug 2, 2023 at 6:36 PM Amul Sul wrote: > > > > Hi, > > > > Currently, we have an option to drop the expression of stored generated > columns > > as: > > > > ALTER [ COLUMN ] column_name DROP EXPRESSION [ IF EXISTS ] > > > > But don't have s

Re: Extract numeric filed in JSONB more effectively

2023-08-02 Thread Pavel Stehule
Hi čt 3. 8. 2023 v 2:51 odesílatel Andy Fan napsal: > Hi Jian: > > >> return PointerGetDatum(v->val.numeric); >> should be something like >> PG_RETURN_NUMERIC(v->val.numeric); >> ? >> > > Thanks for this reminder, a new patch is attached. and commitfest > entry is added as well[1]. For recordin

Re: Fix incorrect start up costs for WindowAgg paths (bug #17862)

2023-08-02 Thread David Rowley
On Wed, 31 May 2023 at 12:59, David Rowley wrote: > > On Wed, 12 Apr 2023 at 21:03, David Rowley wrote: > > I'll add this to the "Older bugs affecting stable branches" section of > > the PG 16 open items list > > When I wrote the above, it was very soon after the feature freeze for > PG16. I wond

Re: Oversight in reparameterize_path_by_child leading to executor crash

2023-08-02 Thread Ashutosh Bapat
On Tue, Aug 1, 2023 at 6:50 PM Tom Lane wrote: > > Alternatively, could we postpone the reparameterization until > createplan.c? Having to build reparameterized expressions we might > not use seems expensive, and it would also contribute to the memory > bloat being complained of in nearby thread

Re: [PATCH] Reuse Workers and Replication Slots during Logical Replication

2023-08-02 Thread Peter Smith
On Wed, Aug 2, 2023 at 11:19 PM Amit Kapila wrote: > > On Wed, Aug 2, 2023 at 4:09 PM Melih Mutlu wrote: > > > > PFA an updated version with some of the earlier reviews addressed. > > Forgot to include them in the previous email. > > > > It is always better to explicitly tell which reviews are ad

Fix bogus Asserts in calc_non_nestloop_required_outer

2023-08-02 Thread Richard Guo
As stated in [1], all paths arriving here are parameterized by top parents, so we should check against top_parent_relids if it exists in the two Asserts. Attached is a patch fixing that. [1] https://www.postgresql.org/message-id/CAMbWs4_UoVcCwkVMfi9TjSC%3Do5U6BRHUNZiVhrvSbDfU2HaeDA%40mail.gmail.c

Re: Use of additional index columns in rows filtering

2023-08-02 Thread Peter Geoghegan
On Wed, Aug 2, 2023 at 6:48 AM Tomas Vondra wrote: > How come we don't know that until the execution time? Surely when > building the paths/plans, we match the clauses to the index keys, no? Or > are you saying that just having a scan key is not enough for it to be > "access predicate"? In princi

Re: Extract numeric filed in JSONB more effectively

2023-08-02 Thread Andy Fan
Hi Jian: > return PointerGetDatum(v->val.numeric); > should be something like > PG_RETURN_NUMERIC(v->val.numeric); > ? > Thanks for this reminder, a new patch is attached. and commitfest entry is added as well[1]. For recording purposes, I compared the new operator with all the existing operat

Re: Configurable FP_LOCK_SLOTS_PER_BACKEND

2023-08-02 Thread Matt Smiley
I thought it might be helpful to share some more details from one of the case studies behind Nik's suggestion. Bursty contention on lock_manager lwlocks recently became a recurring cause of query throughput drops for GitLab.com, and we got to study the behavior via USDT and uprobe instrumentation

First draft of back-branch release notes is done

2023-08-02 Thread Tom Lane
... at https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=c6344d7686f3e3c8243c2c6771996cfc63e71eae This is a bit earlier than usual because I will be tied up with $LIFE for the next couple of days. I will catch up with any subsequent back-branch commits over the weekend. As usua

Re: [PATCH] Allow Postgres to pick an unused port to listen

2023-08-02 Thread Daniel Gustafsson
> On 10 Jul 2023, at 14:27, Daniel Gustafsson wrote: > This patch is Waiting on Author in the current commitfest with no new patch > presented following the discussion here. Is there an update ready or should > we > close it in this CF in favour of a future one? Since the thread stalled here w

Re: An attempt to avoid locally-committed-but-not-replicated-to-standby-transactions in synchronous replication

2023-08-02 Thread Daniel Gustafsson
> On 30 Jan 2023, at 06:55, Bharath Rupireddy > wrote: > I started to spend time on this feature again. Thanks all for your > comments so far. Since there hasn't been any updates for the past six months, and the patch hasn't applied for a few months, I am marking this returned with feedback for

Re: POC, WIP: OR-clause support for indexes

2023-08-02 Thread Peter Geoghegan
On Wed, Aug 2, 2023 at 8:58 AM Alena Rybakina wrote: > No, I haven't thought about it yet. I studied the example and it would > really be nice to add optimization here. I didn't notice any problems > with its implementation. I also have an obvious example with the "or" > operator, for example > ,

Re: Synchronizing slots from primary to standby

2023-08-02 Thread Bharath Rupireddy
On Tue, Aug 1, 2023 at 5:01 PM shveta malik wrote: > > > The work division amongst the sync workers can > > be simple, the logical replication launcher builds a shared memory > > structure based on number of slots to sync and starts the sync workers > > dynamically, and each sync worker picks {dbo

Re: add timing information to pg_upgrade

2023-08-02 Thread Nathan Bossart
On Wed, Aug 02, 2023 at 09:09:14AM -0700, Nathan Bossart wrote: > On Wed, Aug 02, 2023 at 01:02:53PM +0530, Bharath Rupireddy wrote: >> On Wed, Aug 2, 2023 at 12:45 PM Peter Eisentraut >> wrote: >>> I think we should change the output format to be more like initdb, like >>> >>> Doing somethi

Re: SIGQUIT handling, redux

2023-08-02 Thread Andres Freund
Hi, On 2023-08-02 12:35:19 -0400, Tom Lane wrote: > Andres Freund writes: > > On 2020-09-11 11:52:55 -0400, Tom Lane wrote: > >> It's simple enough that maybe we could back-patch it, once it's > >> aged awhile in HEAD. OTOH, given the lack of field reports of > >> trouble here, I'm not sure back

Re: SIGQUIT handling, redux

2023-08-02 Thread Tom Lane
Andres Freund writes: > On 2020-09-11 11:52:55 -0400, Tom Lane wrote: >> It's simple enough that maybe we could back-patch it, once it's >> aged awhile in HEAD. OTOH, given the lack of field reports of >> trouble here, I'm not sure back-patching is worth the risk. > FWIW, looking at collected st

Re: SIGQUIT handling, redux

2023-08-02 Thread Andres Freund
Hi, On 2020-09-11 11:52:55 -0400, Tom Lane wrote: > It's simple enough that maybe we could back-patch it, once it's > aged awhile in HEAD. OTOH, given the lack of field reports of > trouble here, I'm not sure back-patching is worth the risk. FWIW, looking at collected stack traces in azure, ther

Re: pg_upgrade fails with in-place tablespace

2023-08-02 Thread Rui Zhao
> I don't think that your solution is the correct move. Having > pg_tablespace_location() return the physical location of the > tablespace is very useful because that's the location where the > physical files are, and client applications don't need to know the > logic behind the way a path is built

Re: add timing information to pg_upgrade

2023-08-02 Thread Nathan Bossart
On Wed, Aug 02, 2023 at 01:02:53PM +0530, Bharath Rupireddy wrote: > On Wed, Aug 2, 2023 at 12:45 PM Peter Eisentraut wrote: >> I think we should change the output format to be more like initdb, like >> >> Doing something ... ok >> >> without horizontally aligning all the "ok"s. > > While th

Re: PATCH: Using BRIN indexes for sorted output

2023-08-02 Thread Tomas Vondra
On 8/2/23 17:25, Sergey Dudoladov wrote: > Hello, > >> Parallel version is not supported, but I think it should be possible. > > @Tomas are you working on this ? If not, I would like to give it a try. > Feel free to try. Just keep it in a separate part/patch, to make it easier to combine the

Re: add timing information to pg_upgrade

2023-08-02 Thread Nathan Bossart
On Wed, Aug 02, 2023 at 09:14:06AM +0200, Peter Eisentraut wrote: > On 01.08.23 18:00, Nathan Bossart wrote: >> One of the main purposes of this thread is to gauge interest. I'm hoping >> there are other developers who are interested in reducing >> pg_upgrade-related downtime, and it seemed like i

Re: ALTER COLUMN ... SET EXPRESSION to alter stored generated column's expression

2023-08-02 Thread jian he
On Wed, Aug 2, 2023 at 6:36 PM Amul Sul wrote: > > Hi, > > Currently, we have an option to drop the expression of stored generated > columns > as: > > ALTER [ COLUMN ] column_name DROP EXPRESSION [ IF EXISTS ] > > But don't have support to update that expression. The attached patch provides > tha

Re: PATCH: Using BRIN indexes for sorted output

2023-08-02 Thread Sergey Dudoladov
Hello, > Parallel version is not supported, but I think it should be possible. @Tomas are you working on this ? If not, I would like to give it a try. > static void > AssertCheckRanges(BrinSortState *node) > { > #ifdef USE_ASSERT_CHECKING > > #endif > } I guess it should not be empty at the ong

Re: Improve const use in zlib-using code

2023-08-02 Thread Tristan Partin
Peter, I like the idea. Though the way you have it implemented at the moment seems like a trap in that any time zlib.h is included someone also has to remember to add this define. I would recommend adding the define to the build systems instead. Since you put in the work to find the version

Re: Use of additional index columns in rows filtering

2023-08-02 Thread Tomas Vondra
On 8/2/23 02:50, Peter Geoghegan wrote: > On Mon, Jul 24, 2023 at 11:59 AM Peter Geoghegan wrote: >>> That might be true but I'm not sure what to do about that unless we >>> incorporate some "robustness" measure into the costing. If every >>> measure we have says one plan is better, don't we have

Re: [PATCH] Reuse Workers and Replication Slots during Logical Replication

2023-08-02 Thread Amit Kapila
On Wed, Aug 2, 2023 at 4:09 PM Melih Mutlu wrote: > > PFA an updated version with some of the earlier reviews addressed. > Forgot to include them in the previous email. > It is always better to explicitly tell which reviews are addressed but anyway, I have done some minor cleanup in the 0001 patc

Re: Adding a LogicalRepWorker type field

2023-08-02 Thread Melih Mutlu
Hi, Peter Smith , 2 Ağu 2023 Çar, 09:27 tarihinde şunu yazdı: > On Wed, Aug 2, 2023 at 3:35 PM Masahiko Sawada > wrote: > > > > I can see the problem you stated and it's true that the worker's type > > never changes during its lifetime. But I'm not sure we really need to > > add a new variable t

Re: Potential memory leak in contrib/intarray's g_intbig_compress

2023-08-02 Thread Matthias van de Meent
On Fri, 14 Jul 2023 at 07:57, Michael Paquier wrote: > > On Thu, Jul 13, 2023 at 06:28:39PM +0200, Matthias van de Meent wrote: > > There are similar pfree calls in the _int_gist.c file's g_int_compress > > function, which made me think we do need to clean up after use, but > > indeed these pfrees

Re: Oversight in reparameterize_path_by_child leading to executor crash

2023-08-02 Thread Richard Guo
On Tue, Aug 1, 2023 at 9:20 PM Tom Lane wrote: > Richard Guo writes: > > So what I'm thinking is that maybe we can add a new type of path, named > > SampleScanPath, to have the TableSampleClause per path. Then we can > > safely reparameterize the TableSampleClause as needed for each > > SampleS

Re: [PATCH] Reuse Workers and Replication Slots during Logical Replication

2023-08-02 Thread Melih Mutlu
Hi, > PFA an updated version with some of the earlier reviews addressed. Forgot to include them in the previous email. Thanks, -- Melih Mutlu Microsoft v24-0003-Reuse-connection-when-tablesync-workers-change-t.patch Description: Binary data v24-0002-Reuse-Tablesync-Workers.patch Description:

ALTER COLUMN ... SET EXPRESSION to alter stored generated column's expression

2023-08-02 Thread Amul Sul
Hi, Currently, we have an option to drop the expression of stored generated columns as: ALTER [ COLUMN ] column_name DROP EXPRESSION [ IF EXISTS ] But don't have support to update that expression. The attached patch provides that as: ALTER [ COLUMN ] column_name SET EXPRESSION expression Note

Re: pgbnech: allow to cancel queries during benchmark

2023-08-02 Thread Yugo NAGATA
On Wed, 2 Aug 2023 16:37:53 +0900 Yugo NAGATA wrote: > Hello Fabien, > > On Fri, 14 Jul 2023 20:32:01 +0900 > Yugo NAGATA wrote: > > I attached the updated patch. I'm sorry. I forgot to attach the patch. Regards, Yugo Nagata > > > Hello Fabien, > > > > Thank you for your review! > > > >

Improve const use in zlib-using code

2023-08-02 Thread Peter Eisentraut
Now that we have effectively de-supported CentOS 6, by removing support for its OpenSSL version, I think we could also modernize the use of some other libraries, such as zlib. If we define ZLIB_CONST before including zlib.h, zlib augments some interfaces with const decorations. By doing that w

Re: [PoC] Reducing planning time when tables have many partitions

2023-08-02 Thread Andrey Lepikhov
On 2/8/2023 13:40, Yuya Watari wrote: As seen from the above, verifying iteration results was the cause of the performance degradation. I agree that we should avoid such degradation because it negatively affects the development of PostgreSQL. Removing the verification when committing this patch i

Re: [PATCH] Reuse Workers and Replication Slots during Logical Replication

2023-08-02 Thread Melih Mutlu
Hi, Amit Kapila , 2 Ağu 2023 Çar, 12:01 tarihinde şunu yazdı: > I think we are getting the error (ERROR: could not find logical > decoding starting point) because we wouldn't have waited for WAL to > become available before reading it. It could happen due to the > following code: > WalSndWaitFor

Re: Support to define custom wait events for extensions

2023-08-02 Thread Masahiro Ikeda
On 2023-08-01 12:23, Andres Freund wrote: Hi, On 2023-08-01 12:14:49 +0900, Michael Paquier wrote: On Tue, Aug 01, 2023 at 11:51:35AM +0900, Masahiro Ikeda wrote: > Thanks for committing the main patch. > > In my understanding, the rest works are > * to support WaitEventExtensionMultiple() > *

Re: multiple membership grants and information_schema.applicable_roles

2023-08-02 Thread Peter Eisentraut
On 24.07.23 08:42, Pavel Luzanov wrote: I do see what seems like a different issue: the standard appears to expect that indirect role grants should also be shown (via the recursive CTE), and we are not doing that. I noticed this, but the view stays unchanged so long time. I thought it was done

Re: Adding a LogicalRepWorker type field

2023-08-02 Thread Amit Kapila
On Wed, Aug 2, 2023 at 2:46 PM Bharath Rupireddy wrote: > > On Wed, Aug 2, 2023 at 12:14 PM Peter Smith wrote: > > > > We can't use the same names for both with/without-parameter functions > > because there is no function overloading in C. In patch v3-0001 I've > > replaced the "dual set of macro

Re: add timing information to pg_upgrade

2023-08-02 Thread Peter Eisentraut
On 02.08.23 10:30, Bharath Rupireddy wrote: Moreover, the ts command gives me the timestamps for each of the messages printed, so an extra step is required to calculate the time taken for an operation. There is "ts -i" for that.

Re: Adding a LogicalRepWorker type field

2023-08-02 Thread Bharath Rupireddy
On Wed, Aug 2, 2023 at 12:14 PM Peter Smith wrote: > > We can't use the same names for both with/without-parameter functions > because there is no function overloading in C. In patch v3-0001 I've > replaced the "dual set of macros", with a single inline function of a > different name, and one set

Re: PG_CATCH used without PG_RETHROW

2023-08-02 Thread 正华吕
Hi, I think this is a bug because this function's CATCH clause does not restore memroycontext. Thus when leaving the function, the CurrentMemroyContext will be ErrorMemroyContext. I see this part of code is refactored in master branch, but in REL_16_STABLE, the code is still there. The following

Re: [PATCH] Reuse Workers and Replication Slots during Logical Replication

2023-08-02 Thread Amit Kapila
On Tue, Aug 1, 2023 at 9:44 AM Peter Smith wrote: > > > FYI, here is some more information about ERRORs seen. > > The patches were re-tested -- applied in stages (and also against the > different scripts) to identify where the problem was introduced. Below > are the observations: > > ~~~ > > Using

Re: add timing information to pg_upgrade

2023-08-02 Thread Bharath Rupireddy
On Wed, Aug 2, 2023 at 12:44 PM Peter Eisentraut wrote: > > On 01.08.23 18:00, Nathan Bossart wrote: > > One of the main purposes of this thread is to gauge interest. I'm hoping > > there are other developers who are interested in reducing > > pg_upgrade-related downtime, and it seemed like it'd

Re: cataloguing NOT NULL constraints

2023-08-02 Thread Peter Eisentraut
On 24.07.23 12:32, Alvaro Herrera wrote: However, 11.16 ( as part of 11.12 ), says that DROP NOT NULL causes the indication of the column as NOT NULL to be removed. This, to me, says that if you do have multiple such constraints, you'd better remove them all with that command. All in all, I lea

RE: [PoC] pg_upgrade: allow to upgrade publisher node

2023-08-02 Thread Hayato Kuroda (Fujitsu)
Dear Amit, Thank you for giving comments! PSA new version patchset. > 1. Do we really need 0001 patch after the latest change proposed by > Vignesh in the 0004 patch? I removed 0001 patch and revived old patch which serializes slots at shutdown. This is because the problem which slots are not se

RE: [PoC] pg_upgrade: allow to upgrade publisher node

2023-08-02 Thread Hayato Kuroda (Fujitsu)
Dear Vignesh, Thank you for making the PoC! > Here is a patch which checks that there are no WAL records other than > CHECKPOINT_SHUTDOWN WAL record to be consumed based on the discussion > from [1]. Basically I agreed your approach. Thanks! > Patch 0001 and 0002 is same as the patch posted by

Re: [PATCH] [zh_CN.po] fix a typo in simplified Chinese translation file

2023-08-02 Thread Peter Eisentraut
On 01.08.23 10:09, Junwang Zhao wrote: add the missing leading `l` for log_statement_sample_rate I have committed this fix to the translations repository.

Re: pgbnech: allow to cancel queries during benchmark

2023-08-02 Thread Yugo NAGATA
Hello Fabien, On Fri, 14 Jul 2023 20:32:01 +0900 Yugo NAGATA wrote: I attached the updated patch. > Hello Fabien, > > Thank you for your review! > > On Mon, 3 Jul 2023 20:39:23 +0200 (CEST) > Fabien COELHO wrote: > > > > > Yugo-san, > > > > Some feedback about v1 of this patch. > > > > P

Re: add timing information to pg_upgrade

2023-08-02 Thread Bharath Rupireddy
On Wed, Aug 2, 2023 at 12:45 PM Peter Eisentraut wrote: > > On 01.08.23 17:45, Nathan Bossart wrote: > > The message is too long, so there's no space between it and the "ok" > > message: > > > > Checking for incompatible "aclitem" data type in user tablesok > > > > Instead of altering the me

Re: add timing information to pg_upgrade

2023-08-02 Thread Peter Eisentraut
On 01.08.23 17:45, Nathan Bossart wrote: The message is too long, so there's no space between it and the "ok" message: Checking for incompatible "aclitem" data type in user tablesok Instead of altering the messages, we could bump MESSAGE_WIDTH from 60 to 62 or 64. Do you prefer that ap

Re: add timing information to pg_upgrade

2023-08-02 Thread Peter Eisentraut
On 01.08.23 18:00, Nathan Bossart wrote: One of the main purposes of this thread is to gauge interest. I'm hoping there are other developers who are interested in reducing pg_upgrade-related downtime, and it seemed like it'd be nice to have built-in functionality for measuring the step times ins