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 1w7DeI-0055El-0M for pgsql-novice@arkaria.postgresql.org; Mon, 30 Mar 2026 14:31:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w7DeG-003j5n-1X for pgsql-novice@arkaria.postgresql.org; Mon, 30 Mar 2026 14:31:24 +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 1w7DeG-003j5f-0l for pgsql-novice@lists.postgresql.org; Mon, 30 Mar 2026 14:31:24 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1w7DeE-00000001ogZ-3e0r for pgsql-novice@lists.postgresql.org; Mon, 30 Mar 2026 14:31:23 +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 62UEVI9i2006841; Mon, 30 Mar 2026 10:31:18 -0400 From: Tom Lane To: Ibrahim Shaame cc: depesz@depesz.com, "pgsql-novice@lists.postgresql.org" Subject: Re: Adding column in a recursive query In-reply-to: References: Comments: In-reply-to Ibrahim Shaame message dated "Mon, 30 Mar 2026 17:22:53 +0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2006839.1774881078.1@sss.pgh.pa.us> Date: Mon, 30 Mar 2026 10:31:18 -0400 Message-ID: <2006840.1774881078@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Ibrahim Shaame writes: > Thanks for the reply. Both are integers and they work well without the two > lines. So what changed one of them to text. Can you see where? I have not > been able to identify. This bit is forcing the column names for just the first three output columns, leaving the rest to default from the SELECT targetlist: WITH RECURSIVE x(jina, namba, nasaba_1) AS ( That's a hazardous practice: usually I'd force all or none of the column names that way. In this case, I speculate that you carelessly added the new column as one of the physically first three SELECT outputs, and didn't adjust this list to match, leading to confusion about which column is "x.namba". If that's not it, you need to be a great deal more specific about exactly how you changed the query. regards, tom lane