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 1wamES-00238w-2y for pgsql-hackers@arkaria.postgresql.org; Sat, 20 Jun 2026 03:18:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wamDS-000WjN-03 for pgsql-hackers@arkaria.postgresql.org; Sat, 20 Jun 2026 03:17:54 +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 1wamDR-000WjF-1w for pgsql-hackers@lists.postgresql.org; Sat, 20 Jun 2026 03:17:53 +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 1wamDM-00000001ET4-3NRw for pgsql-hackers@postgresql.org; Sat, 20 Jun 2026 03:17:52 +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=cjkAkWz+E/BU9GUoj2scfFNYLkQNlFwHhy9Bz3PZkYk=; b=efI1ade5q8o0Nfq94QdHRV+g/U 6GEHPrHCgxf9tD5aWZi76so8f6C33X2TRr+X+s2JvV6jdgBaIchR5pIWnJ2xw74MkfoYU5GjpTpa/ uxqi5UoH/KYVnBHGYIpE46apfKAZaMUUz164ndRygB8eNWE9LIkzvvDFUWFUG9ncKVpEH5rV3dt5l omCZd3AMhfIt86PhAaNd8P4HR1ewtOi7OqxKcFRUy6ss/YVB7GoSjQfzXsSwobKavkrPGDH5PgVFQ bJVHWSnj7/LqKVoXm5O3zZcQFf350PnlYSNZYkz+VtP3uZCOBKlaWcujnRFwZ5f0ORh7s2uC4jndP GmnPKQFg==; Received: from [2409:11:4120:300:8c7a:750b:6939:66bf] (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 1wamDD-003bpT-0v; Sat, 20 Jun 2026 03:17:41 +0000 Date: Sat, 20 Jun 2026 12:17:19 +0900 (JST) Message-Id: <20260620.121719.209332541992434500.ishii@postgresql.org> To: jian.universality@gmail.com Cc: assam258@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:8c7a:750b:6939:66bf (failed) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi Jian, Only comments to error messages. > CREATE TABLE stock (company TEXT, tdate DATE, price INTEGER); > CREATE TEMP TABLE stock (company TEXT, tdate DATE, price INTEGER); > SELECT count(*) over w FROM stock WINDOW w AS ( ROWS BETWEEN CURRENT > ROW AND UNBOUNDED FOLLOWING PATTERN (A) DEFINE A AS > pg_temp.stock.price > 0 ); > SELECT count(*) over w FROM stock WINDOW w AS ( ROWS BETWEEN CURRENT > ROW AND UNBOUNDED FOLLOWING PATTERN (A) DEFINE A AS public.stock.price >> 0 ); > SELECT count(*) over w FROM stock WINDOW w AS ( ROWS BETWEEN CURRENT > ROW AND UNBOUNDED FOLLOWING PATTERN (A) DEFINE A AS stock.price > 0 ); > > The error messages for the above 3 SELECT queries are different. > (pg_temp.stock.price, public.stock.price, stock.price) mean the same > thing: column reference, > Should we try to make the error messages consistent? I have tested above queries to see how error messages actually look like. These errors raised by different reasons and becomes different looks natural. I see no consistency problem here. SELECT count(*) over w FROM stock WINDOW w AS ( ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING PATTERN (A) DEFINE A AS pg_temp.stock.price > 0 ); (1) psql:rangevar.sql:6: ERROR: 42601: qualified expression "pg_temp.stock.price" is not allowed in DEFINE clause LINE 3: pg_temp.stock.price > 0 ); ^ LOCATION: transformColumnRef, parse_expr.c:966 "stock" table in the FROM clause is actually pg_temp.stock. The expression "pg_temp.stock.price > 0" is valid in general but in a DEFINE clause schema qualified column reference is not allowed by the standard. So the error messages look reasonable to me. SELECT count(*) over w FROM stock WINDOW w AS ( ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING PATTERN (A) DEFINE A AS public.stock.price > 0 ); (2) psql:rangevar.sql:9: ERROR: 42P01: invalid reference to FROM-clause entry for table "stock" LINE 2: ...W AND UNBOUNDED FOLLOWING PATTERN (A) DEFINE A AS public.sto... ^ DETAIL: There is an entry for table "stock", but it cannot be referenced from this part of the query. LOCATION: errorMissingRTE, parse_relation.c:3864 "stock" table in the FROM clause is actually pg_temp.stock. The expression "public.stock.price > 0" is not valid because public.stock is not in the FROM clause. The error messages look reasonable to me. SELECT count(*) over w FROM stock WINDOW w AS ( ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING PATTERN (A) DEFINE A AS stock.price > 0 ); (3) psql:rangevar.sql:11: ERROR: 42601: range variable qualified expression "stock.price" is not allowed in DEFINE clause LINE 2: ...W AND UNBOUNDED FOLLOWING PATTERN (A) DEFINE A AS stock.pric... ^ LOCATION: transformColumnRef, parse_expr.c:674 The error message precisely points out that the range variable "stock" qualifies "stock.price", which is not allowed by the standard. I see no problem here. > ERROR: range variable qualified expression "rpr_composite.items" is > not allowed in DEFINE clause > > "Range variable qualified expression" is non-standard that may confuse users. Which part of it do you think "non-standard"? The standard uses both terms "Range variable" and "qualified". > To improve clarity and consistency, let's align this with the > established error pattern: > > ERROR: invalid reference to FROM-clause entry for table "the_table" -1. As I explained above, these 3 errors raised by the different reasons. "invalid reference to FROM-clause entry for table "the_table" is only applied to (2). So unified (1) and (3) will make more confusion. Regards, -- Tatsuo Ishii SRA OSS K.K. English: http://www.sraoss.co.jp/index_en/ Japanese:http://www.sraoss.co.jp