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 1siwAJ-00BLxn-25 for pgsql-bugs@arkaria.postgresql.org; Tue, 27 Aug 2024 13:23:19 +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 1siwAH-007QuT-20 for pgsql-bugs@arkaria.postgresql.org; Tue, 27 Aug 2024 13:23:17 +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 1siwAG-007QuL-PK for pgsql-bugs@lists.postgresql.org; Tue, 27 Aug 2024 13:23:17 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1siwAD-001lH5-CX for pgsql-bugs@lists.postgresql.org; Tue, 27 Aug 2024 13:23:16 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 47RDN8rj3038763; Tue, 27 Aug 2024 09:23:08 -0400 From: Tom Lane To: Richard Guo cc: tlhquynh@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18589: pg_get_viewdef returns wrong query In-reply-to: References: <18589-70091cb81db1a3f1@postgresql.org> <2906775.1724692311@sss.pgh.pa.us> Comments: In-reply-to Richard Guo message dated "Tue, 27 Aug 2024 18:03:44 +0800" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <3038761.1724764988.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Tue, 27 Aug 2024 09:23:08 -0400 Message-ID: <3038762.1724764988@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Richard Guo writes: > Alternatively, can we set special_exprkind = EXPR_KIND_ORDER_BY in > get_rule_orderby? I’m looking for a approach that is parallel to how > we set special_exprkind = EXPR_KIND_GROUP_BY in get_basic_select_query. I don't want to do that because it would result in prefixing Vars within grouping/ordering expressions, which is unnecessary. Only a bare Var requires this treatment. regards, tom lane