Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vLDvI-008pEC-0A for pgsql-hackers@arkaria.postgresql.org; Tue, 18 Nov 2025 05:06:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vLDvG-0040fc-1o for pgsql-hackers@arkaria.postgresql.org; Tue, 18 Nov 2025 05:06:34 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vLDvG-0040fU-0j for pgsql-hackers@lists.postgresql.org; Tue, 18 Nov 2025 05:06:34 +0000 Received: from mail-qt1-x831.google.com ([2607:f8b0:4864:20::831]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vLDvE-0007Pk-1N for pgsql-hackers@postgresql.org; Tue, 18 Nov 2025 05:06:34 +0000 Received: by mail-qt1-x831.google.com with SMTP id d75a77b69052e-4ed7024c8c5so37878311cf.3 for ; Mon, 17 Nov 2025 21:06:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763442391; x=1764047191; darn=postgresql.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=olo9WVZryBeiW2ypp1GvY+c/zJvTlDtE5/T+GfLkk38=; b=BkQ5OLqTf5rI/Nl4eVPrO33IoAKe6AFziicKUxG0ZH1yEQg3FwEWcuXZ07WJ1vrU0Y Qpnb25iL7NccPaMl0ZF4M82hLGBq2WKWiCxtZBq953/7lTQeRYefHK/xCKvni2gFCJfM U+wffpmDHhpnJ0/KZUg8kubw94VApg7EKfJr4jvYjDVNU8aWsZLlzlCdjhrFj0UtRsTu 2RFaoM/4Hqqk4ZpZClS8Sfu2d3xIkuZd6efxcpGPUSOMMste3a+pabsGEcCqBPTyy90c MvoZhn8KGZhJ2fM242l8ecYvXoDrJXstMoo2ztcNomq/PhbKqkwcBpVH9ApBtBGpI09u B3Uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763442391; x=1764047191; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=olo9WVZryBeiW2ypp1GvY+c/zJvTlDtE5/T+GfLkk38=; b=BjXAyFy4NFnUJ+z2CupP5rRxLnJVXoOqhvot29ma01RkuxKi3382DNtEV0tHmZaeoF wIKLlMeNAa1ca2S7cC5NFZla90yRIpol+Pz6i4ejsdnS55ColhiwjoggJkw8armeQFWX BJ6nUnW5qCtDcMm37+7xsUmGTJa+4Mbk5lP2loUPm97FHRbDCbZJPwRk3zL9AAuYmRwS BiAX3k/95p+SsnI6HggsBLETIL2SK1dS1XMYbDKhUSrKWbgksT0Pw/Yn/o543F7lKQCl NlAcAxDroMfKkbpM+wKfUNvMXPjy/QkT/OsnUU/EEVIDctTRRexHsXmSWL9pZ7GR0/89 AB1g== X-Forwarded-Encrypted: i=1; AJvYcCXzQKICxQXqGgvYcxRBGULOFbxQPKJ6KUxo+0eY2/zEYHIzvhLtUPKxKvoDNlItSFtwSe5TFmVDwcep3nC8@postgresql.org X-Gm-Message-State: AOJu0Yxz4e2Ido5hL17E/C9t08uWSQeCAId7WU9IPyoV8KciB13jxiJN yfAQTlsxkE59xY4fZB7kCg89q1/O9MlJT0xeVPAc9El53KVase0cbiB9 X-Gm-Gg: ASbGncssbnzA13a03lwKo3LF0Y9LOzp4GfNmNlqiah1OIPIY4YkOxFIcz6PhOAWp27l 6L+Mg+u44f9K1kdPUiZKS3eXJciCDke0RRCxL9gKUm8uzJCfPnsOuuPad1ZX50r+EfPBlBsnf0p Xb5vgJebS5GsM75eDxlf8ycWaW7z31u4mmgnedsjLqkpU3U963dQZfqFp+xxUvFjZPIslSl8YDg Z5sdZpD/3+5smLoXZiCiWCUJxKwwqPRsp0Ok+amlzqdFPHXTAn7ha3idMMkZVl1dojm46lMg8vQ sUcr4Y9H3ivv6wNmg/ylbBciNplw+NyItPWUz/dJAxPZG42a5DmM7iBeTvnZIqkIyBsXpnFS1Ra h/DBK0FA0BHgJnct6Bp/xXHLSZMGxT1z2ajJoeexX7lWtBdrj94sZDVKBTCQ177OKWOfo1DDnfz Mje8klYk3H+Q== X-Google-Smtp-Source: AGHT+IHoGpFD9ZCiQfHvrMzgmFKTCtgJSjq0OaUsjPJrJZyLpyMSoIBXEV437RpIoO1sfwysAUYP3w== X-Received: by 2002:ac8:7f8e:0:b0:4ee:26bd:13ed with SMTP id d75a77b69052e-4ee26bd1927mr55217341cf.41.1763442390653; Mon, 17 Nov 2025 21:06:30 -0800 (PST) Received: from smtpclient.apple ([209.127.78.222]) by smtp.gmail.com with ESMTPSA id af79cd13be357-8b2aeec7f0asm1130467985a.24.2025.11.17.21.06.26 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Nov 2025 21:06:30 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.700.81\)) Subject: Re: Row pattern recognition From: Chao Li In-Reply-To: Date: Tue, 18 Nov 2025 13:05:52 +0800 Cc: david.g.johnston@gmail.com, vik@postgresfriends.org, jacob.champion@enterprisedb.com, er@xs4all.nl, peter@eisentraut.org, pgsql-hackers@postgresql.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <20250816.174552.1094782787078410357.ishii@postgresql.org> <20250924.193523.694296225366690354.ishii@postgresql.org> <20251117.155715.178271279022552982.ishii@postgresql.org> <20251118.113320.572888636385647268.ishii@postgresql.org> To: Tatsuo Ishii X-Mailer: Apple Mail (2.3826.700.81) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Nov 18, 2025, at 13:03, Chao Li wrote: >=20 > Hi Tatsuo-san, >=20 > I just reviewed 0006 docs changes and 0001. I plan to slowly review = the patch, maybe one commit a day.=20 >=20 >> On Nov 18, 2025, at 10:33, Tatsuo Ishii wrote: >>=20 >> Attached are the v35 patches for Row pattern recognition. In = v34-0001 >> gram.y patch, %type for RPR were misplaced. v35-0001 fixes this. = Other >> patches are not changed. >>=20 >> Best regards, >> -- >> Tatsuo Ishii >> SRA OSS K.K. >> English: http://www.sraoss.co.jp/index_en/ >> Japanese:http://www.sraoss.co.jp >> = >=20 > I got a few comments, maybe just questions: >=20 > 1 - 0001 - kwlist.h > ``` > +PG_KEYWORD("define", DEFINE, RESERVED_KEYWORD, BARE_LABEL) > ``` >=20 > Why do we add =E2=80=9Cdefine=E2=80=9D as a reserved keyword? =46rom = the SQL example you put in 0006: > ``` > > SELECT company, tdate, price, > first_value(price) OVER w, > max(price) OVER w, > count(price) OVER w > FROM stock > WINDOW w AS ( > PARTITION BY company > ORDER BY tdate > ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING > AFTER MATCH SKIP PAST LAST ROW > INITIAL > PATTERN (LOWPRICE UP+ DOWN+) > DEFINE > LOWPRICE AS price <=3D 100, > UP AS price > PREV(price), > DOWN AS price < PREV(price) > ); > > ``` >=20 > PARTITION is at the same level as DEFINE, but it=E2=80=99s not defined = as a reserved keyword: > ``` > PG_KEYWORD("partition", PARTITION, UNRESERVED_KEYWORD, BARE_LABEL) > ``` >=20 > Even in this patch,=E2=80=9Dinitial=E2=80=9D,=E2=80=9Dpast=E2=80=9D, = =E2=80=9Cpattern=E2=80=9D and =E2=80=9Cseek=E2=80=9D are defined as = unreserved, why? =20 >=20 > So I just want to clarify. >=20 > 2 - 0001 - gram.y > ``` > opt_row_pattern_initial_or_seek: > INITIAL { $$ =3D true; } > | SEEK > { > ereport(ERROR, > (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), > errmsg("SEEK is not supported"), > errhint("Use INITIAL instead."), > parser_errposition(@1))); > } > | /*EMPTY*/ { $$ =3D true; } > ; > ``` >=20 > As SEEK is specially listed here, I guess it might be supported in = future. If that is true, would it be better to defer the semantic check = to later parse phase, which would future work easier. >=20 > 3 - 0001 - parsenodes.h > ``` > +/* > + * RowPatternCommonSyntax - raw representation of row pattern common = syntax > + * > + */ > +typedef struct RPCommonSyntax > +{ > + NodeTag type; > + RPSkipTo rpSkipTo; /* Row Pattern AFTER MATCH SKIP type */ > + bool initial; /* true if is > + * initial */ > + List *rpPatterns; /* PATTERN variables (list of A_Expr) */ > + List *rpDefs; /* row pattern definitions clause (list of > + * ResTarget) */ > +} RPCommonSyntax; > + > /* > * WindowDef - raw representation of WINDOW and OVER clauses > * > @@ -593,6 +618,7 @@ typedef struct WindowDef > char *refname; /* referenced window name, if any */ > List *partitionClause; /* PARTITION BY expression list */ > List *orderClause; /* ORDER BY (list of SortBy) */ > + RPCommonSyntax *rpCommonSyntax; /* row pattern common syntax */ > ``` >=20 > RP fields are directly defined in WindowClause, then why do we need a = wrapper of RPCommonSyntax? Can we directly define RP fields in WindowRef = as well? >=20 4 - 0001 - parsenodes.h ``` + /* Row Pattern AFTER MACH SKIP clause */ ``` Typo: MACH -> MATCH Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/