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 1mbAjP-00051d-UK for pgsql-bugs@arkaria.postgresql.org; Fri, 15 Oct 2021 00:05:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mbAjO-0003R3-R5 for pgsql-bugs@arkaria.postgresql.org; Fri, 15 Oct 2021 00:05:50 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mbAjO-0003Qu-H6 for pgsql-bugs@lists.postgresql.org; Fri, 15 Oct 2021 00:05:50 +0000 Received: from mail-pg1-x531.google.com ([2607:f8b0:4864:20::531]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mbAjK-0000Ho-9Z for pgsql-bugs@lists.postgresql.org; Fri, 15 Oct 2021 00:05:49 +0000 Received: by mail-pg1-x531.google.com with SMTP id f5so6965329pgc.12 for ; Thu, 14 Oct 2021 17:05:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=rx6hNw0DP2F8HAlkvt3JKC/F/VHA5oiRnj51dxyHhkU=; b=X4m7kJ+UWaHP21HlRoxcymJYZO3UYVhD6L59Z6m/DL4Ew7HPkezeeYDAZ75jKBymut ITiX6UIftl6mDCqyKoGx4qIDOEfsEUqxZDJr+3FYje5crRB1z641l50fBlX0vHvHAwCG wSTGW4Rwn4yqBTncCRqJu6mNEFusdRS9oiiei/loVVxfHvn6JgXkkiDvJe33KSHXVgFy FMlQD2wBwsBIZ+Qhd9KT7jkxwg98vi+ABbAzxqxMkEI6r5FXAjExSKQEXmWuG/q0CGn7 PEv62CesiUSEgfBitvXpkYyu6lyiDBwvpAcHVPA9yl/sN+sJFEBBbe3+Irz5rFt3hMib 4BFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=rx6hNw0DP2F8HAlkvt3JKC/F/VHA5oiRnj51dxyHhkU=; b=lpDgYXx0dWcuRto3hWEf60UkTnWaivJsCbJ+mi5Mir7Tz1WSUdwLf4K/wCtj8HXvs0 2ZCMfMvt0uKgrJFdBrN2gihoeK+SBWAcp3vz0BmFGAShsYgZo7CLaEhzPrWa1DRf9iCS MJ8m691UPhvmvywUOA75gWWVR6tLuhjivGxbNjxn75bx4GvayqYpgCajM7AyHQu7l7jX WxEyK3h6io8b9FOzh0MKy51GTL6RIlc7fcoT1epWx83dLdVG2DfJtCiGI4EGzzZMmbCH 8+eAQdX+JgLd28rWRkiOFfipAeFBjviTNVWLjorq5rP3n6c7urMeGT2P1fQMBncG9LbO OxdA== X-Gm-Message-State: AOAM533YvvOJloERJhfUxyXQknGdPI1+ExE0r6UCUTPwJ9Yd6ttravf+ 1+lQ4Ub9aTdxulo5n7DJdi3Xq9mCY4VoSMHzyMg= X-Google-Smtp-Source: ABdhPJzEovZJl5I+muIuokNKQ2QosnCfIlCE5dCsDMhP1eHzLVtBYPvxnJzFJr/zyvqO4aWxHonOZnJ/uHUV2ZVhTGA= X-Received: by 2002:aa7:8010:0:b0:44c:9d9:ecc with SMTP id j16-20020aa78010000000b0044c09d90eccmr8349398pfi.39.1634256343856; Thu, 14 Oct 2021 17:05:43 -0700 (PDT) MIME-Version: 1.0 References: <8261632200581@mail.yandex.ru> <721942.1634180151@sss.pgh.pa.us> In-Reply-To: From: Masahiko Sawada Date: Fri, 15 Oct 2021 09:05:07 +0900 Message-ID: Subject: Re: Inconsistent behavior of pg_dump/pg_restore on DEFAULT PRIVILEGES To: Michael Paquier Cc: Tom Lane , Neil Chen , "Boris P. Korzun" , "pgsql-bugs@lists.postgresql.org" Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Oct 14, 2021 at 4:53 PM Michael Paquier wrote: > > On Thu, Oct 14, 2021 at 02:22:21PM +0900, Masahiko Sawada wrote: > > Agreed. Please find an attached new patch. > > I have not dived into the details of the patch yet, but I can see the > following diffs in some of the dumps dropped by the new test added > between HEAD and the patch: I've checked where these differences come from: > 1) For DEFAULT PRIVILEGES FOR FUNCTIONS: > -ALTER DEFAULT PRIVILEGES FOR ROLE regress_dump_test_role IN SCHEMA > dump_test REVOKE ALL ON FUNCTIONS FROM PUBLIC; > +ALTER DEFAULT PRIVILEGES FOR ROLE regress_dump_test_role IN SCHEMA > dump_test GRANT ALL ON FUNCTIONS TO regress_dump_test_role; The test query and the default privileges I got are: ALTER DEFAULT PRIVILEGES FOR ROLE regress_dump_test_role IN SCHEMA dump_test GRANT EXECUTE ON FUNCTIONS TO regress_dump_test_role; Default access privileges Owner | Schema | Type | Access privileges ------------------------+-----------+----------+------------------------------------------------- regress_dump_test_role | dump_test | function | regress_dump_test_role=X/regress_dump_test_role (1 row) The query dumped by the current pg_dump (i.g., HEAD, w/o patch) is: ALTER DEFAULT PRIVILEGES FOR ROLE regress_dump_test_role IN SCHEMA dump_test REVOKE ALL ON FUNCTIONS FROM PUBLIC; The query dumped by pg_dump with the patch is: ALTER DEFAULT PRIVILEGES FOR ROLE regress_dump_test_role IN SCHEMA dump_test GRANT ALL ON FUNCTIONS TO regress_dump_test_role; The query dumped by the current pg_dump is wrong and the patch fixes it. This difference looks good to me. > 2) For DEFAULT PRIVILEGES FOR TABLES: > -ALTER DEFAULT PRIVILEGES FOR ROLE regress_dump_test_role IN SCHEMA > dump_test REVOKE ALL ON TABLES FROM regress_dump_test_role; > ALTER DEFAULT PRIVILEGES FOR ROLE regress_dump_test_role IN SCHEMA > dump_test GRANT SELECT ON TABLES TO regress_dump_test_role; The test query and the default privileges I got are: ALTER DEFAULT PRIVILEGES FOR ROLE regress_dump_test_role IN SCHEMA dump_test GRANT SELECT ON TABLES TO regress_dump_test_role; Default access privileges Owner | Schema | Type | Access privileges ------------------------+-----------+-------+------------------------------------------------- regress_dump_test_role | dump_test | table | regress_dump_test_role=r/regress_dump_test_role (1 row) The query dumped by the current pg_dump (i.g., HEAD, w/o patch) is: ALTER DEFAULT PRIVILEGES FOR ROLE regress_dump_test_role IN SCHEMA dump_test REVOKE ALL ON TABLES FROM regress_dump_test_role; ALTER DEFAULT PRIVILEGES FOR ROLE regress_dump_test_role IN SCHEMA dump_test GRANT SELECT ON TABLES TO regress_dump_test_role; The query dumped by pg_dump with the patch is: ALTER DEFAULT PRIVILEGES FOR ROLE regress_dump_test_role IN SCHEMA dump_test GRANT SELECT ON TABLES TO regress_dump_test_role; The current pg_dump produced a REVOKE ALL ON TABLES FROM regress_dump_test_role but it seems unnecessary. The patch removes it so looks good to me too. Regards, -- Masahiko Sawada EDB: https://www.enterprisedb.com/