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 1s1dj4-00DjA1-5Z for pgsql-hackers@arkaria.postgresql.org; Tue, 30 Apr 2024 03:00:13 +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 1s1dj0-003S3x-LI for pgsql-hackers@arkaria.postgresql.org; Tue, 30 Apr 2024 03:00:11 +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 1s1dj0-003S3p-Bl for pgsql-hackers@lists.postgresql.org; Tue, 30 Apr 2024 03:00:11 +0000 Received: from mail-lf1-x12b.google.com ([2a00:1450:4864:20::12b]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1s1diu-000hfi-HF for pgsql-hackers@lists.postgresql.org; Tue, 30 Apr 2024 03:00:10 +0000 Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-5196fe87775so5716368e87.3 for ; Mon, 29 Apr 2024 20:00:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714446003; x=1715050803; 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=BqdbEI8L0lZJ0KZfjV/wcZXokTPh+SdBTm4mQLLN2s0=; b=UvSU8satQv6tOBYj3oRHIOu/T03zruaSOLQ1skESBzHEJL4xYakpdfu7JGvv0I6LcG FRBjo2H1uAyyain3qNNzyRZ+nLs9SeWV/H1F3GcDfUaxU8vcQwmINn//3sCd93F69f6y PN3ssKf0XAfTFhYhHzIxdtP8qnTUqOe6TtVBd3iwxWFFfYqNpgFtwhwaiI42KsMY9U60 S1kPjnWdYLJiS7oVQujNasc1fP1VKGFk+VI/adL7FvhcW8U9Kgi6qslUjuw15XjUO06w WNqlOAgQubFWDkqJSG7fuet2GxuTvTyfVqI4yCYtf04umjDP0vZ7OdfDtCYmls8Y5sf7 iWdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714446003; x=1715050803; 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=BqdbEI8L0lZJ0KZfjV/wcZXokTPh+SdBTm4mQLLN2s0=; b=OiuYHad5JwbX21ns8cLUrkCQOm3vM4SgsZncn5if7p67IT/nhGRIYarwLwDjTAfuGF JR4nC0kLHJb8F5W1WTWvGMyRGiD3R4QAFUHokg5n8hPF6TseVIXAdmjPq/Uy1BR5RjDS 4W3ZnJaXsuUdguOFO6jWqNC4gg1dzWjrmzPvEV2nsmtjJUqytzl4Rr01hOYLAOi1CEwg 4EZxS+c6fR1EWLoLcYwrIPNbjf+gZ+YH3Eqbo9B+GWeidw0lpQKFYKlcigywFWUWtHmz M/MLlCO/PNqh2laCkwaEZ5S2ECoBupnG28LE1VkzlKiZNncJxDTAWJlfIrQd3OCBCXns 4azA== X-Forwarded-Encrypted: i=1; AJvYcCW9DjF7U751WWexDB78CWkNypu62A1zFsHN9P6FFRX55FULrZI0c6wZ7RvOvuImFAxQc9BmLfj5KEQUNamciEKrsqEldsRNHCxnymcPR+34wXb1 X-Gm-Message-State: AOJu0YywuM5V8LMClZjam+z5YAUWCy0jzIhtZypspR+i9q3yRJ7X4uRz cqgph0tYS4Idrksgvo4DJSMwsboYuCzuAd0i9n9cqPlnaqZyTjDF X-Google-Smtp-Source: AGHT+IEiLxJ3q7EBA9xcy4UH6d54CrBU1QRpD/LmjtpdJNkMrsnc76siWnrJmQhtL6rMFX0YMmW+sg== X-Received: by 2002:ac2:4c81:0:b0:519:1a91:30cc with SMTP id d1-20020ac24c81000000b005191a9130ccmr5497698lfl.4.1714446002387; Mon, 29 Apr 2024 20:00:02 -0700 (PDT) Received: from [1.0.0.7] ([178.155.23.194]) by smtp.gmail.com with ESMTPSA id u5-20020a056512128500b0051d87b66ce0sm734136lfs.247.2024.04.29.20.00.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 29 Apr 2024 20:00:01 -0700 (PDT) Message-ID: <8034d1c6-5f0e-e858-9af9-45d5e246515e@gmail.com> Date: Tue, 30 Apr 2024 06: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: Dmitry Koval , Alexander Korotkov Cc: Robert Haas , PostgreSQL Hackers References: <0f655bcd-6487-4179-f9cf-c248efbad510@gmail.com> <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 30.04.2024 03:10, Dmitry Koval wrote: > Hi! > > 1. > 29.04.2024 21:00, Alexander Lakhin wrote: >> I still wonder, why that constraint (now with a less questionable name) is >> created during MERGE? > > The SPLIT/MERGE PARTITION(S) commands for creating partitions reuse the existing code of CREATE TABLE .. LIKE ... > command. A new partition was created with the name "merge-16385-26BCB0-tmp" (since there was an old partition with the > same name). The constraint "merge-16385-26BCB0-tmp_i_not_null" was created too together with the partition. > Subsequently, the table was renamed, but the constraint was not. > Now a new partition is immediately created with the correct name (the old partition is renamed). Maybe I'm doing something wrong, but the following script: CREATE TABLE t (i int, PRIMARY KEY(i)) PARTITION BY RANGE (i); CREATE TABLE tp_0 PARTITION OF t FOR VALUES FROM (0) TO (1); CREATE TABLE tp_1 PARTITION OF t FOR VALUES FROM (1) TO (2); CREATE TABLE t2 (LIKE t INCLUDING ALL); CREATE TABLE tp2 (LIKE tp_0 INCLUDING ALL); creates tables t2, tp2 without not-null constraints. But after ALTER TABLE t MERGE PARTITIONS (tp_0, tp_1) INTO tp_0; I see: \d+ tp_0 ... Indexes:     "tp_0_pkey" PRIMARY KEY, btree (i) Not-null constraints:     "tp_0_i_not_null" NOT NULL "i" Best regards, Alexander