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.94.2) (envelope-from ) id 1uH2nW-00CQiG-3F for pgsql-bugs@arkaria.postgresql.org; Mon, 19 May 2025 15:53:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uH2nV-00GnBO-2n for pgsql-bugs@arkaria.postgresql.org; Mon, 19 May 2025 15:53:01 +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.94.2) (envelope-from ) id 1uH2nU-00GnBB-NI for pgsql-bugs@lists.postgresql.org; Mon, 19 May 2025 15:53:00 +0000 Received: from lahtoruutu.iki.fi ([2a0b:5c81:1c1::37]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uH2nR-002b87-23 for pgsql-bugs@lists.postgresql.org; Mon, 19 May 2025 15:52:59 +0000 Received: from [192.168.1.112] (iptv-hkibng21-58c090-167.dhcp.inet.fi [88.192.144.167]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: hlinnaka) by lahtoruutu.iki.fi (Postfix) with ESMTPSA id 4b1Mdt668Wz49Py8; Mon, 19 May 2025 18:52:50 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1747669971; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9M6ikcM/h1pLaDxWdB1HG3/qdO2m1WvKQQzH9hK4u1g=; b=uug4JuRZmAqbEaW1PRS6lRgOVEeDSnPtke0wHWPnanXAoBGbu8ZXTXv1H/P4QIUqTnmvkG 05njoblmZS2zMkuU8wl/tXC6dWwscc5UqCsit+HnDJjLsBqTeHPLJIqvGR1luw4FILRz9u kXBEIHi8YXS9Trq0Vqg0U/q5NK8AA2uMg8xjEdpalTxVzbyzZ9y2NSCk+5dl5NfhoAf3Sn 6bj0N0wBEXlNF0Mwk5xMZwc8aCBCX56qO3ss0QYewpbk1f/fldf7WGQMkd77vKiRN3He8U Lxj8wlqP8Jjpx3cJXJ+LHRWQUzo3F7GwEy6VEUaZLfijb8jHsGv3rEpFrgGgUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1747669971; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9M6ikcM/h1pLaDxWdB1HG3/qdO2m1WvKQQzH9hK4u1g=; b=NcW0xSFElpdK9U5KGi1BxNHFGROxnETVp/VHIxNv4tWOwoMynm+igDPC4zfDQFQkxxoaNS P5++2FZvoKt5w8eKhnyF0mydWi6MPYCb5/i2umlJ/fR91iEV7ZmI0m3yeDqceL12DNeF/H CdqSX/8pnzXj2fWryPuVH65jyBEQiu75Kv+sG6InsGHhp1TTZo7Ta/voE00Men6fHOYm2z BGdb3gdlndnVoi1otirGclP8Ah/szFpfc0FG0ja+iZVwXv7RkqwUrb+KigdL5CpNMwM2cX 9Az4vFEjfirKZG6N+wYFjrCEcBMeUhluQh/RekCfy9fYApxrD3UDcqvbIHAVGw== ARC-Seal: i=1; s=lahtoruutu; d=iki.fi; t=1747669971; a=rsa-sha256; cv=none; b=QyCBseXLxLCnPZzUKKWRyVibG0/DUvRQnBLxC2bpEV+D4QQ+nmzYZ98zlqsk/P5Ps15E8X h9mC61jvhjoErQP/ukgcFOcN/wIUonfElD+Rm66MORLvnTL+9UZkNktwqh1KT+54p6K/ue 9YY2jG5UuItlFNurHqe0tmjF83r/D1kIzH6E8xWAxj+f+NpZZoOXHrbvX8s0kz5RtrC9Hl 4U5zZ+9IucHuQYyjulDyjcGm0WDzPemWfi2xkS8jVhm+rgUmOuWYIoZqDe89HbILUYm4RB 57sybx1fABb5EHsvdcZPZmuabg+cSkMjbG+6mqiMU3BkI8pbJEC9yNzXTNU+fA== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=hlinnaka smtp.mailfrom=hlinnaka@iki.fi Message-ID: Date: Mon, 19 May 2025 18:52:50 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: BUG #18929: After the view is created, executed query against the view definition, reported syntax error. From: Heikki Linnakangas To: 707330139@qq.com, pgsql-bugs@lists.postgresql.org References: <18929-077d6b7093b176e2@postgresql.org> <349f86e9-6922-4fcc-9725-b8a6f0667bea@iki.fi> Content-Language: en-US In-Reply-To: <349f86e9-6922-4fcc-9725-b8a6f0667bea@iki.fi> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 15/05/2025 17:41, Heikki Linnakangas wrote: > On 15/05/2025 07:04, PG Bug reporting form wrote: >> postgres=#  \d+ limit_thousand_v_3 >>                        View "public.limit_thousand_v_3" >>    Column  |  Type   | Collation | Nullable | Default | Storage | >> Description >> ----------+---------+-----------+----------+---------+--------- >> +------------- >>   thousand | integer |           |          |         | plain   | >> View definition: >>   SELECT thousand >>     FROM onek >>    WHERE thousand < 995 >>    ORDER BY thousand >>   FETCH FIRST NULL::bigint + 1::bigint ROWS WITH TIES; >> postgres=# SELECT thousand >> postgres-#    FROM onek >> postgres-#   WHERE thousand < 995 >> postgres-#   ORDER BY thousand >> postgres-#  FETCH FIRST NULL::bigint + 1::bigint ROWS WITH TIES; >> ERROR:  syntax error at or near "::" >> LINE 5:  FETCH FIRST NULL::bigint + 1::bigint ROWS WITH TIES; >>                           ^ > > Agreed that's a bug. Attached is a simple patch to add parens to all > deparsed FETCH FIRST n ROWS WITH TIES expressions. > > It would be nice to skip the parens for simple literals, but > unfortunately it's non-trivial to distinguish Consts that are printed as > simple literals from more complicated cases that are printed as > typecasts, like '123'::bigint. XMLEXISTS is another expression type that > takes a 'c_expr' in the the grammar, and it also just always adds the > parens. > > I'll commit this fix, unless someone comes up with something more > sophisticated. Committed, thanks for the report. -- Heikki Linnakangas Neon (https://neon.tech)