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 1mudBv-0006vl-CB for pgsql-hackers@arkaria.postgresql.org; Tue, 07 Dec 2021 16:19:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mudBu-0004mD-9J for pgsql-hackers@arkaria.postgresql.org; Tue, 07 Dec 2021 16:19:42 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mudBt-0004lv-UB for pgsql-hackers@lists.postgresql.org; Tue, 07 Dec 2021 16:19:42 +0000 Received: from mail-lf1-x12c.google.com ([2a00:1450:4864:20::12c]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mudBr-0003AS-GY for pgsql-hackers@lists.postgresql.org; Tue, 07 Dec 2021 16:19:40 +0000 Received: by mail-lf1-x12c.google.com with SMTP id m27so34648997lfj.12 for ; Tue, 07 Dec 2021 08:19:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=MRVfIMPBCKaZoCy3szFATXh6dK9yMWszP546vvn28Mw=; b=PfdNfQnl3QeaU91fXe/MCNWEttDqQZOtSrZ4PL3+C10B77o7jgH6Fsa7KJTTj+k9Be Yvv8Gcw9IZR5H6yWxZepkvgbH4F5Iq3xoobZhBLJEBLPVZW+vjArkcQUg8e02rTDBSNK /MhM3vDVEaHHUcRq1kkSKU7bbvk9MXf2dJn+yLxckTI5i2to05d6EtDGHuuSWdIH77Jk /03PGWcakFgqZddq/yKw2ttKDslMcHLSu11dsE/xSSU76yZ/HsruQKVVdLMSlOg5YACy wAOudC7BHaJc4y6IcAwOKtyBRgFE72yjOncLCo5YHNi8hFDNKsS09f6loTfmxZJf9SWo 7WyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=MRVfIMPBCKaZoCy3szFATXh6dK9yMWszP546vvn28Mw=; b=wF3USH6Pz10OaYuuw0UQ+Du65NXgyucR6iDbEFeoR0g1C2qlrZrWd/zy/FeBq31+q3 toeHmxU3UnEmL/edO6PlfSuTrTjwPV7EOhBt7MIeAgbiuxEcZrKLV2PbPglLKz5M3X6A uCgInSe3KgOQmU6/UqyBYHF/bTB822Hv59fXdGTutzxPlR/MtMmoosjZHDPi3PPvYSN0 rG2YAt6pUhWZGrL55tyYDKDLx0erv29XyswXlJJKlYezyZvBRSwwJWeds2QEByW+20DA kwihHbtUiwSDuVzp/eweZOKzKa+BvivoJbDhxiZOEtR6NII0g6AAQjhg/mUI19L9ZcrT PMqQ== X-Gm-Message-State: AOAM532GxV3HvujYJ1Hp5+l25N4mU1vC24Nn4bduwsWiHm7kzaFcmdSh Ok1kO+AbePSG0POTA/2wDdW5u/enKue5CazFReVYYj684Ho= X-Google-Smtp-Source: ABdhPJzZSXCp4E8j7FKZL5zAnoW69VyRzbyxxTQ4O4yg6ErDDv27bUXInlrzWLhiDSpqQuAp0aeZ3ctkEib11cYipU4= X-Received: by 2002:a05:6512:2ef:: with SMTP id m15mr13151986lfq.268.1638893978010; Tue, 07 Dec 2021 08:19:38 -0800 (PST) MIME-Version: 1.0 References: <2950001.1638729947@sss.pgh.pa.us> <3360468.1638824732@sss.pgh.pa.us> In-Reply-To: <3360468.1638824732@sss.pgh.pa.us> From: Robert Haas Date: Tue, 7 Dec 2021 11:19:27 -0500 Message-ID: Subject: Re: ExecTypeSetColNames is fundamentally broken To: Tom Lane Cc: PostgreSQL Hackers Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Dec 6, 2021 at 4:05 PM Tom Lane wrote: > Well, that was what I thought when I wrote bf7ca1587, but it leads > to logical contradictions. Consider > > create table t (a int, b int); > > create function f(t) returns ... ; > > select f(t) from t; > > select f(t) from t(x,y); > > If we adopt the "rename for all purposes" interpretation, then > the second SELECT must fail, because what f() is being passed is > no longer of type t. If you ask me, that'll be a bigger problem > for users than the change I'm proposing (quite independently of > how hard it might be to implement). It certainly will break > a behavior that goes back much further than bf7ca1587. For me, the second SELECT does fail: rhaas=# select f(t) from t(x,y); ERROR: column "x" does not exist LINE 1: select f(t) from t(x,y); ^ If it didn't fail, what would the behavior be? I suppose you could make an argument for trying to match up the columns by position, but if so this ought to work: rhaas=# create table u(a int, b int); CREATE TABLE rhaas=# select f(u) from u; ERROR: function f(u) does not exist rhaas=# select f(u::t) from u; ERROR: cannot cast type u to t Matching columns by name can't work because the names don't match. Matching columns by position does not work. So if that example succeeds, the only real explanation is that we magically know that we've still got a value of type t despite the user's best attempt to decree otherwise. I know PostgreSQL sometimes ... does things like that. I have no idea why anyone would consider it a desirable behavior, though. -- Robert Haas EDB: http://www.enterprisedb.com