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 1kk982-0004On-RI for pgsql-bugs@arkaria.postgresql.org; Tue, 01 Dec 2020 17:07:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kk981-0001u5-Lu for pgsql-bugs@arkaria.postgresql.org; Tue, 01 Dec 2020 17:07:49 +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 1kk981-0001r4-G0 for pgsql-bugs@lists.postgresql.org; Tue, 01 Dec 2020 17:07:49 +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 1kk97z-0008U0-5k for pgsql-bugs@lists.postgresql.org; Tue, 01 Dec 2020 17:07:48 +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 0B1H7fnl1399711; Tue, 1 Dec 2020 12:07:42 -0500 From: Tom Lane To: Marc Boeren cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #16758: create temporary table with the same name loses defaults, indexes In-reply-to: References: <16758-840e84a6cfab276d@postgresql.org> <1396479.1606838336@sss.pgh.pa.us> Comments: In-reply-to Marc Boeren message dated "Tue, 01 Dec 2020 16:26:40 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1399709.1606842461.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2020 12:07:41 -0500 Message-ID: <1399710.1606842461@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk [ please keep the mailing list cc'd ] Marc Boeren writes: >> Without having dug into the code, I bet what is >> happening is that after creating pg_temp.xx, the LIKE code is looking >> to see "what indexes exist on table xx?", to which the answer is "none" >> because it finds pg_temp.xx. We need to nail down the schema in which >> xx is sought for that step. As a workaround, you could nail down the >> schema manually: >> = >> create temporary table xx (like public.xx including DEFAULTS including >> CONSTRAINTS including INDEXES); > This workaround works both on the example code, and on my production cod= e. Thanks for confirming the diagnosis! > Not sure if it's a bug worth fixing, but perhaps a mention in the docume= ntation? No, it's definitely a bug IMO. The change in behavior was not intentional. regards, tom lane