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 1uHkqw-0091zi-Ld for pgsql-hackers@arkaria.postgresql.org; Wed, 21 May 2025 14:55:30 +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 1uHkqu-007fXp-LP for pgsql-hackers@arkaria.postgresql.org; Wed, 21 May 2025 14:55:28 +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 1uHkqu-007fXh-BV for pgsql-hackers@lists.postgresql.org; Wed, 21 May 2025 14:55:28 +0000 Received: from mail-vs1-xe32.google.com ([2607:f8b0:4864:20::e32]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uHkqr-0009fG-32 for pgsql-hackers@lists.postgresql.org; Wed, 21 May 2025 14:55:27 +0000 Received: by mail-vs1-xe32.google.com with SMTP id ada2fe7eead31-4e1432aaa68so4152534137.1 for ; Wed, 21 May 2025 07:55:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1747839325; x=1748444125; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=J/3Sl+M9kvs8k7wa+sFu/XqIVqzq2ZBpPfgsFeZh/xI=; b=Gp4GPR0vFteQWmc+CKarHwm0ZbDo/g5C7Hn8g1nbYbLX/tpAotHVWnGxPMooDa9Bc4 ahAIC3pMw0oVlKXACXguxFX5b4ud9Ngz/WPnpHARH/xceJgzmezwjrD3Dy+Oa5KdGnQ1 t+2hQulntfnQEubzcVaCzzvX9wVdShq7k70AVQwSUOoNyVQSh+/Qp1WgPu+vv1VimNBN 1FGEF3dqo/DTismNQraOfTLc7lOjGjZH/0DwtH2vnkjm6CAH34hQxW3lvy+FCjD0ZWBZ BMp28qbEqcEXqXud8O5tvay0fMiFASMUiMNn2SiAGJ0+pXBjVV3jxLM3aeFbsnOjvF4J bQeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747839325; x=1748444125; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=J/3Sl+M9kvs8k7wa+sFu/XqIVqzq2ZBpPfgsFeZh/xI=; b=ZtB0gZCbDRXb+qO3BpSkdzxe/l5OC8Jho0xynFR0uJJbc4BfIeehvi3ZCH+4x1UrXj E4/K3aEoHPO310I34IAXFN0Wu13HKdENzsA/yalNa16CSra2qxKhcmC/xze/9h09JnMp ODqlw9NXxl34c1/zxFBZGyE5JBIej7QEfk5G+fovP7ssJr1rhe+8z9WNkw+Oh4kzPo19 Z5eQ9fFGIfRVFyY2tMad097H/nGF579r2x4vLLf0CgV7adEDY0CrxRgf/0kPpc5JIGLe OOO/0w2rZw3PJm/a9eIuAvXaToCFgdDTEheqp6tTd5Yg+xb6qc34o786SDe+GMAgJ/uH tqTw== X-Gm-Message-State: AOJu0Yy0UuPshzk+Es3LFOGY9hFw5PdPadFH8JiIKJN/lDAqnhweIur+ 8Zkki3BIqwZcv3BnyNs1XExOOf66jn3TdUBWQ4Vn1th0F6S0BHhGaWZCQ51ntugnzw9DdyW7D0L SbEc2ZQmUkBc30jDu14vCZnUznEeb2ZY= X-Gm-Gg: ASbGnctt84tfCDYjb+pq1Uz/k1AXcUz6MeWvZbsCiuiaqhj2OVy6D30HACFjfLT9cPR FK9s1beXRVyAYtPHdoMyXfujflW/CksUsUPovzqpt1sLWvVSiv4cSm7zIEte+n346GtSyZdpNrF U3Ixl9d8s6ugo0ZUlImUqzn9AYCkLwN6KKkdEb8yTHuWe2N4MWGf1JPsdzXY17LDZ1DJKG3k4= X-Google-Smtp-Source: AGHT+IEyWFWeZnRJnbb5k2/PqK068/FxPd+S3hOUKFQnNSwiTDJXmT8aQedz/G/4w3VfGMgFLbE39j1WYYy1BxoG5fc= X-Received: by 2002:a05:6102:1622:b0:4c5:8b12:cd74 with SMTP id ada2fe7eead31-4dfa6ac490emr22249751137.2.1747839325330; Wed, 21 May 2025 07:55:25 -0700 (PDT) MIME-Version: 1.0 References: <171085360143.2046436.7217841141682511557.pgcf@coridan.postgresql.org> <859476bf-3cb0-455e-b093-b8ab5ef17f0e@postgrespro.ru> <4e2764f7-f6be-478f-8d7f-f921dbd10f5f@postgrespro.ru> In-Reply-To: From: jian he Date: Wed, 21 May 2025 22:54:48 +0800 X-Gm-Features: AX0GCFs0LjMDwQsJWYYV8Xmu7nwuK-PK7BuEf3dfKFf4YBSCXaNC5g1ixXSc6mU Message-ID: Subject: Re: Add SPLIT PARTITION/MERGE PARTITIONS commands To: Dmitry Koval Cc: pgsql-hackers@lists.postgresql.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, May 21, 2025 at 8:30=E2=80=AFPM Dmitry Koval wrote: > > Hi! > > >per https://www.postgresql.org/docs/current/sql-altertable.html > >"You must own the table to use ALTER TABLE." > >That means the current user must own the to be SPLITed partition. > > Last statement may be incorrect (if the logic is different). > Current user can attach another user's partition. If current user can > change (attach) another user's partition, why can't he split the > partition? After attach, partition is part of current user's table, and > current user can change his own table. (Moreover, the owner of the new > partitions is the same as the owner of the split partition.) > > -- I think if he can attach another partition, then he can split the partition= . currently ALTER TABLE ATTACH PARTITION requires the current user both own the partitioned table and the to be attached partition. for example: begin; create role alice; create role bob; GRANT all privileges on schema public to alice; GRANT all privileges on schema public to bob; set role bob; create table at_partitioned (a int, b text) partition by range (a); set role alice; create table at_part_2 (b text, a int); set role bob; alter table at_partitioned attach partition at_part_2 for values from (1000) to (2000); --should error rollback; ---------------- begin; create role alice; create role bob; GRANT all privileges on schema public to alice; GRANT all privileges on schema public to bob; set role bob; create table at_partitioned (a int, b text) partition by range (a); set role alice; create table at_part_2 (b text, a int); alter table at_partitioned attach partition at_part_2 for values from (1000) to (2000); --should error rollback; P.S. maybe using sql examples can illustrate the idea more intuitively, sometimes words may cause confusion.