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 1s12GS-008yBL-7h for pgsql-hackers@arkaria.postgresql.org; Sun, 28 Apr 2024 11:00:12 +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 1s12GN-00CgtB-Ig for pgsql-hackers@arkaria.postgresql.org; Sun, 28 Apr 2024 11:00:08 +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 1s12GN-00Cgt3-6j for pgsql-hackers@lists.postgresql.org; Sun, 28 Apr 2024 11:00:08 +0000 Received: from mail-lf1-x12a.google.com ([2a00:1450:4864:20::12a]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1s12GK-000RSf-UN for pgsql-hackers@lists.postgresql.org; Sun, 28 Apr 2024 11:00:06 +0000 Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-51abd9fcbf6so5941818e87.1 for ; Sun, 28 Apr 2024 04:00:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714302002; x=1714906802; darn=lists.postgresql.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=/NS3rErvNwMAWskV6kRsX2mj2Ga3N5i17yutLgdKAy0=; b=YQn+wQlA+xCT81f5jt/6YB9+IOAYykwlGSyFmmwkjcSBOlO/OZtei4HbgDzNgoT4V0 +BCPXLCUmngm11/iVRQxGslfCifCyk58cPDVxWbp7qirgyIfmzzt3DzUmFFj6tjsBHIy bwZgzM2XT82ujXSYKe2qdaSen0Qes5lMqEh1T+Gk+GIlXiwK4E6Cc3X/kMzNd3taQCTT s6DyakzV11vNmGYCxxnV7oDabbpa8KuSCMtIrQiHslgsSW/glBhvy6hlxpuPmo16Apu2 kLRp1csMPDTMdnZJ0kf1KOoqK5eZ56Sk6gleZ2qelKijEgnpqB8HTVsz8TJtARW7TQ2h aWOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714302002; x=1714906802; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=/NS3rErvNwMAWskV6kRsX2mj2Ga3N5i17yutLgdKAy0=; b=Vs9zZqxBGUsUpgRitJ7diEq+HHEtwWqRSZ6si4MhcSIuBneV8Nx4soPmbwZ3TTAcc6 MQcXcssnhrtU3Eo5JSfeIP5ty8GRnpIAyQYVB1mu+W0PRmb8dJiCe3s6sbFhpX/jGNSx eMG45Zh6YcmRbRs7ilzfBy+OsYbMnsy1+By6GTVhk3AkYD0iE9hQSgZlITW+VIbIwh5J CHteGwAHzbPtm0fmO2vl8bV6d+9AnqoBJoPHWNwRp+6IKBEbLlNl47RxYk2ZiJe1t7j4 AJIxEH29Wp0tqGTKVPFfbCLz7IpjXl5EoQFoucHIroDeNmvsewEojzcU7St9ls9pP954 Pvsw== X-Forwarded-Encrypted: i=1; AJvYcCWPxSIdUGbVud7V3BX1l68jw49zOZWv9jK4uYoufvKNh9Jb3kHZdhtTM0zqAxGNVwesEOmeDlRHMRt5aTGHICrDfzAdvX/7lTzcr2LfRf+9lAV4 X-Gm-Message-State: AOJu0YzopluusnbICtTH5PmMpT6HqVd96oewyWRRhkmJOBFx0pPSwI7M Uonld9ESwCF52kuhgXRNrReAnpafdL0Bks6CD7Q0vReQ4q7O98KL X-Google-Smtp-Source: AGHT+IEkteosI6DVLFNESoKVSDMCRksEDHCfr8zLJF61j49SkFLW7E9GTIN7Kwb4LN0IEsJUPzZ3iQ== X-Received: by 2002:ac2:489a:0:b0:51c:d8e6:494a with SMTP id x26-20020ac2489a000000b0051cd8e6494amr4662549lfc.60.1714302001933; Sun, 28 Apr 2024 04:00:01 -0700 (PDT) Received: from [1.0.0.7] ([178.155.23.194]) by smtp.gmail.com with ESMTPSA id v28-20020ac2593c000000b0051905a9c212sm3734428lfi.195.2024.04.28.04.00.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 28 Apr 2024 04:00:01 -0700 (PDT) Message-ID: <0520c72e-8d97-245e-53f9-173beca2ab2e@gmail.com> Date: Sun, 28 Apr 2024 14:00:00 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: Add SPLIT PARTITION/MERGE PARTITIONS commands Content-Language: en-US To: Alexander Korotkov , Dmitry Koval Cc: Justin Pryzby , Robert Haas , Pavel Borisov , pgsql-hackers@lists.postgresql.org References: <56e0000c-6b39-44ce-90b4-d3c3062e408c@postgrespro.ru> <5dee3937-8e9f-cca4-11fb-737709a92b37@gmail.com> From: Alexander Lakhin 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 Hello, 28.04.2024 03:59, Alexander Korotkov wrote: > The revised patchset is attached. I'm going to push it if there are > no objections. I have one additional question regarding security, if you don't mind: What permissions should a user have to perform split/merge? When we deal with mixed ownership, say, bob is an owner of a partitioned table, but not an owner of a partition, should we allow him to perform merge with that partition? Consider the following script: CREATE ROLE alice; GRANT CREATE ON SCHEMA public TO alice; SET SESSION AUTHORIZATION alice; CREATE TABLE t (i int PRIMARY KEY, t text, u text) PARTITION BY RANGE (i); CREATE TABLE tp_00 PARTITION OF t FOR VALUES FROM (0) TO (10); CREATE TABLE tp_10 PARTITION OF t FOR VALUES FROM (10) TO (20); CREATE POLICY p1 ON tp_00 USING (u = current_user); ALTER TABLE tp_00 ENABLE ROW LEVEL SECURITY; INSERT INTO t(i, t, u)  VALUES (0, 'info for bob', 'bob'); INSERT INTO t(i, t, u)  VALUES (1, 'info for alice', 'alice'); RESET SESSION AUTHORIZATION; CREATE ROLE bob; GRANT CREATE ON SCHEMA public TO bob; ALTER TABLE t OWNER TO bob; GRANT SELECT ON TABLE tp_00 TO bob; SET SESSION AUTHORIZATION bob; SELECT * FROM tp_00; --- here bob can see his info only \d  Schema | Name  |       Type        | Owner --------+-------+-------------------+-------  public | t     | partitioned table | bob  public | tp_00 | table             | alice  public | tp_10 | table             | alice -- but then bob can do: ALTER TABLE t MERGE PARTITIONS (tp_00, tp_10) INTO tp_00; -- (yes, he also can detach the partition tp_00, but then he couldn't -- re-attach nor read it) \d  Schema | Name  |       Type        | Owner --------+-------+-------------------+-------  public | t     | partitioned table | bob  public | tp_00 | table             | bob Thus bob effectively have captured the partition with the data. What do you think, does this create a new security risk? Best regards, Alexander