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 1tzIkO-000VVy-Ag for pgsql-hackers@arkaria.postgresql.org; Mon, 31 Mar 2025 17:16:28 +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 1tzIkM-0095J4-70 for pgsql-hackers@arkaria.postgresql.org; Mon, 31 Mar 2025 17:16:26 +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 1tzIkL-0095Iv-KB for pgsql-hackers@lists.postgresql.org; Mon, 31 Mar 2025 17:16:25 +0000 Received: from mail-qk1-x732.google.com ([2607:f8b0:4864:20::732]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tzIkI-002B6L-2c for pgsql-hackers@lists.postgresql.org; Mon, 31 Mar 2025 17:16:24 +0000 Received: by mail-qk1-x732.google.com with SMTP id af79cd13be357-7c54a9d3fcaso432172985a.2 for ; Mon, 31 Mar 2025 10:16:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dunslane-net.20230601.gappssmtp.com; s=20230601; t=1743441381; x=1744046181; 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=VqtoWTV+g9JsPR8p44CA02wJqVrrNHLuyqnjHi9MBQw=; b=AE3uZsN2JT0cQf1rTKpKbcywvjAPUWP0T/GjEhopk6RUXNsOl+lio0BbjEkf/AzFYY kW2LOmSx0NQUbKvLacOYoZlbaHR9+7plxd65rDhw5ZvJsGJUDo5au0tgA3pDWFtPQjl3 yyJYGLwnbZz6TrdWTqfBHjNiz8bbMv6X/JL2zUyW/vVlLHYNA6L9csCpp1b8xAJzFVXs ZNae/9luQhV5mOoLswrY4+N0Xf+YSXAwq2wL8ULTL9inY/aX8ZPVOTwDDXc0WcCnJDFz mWkB8qutUJu+K3x5xzeGO5Mkap8csName1Kh+tQ8mL+ztNu+aEO4r/DaF4ei9zyqfYzE Cf3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743441381; x=1744046181; 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=VqtoWTV+g9JsPR8p44CA02wJqVrrNHLuyqnjHi9MBQw=; b=xIZten0VMkXAtwvyTsO4Y6OaVEYiUfrowrq39lLxAMM6QlS3W5/F1sPwKBTyNoVFTM 38o3KqYGtSJRbTnBB506XNEy0dxSh8EJEsPy+RUfTy2IKti8exSWlBna1WxQCoYqe639 uA6wvxTrlBndyIcsfIgRvcR181OZAa8ZCNwL7xxWnmYqmO37edeXAK3pDUyeu4EDOLyz iAxXGNwfOB+D+afbhZ8PFw6QESjPAc7cJBssXJJTWpuT5/T6LEPwhwqBfmFu1m/ygb+e jfRvpT4eqMx/pCnZ7Nm9k7cLjiqIGmt+MeC/ot9dGnsvhNJ+9CkK50silWJTZeyW29bY A0ng== X-Forwarded-Encrypted: i=1; AJvYcCXnrHH+mHaly+SiKm7G3C8Ic0wUOLgoJJBw5Y9aF1NqT/LANTbVqsZDT4hd8CJJ1ObfqEJ6Uce2toOG5krL@lists.postgresql.org X-Gm-Message-State: AOJu0YzA4KcqqkKK3QByIPo1kPXZw73XLYW+deYzpSuxH5tM1K2rydTs hMz4CGIyG0JBSqVeub9N1ama1AbxpH2hdj7kTNAmSsU2DbbIz4105LyZ13n5gfE= X-Gm-Gg: ASbGncvn9/Sv85l1N3FqmLA8ke0yVB3DwvokxMPiIO7B8LJ7e1qGzk6f5DjApyNYmS9 YThS6PwoTe7yPGcRdpghU4lb6Nf9odiV5aXnK2PpfClmCSrLNCKEhy3SlHovQcVacSa5ORdc+1d S1+CeDLwnVqAFQ+S39zTEHhTs0jwVqBSy+3hUw/hehibXohuq+QuLelGochUU5hbmgiuOkBUcxu LQF8LiZLSAwreay46xq5Qogcl8btA/09DOcH18rD5bz2n7/sjzwNdeHCw2ti1pM85tyUtZreTUP dxvYcn+G1hyBdCOziaTsjbGt0W/XU03Gwd6Fr07D6J81hyGpfy/X8c8= X-Google-Smtp-Source: AGHT+IFXCEi53+Da7kQ70/qhZ2teViPO21KqC8IPBt8ogOyNB+UYMlGbA7EeXdZh8eYiBn5HcAH18A== X-Received: by 2002:a05:620a:2685:b0:7c5:3b9d:61fa with SMTP id af79cd13be357-7c69072a6ffmr1288941885a.26.1743441381349; Mon, 31 Mar 2025 10:16:21 -0700 (PDT) Received: from ?IPV6:2605:a601:a681:6b00::1cb? ([2605:a601:a681:6b00::1cb]) by smtp.googlemail.com with ESMTPSA id d75a77b69052e-477831a37f7sm52360211cf.68.2025.03.31.10.16.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 31 Mar 2025 10:16:20 -0700 (PDT) Message-ID: Date: Mon, 31 Mar 2025 13:16:19 -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= xsBNBE7KWFkBCAClridxur2AIc7eW2AR7izbfp3EnNefie2HbLF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bxQVlINt6fd8P6al3MWOvpP/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: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2025-03-31 Mo 12:16 PM, Mahendra Singh Thalor wrote: > On Mon, 31 Mar 2025 at 19:27, Andrew Dunstan wrote: >> >> 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). > Thanks for the quick review. > > I fixed the above comments and made 2 delta patches. Please have a > look over these. > >> 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. > Sure. I will also use .noci. Thanks for feedback. Thanks. Here are patches that contain (my version of) all the cleanups. With this I get a clean restore run in my test case with no error messages. cheers andrew -- Andrew Dunstan EDB: https://www.enterprisedb.com