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 1tKa5k-009Wdw-6T for pgsql-hackers@arkaria.postgresql.org; Mon, 09 Dec 2024 09:30: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 1tKa5h-006HK8-J7 for pgsql-hackers@arkaria.postgresql.org; Mon, 09 Dec 2024 09:30:10 +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 1tKa5h-006HJl-96 for pgsql-hackers@lists.postgresql.org; Mon, 09 Dec 2024 09:30:10 +0000 Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1tKa5f-001qfd-9l for pgsql-hackers@lists.postgresql.org; Mon, 09 Dec 2024 09:30:09 +0000 Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-aa696d3901bso32329766b.1 for ; Mon, 09 Dec 2024 01:30:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733736607; x=1734341407; 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=WBLfVq6alyWJckoFJlQtjly/B4GKOieb+cGKIAGokks=; b=F3V9Y+kRolzgOeHmvYqE/bkZWfojAjWbE162kl+UZeEn/4Y+MbjGa/7+TSJ/Upmm3j VHsT+4zPjTx+ZsekE536yo2IJqlTxossYNo9yX7SkQpoGe/ffmvcEKrii4auptmjZmpR 1naETqE+4bN0JIkhJbj36bPtfCeukVOgry/ueU3JUvKf27d5QSZCp7qgHzVrv+ZlekaT s/k4YF4ZLIjEPxH6YL46yWpEqchUTTu7xdwoEm8UmhnoYaB8TIDrP3KoGQheQrsVvBgI +m25rHUT7mHlLLkE9A5llNjP5be6axOA1JYiKEjh609NEsptLFPDr99PkAyNX6nrGiBb 0pzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733736607; x=1734341407; 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=WBLfVq6alyWJckoFJlQtjly/B4GKOieb+cGKIAGokks=; b=GGIg9anDZI1OPxg7VSLQUlLpsR/yRicfVKGxMoPwgp4PDzUIaAR7Gd9FzR1XipqApj X3mpyy1pj2sMPYQGNddbrcz03qNgvWbvsH6oyqKyquusKwpqi3WuLcLKzSN1WZE3jZ6W lWgJwOhK4XVw0n+WlwhWD8Finm5oWB1VYfLtDZPjAnOlLjJMMal2+lO25LEIM/AhYPJB jRvt3eAFAfXLCg+VHCX/7GkzNgiS7myKYn7fR/ym8Kd2T3BTbWAbD8pAJK8iWzDv3cGV Gdzcfom8S/blbIw1qrLRv2R5U+oxl39SqYtqfD5Ar24x/6a90MKJzAgmjZA7G/gVObw0 MAsw== X-Forwarded-Encrypted: i=1; AJvYcCVQAMzOY1vAVJESPyNZNVuwMiYXkazdmiiVey2K5U+Rhm2c3x8RSgqpBsqQwBqCujisFtgxv5uD+mNA55d5@lists.postgresql.org X-Gm-Message-State: AOJu0Yy1RK24M0febRmt+eq+LRxlCRI3ZvGc1Ssd6S11eAv98/qDZ+Rl a1nI+EBKJ4/M8sRK8y9CgriewUuDok+n3UdVnchXiJNzuGMzT0TI1eUeg5FssWhHdQPROap3iao nTTnvb+H2c/4UTMX9Ap5Jk0S9myLW3Y1NK0G6rw== X-Gm-Gg: ASbGncu+lZLdug83exfTwYLa3/+Um6GKwXVAm9jGLxlWwJsos0AqTPRRarVbsA199b+ l/at2mT3mjHnVJSKghlEtyaut/YKHZV8= X-Google-Smtp-Source: AGHT+IG2+VPymeCUGiFUx33Je+Ui39xFznxy+e9KOGwjKa+ekvSM1565Pon78beYHaZYtZiGbN4B+k+MdjaWrpg3hgk= X-Received: by 2002:a05:6402:401e:b0:5d2:7270:611f with SMTP id 4fb4d7f45d1cf-5d3be6fbb6cmr10449831a12.22.1733726196933; Sun, 08 Dec 2024 22:36:36 -0800 (PST) MIME-Version: 1.0 References: <171085360143.2046436.7217841141682511557.pgcf@coridan.postgresql.org> <768cbb42-d3f8-45de-89ad-72861f078dc2@postgrespro.ru> <859476bf-3cb0-455e-b093-b8ab5ef17f0e@postgrespro.ru> In-Reply-To: From: Alexander Korotkov Date: Mon, 9 Dec 2024 08:36:25 +0200 Message-ID: Subject: Re: Add SPLIT PARTITION/MERGE PARTITIONS commands To: Dmitry Koval Cc: Robert Haas , 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 Hi! On Fri, Aug 30, 2024 at 11:43=E2=80=AFAM Dmitry Koval wrote: > I plan to prepare fixes for issues from email [1] as separate commits > (for better code readability). Attachment in this email is a variant of > fix for the issue: > > > 1. Function createPartitionTable() should be rewritten using > > partitioned table OID (not name) and without using ProcessUtility(). > > Patch "Refactor createPartitionTable to remove ProcessUtility call" > contains code changes + test (see file > v33-0003-Refactor-createPartitionTable-to-remove-ProcessU.patch). > > But I'm not sure that refactoring createPartitionTable is the best > solution. PostgreSQL code has issue CVE-2014-0062 (commit 5f17304) - see > relation_openrv() call in expandTableLikeClause() function [2] (opening > relation by name after we got relation Oid). > Example for reproduce relation_openrv() call: > > CREATE TABLE t (b bigint, i int DEFAULT 100); > CREATE TABLE t1 (LIKE t_bigint INCLUDING ALL); > > Commit 04158e7fa3 [3] (by Alexander Korotkov) might be a good fix for > this issue. But if we keep commit 04158e7fa3, do we need to refactor the > createPartitionTable function (for removing ProcessUtility)? > Perhaps the existing code > 1) v33-0002-Implement-ALTER-TABLE-.-SPLIT-PARTITION-.-comman.patch > 2) v33-0003-Refactor-createPartitionTable-to-remove-ProcessU.patch + > with patch 04158e7fa3 will look better. > > > I would be very grateful for comments and suggestions. Thank you for continuing your work on the subject. The patches currently doesn't apply cleanly. Please, rebase. I think getting away from expandTableLikeClause() is the right direction to resolve the security problems. That looks great, it finally not as complex as I thought. I think the code requires some polishing: you need to revise the comments given its not part of LIKE clause handling anymore. I see fixes for the issues mentioned in [1] and [2] are still not implemented. Do you plan to do this in this release cycle? Links. 1. https://www.postgresql.org/message-id/CA%2BTgmoY0%3DbT_xBP8csR%3DMFE%3DF= xGE2n2-me2-31jBOgEcLvW7ug%40mail.gmail.com 2. https://www.postgresql.org/message-id/859476bf-3cb0-455e-b093-b8ab5ef17f= 0e%40postgrespro.ru ------ Regards, Alexander Korotkov Supabase