public inbox for [email protected]  
help / color / mirror / Atom feed
[PATCH v13 3/8] Row pattern recognition patch (rewriter).
5+ messages / 4 participants
[nested] [flat]

* [PATCH v13 3/8] Row pattern recognition patch (rewriter).
@ 2024-01-22 09:45  Tatsuo Ishii <[email protected]>
  0 siblings, 0 replies; 5+ messages in thread

From: Tatsuo Ishii @ 2024-01-22 09:45 UTC (permalink / raw)

---
 src/backend/utils/adt/ruleutils.c | 90 +++++++++++++++++++++++++++++++
 1 file changed, 90 insertions(+)

diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 0b2a164057..baded88201 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -428,6 +428,10 @@ static void get_rule_groupingset(GroupingSet *gset, List *targetlist,
 								 bool omit_parens, deparse_context *context);
 static void get_rule_orderby(List *orderList, List *targetList,
 							 bool force_colno, deparse_context *context);
+static void get_rule_pattern(List *patternVariable, List *patternRegexp,
+							 bool force_colno, deparse_context *context);
+static void get_rule_define(List *defineClause, List *patternVariables,
+							bool force_colno, deparse_context *context);
 static void get_rule_windowclause(Query *query, deparse_context *context);
 static void get_rule_windowspec(WindowClause *wc, List *targetList,
 								deparse_context *context);
@@ -6459,6 +6463,64 @@ get_rule_orderby(List *orderList, List *targetList,
 	}
 }
 
+/*
+ * Display a PATTERN clause.
+ */
+static void
+get_rule_pattern(List *patternVariable, List *patternRegexp,
+				 bool force_colno, deparse_context *context)
+{
+	StringInfo  buf = context->buf;
+	const char *sep;
+	ListCell   *lc_var, *lc_reg = list_head(patternRegexp);
+
+	sep = "";
+	appendStringInfoChar(buf, '(');
+	foreach(lc_var, patternVariable)
+	{
+		char *variable = strVal((String *) lfirst(lc_var));
+		char *regexp = NULL;
+
+		if (lc_reg != NULL)
+		{
+			regexp = strVal((String *) lfirst(lc_reg));
+			lc_reg = lnext(patternRegexp, lc_reg);
+		}
+
+		appendStringInfo(buf, "%s%s", sep, variable);
+		if (regexp != NULL)
+			appendStringInfoString(buf, regexp);
+
+		sep = " ";
+	}
+	appendStringInfoChar(buf, ')');
+}
+
+/*
+ * Display a DEFINE clause.
+ */
+static void
+get_rule_define(List *defineClause, List *patternVariables,
+				bool force_colno, deparse_context *context)
+{
+	StringInfo  buf = context->buf;
+	const char *sep;
+	ListCell   *lc_var, *lc_def;
+
+	sep = "  ";
+	Assert(list_length(patternVariables) == list_length(defineClause));
+
+	forboth(lc_var, patternVariables, lc_def, defineClause)
+	{
+		char *varName = strVal(lfirst(lc_var));
+		TargetEntry *te = (TargetEntry *) lfirst(lc_def);
+
+		appendStringInfo(buf, "%s%s AS ", sep, varName);
+		get_rule_expr((Node *) te->expr, context, false);
+		sep = ",\n  ";
+	}
+}
+
 /*
  * Display a WINDOW clause.
  *
@@ -6596,6 +6658,34 @@ get_rule_windowspec(WindowClause *wc, List *targetList,
 			appendStringInfoString(buf, "EXCLUDE GROUP ");
 		else if (wc->frameOptions & FRAMEOPTION_EXCLUDE_TIES)
 			appendStringInfoString(buf, "EXCLUDE TIES ");
+		/* RPR */
+		if (wc->rpSkipTo == ST_NEXT_ROW)
+			appendStringInfoString(buf, "\n  AFTER MATCH SKIP TO NEXT ROW ");
+		else if (wc->rpSkipTo == ST_PAST_LAST_ROW)
+			appendStringInfoString(buf, "\n  AFTER MATCH SKIP PAST LAST ROW ");
+		else if (wc->rpSkipTo == ST_FIRST_VARIABLE)
+			appendStringInfo(buf, "\n  AFTER MATCH SKIP TO FIRST %s ", wc->rpSkipVariable);
+		else if (wc->rpSkipTo == ST_LAST_VARIABLE)
+			appendStringInfo(buf, "\n  AFTER MATCH SKIP TO LAST %s ", wc->rpSkipVariable);
+		else if (wc->rpSkipTo == ST_VARIABLE)
+			appendStringInfo(buf, "\n  AFTER MATCH SKIP TO %s ", wc->rpSkipVariable);
+
+		if (wc->initial)
+			appendStringInfoString(buf, "\n  INITIAL");
+
+		if (wc->patternVariable)
+		{
+			appendStringInfoString(buf, "\n  PATTERN ");
+			get_rule_pattern(wc->patternVariable, wc->patternRegexp, false, context);
+		}
+
+		if (wc->defineClause)
+		{
+			appendStringInfoString(buf, "\n  DEFINE\n");
+			get_rule_define(wc->defineClause, wc->patternVariable, false, context);
+			appendStringInfoChar(buf, ' ');
+		}
+
 		/* we will now have a trailing space; remove it */
 		buf->len--;
 	}
-- 
2.25.1


----Next_Part(Mon_Jan_22_19_26_18_2024_011)--
Content-Type: Text/X-Patch; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="v13-0004-Row-pattern-recognition-patch-planner.patch"



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

* Re: Combine headerscheck and cpluspluscheck scripts
@ 2024-03-07 07:30  Michael Paquier <[email protected]>
  0 siblings, 1 reply; 5+ messages in thread

From: Michael Paquier @ 2024-03-07 07:30 UTC (permalink / raw)
  To: Thomas Munro <[email protected]>; +Cc: Peter Eisentraut <[email protected]>; pgsql-hackers

On Thu, Mar 07, 2024 at 01:37:36PM +1300, Thomas Munro wrote:
> +1

Looking at the patch, nice cleanup.
--
Michael


Attachments:

  [application/pgp-signature] signature.asc (833B, ../../[email protected]/2-signature.asc)
  download

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

* Re: Combine headerscheck and cpluspluscheck scripts
@ 2024-03-10 09:03  Peter Eisentraut <[email protected]>
  parent: Michael Paquier <[email protected]>
  0 siblings, 1 reply; 5+ messages in thread

From: Peter Eisentraut @ 2024-03-10 09:03 UTC (permalink / raw)
  To: Michael Paquier <[email protected]>; Thomas Munro <[email protected]>; +Cc: pgsql-hackers

On 07.03.24 08:30, Michael Paquier wrote:
> On Thu, Mar 07, 2024 at 01:37:36PM +1300, Thomas Munro wrote:
>> +1
> 
> Looking at the patch, nice cleanup.

Committed, thanks.







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

* Re: Combine headerscheck and cpluspluscheck scripts
@ 2024-04-16 15:17  Anton Voloshin <[email protected]>
  parent: Peter Eisentraut <[email protected]>
  0 siblings, 1 reply; 5+ messages in thread

From: Anton Voloshin @ 2024-04-16 15:17 UTC (permalink / raw)
  To: Peter Eisentraut <[email protected]>; Michael Paquier <[email protected]>; Thomas Munro <[email protected]>; +Cc: pgsql-hackers

Hello, hackers,

On 10/03/2024 12:03, Peter Eisentraut wrote:
> Committed, thanks.

This commit (7b8e2ae2f) have turned cpluspluscheck script into a 
--cplusplus option for headerscheck.  I propose to update the 
src/tools/pginclude/README correspondingly, please see the attached patch.

-- 
Anton Voloshin
Postgres Professional, The Russian Postgres Company
https://postgrespro.ru

Attachments:

  [text/x-patch] 0001-Update-src-tools-pginclude-README-to-match-recent-ch.patch (2.5K, ../../[email protected]/2-0001-Update-src-tools-pginclude-README-to-match-recent-ch.patch)
  download | inline diff:
From a50e58f117341e8a9df5f97fa05630f7b8f4bd86 Mon Sep 17 00:00:00 2001
From: Anton Voloshin <[email protected]>
Date: Tue, 16 Apr 2024 17:19:28 +0300
Subject: [PATCH] Update src/tools/pginclude/README to match recent changes to
 cpluspluscheck

7b8e2ae2f have turned cpluspluscheck from separate script into
a --cplusplus option for headerscheck. Update README correspondingly.
---
 src/tools/pginclude/README | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/tools/pginclude/README b/src/tools/pginclude/README
index 712eca76fb3..65372057dad 100644
--- a/src/tools/pginclude/README
+++ b/src/tools/pginclude/README
@@ -1,10 +1,10 @@
 src/tools/pginclude/README
 
-NOTE: headerscheck and cpluspluscheck are in current use, and any
-problems they find should generally get fixed.  The other scripts
-in this directory have not been used in some time, and have issues.
-pgrminclude in particular has a history of creating more problems
-than it fixes.  Be very wary of applying their results blindly.
+NOTE: headerscheck and headerscheck --cplusplus are in current use, and any
+problems they find should generally get fixed.  The other scripts in this
+directory have not been used in some time, and have issues.  pgrminclude in
+particular has a history of creating more problems than it fixes.  Be very
+wary of applying their results blindly.
 
 
 pginclude
@@ -84,16 +84,16 @@ prerequisite, even if postgres_fe.h or c.h would be more appropriate.
 Also note that the contents of macros are not checked; this is intentional.
 
 
-cpluspluscheck
-==============
+headerscheck --cplusplus
+========================
 
-This script can be run to verify that all Postgres include files meet
-the project convention that they will compile as C++ code.  Although
-the project's coding language is C, some people write extensions in C++,
-so it's helpful for include files to be C++-clean.
+The headerscheck in --cplusplus mode can be run to verify that all Postgres
+include files meet the project convention that they will compile as C++
+code.  Although the project's coding language is C, some people write
+extensions in C++, so it's helpful for include files to be C++-clean.
 
 A small number of header files are exempted from this requirement,
-and are skipped by the cpluspluscheck script.
+and are skipped by the script in the --cplusplus mode.
 
 The easy way to run the script is to say "make -s cpluspluscheck" in
 the top-level build directory after completing a build.  You should
-- 
2.43.2



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

* Re: Combine headerscheck and cpluspluscheck scripts
@ 2024-04-18 09:37  Peter Eisentraut <[email protected]>
  parent: Anton Voloshin <[email protected]>
  0 siblings, 0 replies; 5+ messages in thread

From: Peter Eisentraut @ 2024-04-18 09:37 UTC (permalink / raw)
  To: Anton Voloshin <[email protected]>; Michael Paquier <[email protected]>; Thomas Munro <[email protected]>; +Cc: pgsql-hackers

On 16.04.24 17:17, Anton Voloshin wrote:
> On 10/03/2024 12:03, Peter Eisentraut wrote:
>> Committed, thanks.
> 
> This commit (7b8e2ae2f) have turned cpluspluscheck script into a 
> --cplusplus option for headerscheck.  I propose to update the 
> src/tools/pginclude/README correspondingly, please see the attached patch.

Fixed, thanks!







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


end of thread, other threads:[~2024-04-18 09:37 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-01-22 09:45 [PATCH v13 3/8] Row pattern recognition patch (rewriter). Tatsuo Ishii <[email protected]>
2024-03-07 07:30 Re: Combine headerscheck and cpluspluscheck scripts Michael Paquier <[email protected]>
2024-03-10 09:03 ` Re: Combine headerscheck and cpluspluscheck scripts Peter Eisentraut <[email protected]>
2024-04-16 15:17   ` Re: Combine headerscheck and cpluspluscheck scripts Anton Voloshin <[email protected]>
2024-04-18 09:37     ` Re: Combine headerscheck and cpluspluscheck scripts Peter Eisentraut <[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