Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mRihA-0002bG-UF for pgsql-bugs@arkaria.postgresql.org; Sat, 18 Sep 2021 22:20:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mRih9-00060W-87 for pgsql-bugs@arkaria.postgresql.org; Sat, 18 Sep 2021 22:20:27 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mRih8-00060O-Ss for pgsql-bugs@lists.postgresql.org; Sat, 18 Sep 2021 22:20:27 +0000 Received: from mail-qv1-xf34.google.com ([2607:f8b0:4864:20::f34]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mRih5-0006Lm-Rq for pgsql-bugs@lists.postgresql.org; Sat, 18 Sep 2021 22:20:25 +0000 Received: by mail-qv1-xf34.google.com with SMTP id z12so8786581qvx.5 for ; Sat, 18 Sep 2021 15:20:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=systemguards-com-ec.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=zEGsDJsLBGkdMHB5EPuuWCMA9eoux5bqGT/A3oYlVIQ=; b=srtP+QepoHF1XEUlXd5p/ZoZIUmkM4Oc9Vh/9DYEjgnhQvYEfu6egYWk20pnxnPyIy GB4/+We/oraNe7FODiNGnOIL4xwMRa0PFKu9qM4Mts9HvxygQWDd73XO2PN6+AkgJ1MJ QJTDMpYJisMToHMPsfHAMLuJuq9Renk57YLVt3UqEKSw7fU0ald0qdMTYrF8aGj2ie30 9EnoZpS64qBceKXmEf+i/ZjVvN5pvNW2JGvNPU5t1krSEeVxHA/3W9+SFZTmHIix9FHz +e32fLtsEfIrCF4dMyAQSGF0dn9kIy+N5vlICRkKRPkv6V87Z3OS1uk7txHoEtyu7z1l hhnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=zEGsDJsLBGkdMHB5EPuuWCMA9eoux5bqGT/A3oYlVIQ=; b=wpQgsgi9+tyc88C7J6yG0UYwTLBftwfcHmgOxXmbhmDCKFW3YTONTYfwbOYd7bJSYP OtcTzwjbISd7LbxcAAhTfrlRWYIsYH4IGBTMYasEjLW44aZJ42j/HlpH6E7qXhqK5bmX InMrmgwpjsD5baQ6oi94Bn2z4GXRBnBVfZhGUqLSTtAJOP7R+3g4f3OEq5GReYy6c68+ q0Nmo+SiZTc4CBv3QEb2uPooZSI5iw1wFVxOJH+ikxEb56CWSvr97+Tc6GtQIagVkv1p 7FhB7UWnQPdHJDKICOmBJubWJGw23oL95mHvHgrAQWh0bPkcl06UtrIty8kVKqkd2JMT 7hTA== X-Gm-Message-State: AOAM532GYk2rvuO5pIEm+XzCZGnxw7OrY7/UftEdqp654vN+2AaFuljQ KoVVnIyx3bXZuUb/dhHwspkZQg== X-Google-Smtp-Source: ABdhPJxj9xSlhMb9konpA37MXuDU4CNuHmFWsgzL1Ppno2pD3uoAas4LZ3tPq664Ni+b3aYAnkAMJQ== X-Received: by 2002:a0c:90ef:: with SMTP id p102mr18344908qvp.48.1632003621671; Sat, 18 Sep 2021 15:20:21 -0700 (PDT) Received: from ahch-to ([201.183.0.184]) by smtp.gmail.com with ESMTPSA id d12sm7671244qka.60.2021.09.18.15.20.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Sep 2021 15:20:21 -0700 (PDT) Date: Sat, 18 Sep 2021 17:20:17 -0500 From: Jaime Casanova To: Tom Lane Cc: blo.talkto@gmail.com, pgsql-bugs@lists.postgresql.org, Peter Eisentraut Subject: Re: BUG #17061: Impossible to query the fields of the tuple created by SEARCH BREADTH FIRST BY .. SET .. Message-ID: <20210918222017.GA12334@ahch-to> References: <17061-dd7f4825b7da3a9d@postgresql.org> <972632.1623941414@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <972632.1623941414@sss.pgh.pa.us> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Jun 17, 2021 at 10:50:14AM -0400, Tom Lane wrote: > [ screwed up the cc somehow the first time, sorry for the duplicate ] > > PG Bug reporting form writes: > > WITH RECURSIVE mtree(id, name) AS ( ... > > ) SEARCH BREADTH FIRST BY id SET breadth > > SELECT (breadth)."*DEPTH*" > > FROM mtree m; > > ERROR: CTE m does not have attribute 3 > > Yeah, I get that with "SELECT (breadth).*" as well. I'm not entirely sure > what this silly-looking syntax is supposed to mean, but it seems to be > adding an output column named "breadth" to the CTE. The error is > occurring because said column has not been added to the relevant > CommonTableExpr struct. Peter? > Just to add fuel to the fire, I just noted that you cannot create a view based on a recursive CTE using this syntax. """ create view v1 as WITH RECURSIVE mtree(id, name) AS ( SELECT id, name FROM tree WHERE id = 1 UNION ALL SELECT t.id, t.name FROM tree AS t INNER JOIN mtree AS m ON t.parent_id = m.id ) SEARCH BREADTH FIRST BY id SET breadth SELECT * FROM mtree m; ERROR: column "breadth" has pseudo-type record """ -- Jaime Casanova Director de Servicios Profesionales SystemGuards - Consultores de PostgreSQL