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 1mIXzp-0007a5-JS for pgsql-bugs@arkaria.postgresql.org; Tue, 24 Aug 2021 15:05:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mIXzo-0007m3-Cj for pgsql-bugs@arkaria.postgresql.org; Tue, 24 Aug 2021 15:05:48 +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 1mIXzo-0007lu-61 for pgsql-bugs@lists.postgresql.org; Tue, 24 Aug 2021 15:05:48 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mIXzi-00014j-FP for pgsql-bugs@lists.postgresql.org; Tue, 24 Aug 2021 15:05:47 +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 17OF5c0c343748; Tue, 24 Aug 2021 11:05:38 -0400 From: Tom Lane To: David Rowley cc: sait.nisanci@microsoft.com, PostgreSQL mailing lists , Peter Eisentraut Subject: Re: BUG #17158: Distinct ROW fails with Postgres 14 In-reply-to: <333555.1629813806@sss.pgh.pa.us> References: <17158-8a2ba823982537a4@postgresql.org> <333555.1629813806@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Tue, 24 Aug 2021 10:03:26 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <343746.1629817538.1@sss.pgh.pa.us> Date: Tue, 24 Aug 2021 11:05:38 -0400 Message-ID: <343747.1629817538@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk I wrote: > David Rowley writes: >> Tom did have a look at this and raise the question about the >> possibility of not being able to hash in [1]. > Huh. According to the thread, we discussed this exact possibility and > there's a test case verifying it ... so apparently something got > fat-fingered there. I think this is on me, because I must not have looked closely enough at Peter's test case to realize that he was proposing to consider it okay to fail. We can't have that, for exactly the reason seen here, which is that people will consider it a regression if their queries used to work and now hit this error. The proximate cause of the problem is this over-optimistic bit in cache_record_field_properties(): /* * For type RECORD, we can't really tell what will work, since we don't * have access here to the specific anonymous type. Just assume that * everything will (we may get a failure at runtime ...) */ if (typentry->type_id == RECORDOID) { typentry->flags |= (TCFLAGS_HAVE_FIELD_EQUALITY | TCFLAGS_HAVE_FIELD_COMPARE | TCFLAGS_HAVE_FIELD_HASHING | TCFLAGS_HAVE_FIELD_EXTENDED_HASHING); } where 01e658fa74 just blindly added hashing to the set of things we assume an unknown record type can do. While we seem to have mostly gotten away with assuming that comparison ops are available, it's clearly a step too far to assume that hashing is. The correct long-term fix is to remove this assumption altogether in favor of adding code to check more carefully in the planner. But it's probably a bit late in the game to try to fix that for v14. I propose that we just revert this code to the way it was before (and improve the comment to explain what's going on). regards, tom lane