Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tg3EK-007Ivd-4R for pgsql-general@arkaria.postgresql.org; Thu, 06 Feb 2025 14:51:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tg3EJ-008IoL-4Q for pgsql-general@arkaria.postgresql.org; Thu, 06 Feb 2025 14:51:47 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tg3EI-008Io4-Ou for pgsql-general@lists.postgresql.org; Thu, 06 Feb 2025 14:51:46 +0000 Received: from mail1.dalibo.net ([51.159.93.128] helo=mail.dalibo.com) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tg3EF-003XyJ-2h for pgsql-general@lists.postgresql.org; Thu, 06 Feb 2025 14:51:45 +0000 Received: from [192.168.1.131] (55.110.220.81.rev.sfr.net [81.220.110.55]) by mail.dalibo.com (Postfix) with ESMTPSA id 6F61425FA6 for ; Thu, 6 Feb 2025 15:51:42 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=dalibo.com; s=a; t=1738853502; bh=IB0U7oz/GuTUAwEzJV2+cxwWdmh0UiMhiDI8rkOpQ/M=; h=Date:Subject:To:References:From:In-Reply-To:From; b=CaCuUTg3nuoyc6EwocbhFSXNObVcNFQXqOJEl1g+6uNhgPZ9XKXyYZL0j5Kn4TW3s X3BmldenWIxfqjb5HXW0H+GkQ6oSwQd498bBiLNCxMxMaQLGq2M7ADz0WGQlx4OGm9 8ALmisSy5nz+elQKrnNMaPqi/6Rze1laD3OG4F78= Message-ID: Date: Thu, 6 Feb 2025 15:51:42 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: libc to libicu via pg_dump/pg_restore? To: pgsql-general@lists.postgresql.org References: <2256966c-446f-4607-a47d-04b895b0747b@dalibo.com> <7A2A897E-AD8B-47F7-A29F-980D57425AD9@gmail.com> Content-Language: fr From: Guillaume Lelarge Organization: Dalibo In-Reply-To: <7A2A897E-AD8B-47F7-A29F-980D57425AD9@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi Paul, On 06/02/2025 12:20, Paul Foerster wrote: > Hi Guillaume, > >> On 6 Feb 2025, at 11:13, Guillaume Lelarge wrote: >> >> You probably don't need --disable-triggers. You should fix errors in the order they appear. The first one is on the drop of the database: >> >> ERROR: cannot drop the currently open database >> >> pg_restore can't drop the database because it's connected to the database. When you use -c and -C options, you can't connect to the database you want to restore to. You have to connect to another database, such as postgres, so that it can do the drop and the create. After both are done, it will connect to the just-created database to do the restore step. >> >> Look at the pg_restore man page (https://www.postgresql.org/docs/current/app-pgrestore.html). It says on the --create option: >> >> When this option is used, the database named with -d is used only to issue the initial DROP DATABASE and CREATE DATABASE commands. All data is restored into the database name that appears in the archive. > > This is intended because the dump contains a create database statement which creates the database with libc which is exactly what I do NOT want. I want it to be a libicu database. So I pre-create it as such and inhibit recreation by pg_restore by sitting on it with a session. So the first message about the database not being created is expected and can be ignored. This works fine for all databases so far. > You're right. Now I see the "create database" query in your previous email. I should have been more careful, sorry for the noise. > My problem is the constraint violation which inhibits the foreign key contraints from being created. > > Everything works for all databases. Only this one has that problem. And since I disabled triggers during restore, that shouldn't be a problem either. > Well, the doc says that --disable-triggers is only relevant for data-only restore, which is not your use case. So you don't need it and it won't help you. > Btw., the parent table contains the rows in question. So they are imported. I just can't make out why there is a problem. > Me neither. But another comment. You create the database, so there should be no objects in it. Why do you use the -c, -C, and --if-exists options? Try without them. On a new database, you should only need: pg_restore -d mydb mydb.dump.gz Less options, less weird behaviours. -- Guillaume Lelarge Consultant https://dalibo.com