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 1tzFeQ-00HIe9-4j for pgsql-hackers@arkaria.postgresql.org; Mon, 31 Mar 2025 13:58:06 +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 1tzFeO-006IDC-PB for pgsql-hackers@arkaria.postgresql.org; Mon, 31 Mar 2025 13:58:04 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tzFeO-006ID4-7H for pgsql-hackers@lists.postgresql.org; Mon, 31 Mar 2025 13:58:04 +0000 Received: from mail-qk1-x736.google.com ([2607:f8b0:4864:20::736]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tzFeL-002EnQ-0M for pgsql-hackers@lists.postgresql.org; Mon, 31 Mar 2025 13:58:03 +0000 Received: by mail-qk1-x736.google.com with SMTP id af79cd13be357-7c5ba363f1aso655137585a.0 for ; Mon, 31 Mar 2025 06:57:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dunslane-net.20230601.gappssmtp.com; s=20230601; t=1743429478; x=1744034278; darn=lists.postgresql.org; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :from:references:cc:to:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=syo37QCw83AL3+qAopXlGJO4CAJ4mMHZocUL9abWOuc=; b=eM0/cpJQ0BKGOiM2BzEfTH+SczLLzl3KtfiWVR2gopKmsrlKRl0qQQt1kR51J3fT89 FWQ9mLfUgtxqPtL3/LThfsZR4XInYy/GXXgiSfEbwTV9iFT5jEQH6C7y+Xw/ewnO94Ep tn+AOTkaou6Z2h6/zZeHRux0BK/JfucdPlG2CBKXKx9cUxXYOSyRd6B7OsEiEc6LmLZj lC0vosWmdFtDMriP3t97fxWDuAxsHtzh/qZKU5jPki4ObvwQhao7I0pXWImlhsBUOExn 7ClqHYGWX8udpxT1dXeMXyEHYOLP3A4Rr6fWRz1nHuYMKducQldtRHkOo+uEYot49Afv V7rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743429478; x=1744034278; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :from:references:cc:to:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=syo37QCw83AL3+qAopXlGJO4CAJ4mMHZocUL9abWOuc=; b=jmA1nLg/Y4v82Z96iRV3+zEj/XDQIpXekmIZ5hWQsXWpY1ZlEB8Xk7jjEjMkPVC7Av r5kP3DEALVEfgsZik1xB8EJXLy57wNKdmwYysboYCfJdum8eYYHBuMwoLikdC62RscvX F86Arxoz40uE3JVOAZbyz3oQ9DE5HNMFnziIi/zxYLYqSqXl6CGBT1X+yRqrbu5Wgcql /9yWvuT0YgYaBo9A+eKw+OcoerF/WB+8hHyowDYAgRkVpoy0N6fiTDtN9fCL2ukPLsF0 CXasKg+nmJXz31vZdMtu8h5HBjKGxeXDG75FUz0i4AmDJRhi9IgDtuCs4tjgpXvJi3HA 2Xtg== X-Forwarded-Encrypted: i=1; AJvYcCXeUAdvBnuE4W2eLd9C86YJeuYDygnbyBArncOWFtgVMkj8peATNdV4VNHAwDbKbZpn7saoe2s2KHHlzJTR@lists.postgresql.org X-Gm-Message-State: AOJu0YweT2J95bbPd29xHOPgXrb74fg1g7hV/rMJmFsnfhqHYu1o0IKA 10n8I64BQ4TYGDyxQmZ16PJyaoIfRgDdrMQAAS/GsC9irHh1dw3BxVP1UxuonfY= X-Gm-Gg: ASbGncuF86YNKxF2dyWg3G4og8xubms4cXSiX7eXnmGldQtQcghDs8HdOdXaO9MHHAe 9XRrBGcEGM+Z7WNKIt3cul2tIECfJxt088xBRMg55zXtuI209OhIGF4a19vE1re3q+tugi+0Xyt 5W/ZNI7iXC+7DYWqex0hCK3ogya71kJWzVzlruKGyFLoSpzGqW+1V+f5HZV0PH5HSmA+gejST5A ehyYm3SVKZdQrgYYOxlqtWsGDobJR/M3DYfoy0ScTa00Mm0qkFBbGRbxFrklrKYY45F3Xfl411p kQYNLrQAOibxCg+d2SzJ5AZ84GRYOmqF4WZ+/C/iLGD9w0Qqcgbk4f8= X-Google-Smtp-Source: AGHT+IFo4IPEcEhVPE2ncUiwzlh+A4nHYR3SPcW6eq+I93MpRXpyGfKCjBPPCwyb03dIqcONKanJwQ== X-Received: by 2002:a05:620a:f01:b0:7c3:d711:6ffb with SMTP id af79cd13be357-7c690875736mr1432044085a.41.1743429478526; Mon, 31 Mar 2025 06:57:58 -0700 (PDT) Received: from ?IPV6:2605:a601:a681:6b00::1cb? ([2605:a601:a681:6b00::1cb]) by smtp.googlemail.com with ESMTPSA id af79cd13be357-7c5f779aa36sm502384585a.117.2025.03.31.06.57.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 31 Mar 2025 06:57:58 -0700 (PDT) Message-ID: Date: Mon, 31 Mar 2025 09:57:56 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Non-text mode for pg_dumpall To: Mahendra Singh Thalor Cc: jian he , =?UTF-8?Q?=C3=81lvaro_Herrera?= , Srinath Reddy , pgsql-hackers@lists.postgresql.org References: <202503111705.xy7fddu36qae@alvherre.pgsql> <4ef51faa-993f-46ea-9e68-7baf736c07b8@dunslane.net> <763d1c6e-9298-4bac-9bea-9331db78a154@dunslane.net> From: Andrew Dunstan Content-Language: en-US Autocrypt: addr=andrew@dunslane.net; keydata= xsBNBE7KWFkBCAClridxur2AIc7eW2AR7izbfp3EnNefie2HbLF0izW5Ik5UjX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P6al3MWOvpP/ExJPguEfjOsO6Njy xjo3WfpD4lHMOR/Oc3/8mScEF84rF2jXbsFgelWnbPWAvXY+pD0dXOFRkagGmC/viwBDqq5b 5tk76kKmUbZxABEBAAHCwHwEGAEIACYCGwwWIQTkPlhGHfx8v0RpFaWZ+n/LWfw7gQUCZFlx 5wUJGVGAjgAKCRCZ+n/LWfw7gf+iB/4g8CPY5jihf5r/8EsoIGe2H+dpVmpPF8YGBzTIvCz/ fQoOq8AX/pE76QEuFnFZWfjw+wgBXgCVmkox2Eflkk6z4ND3pcwGZ6CfCxTQCDk/dij+2DQ4 6bmDCy/sBgcbz9mTpoLC11HLoPae6YN9nBNQRZDcEFEu54OaVOqlIdbA6m+POIBCXZdHOFc0 WoDTgxHRzC1jgQNidyd6tKqcsVJs0dzF0oKTmFFmUAqTdJO12LBuNA1rlqrR3EtpYk8B/wtS 5dIMD7Q8hwQpL+4C6GNpb6ZKnPkLi47pDOLhz2qBrqN+rqUEsT3YnExYpzj5yOBi+FlmV1Hw 49QYe1sn2ZPs In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2025-03-31 Mo 5:34 AM, Mahendra Singh Thalor wrote: > > > > > There are a couple of rough edges, though. > > > > First, I see this: > > > > > > andrew@ub22arm:inst $ bin/pg_restore -C -d postgres > > --exclude-database=regression_dummy_seclabel > > --exclude-database=regression_test_extensions > > --exclude-database=regression_test_pg_dump dest > > pg_restore: error: could not execute query: "ERROR:  role "andrew" > > already exists > > " > > Command was: " > > > > -- > > -- Roles > > -- > > > > CREATE ROLE andrew;" > > pg_restore: warning: errors ignored on global.dat file restore: 1 > > pg_restore: error: could not execute query: ERROR:  database "template1" > > already exists > > Command was: CREATE DATABASE template1 WITH TEMPLATE = template0 > > ENCODING = 'SQL_ASCII' LOCALE_PROVIDER = libc LOCALE = 'C'; > > > > > > pg_restore: warning: errors ignored on database "template1" restore: 1 > > pg_restore: error: could not execute query: ERROR:  database "postgres" > > already exists > > Command was: CREATE DATABASE postgres WITH TEMPLATE = template0 ENCODING > > = 'SQL_ASCII' LOCALE_PROVIDER = libc LOCALE = 'C'; > > > > > > pg_restore: warning: errors ignored on database "postgres" restore: 1 > > pg_restore: warning: errors ignored on restore: 3 > > > > > > > > It seems pointless to be trying to create the rolw that we are connected > > as, and we also expect template1 and postgres to exist. > > Thanks Andrew for the updated patches. > > Here, I am attaching a delta patch which solves the errors for the > already created database and we need to reset some flags also. Please > have a look over this delta patch and merge it. > > If we want to skip errors for connected user (CREATE ROLE username), > then we need to handle it by comparing sql commands in > process_global_sql_commands function or we can compare errors after > executing it. > delta_0002* patch is doing some handling but this is not a proper fix. > > I think we can merge delta_0001* and later, we can work on delta_0002. Yes, delta 1 looks OK, except that the pstrdup() calls are probably unnecessary. Delta 2 needs some significant surgery at least. I think we can use it as at least a partial fix, to avoid trying to create the role we're running as (Should use PQuser() for that rather than cparams.user). BTW, if you're sending delta patches, make sure they don't have .patch extensions. Otherwise, the CFBot gets upset. I usually just add .noci to the file names. cheers andrew -- Andrew Dunstan EDB: https://www.enterprisedb.com