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 1uFZmU-0065RA-Dj for pgsql-bugs@arkaria.postgresql.org; Thu, 15 May 2025 14:41:55 +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 1uFZmS-00Ezm9-W6 for pgsql-bugs@arkaria.postgresql.org; Thu, 15 May 2025 14:41:53 +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.94.2) (envelope-from ) id 1uFZmS-00Ezm0-Lh for pgsql-bugs@lists.postgresql.org; Thu, 15 May 2025 14:41:52 +0000 Received: from lahtoruutu.iki.fi ([2a0b:5c81:1c1::37]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uFZmP-0022fx-2U for pgsql-bugs@lists.postgresql.org; Thu, 15 May 2025 14:41:52 +0000 Received: from [10.23.100.105] (unknown [212.123.218.234]) (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 4ZytFg63yTz49PyJ; Thu, 15 May 2025 17:41:43 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1747320104; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=FFAc4me6dA43gTpAEn3lm8rrtdJH+GgGmL2LNHmav4A=; b=L3RiNlCn/PDWgFhJi/m0oCKC/KfH0NuXOe+wwtT0BQUCLIyOfcePsmmdmFMoaF8LKYCj3u MfRTZAOylzGUoCdvHi+6yrFNmupzmVcfY9jzMZnRCG0eYSIOawUQU/f4v46m0bSMn/hhKy gmJZAVTb4OgpGhXIXTRBMsUZt20xCu3U5wKjfmHhOq5dX/ZhJ7udjRb2EPy+++xGLAnoVt 6Gel1x9lbz1oLOLyDb1IiBtzmF9dvwOHqZIgRJQIrZip1UbYhVdZxJ1Ct5ry2hfnMsTwvi jzsyTQQfFENgRSYzcrFxE0Dv0/mDvE41dYr1aqJcIlHX2xy8uY45Qj4Qsf66yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1747320104; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=FFAc4me6dA43gTpAEn3lm8rrtdJH+GgGmL2LNHmav4A=; b=b/5URDa/yABUaTQCEIMHY5lzlPzQcyGztl6fkjKdxAoOgUB4PrfyjrP9P2NoTm+Z/1D8JS Y/V36m63Hto+YZOaAWqcC5iN0MUTMGbhzbU/A8dutvfy8E6/tomAnpYrZepeY1ftTz5Dp9 330aCaHh/63VmBgWZGdHEjP6fnVZkMGONQr+D/boN1i/l2gYiw2ZyRbDkRPOL2iaVw83h7 NXSFnCvFjR1oj+Tra5+GF50+tAdHF2I7b8Y66k2ZW+nZurGLa+lSI6QxnWdgzWzWVY0LW/ RyRLdaxa6+H0988zySCSCeGSYr5Z0KNTw6w8r7wznN7up9A/lVMaQrQ+WHgD8g== ARC-Seal: i=1; s=lahtoruutu; d=iki.fi; t=1747320104; a=rsa-sha256; cv=none; b=GpHbN4JaqKIM4iB7op1/4s/BR/GMvOb060dfJAmXcLgPVzcHL0Lgm3bHUKFojbIA6PdXjh dhDYrl0QacxXdd0LhaR3RLtxYlINeW8EO7ty5loUFBpS89HATt6W9bAApjoy0gv4LHxcBs dB7c6JfergRk0k+HzlRVnDLh7sNxuK8oxkacmNLhg2ecDt2fh+/jYrBoZz3LqjDnPzz4k/ N/lkiaiC+uz+A4gZQddm3F3MccCnsOEEApgNa8gBjBHV6HoKP04MHTrHwXlIP7MO/Bxkok htrGoDcSv3rWtjX0octxG2iLI+8n9BReGm6NzvrQn4qM5uDwoS+N+tOavl4WVA== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=hlinnaka smtp.mailfrom=hlinnaka@iki.fi Content-Type: multipart/mixed; boundary="------------dd1fcPV7O4xu2s42CRDOtmuB" Message-ID: <349f86e9-6922-4fcc-9725-b8a6f0667bea@iki.fi> Date: Thu, 15 May 2025 17:41:42 +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. To: 707330139@qq.com, pgsql-bugs@lists.postgresql.org, PG Bug reporting form References: <18929-077d6b7093b176e2@postgresql.org> Content-Language: en-US From: Heikki Linnakangas In-Reply-To: <18929-077d6b7093b176e2@postgresql.org> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------dd1fcPV7O4xu2s42CRDOtmuB Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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. -- Heikki Linnakangas Neon (https://neon.tech) --------------dd1fcPV7O4xu2s42CRDOtmuB Content-Type: text/x-patch; charset=UTF-8; name="fix-with-ties-deparse.patch" Content-Disposition: attachment; filename="fix-with-ties-deparse.patch" Content-Transfer-Encoding: base64 ZGlmZiAtLWdpdCBhL3NyYy9iYWNrZW5kL3V0aWxzL2FkdC9ydWxldXRpbHMuYyBiL3NyYy9i YWNrZW5kL3V0aWxzL2FkdC9ydWxldXRpbHMuYwppbmRleCA0NjdiMDgxOThiOC4uNDc0Y2E3 ZTlhZTMgMTAwNjQ0Ci0tLSBhL3NyYy9iYWNrZW5kL3V0aWxzL2FkdC9ydWxldXRpbHMuYwor KysgYi9zcmMvYmFja2VuZC91dGlscy9hZHQvcnVsZXV0aWxzLmMKQEAgLTU5NTYsOSArNTk1 NiwxOSBAQCBnZXRfc2VsZWN0X3F1ZXJ5X2RlZihRdWVyeSAqcXVlcnksIGRlcGFyc2VfY29u dGV4dCAqY29udGV4dCkKIAl7CiAJCWlmIChxdWVyeS0+bGltaXRPcHRpb24gPT0gTElNSVRf T1BUSU9OX1dJVEhfVElFUykKIAkJeworCQkJLyoKKwkJCSAqIFRoZSBsaW1pdENvdW50IGFy ZyBpcyBhIGNfZXhwciwgc28gaXQgbmVlZHMgcGFyZW5zLiBTaW1wbGUKKwkJCSAqIGxpdGVy YWxzIGFuZCBmdW5jdGlvbiBleHByZXNzaW9ucyB3b3VsZCBub3QgbmVlZCBwYXJlbnMsIGJ1 dAorCQkJICogdW5mb3J0dW5hdGVseSBpdCdzIGhhcmQgdG8gdGVsbCBpZiBhIENvbnN0IHd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