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 1v8gNh-001MtG-M1 for pgsql-bugs@arkaria.postgresql.org; Tue, 14 Oct 2025 14:52:05 +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 1v8gMh-00109K-1E for pgsql-bugs@arkaria.postgresql.org; Tue, 14 Oct 2025 14:51:02 +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 1v8gMg-001093-P3 for pgsql-bugs@lists.postgresql.org; Tue, 14 Oct 2025 14:51:01 +0000 Received: from lana.depesz.com ([88.198.49.178] helo=depesz.com) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1v8gMd-001jTi-1p for pgsql-bugs@lists.postgresql.org; Tue, 14 Oct 2025 14:51:00 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=depesz.com; s=20170201; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Reply-To: Message-ID:Subject:To:Sender:From:Date:Cc:Content-ID:Content-Description: In-Reply-To:References; bh=AUeUEUFBjSO1djvisEM2IeXl8YxrQaJ16eDq86mfupc=; b=PU 1jg5cFpV1/5KPakDC+ulEXr4T9yC56bisUhlZsbchDyBqubhsT4oA7rjTTZdFTGiKieHHfYK1KRfc M8B5+fbkzu2hJZFyfitkkr7gfpmeCwQUndb9aGHDhu6B/NRvN2Z8DiqshfrgxQ4dHaynEmQqj4VMi DpqUjYvG1PXbSAM=; Received: from depesz by depesz.com with local (Exim 4.96) (envelope-from ) id 1v8gMa-00EyQ3-0A for pgsql-bugs@lists.postgresql.org; Tue, 14 Oct 2025 16:50:56 +0200 Date: Tue, 14 Oct 2025 16:50:56 +0200 From: hubert depesz lubaczewski Sender: depesz@depesz.com To: pgsql-bugs@lists.postgresql.org Subject: order by alias - doesn't work sometimes? Message-ID: Reply-To: depesz@depesz.com MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, It very well might not be a bug, but it caught me by surprise. Tested on Pg 19 from git head: =$ select unnest( ARRAY['d', 'c', 'a'] ) x order by x; x ─── a c d (3 rows) Works, and shows that I can order by alias name of column that is generated by srf. But: =$ select unnest( ARRAY['d', 'c', 'a'] ) x order by x <> 'a'; ERROR: column "x" does not exist LINE 1: select unnest( ARRAY['d', 'c', 'a'] ) x order by x <> 'a'; ^ Obviously I can put the unnest() call in from, and then it works, but I'm curious, why we can `order by x`, but not `order by x <> 'a'` ? Best regards, depesz