public inbox for [email protected]  
help / color / mirror / Atom feed
Re: Set log_lock_waits=on by default
15+ messages / 10 participants
[nested] [flat]

* Re: Set log_lock_waits=on by default
@ 2024-01-24 17:19 Michael Banck <[email protected]>
  2024-07-18 10:25 ` Re: Set log_lock_waits=on by default Michael Banck <[email protected]>
  0 siblings, 1 reply; 15+ messages in thread

From: Michael Banck @ 2024-01-24 17:19 UTC (permalink / raw)
  To: Laurenz Albe <[email protected]>; +Cc: [email protected]

Hi,

On Thu, Jan 11, 2024 at 03:24:55PM +0100, Michael Banck wrote:
> On Thu, Dec 21, 2023 at 02:29:05PM +0100, Laurenz Albe wrote:
> > Here is a patch to implement this.
> > Being stuck behind a lock for more than a second is almost
> > always a problem, so it is reasonable to turn this on by default.
> 
> I also think that this should be set to on.
> 
> I had a look at the patch and it works fine. 
>
> Regarding the documentation, maybe the back-reference at
> deadlock_timeout could be made a bit more explicit then as well, as in
> the attached patch, but this is mostly bikeshedding.

I've marked it ready for committer now, as the above really is
bikeshedding.


Michael





^ permalink  raw  reply  [nested|flat] 15+ messages in thread

* Re: Set log_lock_waits=on by default
  2024-01-24 17:19 Re: Set log_lock_waits=on by default Michael Banck <[email protected]>
@ 2024-07-18 10:25 ` Michael Banck <[email protected]>
  2024-07-19 09:54   ` Re: Set log_lock_waits=on by default Laurenz Albe <[email protected]>
  2024-07-19 14:28   ` Re: Set log_lock_waits=on by default Greg Sabino Mullane <[email protected]>
  0 siblings, 2 replies; 15+ messages in thread

From: Michael Banck @ 2024-07-18 10:25 UTC (permalink / raw)
  To: Tom Lane <[email protected]>; +Cc: Nathan Bossart <[email protected]>; Laurenz Albe <[email protected]>; [email protected]

Hi,

this patch is still on the table, though for v18 now.

Nathan mentioned up-thread that he was hesitant to commit this without
further discussion. Laurenz, Stephen and I are +1 on this, but when it 
comes to committers having chimed in only Tom did so far and was -1.

Are there any others who have an opinion on this?

On Tue, Feb 06, 2024 at 12:29:10PM -0500, Tom Lane wrote:
> Nathan Bossart <[email protected]> writes:
> > It looks like there are two ideas:
> 
> > * Separate log_lock_waits from deadlock_timeout.  It looks like this idea
> >   has a decent amount of support, but I didn't see any patch for it so far.
> 
> I think the support comes from people who have not actually looked at
> the code.  The reason they are not separate is that the same timeout
> service routine does both things.  To pull them apart, you would have
> to (1) detangle that code and (2) incur the overhead of two timeout
> events queued for every lock wait.  It's not clear to me that it's
> worth it.  In some sense, deadlock_timeout is exactly the length of
> time after which you want to get concerned.
> 
> >   IMHO this is arguably a prerequisite for setting log_lock_waits on by
> >   default, as we could then easily set it higher by default to help address
> >   concerns about introducing too much noise in the logs.
> 
> Well, that's the question --- would it be sane to enable
> log_lock_waits by default if we don't separate them?

I think it would be, I have not seen people change the value of
deadlock_timeout so far, and I think 1s is a reasonable long time for a
default lock wait to be reported.
 
> > * Set log_lock_waits on by default.  The folks on this thread seem to
> >   support this idea, but given the lively discussion for enabling
> >   log_checkpoints by default [0], I'm hesitant to commit something like
> >   this without further community discussion.
> 
> I was, and remain, of the opinion that that was a bad idea that
> we'll eventually revert, just like we previously got rid of most
> inessential log chatter in the default configuration.

I somewhat agree here in the sense that log_checkpoints is really only
useful for heavily-used servers, but this is a digression and due to the
fact that log_checkpoints emits log lines periodically while
log_lock_waits only emits them for application conflicts (and arguably
application bugs), I do not think those would be in the "issential log
chatter" group similar to how all SQL errors are not in that group
either.


Michael






^ permalink  raw  reply  [nested|flat] 15+ messages in thread

* Re: Set log_lock_waits=on by default
  2024-01-24 17:19 Re: Set log_lock_waits=on by default Michael Banck <[email protected]>
  2024-07-18 10:25 ` Re: Set log_lock_waits=on by default Michael Banck <[email protected]>
@ 2024-07-19 09:54   ` Laurenz Albe <[email protected]>
  2024-07-19 13:24     ` Re: Set log_lock_waits=on by default Christoph Berg <[email protected]>
  2024-07-19 14:29     ` Re: Set log_lock_waits=on by default Jelte Fennema-Nio <[email protected]>
  2025-04-08 14:32     ` Re: Set log_lock_waits=on by default Laurenz Albe <[email protected]>
  1 sibling, 3 replies; 15+ messages in thread

From: Laurenz Albe @ 2024-07-19 09:54 UTC (permalink / raw)
  To: Michael Banck <[email protected]>; Tom Lane <[email protected]>; +Cc: Nathan Bossart <[email protected]>; [email protected]

On Thu, 2024-07-18 at 12:25 +0200, Michael Banck wrote:
> this patch is still on the table, though for v18 now.
> 
> Nathan mentioned up-thread that he was hesitant to commit this without
> further discussion. Laurenz, Stephen and I are +1 on this, but when it 
> comes to committers having chimed in only Tom did so far and was -1.
> 
> Are there any others who have an opinion on this?

If we want to tally up, there were also +1 votes from Christoph Berg,
Shinya Kato, Nikolay Samokhvalov, Jeremy Schneider and Frédéric Yhuel.

The major criticism is Tom's that it might unduly increase the log volume.

I'm not trying to rush things, but I see little point in kicking a trivial
patch like this through many commitfests.  If no committer wants to step
up and commit this, it should be rejected.

Yours,
Laurenz Albe






^ permalink  raw  reply  [nested|flat] 15+ messages in thread

* Re: Set log_lock_waits=on by default
  2024-01-24 17:19 Re: Set log_lock_waits=on by default Michael Banck <[email protected]>
  2024-07-18 10:25 ` Re: Set log_lock_waits=on by default Michael Banck <[email protected]>
  2024-07-19 09:54   ` Re: Set log_lock_waits=on by default Laurenz Albe <[email protected]>
@ 2024-07-19 13:24     ` Christoph Berg <[email protected]>
  2024-07-19 14:14       ` Re: Set log_lock_waits=on by default Robert Haas <[email protected]>
  2 siblings, 1 reply; 15+ messages in thread

From: Christoph Berg @ 2024-07-19 13:24 UTC (permalink / raw)
  To: Laurenz Albe <[email protected]>; +Cc: Michael Banck <[email protected]>; Tom Lane <[email protected]>; Nathan Bossart <[email protected]>; [email protected]

Re: Laurenz Albe
> The major criticism is Tom's that it might unduly increase the log volume.
> 
> I'm not trying to rush things, but I see little point in kicking a trivial
> patch like this through many commitfests.  If no committer wants to step
> up and commit this, it should be rejected.

That would be a pity, I still think log_lock_waits=on by default would
be a good thing.

I have not seen any server yet where normal, legitimate operation
would routinely trigger the message. (If it did, people should likely
have used SKIP LOCKED or NOWAIT instead.) It would only increase the
log volume on systems that have a problem.

Christoph






^ permalink  raw  reply  [nested|flat] 15+ messages in thread

* Re: Set log_lock_waits=on by default
  2024-01-24 17:19 Re: Set log_lock_waits=on by default Michael Banck <[email protected]>
  2024-07-18 10:25 ` Re: Set log_lock_waits=on by default Michael Banck <[email protected]>
  2024-07-19 09:54   ` Re: Set log_lock_waits=on by default Laurenz Albe <[email protected]>
  2024-07-19 13:24     ` Re: Set log_lock_waits=on by default Christoph Berg <[email protected]>
@ 2024-07-19 14:14       ` Robert Haas <[email protected]>
  0 siblings, 0 replies; 15+ messages in thread

From: Robert Haas @ 2024-07-19 14:14 UTC (permalink / raw)
  To: Christoph Berg <[email protected]>; +Cc: Laurenz Albe <[email protected]>; Michael Banck <[email protected]>; Tom Lane <[email protected]>; Nathan Bossart <[email protected]>; [email protected]

On Fri, Jul 19, 2024 at 9:24 AM Christoph Berg <[email protected]> wrote:
> I have not seen any server yet where normal, legitimate operation
> would routinely trigger the message. (If it did, people should likely
> have used SKIP LOCKED or NOWAIT instead.) It would only increase the
> log volume on systems that have a problem.

I've definitely seen systems where this setting would have generated
regular output, because I see a lot of systems that are chronically
overloaded. I think waits of more than 1 second for tuple locks could
be pretty routine on some servers -- or XID or VXID locks. So I'm more
cautious about this than most people on this thread: log_checkpoints
won't generate more than a few lines of output per checkpoint
interval, and a checkpoint cycle will be on the order of minutes, so
it's really never that much volume. On the other hand, in theory, this
setting can generate arbitrarily many messages.

That's why I originally proposed separating deadlock_timeout from
log_lock_waits, because I think 1s might actually end up being kind of
noisy for some people. On the other hand, I take Tom's point that
separating those things would be hard to code and, probably more
importantly, require a second timer.

I'm not strongly opposed to just turning this on by default. It's not
like we can't change our minds, and it's also not like individual
customers can't change the default. I think Tom has entirely the wrong
idea about what a typical log file on a production server looks like.
In every case I've seen, it's full of application generated errors
that will never be fixed, connection logging, statement logging, and
other stuff that is there just in case but will normally be ignored.
Finding the messages that indicate real database problems is typically
quite difficult, even if they're all enabled. If they're disabled by
default, well then the useless crap is the ONLY thing you find in the
log file, and when the customer has a problem, the first thing you
have to do is tell them to turn on all the GUCs that log the actually
important stuff and wait until the problem recurs.

I have yet to run into a customer who was thrilled about receiving that message.

-- 
Robert Haas
EDB: http://www.enterprisedb.com






^ permalink  raw  reply  [nested|flat] 15+ messages in thread

* Re: Set log_lock_waits=on by default
  2024-01-24 17:19 Re: Set log_lock_waits=on by default Michael Banck <[email protected]>
  2024-07-18 10:25 ` Re: Set log_lock_waits=on by default Michael Banck <[email protected]>
  2024-07-19 09:54   ` Re: Set log_lock_waits=on by default Laurenz Albe <[email protected]>
@ 2024-07-19 14:29     ` Jelte Fennema-Nio <[email protected]>
  2 siblings, 0 replies; 15+ messages in thread

From: Jelte Fennema-Nio @ 2024-07-19 14:29 UTC (permalink / raw)
  To: Laurenz Albe <[email protected]>; +Cc: Michael Banck <[email protected]>; Tom Lane <[email protected]>; Nathan Bossart <[email protected]>; [email protected]

Late to the party, but +1 from me on this default change also

On Fri, 19 Jul 2024 at 11:54, Laurenz Albe <[email protected]> wrote:

> On Thu, 2024-07-18 at 12:25 +0200, Michael Banck wrote:
> > this patch is still on the table, though for v18 now.
> >
> > Nathan mentioned up-thread that he was hesitant to commit this without
> > further discussion. Laurenz, Stephen and I are +1 on this, but when it
> > comes to committers having chimed in only Tom did so far and was -1.
> >
> > Are there any others who have an opinion on this?
>
> If we want to tally up, there were also +1 votes from Christoph Berg,
> Shinya Kato, Nikolay Samokhvalov, Jeremy Schneider and Frédéric Yhuel.
>
> The major criticism is Tom's that it might unduly increase the log volume.
>
> I'm not trying to rush things, but I see little point in kicking a trivial
> patch like this through many commitfests.  If no committer wants to step
> up and commit this, it should be rejected.
>
> Yours,
> Laurenz Albe
>
>
>


^ permalink  raw  reply  [nested|flat] 15+ messages in thread

* Re: Set log_lock_waits=on by default
  2024-01-24 17:19 Re: Set log_lock_waits=on by default Michael Banck <[email protected]>
  2024-07-18 10:25 ` Re: Set log_lock_waits=on by default Michael Banck <[email protected]>
  2024-07-19 09:54   ` Re: Set log_lock_waits=on by default Laurenz Albe <[email protected]>
@ 2025-04-08 14:32     ` Laurenz Albe <[email protected]>
  2025-09-04 05:12       ` Re: Set log_lock_waits=on by default Shinya Kato <[email protected]>
  2 siblings, 1 reply; 15+ messages in thread

From: Laurenz Albe @ 2025-04-08 14:32 UTC (permalink / raw)
  To: Michael Banck <[email protected]>; Tom Lane <[email protected]>; +Cc: Nathan Bossart <[email protected]>; [email protected]

On Fri, 2024-07-19 at 11:54 +0200, Laurenz Albe wrote:
> On Thu, 2024-07-18 at 12:25 +0200, Michael Banck wrote:
> > this patch is still on the table, though for v18 now.
> > 
> > Nathan mentioned up-thread that he was hesitant to commit this without
> > further discussion. Laurenz, Stephen and I are +1 on this, but when it 
> > comes to committers having chimed in only Tom did so far and was -1.
> > 
> > Are there any others who have an opinion on this?
> 
> If we want to tally up, there were also +1 votes from Christoph Berg,
> Shinya Kato, Nikolay Samokhvalov, Jeremy Schneider and Frédéric Yhuel.
> 
> The major criticism is Tom's that it might unduly increase the log volume.
> 
> I'm not trying to rush things, but I see little point in kicking a trivial
> patch like this through many commitfests.  If no committer wants to step
> up and commit this, it should be rejected.

Well, it didn't make v18.

But this patch got enough votes in favor that I am not going to withdraw it.

Yours,
Laurenz Albe






^ permalink  raw  reply  [nested|flat] 15+ messages in thread

* Re: Set log_lock_waits=on by default
  2024-01-24 17:19 Re: Set log_lock_waits=on by default Michael Banck <[email protected]>
  2024-07-18 10:25 ` Re: Set log_lock_waits=on by default Michael Banck <[email protected]>
  2024-07-19 09:54   ` Re: Set log_lock_waits=on by default Laurenz Albe <[email protected]>
  2025-04-08 14:32     ` Re: Set log_lock_waits=on by default Laurenz Albe <[email protected]>
@ 2025-09-04 05:12       ` Shinya Kato <[email protected]>
  2025-09-07 21:46         ` Re: Set log_lock_waits=on by default Laurenz Albe <[email protected]>
  0 siblings, 1 reply; 15+ messages in thread

From: Shinya Kato @ 2025-09-04 05:12 UTC (permalink / raw)
  To: Laurenz Albe <[email protected]>; +Cc: Michael Banck <[email protected]>; Tom Lane <[email protected]>; Nathan Bossart <[email protected]>; [email protected]

Hi,

On Tue, Apr 8, 2025 at 11:33 PM Laurenz Albe <[email protected]> wrote:
> Well, it didn't make v18.
>
> But this patch got enough votes in favor that I am not going to withdraw it.

Thank you for discussing it.

diff --git a/src/backend/utils/misc/guc_tables.c
b/src/backend/utils/misc/guc_tables.c
index f7c9882f7c..1f3d56e6ee 100644
--- a/src/backend/utils/misc/guc_tables.c
+++ b/src/backend/utils/misc/guc_tables.c
@@ -1519,7 +1519,7 @@ struct config_bool ConfigureNamesBool[] =
  NULL
  },
  &log_lock_waits,
- false,
+ true,
  NULL, NULL, NULL
  },
  {

Due to 635998965 [0], you need to change guc_parameters.dat instead of
guc_tables.c.

[0] https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=63599896545c7869f7dd28cd593e8b548983d...


--
Best regards,
Shinya Kato
NTT OSS Center





^ permalink  raw  reply  [nested|flat] 15+ messages in thread

* Re: Set log_lock_waits=on by default
  2024-01-24 17:19 Re: Set log_lock_waits=on by default Michael Banck <[email protected]>
  2024-07-18 10:25 ` Re: Set log_lock_waits=on by default Michael Banck <[email protected]>
  2024-07-19 09:54   ` Re: Set log_lock_waits=on by default Laurenz Albe <[email protected]>
  2025-04-08 14:32     ` Re: Set log_lock_waits=on by default Laurenz Albe <[email protected]>
  2025-09-04 05:12       ` Re: Set log_lock_waits=on by default Shinya Kato <[email protected]>
@ 2025-09-07 21:46         ` Laurenz Albe <[email protected]>
  2025-09-08 02:38           ` Re: Set log_lock_waits=on by default Chao Li <[email protected]>
  2025-09-12 06:06           ` Re: Set log_lock_waits=on by default Peter Eisentraut <[email protected]>
  0 siblings, 2 replies; 15+ messages in thread

From: Laurenz Albe @ 2025-09-07 21:46 UTC (permalink / raw)
  To: Shinya Kato <[email protected]>; +Cc: Michael Banck <[email protected]>; Tom Lane <[email protected]>; Nathan Bossart <[email protected]>; [email protected]

On Thu, 2025-09-04 at 14:12 +0900, Shinya Kato wrote:
> Due to 635998965 [0], you need to change guc_parameters.dat instead of
> guc_tables.c.

Thanks for pointing that out to me!
Here is an updated patch.

Yours,
Laurenz Albe


Attachments:

  [text/x-patch] v2-0001-Default-to-log_lock_waits-on.patch (3.2K, ../../[email protected]/2-v2-0001-Default-to-log_lock_waits-on.patch)
  download | inline diff:
From aa04f6cf6e7c89f1107ffc6eb661da65082459fe Mon Sep 17 00:00:00 2001
From: Laurenz Albe <[email protected]>
Date: Sun, 7 Sep 2025 23:44:38 +0200
Subject: [PATCH v2] Default to log_lock_waits=on

If someone is stuck behind a lock for more than a second,
that is almost always a problem that is worth a log entry.

Author: Laurenz Albe <[email protected]>
Reviewed-By: Michael Banck <[email protected]>
Reviewed-By: Robert Haas <[email protected]>
Reviewed-By: Christoph Berg <[email protected]>
Reviewed-By: Stephen Frost <[email protected]>
Discussion: https://postgr.es/m/b8b8502915e50f44deb111bc0b43a99e2733e117.camel%40cybertec.at
---
 doc/src/sgml/config.sgml                      | 2 +-
 src/backend/storage/lmgr/proc.c               | 2 +-
 src/backend/utils/misc/guc_parameters.dat     | 2 +-
 src/backend/utils/misc/postgresql.conf.sample | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index 2a3685f474a..3c33d5d0fbc 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -7929,7 +7929,7 @@ log_line_prefix = '%m [%p] %q%u@%d/%a '
         Controls whether a log message is produced when a session waits
         longer than <xref linkend="guc-deadlock-timeout"/> to acquire a
         lock.  This is useful in determining if lock waits are causing
-        poor performance.  The default is <literal>off</literal>.
+        poor performance.  The default is <literal>on</literal>.
         Only superusers and users with the appropriate <literal>SET</literal>
         privilege can change this setting.
        </para>
diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c
index e9ef0fbfe32..96f29aafc39 100644
--- a/src/backend/storage/lmgr/proc.c
+++ b/src/backend/storage/lmgr/proc.c
@@ -60,7 +60,7 @@ int			LockTimeout = 0;
 int			IdleInTransactionSessionTimeout = 0;
 int			TransactionTimeout = 0;
 int			IdleSessionTimeout = 0;
-bool		log_lock_waits = false;
+bool		log_lock_waits = true;
 
 /* Pointer to this process's PGPROC struct, if any */
 PGPROC	   *MyProc = NULL;
diff --git a/src/backend/utils/misc/guc_parameters.dat b/src/backend/utils/misc/guc_parameters.dat
index 0da01627cfe..6bc6be13d2a 100644
--- a/src/backend/utils/misc/guc_parameters.dat
+++ b/src/backend/utils/misc/guc_parameters.dat
@@ -566,7 +566,7 @@
 { name => 'log_lock_waits', type => 'bool', context => 'PGC_SUSET', group => 'LOGGING_WHAT',
   short_desc => 'Logs long lock waits.',
   variable => 'log_lock_waits',
-  boot_val => 'false',
+  boot_val => 'true',
 },
 
 { name => 'log_lock_failures', type => 'bool', context => 'PGC_SUSET', group => 'LOGGING_WHAT',
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
index 26c08693564..c36fcb9ab61 100644
--- a/src/backend/utils/misc/postgresql.conf.sample
+++ b/src/backend/utils/misc/postgresql.conf.sample
@@ -624,7 +624,7 @@
 					#        processes
 					#   %% = '%'
 					# e.g. '<%u%%%d> '
-#log_lock_waits = off			# log lock waits >= deadlock_timeout
+#log_lock_waits = on			# log lock waits >= deadlock_timeout
 #log_lock_failures = off		# log lock failures
 #log_recovery_conflict_waits = off	# log standby recovery conflict waits
 					# >= deadlock_timeout
-- 
2.51.0



^ permalink  raw  reply  [nested|flat] 15+ messages in thread

* Re: Set log_lock_waits=on by default
  2024-01-24 17:19 Re: Set log_lock_waits=on by default Michael Banck <[email protected]>
  2024-07-18 10:25 ` Re: Set log_lock_waits=on by default Michael Banck <[email protected]>
  2024-07-19 09:54   ` Re: Set log_lock_waits=on by default Laurenz Albe <[email protected]>
  2025-04-08 14:32     ` Re: Set log_lock_waits=on by default Laurenz Albe <[email protected]>
  2025-09-04 05:12       ` Re: Set log_lock_waits=on by default Shinya Kato <[email protected]>
  2025-09-07 21:46         ` Re: Set log_lock_waits=on by default Laurenz Albe <[email protected]>
@ 2025-09-08 02:38           ` Chao Li <[email protected]>
  2025-09-08 07:03             ` Re: Set log_lock_waits=on by default Laurenz Albe <[email protected]>
  1 sibling, 1 reply; 15+ messages in thread

From: Chao Li @ 2025-09-08 02:38 UTC (permalink / raw)
  To: Laurenz Albe <[email protected]>; +Cc: Shinya Kato <[email protected]>; Michael Banck <[email protected]>; Tom Lane <[email protected]>; Nathan Bossart <[email protected]>; [email protected]



> On Sep 8, 2025, at 05:46, Laurenz Albe <[email protected]> wrote:
> 
> On Thu, 2025-09-04 at 14:12 +0900, Shinya Kato wrote:
>> Due to 635998965 [0], you need to change guc_parameters.dat instead of
>> guc_tables.c.
> 
> Thanks for pointing that out to me!
> Here is an updated patch.
> 
> Yours,
> Laurenz Albe
> <v2-0001-Default-to-log_lock_waits-on.patch>


I am hesitate to support this change. I agree log_lock_waits is a powerful tool, but it’s more like a diagnostic tool. On a high-concurrency system with many tractions running at the same time, it may quickly fill up log files and make it difficult to find other errors. So, we usually only turn it on when needed, and turn it off once debugging is done.

But v2 code looks good to me.

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/






^ permalink  raw  reply  [nested|flat] 15+ messages in thread

* Re: Set log_lock_waits=on by default
  2024-01-24 17:19 Re: Set log_lock_waits=on by default Michael Banck <[email protected]>
  2024-07-18 10:25 ` Re: Set log_lock_waits=on by default Michael Banck <[email protected]>
  2024-07-19 09:54   ` Re: Set log_lock_waits=on by default Laurenz Albe <[email protected]>
  2025-04-08 14:32     ` Re: Set log_lock_waits=on by default Laurenz Albe <[email protected]>
  2025-09-04 05:12       ` Re: Set log_lock_waits=on by default Shinya Kato <[email protected]>
  2025-09-07 21:46         ` Re: Set log_lock_waits=on by default Laurenz Albe <[email protected]>
  2025-09-08 02:38           ` Re: Set log_lock_waits=on by default Chao Li <[email protected]>
@ 2025-09-08 07:03             ` Laurenz Albe <[email protected]>
  0 siblings, 0 replies; 15+ messages in thread

From: Laurenz Albe @ 2025-09-08 07:03 UTC (permalink / raw)
  To: Chao Li <[email protected]>; +Cc: Shinya Kato <[email protected]>; Michael Banck <[email protected]>; Tom Lane <[email protected]>; Nathan Bossart <[email protected]>; [email protected]

On Mon, 2025-09-08 at 10:38 +0800, Chao Li wrote:
> I am hesitate to support this change. I agree log_lock_waits is a powerful tool,
> but it’s more like a diagnostic tool. On a high-concurrency system with many tractions
> running at the same time, it may quickly fill up log files and make it difficult
> to find other errors. So, we usually only turn it on when needed, and turn it off
> once debugging is done.

You still can do that - only the default changed.

I think that if your log fills up with messages indicating that sessions are stuck
behind a lock for more than one second, and it is a high concurrency system, you
have got a severe problem that you want to know about.

What I argue is that while log_lock_waits=on is not the correct setting for
everybody, it is the correct setting for the vast majority of databases.

Yours,
Laurenz Albe





^ permalink  raw  reply  [nested|flat] 15+ messages in thread

* Re: Set log_lock_waits=on by default
  2024-01-24 17:19 Re: Set log_lock_waits=on by default Michael Banck <[email protected]>
  2024-07-18 10:25 ` Re: Set log_lock_waits=on by default Michael Banck <[email protected]>
  2024-07-19 09:54   ` Re: Set log_lock_waits=on by default Laurenz Albe <[email protected]>
  2025-04-08 14:32     ` Re: Set log_lock_waits=on by default Laurenz Albe <[email protected]>
  2025-09-04 05:12       ` Re: Set log_lock_waits=on by default Shinya Kato <[email protected]>
  2025-09-07 21:46         ` Re: Set log_lock_waits=on by default Laurenz Albe <[email protected]>
@ 2025-09-12 06:06           ` Peter Eisentraut <[email protected]>
  2025-09-12 07:01             ` Re: Set log_lock_waits=on by default Laurenz Albe <[email protected]>
  1 sibling, 1 reply; 15+ messages in thread

From: Peter Eisentraut @ 2025-09-12 06:06 UTC (permalink / raw)
  To: Laurenz Albe <[email protected]>; Shinya Kato <[email protected]>; +Cc: Michael Banck <[email protected]>; Tom Lane <[email protected]>; Nathan Bossart <[email protected]>; [email protected]

On 07.09.25 23:46, Laurenz Albe wrote:
> On Thu, 2025-09-04 at 14:12 +0900, Shinya Kato wrote:
>> Due to 635998965 [0], you need to change guc_parameters.dat instead of
>> guc_tables.c.
> 
> Thanks for pointing that out to me!
> Here is an updated patch.

committed






^ permalink  raw  reply  [nested|flat] 15+ messages in thread

* Re: Set log_lock_waits=on by default
  2024-01-24 17:19 Re: Set log_lock_waits=on by default Michael Banck <[email protected]>
  2024-07-18 10:25 ` Re: Set log_lock_waits=on by default Michael Banck <[email protected]>
  2024-07-19 09:54   ` Re: Set log_lock_waits=on by default Laurenz Albe <[email protected]>
  2025-04-08 14:32     ` Re: Set log_lock_waits=on by default Laurenz Albe <[email protected]>
  2025-09-04 05:12       ` Re: Set log_lock_waits=on by default Shinya Kato <[email protected]>
  2025-09-07 21:46         ` Re: Set log_lock_waits=on by default Laurenz Albe <[email protected]>
  2025-09-12 06:06           ` Re: Set log_lock_waits=on by default Peter Eisentraut <[email protected]>
@ 2025-09-12 07:01             ` Laurenz Albe <[email protected]>
  0 siblings, 0 replies; 15+ messages in thread

From: Laurenz Albe @ 2025-09-12 07:01 UTC (permalink / raw)
  To: Peter Eisentraut <[email protected]>; Shinya Kato <[email protected]>; +Cc: Michael Banck <[email protected]>; Tom Lane <[email protected]>; Nathan Bossart <[email protected]>; [email protected]

On Fri, 2025-09-12 at 08:06 +0200, Peter Eisentraut wrote:
> committed

Thank you!

Laurenz Albe





^ permalink  raw  reply  [nested|flat] 15+ messages in thread

* Re: Set log_lock_waits=on by default
  2024-01-24 17:19 Re: Set log_lock_waits=on by default Michael Banck <[email protected]>
  2024-07-18 10:25 ` Re: Set log_lock_waits=on by default Michael Banck <[email protected]>
@ 2024-07-19 14:28   ` Greg Sabino Mullane <[email protected]>
  1 sibling, 0 replies; 15+ messages in thread

From: Greg Sabino Mullane @ 2024-07-19 14:28 UTC (permalink / raw)
  To: Michael Banck <[email protected]>; +Cc: Tom Lane <[email protected]>; Nathan Bossart <[email protected]>; Laurenz Albe <[email protected]>; [email protected]

>
> Are there any others who have an opinion on this?


Big +1 to having it on by default. It's already one of the first things I
turn on by default on any system I come across. The log spam is minimal,
compared to all the other stuff that ends up in there. And unlike most of
that stuff, this is output you generally want and need, when problems start
occurring.

Cheers,
Greg


^ permalink  raw  reply  [nested|flat] 15+ messages in thread

* [PATCH v26 1/9] Row pattern recognition patch for raw parser.
@ 2024-12-30 12:44 Tatsuo Ishii <[email protected]>
  0 siblings, 0 replies; 15+ messages in thread

From: Tatsuo Ishii @ 2024-12-30 12:44 UTC (permalink / raw)

---
 src/backend/parser/gram.y       | 221 ++++++++++++++++++++++++++++++--
 src/include/nodes/parsenodes.h  |  67 ++++++++++
 src/include/parser/kwlist.h     |   8 ++
 src/include/parser/parse_node.h |   1 +
 4 files changed, 286 insertions(+), 11 deletions(-)

diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index bd5ebb35c4..52f9896eda 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -664,6 +664,21 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
 				json_object_constructor_null_clause_opt
 				json_array_constructor_null_clause_opt
 
+%type <target>	row_pattern_measure_item
+				row_pattern_definition
+%type <node>	opt_row_pattern_common_syntax
+				opt_row_pattern_skip_to
+				row_pattern_subset_item
+				row_pattern_term
+%type <list>	opt_row_pattern_measures
+				row_pattern_measure_list
+				row_pattern_definition_list
+				opt_row_pattern_subset_clause
+				row_pattern_subset_list
+				row_pattern_subset_rhs
+				row_pattern
+%type <boolean>	opt_row_pattern_initial_or_seek
+				first_or_last
 
 /*
  * Non-keyword token types.  These are hard-wired into the "flex" lexer.
@@ -707,7 +722,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
 	CURRENT_TIME CURRENT_TIMESTAMP CURRENT_USER CURSOR CYCLE
 
 	DATA_P DATABASE DAY_P DEALLOCATE DEC DECIMAL_P DECLARE DEFAULT DEFAULTS
-	DEFERRABLE DEFERRED DEFINER DELETE_P DELIMITER DELIMITERS DEPENDS DEPTH DESC
+	DEFERRABLE DEFERRED DEFINE DEFINER DELETE_P DELIMITER DELIMITERS DEPENDS DEPTH DESC
 	DETACH DICTIONARY DISABLE_P DISCARD DISTINCT DO DOCUMENT_P DOMAIN_P
 	DOUBLE_P DROP
 
@@ -723,7 +738,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
 	HANDLER HAVING HEADER_P HOLD HOUR_P
 
 	IDENTITY_P IF_P ILIKE IMMEDIATE IMMUTABLE IMPLICIT_P IMPORT_P IN_P INCLUDE
-	INCLUDING INCREMENT INDENT INDEX INDEXES INHERIT INHERITS INITIALLY INLINE_P
+	INCLUDING INCREMENT INDENT INDEX INDEXES INHERIT INHERITS INITIAL INITIALLY INLINE_P
 	INNER_P INOUT INPUT_P INSENSITIVE INSERT INSTEAD INT_P INTEGER
 	INTERSECT INTERVAL INTO INVOKER IS ISNULL ISOLATION
 
@@ -736,7 +751,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
 	LEADING LEAKPROOF LEAST LEFT LEVEL LIKE LIMIT LISTEN LOAD LOCAL
 	LOCALTIME LOCALTIMESTAMP LOCATION LOCK_P LOCKED LOGGED
 
-	MAPPING MATCH MATCHED MATERIALIZED MAXVALUE MERGE MERGE_ACTION METHOD
+	MAPPING MATCH MATCHED MATERIALIZED MAXVALUE MEASURES MERGE MERGE_ACTION METHOD
 	MINUTE_P MINVALUE MODE MONTH_P MOVE
 
 	NAME_P NAMES NATIONAL NATURAL NCHAR NESTED NEW NEXT NFC NFD NFKC NFKD NO
@@ -748,8 +763,9 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
 	ORDER ORDINALITY OTHERS OUT_P OUTER_P
 	OVER OVERLAPS OVERLAY OVERRIDING OWNED OWNER
 
-	PARALLEL PARAMETER PARSER PARTIAL PARTITION PASSING PASSWORD PATH
-	PERIOD PLACING PLAN PLANS POLICY
+	PARALLEL PARAMETER PARSER PARTIAL PARTITION PASSING PASSWORD PAST
+	PATH PATTERN_P PERIOD PERMUTE PLACING PLAN PLANS POLICY
+
 	POSITION PRECEDING PRECISION PRESERVE PREPARE PREPARED PRIMARY
 	PRIOR PRIVILEGES PROCEDURAL PROCEDURE PROCEDURES PROGRAM PUBLICATION
 
@@ -760,12 +776,13 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
 	RESET RESTART RESTRICT RETURN RETURNING RETURNS REVOKE RIGHT ROLE ROLLBACK ROLLUP
 	ROUTINE ROUTINES ROW ROWS RULE
 
-	SAVEPOINT SCALAR SCHEMA SCHEMAS SCROLL SEARCH SECOND_P SECURITY SELECT
+	SAVEPOINT SCALAR SCHEMA SCHEMAS SCROLL SEARCH SECOND_P SECURITY SEEK SELECT
 	SEQUENCE SEQUENCES
+
 	SERIALIZABLE SERVER SESSION SESSION_USER SET SETS SETOF SHARE SHOW
 	SIMILAR SIMPLE SKIP SMALLINT SNAPSHOT SOME SOURCE SQL_P STABLE STANDALONE_P
 	START STATEMENT STATISTICS STDIN STDOUT STORAGE STORED STRICT_P STRING_P STRIP_P
-	SUBSCRIPTION SUBSTRING SUPPORT SYMMETRIC SYSID SYSTEM_P SYSTEM_USER
+	SUBSCRIPTION SUBSET SUBSTRING SUPPORT SYMMETRIC SYSID SYSTEM_P SYSTEM_USER
 
 	TABLE TABLES TABLESAMPLE TABLESPACE TARGET TEMP TEMPLATE TEMPORARY TEXT_P THEN
 	TIES TIME TIMESTAMP TO TRAILING TRANSACTION TRANSFORM
@@ -874,6 +891,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
 %nonassoc	UNBOUNDED NESTED /* ideally would have same precedence as IDENT */
 %nonassoc	IDENT PARTITION RANGE ROWS GROUPS PRECEDING FOLLOWING CUBE ROLLUP
 			SET KEYS OBJECT_P SCALAR VALUE_P WITH WITHOUT PATH
+			MEASURES AFTER INITIAL SEEK PATTERN_P
 %left		Op OPERATOR		/* multi-character ops and user-defined operators */
 %left		'+' '-'
 %left		'*' '/' '%'
@@ -16326,7 +16344,8 @@ over_clause: OVER window_specification
 		;
 
 window_specification: '(' opt_existing_window_name opt_partition_clause
-						opt_sort_clause opt_frame_clause ')'
+						opt_sort_clause opt_row_pattern_measures opt_frame_clause
+						opt_row_pattern_common_syntax ')'
 				{
 					WindowDef  *n = makeNode(WindowDef);
 
@@ -16334,10 +16353,12 @@ window_specification: '(' opt_existing_window_name opt_partition_clause
 					n->refname = $2;
 					n->partitionClause = $3;
 					n->orderClause = $4;
+					n->rowPatternMeasures = $5;
 					/* copy relevant fields of opt_frame_clause */
-					n->frameOptions = $5->frameOptions;
-					n->startOffset = $5->startOffset;
-					n->endOffset = $5->endOffset;
+					n->frameOptions = $6->frameOptions;
+					n->startOffset = $6->startOffset;
+					n->endOffset = $6->endOffset;
+					n->rpCommonSyntax = (RPCommonSyntax *)$7;
 					n->location = @1;
 					$$ = n;
 				}
@@ -16361,6 +16382,31 @@ opt_partition_clause: PARTITION BY expr_list		{ $$ = $3; }
 			| /*EMPTY*/								{ $$ = NIL; }
 		;
 
+/*
+ * ROW PATTERN_P MEASURES
+ */
+opt_row_pattern_measures: MEASURES row_pattern_measure_list	{ $$ = $2; }
+			| /*EMPTY*/								{ $$ = NIL; }
+		;
+
+row_pattern_measure_list:
+			row_pattern_measure_item
+					{ $$ = list_make1($1); }
+			| row_pattern_measure_list ',' row_pattern_measure_item
+					{ $$ = lappend($1, $3); }
+		;
+
+row_pattern_measure_item:
+			a_expr AS ColLabel
+				{
+					$$ = makeNode(ResTarget);
+					$$->name = $3;
+					$$->indirection = NIL;
+					$$->val = (Node *) $1;
+					$$->location = @1;
+				}
+		;
+
 /*
  * For frame clauses, we return a WindowDef, but only some fields are used:
  * frameOptions, startOffset, and endOffset.
@@ -16520,6 +16566,143 @@ opt_window_exclusion_clause:
 			| /*EMPTY*/				{ $$ = 0; }
 		;
 
+opt_row_pattern_common_syntax:
+opt_row_pattern_skip_to opt_row_pattern_initial_or_seek
+				PATTERN_P '(' row_pattern ')'
+				opt_row_pattern_subset_clause
+				DEFINE row_pattern_definition_list
+			{
+				RPCommonSyntax *n = makeNode(RPCommonSyntax);
+				n->rpSkipTo = ((RPCommonSyntax *)$1)->rpSkipTo;
+				n->rpSkipVariable = ((RPCommonSyntax *)$1)->rpSkipVariable;
+				n->initial = $2;
+				n->rpPatterns = $5;
+				n->rpSubsetClause = $7;
+				n->rpDefs = $9;
+				$$ = (Node *) n;
+			}
+			| /*EMPTY*/		{ $$ = NULL; }
+	;
+
+opt_row_pattern_skip_to:
+			AFTER MATCH SKIP TO NEXT ROW
+				{
+					RPCommonSyntax *n = makeNode(RPCommonSyntax);
+					n->rpSkipTo = ST_NEXT_ROW;
+					n->rpSkipVariable = NULL;
+					$$ = (Node *) n;
+			}
+			| AFTER MATCH SKIP PAST LAST_P ROW
+				{
+					RPCommonSyntax *n = makeNode(RPCommonSyntax);
+					n->rpSkipTo = ST_PAST_LAST_ROW;
+					n->rpSkipVariable = NULL;
+					$$ = (Node *) n;
+				}
+			| AFTER MATCH SKIP TO first_or_last ColId
+				{
+					RPCommonSyntax *n = makeNode(RPCommonSyntax);
+					n->rpSkipTo = $5? ST_FIRST_VARIABLE : ST_LAST_VARIABLE;
+					n->rpSkipVariable = $6;
+					$$ = (Node *) n;
+				}
+/*
+			| AFTER MATCH SKIP TO LAST_P ColId		%prec LAST_P
+				{
+					RPCommonSyntax *n = makeNode(RPCommonSyntax);
+					n->rpSkipTo = ST_LAST_VARIABLE;
+					n->rpSkipVariable = $6;
+					$$ = n;
+				}
+			| AFTER MATCH SKIP TO ColId
+				{
+					RPCommonSyntax *n = makeNode(RPCommonSyntax);
+					n->rpSkipTo = ST_VARIABLE;
+					n->rpSkipVariable = $5;
+					$$ = n;
+				}
+*/
+			| /*EMPTY*/
+				{
+					RPCommonSyntax *n = makeNode(RPCommonSyntax);
+					/* temporary set default to ST_NEXT_ROW */
+					n->rpSkipTo = ST_PAST_LAST_ROW;
+					n->rpSkipVariable = NULL;
+					$$ = (Node *) n;
+				}
+	;
+
+first_or_last:
+			FIRST_P		{ $$ = true; }
+			| LAST_P	{ $$ = false; }
+	;
+
+opt_row_pattern_initial_or_seek:
+			INITIAL			{ $$ = true; }
+			| SEEK
+				{
+					ereport(ERROR,
+							(errcode(ERRCODE_SYNTAX_ERROR),
+							 errmsg("SEEK is not supported"),
+							 errhint("Use INITIAL."),
+							 parser_errposition(@1)));
+				}
+			| /*EMPTY*/		{ $$ = true; }
+		;
+
+row_pattern:
+			row_pattern_term							{ $$ = list_make1($1); }
+			| row_pattern row_pattern_term				{ $$ = lappend($1, $2); }
+		;
+
+row_pattern_term:
+			ColId	{ $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "", (Node *)makeString($1), NULL, @1); }
+			| ColId '*'	{ $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "*", (Node *)makeString($1), NULL, @1); }
+			| ColId '+'	{ $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "+", (Node *)makeString($1), NULL, @1); }
+			| ColId '?'	{ $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "?", (Node *)makeString($1), NULL, @1); }
+		;
+
+opt_row_pattern_subset_clause:
+			SUBSET row_pattern_subset_list	{ $$ = $2; }
+			| /*EMPTY*/												{ $$ = NIL; }
+		;
+
+row_pattern_subset_list:
+			row_pattern_subset_item									{ $$ = list_make1($1); }
+			| row_pattern_subset_list ',' row_pattern_subset_item	{ $$ = lappend($1, $3); }
+			| /*EMPTY*/												{ $$ = NIL; }
+		;
+
+row_pattern_subset_item: ColId '=' '(' row_pattern_subset_rhs ')'
+			{
+				RPSubsetItem *n = makeNode(RPSubsetItem);
+				n->name = $1;
+				n->rhsVariable = $4;
+				$$ = (Node *) n;
+			}
+		;
+
+row_pattern_subset_rhs:
+			ColId								{ $$ = list_make1(makeStringConst($1, @1)); }
+			| row_pattern_subset_rhs ',' ColId	{ $$ = lappend($1, makeStringConst($3, @1)); }
+			| /*EMPTY*/							{ $$ = NIL; }
+		;
+
+row_pattern_definition_list:
+			row_pattern_definition										{ $$ = list_make1($1); }
+			| row_pattern_definition_list ',' row_pattern_definition	{ $$ = lappend($1, $3); }
+		;
+
+row_pattern_definition:
+			ColId AS a_expr
+				{
+					$$ = makeNode(ResTarget);
+					$$->name = $1;
+					$$->indirection = NIL;
+					$$->val = (Node *) $3;
+					$$->location = @1;
+				}
+		;
 
 /*
  * Supporting nonterminals for expressions.
@@ -17732,6 +17915,7 @@ unreserved_keyword:
 			| INDEXES
 			| INHERIT
 			| INHERITS
+			| INITIAL
 			| INLINE_P
 			| INPUT_P
 			| INSENSITIVE
@@ -17760,6 +17944,7 @@ unreserved_keyword:
 			| MATCHED
 			| MATERIALIZED
 			| MAXVALUE
+			| MEASURES
 			| MERGE
 			| METHOD
 			| MINUTE_P
@@ -17804,8 +17989,11 @@ unreserved_keyword:
 			| PARTITION
 			| PASSING
 			| PASSWORD
+			| PAST
 			| PATH
+			| PATTERN_P
 			| PERIOD
+			| PERMUTE
 			| PLAN
 			| PLANS
 			| POLICY
@@ -17857,6 +18045,7 @@ unreserved_keyword:
 			| SEARCH
 			| SECOND_P
 			| SECURITY
+			| SEEK
 			| SEQUENCE
 			| SEQUENCES
 			| SERIALIZABLE
@@ -17884,6 +18073,7 @@ unreserved_keyword:
 			| STRING_P
 			| STRIP_P
 			| SUBSCRIPTION
+			| SUBSET
 			| SUPPORT
 			| SYSID
 			| SYSTEM_P
@@ -18078,6 +18268,7 @@ reserved_keyword:
 			| CURRENT_USER
 			| DEFAULT
 			| DEFERRABLE
+			| DEFINE
 			| DESC
 			| DISTINCT
 			| DO
@@ -18241,6 +18432,7 @@ bare_label_keyword:
 			| DEFAULTS
 			| DEFERRABLE
 			| DEFERRED
+			| DEFINE
 			| DEFINER
 			| DELETE_P
 			| DELIMITER
@@ -18318,6 +18510,7 @@ bare_label_keyword:
 			| INDEXES
 			| INHERIT
 			| INHERITS
+			| INITIAL
 			| INITIALLY
 			| INLINE_P
 			| INNER_P
@@ -18372,6 +18565,7 @@ bare_label_keyword:
 			| MATCHED
 			| MATERIALIZED
 			| MAXVALUE
+			| MEASURES
 			| MERGE
 			| MERGE_ACTION
 			| METHOD
@@ -18428,8 +18622,11 @@ bare_label_keyword:
 			| PARTITION
 			| PASSING
 			| PASSWORD
+			| PAST
 			| PATH
+			| PATTERN_P
 			| PERIOD
+			| PERMUTE
 			| PLACING
 			| PLAN
 			| PLANS
@@ -18487,6 +18684,7 @@ bare_label_keyword:
 			| SCROLL
 			| SEARCH
 			| SECURITY
+			| SEEK
 			| SELECT
 			| SEQUENCE
 			| SEQUENCES
@@ -18520,6 +18718,7 @@ bare_label_keyword:
 			| STRING_P
 			| STRIP_P
 			| SUBSCRIPTION
+			| SUBSET
 			| SUBSTRING
 			| SUPPORT
 			| SYMMETRIC
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index 0f9462493e..defc62bf9b 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -552,6 +552,48 @@ typedef struct SortBy
 	ParseLoc	location;		/* operator location, or -1 if none/unknown */
 } SortBy;
 
+/*
+ * AFTER MATCH row pattern skip to types in row pattern common syntax
+ */
+typedef enum RPSkipTo
+{
+	ST_NONE,					/* AFTER MATCH omitted */
+	ST_NEXT_ROW,				/* SKIP TO NEXT ROW */
+	ST_PAST_LAST_ROW,			/* SKIP TO PAST LAST ROW */
+	ST_FIRST_VARIABLE,			/* SKIP TO FIRST variable name */
+	ST_LAST_VARIABLE,			/* SKIP TO LAST variable name */
+	ST_VARIABLE					/* SKIP TO variable name */
+} RPSkipTo;
+
+/*
+ * Row Pattern SUBSET clause item
+ */
+typedef struct RPSubsetItem
+{
+	NodeTag		type;
+	char	   *name;			/* Row Pattern SUBSET clause variable name */
+	List	   *rhsVariable;	/* Row Pattern SUBSET rhs variables (list of
+								 * char *string) */
+} RPSubsetItem;
+
+/*
+ * RowPatternCommonSyntax - raw representation of row pattern common syntax
+ *
+ */
+typedef struct RPCommonSyntax
+{
+	NodeTag		type;
+	RPSkipTo	rpSkipTo;		/* Row Pattern AFTER MATCH SKIP type */
+	char	   *rpSkipVariable; /* Row Pattern Skip To variable name, if any */
+	bool		initial;		/* true if <row pattern initial or seek> is
+								 * initial */
+	List	   *rpPatterns;		/* PATTERN variables (list of A_Expr) */
+	List	   *rpSubsetClause; /* row pattern subset clause (list of
+								 * RPSubsetItem), if any */
+	List	   *rpDefs;			/* row pattern definitions clause (list of
+								 * ResTarget) */
+} RPCommonSyntax;
+
 /*
  * WindowDef - raw representation of WINDOW and OVER clauses
  *
@@ -567,6 +609,9 @@ typedef struct WindowDef
 	char	   *refname;		/* referenced window name, if any */
 	List	   *partitionClause;	/* PARTITION BY expression list */
 	List	   *orderClause;	/* ORDER BY (list of SortBy) */
+	List	   *rowPatternMeasures; /* row pattern measures (list of
+									 * ResTarget) */
+	RPCommonSyntax *rpCommonSyntax; /* row pattern common syntax */
 	int			frameOptions;	/* frame_clause options, see below */
 	Node	   *startOffset;	/* expression for starting bound, if any */
 	Node	   *endOffset;		/* expression for ending bound, if any */
@@ -1530,6 +1575,11 @@ typedef struct GroupingSet
  * the orderClause might or might not be copied (see copiedOrder); the framing
  * options are never copied, per spec.
  *
+ * "defineClause" is Row Pattern Recognition DEFINE clause (list of
+ * TargetEntry). TargetEntry.resname represents row pattern definition
+ * variable name. "patternVariable" and "patternRegexp" represents PATTERN
+ * clause.
+ *
  * The information relevant for the query jumbling is the partition clause
  * type and its bounds.
  */
@@ -1559,6 +1609,23 @@ typedef struct WindowClause
 	Index		winref;			/* ID referenced by window functions */
 	/* did we copy orderClause from refname? */
 	bool		copiedOrder pg_node_attr(query_jumble_ignore);
+	/* Row Pattern AFTER MACH SKIP clause */
+	RPSkipTo	rpSkipTo;		/* Row Pattern Skip To type */
+	char	   *rpSkipVariable; /* Row Pattern Skip To variable */
+	bool		initial;		/* true if <row pattern initial or seek> is
+								 * initial */
+	/* Row Pattern DEFINE clause (list of TargetEntry) */
+	List	   *defineClause;
+	/* Row Pattern DEFINE variable initial names (list of String) */
+	List	   *defineInitial;
+	/* Row Pattern PATTERN variable name (list of String) */
+	List	   *patternVariable;
+
+	/*
+	 * Row Pattern PATTERN regular expression quantifier ('+' or ''. list of
+	 * String)
+	 */
+	List	   *patternRegexp;
 } WindowClause;
 
 /*
diff --git a/src/include/parser/kwlist.h b/src/include/parser/kwlist.h
index 899d64ad55..f52d797615 100644
--- a/src/include/parser/kwlist.h
+++ b/src/include/parser/kwlist.h
@@ -129,6 +129,7 @@ PG_KEYWORD("default", DEFAULT, RESERVED_KEYWORD, BARE_LABEL)
 PG_KEYWORD("defaults", DEFAULTS, UNRESERVED_KEYWORD, BARE_LABEL)
 PG_KEYWORD("deferrable", DEFERRABLE, RESERVED_KEYWORD, BARE_LABEL)
 PG_KEYWORD("deferred", DEFERRED, UNRESERVED_KEYWORD, BARE_LABEL)
+PG_KEYWORD("define", DEFINE, RESERVED_KEYWORD, BARE_LABEL)
 PG_KEYWORD("definer", DEFINER, UNRESERVED_KEYWORD, BARE_LABEL)
 PG_KEYWORD("delete", DELETE_P, UNRESERVED_KEYWORD, BARE_LABEL)
 PG_KEYWORD("delimiter", DELIMITER, UNRESERVED_KEYWORD, BARE_LABEL)
@@ -215,6 +216,7 @@ PG_KEYWORD("index", INDEX, UNRESERVED_KEYWORD, BARE_LABEL)
 PG_KEYWORD("indexes", INDEXES, UNRESERVED_KEYWORD, BARE_LABEL)
 PG_KEYWORD("inherit", INHERIT, UNRESERVED_KEYWORD, BARE_LABEL)
 PG_KEYWORD("inherits", INHERITS, UNRESERVED_KEYWORD, BARE_LABEL)
+PG_KEYWORD("initial", INITIAL, UNRESERVED_KEYWORD, BARE_LABEL)
 PG_KEYWORD("initially", INITIALLY, RESERVED_KEYWORD, BARE_LABEL)
 PG_KEYWORD("inline", INLINE_P, UNRESERVED_KEYWORD, BARE_LABEL)
 PG_KEYWORD("inner", INNER_P, TYPE_FUNC_NAME_KEYWORD, BARE_LABEL)
@@ -273,6 +275,7 @@ PG_KEYWORD("match", MATCH, UNRESERVED_KEYWORD, BARE_LABEL)
 PG_KEYWORD("matched", MATCHED, UNRESERVED_KEYWORD, BARE_LABEL)
 PG_KEYWORD("materialized", MATERIALIZED, UNRESERVED_KEYWORD, BARE_LABEL)
 PG_KEYWORD("maxvalue", MAXVALUE, UNRESERVED_KEYWORD, BARE_LABEL)
+PG_KEYWORD("measures", MEASURES, UNRESERVED_KEYWORD, BARE_LABEL)
 PG_KEYWORD("merge", MERGE, UNRESERVED_KEYWORD, BARE_LABEL)
 PG_KEYWORD("merge_action", MERGE_ACTION, COL_NAME_KEYWORD, BARE_LABEL)
 PG_KEYWORD("method", METHOD, UNRESERVED_KEYWORD, BARE_LABEL)
@@ -337,8 +340,11 @@ PG_KEYWORD("partial", PARTIAL, UNRESERVED_KEYWORD, BARE_LABEL)
 PG_KEYWORD("partition", PARTITION, UNRESERVED_KEYWORD, BARE_LABEL)
 PG_KEYWORD("passing", PASSING, UNRESERVED_KEYWORD, BARE_LABEL)
 PG_KEYWORD("password", PASSWORD, UNRESERVED_KEYWORD, BARE_LABEL)
+PG_KEYWORD("past", PAST, UNRESERVED_KEYWORD, BARE_LABEL)
 PG_KEYWORD("path", PATH, UNRESERVED_KEYWORD, BARE_LABEL)
+PG_KEYWORD("pattern", PATTERN_P, UNRESERVED_KEYWORD, BARE_LABEL)
 PG_KEYWORD("period", PERIOD, UNRESERVED_KEYWORD, BARE_LABEL)
+PG_KEYWORD("permute", PERMUTE, UNRESERVED_KEYWORD, BARE_LABEL)
 PG_KEYWORD("placing", PLACING, RESERVED_KEYWORD, BARE_LABEL)
 PG_KEYWORD("plan", PLAN, UNRESERVED_KEYWORD, BARE_LABEL)
 PG_KEYWORD("plans", PLANS, UNRESERVED_KEYWORD, BARE_LABEL)
@@ -399,6 +405,7 @@ PG_KEYWORD("scroll", SCROLL, UNRESERVED_KEYWORD, BARE_LABEL)
 PG_KEYWORD("search", SEARCH, UNRESERVED_KEYWORD, BARE_LABEL)
 PG_KEYWORD("second", SECOND_P, UNRESERVED_KEYWORD, AS_LABEL)
 PG_KEYWORD("security", SECURITY, UNRESERVED_KEYWORD, BARE_LABEL)
+PG_KEYWORD("seek", SEEK, UNRESERVED_KEYWORD, BARE_LABEL)
 PG_KEYWORD("select", SELECT, RESERVED_KEYWORD, BARE_LABEL)
 PG_KEYWORD("sequence", SEQUENCE, UNRESERVED_KEYWORD, BARE_LABEL)
 PG_KEYWORD("sequences", SEQUENCES, UNRESERVED_KEYWORD, BARE_LABEL)
@@ -432,6 +439,7 @@ PG_KEYWORD("strict", STRICT_P, UNRESERVED_KEYWORD, BARE_LABEL)
 PG_KEYWORD("string", STRING_P, UNRESERVED_KEYWORD, BARE_LABEL)
 PG_KEYWORD("strip", STRIP_P, UNRESERVED_KEYWORD, BARE_LABEL)
 PG_KEYWORD("subscription", SUBSCRIPTION, UNRESERVED_KEYWORD, BARE_LABEL)
+PG_KEYWORD("subset", SUBSET, UNRESERVED_KEYWORD, BARE_LABEL)
 PG_KEYWORD("substring", SUBSTRING, COL_NAME_KEYWORD, BARE_LABEL)
 PG_KEYWORD("support", SUPPORT, UNRESERVED_KEYWORD, BARE_LABEL)
 PG_KEYWORD("symmetric", SYMMETRIC, RESERVED_KEYWORD, BARE_LABEL)
diff --git a/src/include/parser/parse_node.h b/src/include/parser/parse_node.h
index 2375e95c10..737f8a9e0e 100644
--- a/src/include/parser/parse_node.h
+++ b/src/include/parser/parse_node.h
@@ -51,6 +51,7 @@ typedef enum ParseExprKind
 	EXPR_KIND_WINDOW_FRAME_RANGE,	/* window frame clause with RANGE */
 	EXPR_KIND_WINDOW_FRAME_ROWS,	/* window frame clause with ROWS */
 	EXPR_KIND_WINDOW_FRAME_GROUPS,	/* window frame clause with GROUPS */
+	EXPR_KIND_RPR_DEFINE,		/* DEFINE */
 	EXPR_KIND_SELECT_TARGET,	/* SELECT target list item */
 	EXPR_KIND_INSERT_TARGET,	/* INSERT target list item */
 	EXPR_KIND_UPDATE_SOURCE,	/* UPDATE assignment source item */
-- 
2.25.1


----Next_Part(Mon_Dec_30_22_37_18_2024_171)--
Content-Type: Text/X-Patch; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="v26-0002-Row-pattern-recognition-patch-parse-analysis.patch"



^ permalink  raw  reply  [nested|flat] 15+ messages in thread


end of thread, other threads:[~2025-09-12 07:01 UTC | newest]

Thread overview: 15+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-01-24 17:19 Re: Set log_lock_waits=on by default Michael Banck <[email protected]>
2024-07-18 10:25 ` Michael Banck <[email protected]>
2024-07-19 09:54   ` Laurenz Albe <[email protected]>
2024-07-19 13:24     ` Christoph Berg <[email protected]>
2024-07-19 14:14       ` Robert Haas <[email protected]>
2024-07-19 14:29     ` Jelte Fennema-Nio <[email protected]>
2025-04-08 14:32     ` Laurenz Albe <[email protected]>
2025-09-04 05:12       ` Shinya Kato <[email protected]>
2025-09-07 21:46         ` Laurenz Albe <[email protected]>
2025-09-08 02:38           ` Chao Li <[email protected]>
2025-09-08 07:03             ` Laurenz Albe <[email protected]>
2025-09-12 06:06           ` Peter Eisentraut <[email protected]>
2025-09-12 07:01             ` Laurenz Albe <[email protected]>
2024-07-19 14:28   ` Greg Sabino Mullane <[email protected]>
2024-12-30 12:44 [PATCH v26 1/9] Row pattern recognition patch for raw parser. Tatsuo Ishii <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox