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 1wUzaP-001b7K-1c for pgsql-hackers@arkaria.postgresql.org; Thu, 04 Jun 2026 04:21:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wUzaN-004q3M-2J for pgsql-hackers@arkaria.postgresql.org; Thu, 04 Jun 2026 04:21:39 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wUzaN-004q3D-1M for pgsql-hackers@lists.postgresql.org; Thu, 04 Jun 2026 04:21:39 +0000 Received: from meldrar.postgresql.org ([2a02:c0:301:0:ffff::31]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wUzaH-0000000110q-0yvt for pgsql-hackers@postgresql.org; Thu, 04 Jun 2026 04:21:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=postgresql.org; s=20171124; h=Content-Transfer-Encoding:Content-Type: Mime-Version:References:In-Reply-To:From:Subject:Cc:To:Message-Id:Date:Sender :Reply-To:Content-ID:Content-Description; bh=JircB2gYOB/5G81lerKfwZzJYzJSUcVykU8cIFz8xAc=; b=2lbMhCC11b+mVxm26Ut6udSi+r iMcANCnYmqZdrPhnTsFqOUjQOvVTF4C+4ZDK3Yr3HMS5wdsbcGMUrvQawM3DFLe7siAm/FhdUQLOG IcULwskGPUtIkaBWuexe31uQnBzqvWLuK3njLL8sHfPZjfG7/axxe+Ol5pqJpSmX4gJskEtJ2b30u gKU+zYsWUYM0FEk9hyRTdBygBTsgP+jCskQFJtsnRVNtCURY38vdyQq/m/WvrLUfmp0iDgnv/TyYf cSl8jJ/A16gZd0DzFZINv41EomrRtpKsUaPKXZIL2ARoxhOCkS2dpW2JJY6bfSawz1A7zH9AQx04H 9g0w2SrA==; Received: from [2409:11:4120:300:71f4:8eb:af6f:3752] (helo=localhost) by meldrar.postgresql.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wUza7-002ryI-10; Thu, 04 Jun 2026 04:21:25 +0000 Date: Thu, 04 Jun 2026 13:21:08 +0900 (JST) Message-Id: <20260604.132108.405136284364833955.ishii@postgresql.org> To: assam258@gmail.com Cc: jian.universality@gmail.com, zsolt.parragi@percona.com, sjjang112233@gmail.com, vik@postgresfriends.org, er@xs4all.nl, jacob.champion@enterprisedb.com, david.g.johnston@gmail.com, peter@eisentraut.org, li.evan.chao@gmail.com, pgsql-hackers@postgresql.org Subject: Re: Row pattern recognition From: Tatsuo Ishii In-Reply-To: References: X-Mailer: Mew version 6.8 on Emacs 29.3 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 2409:11:4120:300:71f4:8eb:af6f:3752 (failed) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi Henson, Just a trivial comment to 1. > While going over the row pattern grammar I want to put on record why the > empty pattern -- PATTERN (()) and the like -- is left unsupported, and why > I think that is the right call for this series rather than an oversight. > > Today it is simply a syntax error. row_pattern_primary is either a > variable (ColId) or a parenthesized group '(' row_pattern ')', and > row_pattern has no empty production, so '()' never parses. The standard's > pattern syntax does allow an empty row pattern -- it matches the empty > sequence, i.e. it produces an empty match -- so the question is whether we > should grow the grammar, plus an NFA "empty" element, to accept it. > > My claim is that we do not need to: every way an empty pattern can appear > reduces to something we already handle, so a dedicated empty element in > the executor would be dead weight. There are two cases. > > > 1. The empty pattern is the whole pattern: PATTERN (()) > > This pattern has zero pattern variables. But DEFINE is mandatory (per > ISO/IEC 19075-5, Table 18), an empty DEFINE list is rejected, and every > DEFINE variable must appear in PATTERN -- otherwise we already error with > "DEFINE variable \"%s\" is not used in PATTERN". A pattern with no > variables cannot satisfy any of that: there is nothing for DEFINE to > define, yet DEFINE can be neither omitted nor left empty. So an all-empty > pattern is rejected by the existing rules, with no new check needed. I think current behavior is correct from the standard's point of view. As you explained, there's no way to accept "PATTERN (())" or "PATTERN ()" according to the R020 syntax rule. Note, however, "PATTERN ()" is possible in R010 because it allows to omit the DEFINE clause itself. Regards, -- Tatsuo Ishii SRA OSS K.K. English: http://www.sraoss.co.jp/index_en/ Japanese:http://www.sraoss.co.jp