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 1kXbCW-0007OE-3r for pgsql-general@arkaria.postgresql.org; Wed, 28 Oct 2020 02:28:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kXbCV-0006ba-2X for pgsql-general@arkaria.postgresql.org; Wed, 28 Oct 2020 02:28:35 +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 1kXbCU-0006bT-Qr for pgsql-general@lists.postgresql.org; Wed, 28 Oct 2020 02:28:34 +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 1kXbCR-00073b-Av for pgsql-general@postgresql.org; Wed, 28 Oct 2020 02:28:33 +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 09S2STHt1219520; Tue, 27 Oct 2020 22:28:29 -0400 From: Tom Lane To: raf cc: pgsql-general@postgresql.org Subject: Re: pg_restore: error: schema "public" already exists In-reply-to: <20201028014514.xel46ej4uy3bxdgs@raf.org> References: <20201028014514.xel46ej4uy3bxdgs@raf.org> Comments: In-reply-to raf message dated "Wed, 28 Oct 2020 12:45:14 +1100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1219518.1603852109.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 27 Oct 2020 22:28:29 -0400 Message-ID: <1219519.1603852109@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk raf writes: > A colleague is getting this error when trying to load a > database dump: > pg_restore: error: could not execute query: ERROR: schema "public" al= ready exists > I'm wondering if anyone can explain it. The public schema is a bit of a strange beast, and pg_dump has to special-case it in some ways. We've moved those special cases around from time to time, too. So one likely explanation here has to do with version discrepancies between the pg_dump that made the dump file and the pg_restore that's restoring it. Also, I do not think that you're telling us the whole truth about how your colleague is running pg_dump and/or pg_restore. There shouldn't be any "CREATE SCHEMA public" issued if you didn't say -c. regards, tom lane