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 1uibJD-00DZip-IM for pgsql-hackers@arkaria.postgresql.org; Sun, 03 Aug 2025 16:11:39 +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 1uibJC-00E319-JB for pgsql-hackers@arkaria.postgresql.org; Sun, 03 Aug 2025 16:11:38 +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 1uibJC-00E311-0v for pgsql-hackers@lists.postgresql.org; Sun, 03 Aug 2025 16:11:38 +0000 Received: from mail-oi1-x232.google.com ([2607:f8b0:4864:20::232]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uibJ9-000WzR-0W for pgsql-hackers@lists.postgresql.org; Sun, 03 Aug 2025 16:11:36 +0000 Received: by mail-oi1-x232.google.com with SMTP id 5614622812f47-40a4de175a3so2266370b6e.0 for ; Sun, 03 Aug 2025 09:11:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1754237495; x=1754842295; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=ri3MUskQrPzd6BxBTcAsX74ooJ1ZrfwK2/RGPaKWTr0=; b=Ispm5m/BZibu9wFswLvmPshiFFy6+VAFwzrBLCOEF/gj7h/CjwZGSAYDz1/ARIymTu EeY087tcEIjtYXoJxyGs94ZJMAeskkiEDo2LMADljCuPbSsVWUqintAq/ss+CsrnFl8G pUQsdlr22JAQszcDdZgm9x8Zww1Dcst1JWny62b2N82oJpyvMZbMkIfefxWdn0OCp8y+ Vdmx084XF4xrBL4Gwxte/jYr1FAsldH+egiV66juIbJr6gZASwysnOTU/llAMEhWrDay kzeKOnxfrTLF2DCPLQ5Hn+lPSD3koPIzZ+IqKBbQFXaxFovkphGVo3bPoAwvSkZylYjM 4AYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754237495; x=1754842295; h=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=ri3MUskQrPzd6BxBTcAsX74ooJ1ZrfwK2/RGPaKWTr0=; b=BkfdurKcmmXy6Xrcg5fVsa0u6QDundJEAvIqGmBcAT+Dv6S5vpvulhskotplKU8CUN 4Rjle+l+359EU/JPe/fgruNiE4VGvRr+Z+LYNp1E0YKhXDifu7vNxFnniQLltM//I3Hc YwmIq8D7ieko3ONOWhZpV5/YcdnkUKn9/DUPHUQ7nd9g5BZY691U6jLu9ezl0r5KgZmo FsIoCjKtsIJeuiouniLR8P54Ppt9PU+ZOX6phaJRackuVdR7JGPpZmPeft5jX0GE2gj+ tE6k0evZgWVKyNeTLKj+wYdcguSRFihpJQ9MosIuK8zRkTnW1UAmDGTEYqVVKsGJn241 4FbA== X-Forwarded-Encrypted: i=1; AJvYcCWQrs+2RTz+DDp75RueIF37Eegk0KJm31ivWZ5NicTzfIGMnYQqfv+Ds0d7b/yA3gpScGGnYxf3hlLMXH4m@lists.postgresql.org X-Gm-Message-State: AOJu0YyIyUauFf4GGBf4iY+RUD7y7sl1nxF7TmYVrWcZrD9+0118tTMn eMFD6nVMsmB5Y3qUNvhCuc/FxPHWR2xVmd8MqyVEcZBF8e+evRzJlXKWsjdfKjthG0RpZl9VHpI LBg1vrvyS7nEHdrMqmon9XnR+mNeOlWo= X-Gm-Gg: ASbGncudAG/3XWzAaliIOAxKKxLJFKIlvGCbbT7yBjgBS31hzQviozDySliT0Au//l0 YnbMTDJYBkArRKKys0w9jIO3+h+yTp0eAdBEC8cmbVnaPGqpN/LPXlgN36/KYtk4LgCfQ9ACTXh A5UYsHWgMS1bLsBZjQkHLCvml48b92hAgaAx5IvGhWJ+HkEf3zTGyWXPTl9wF2SCfjzeoKcZpUP XZRrfRiVQ== X-Google-Smtp-Source: AGHT+IEeXpVjzNbUgypQh6Co2ZwEP6DrFlRaUWnVX4s7kRXN96SCy2eJ0l3z7CV3pNTLqxms62d1k96FkmbdgD6fS0g= X-Received: by 2002:a05:6808:4a47:10b0:433:f58e:3fa with SMTP id 5614622812f47-433f58e0eb4mr2014700b6e.2.1754237495435; Sun, 03 Aug 2025 09:11:35 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Shlok Kyal Date: Sun, 3 Aug 2025 21:41:24 +0530 X-Gm-Features: Ac12FXy9wuysqVTPQjaWC1ZQ27iG6cEHH34qT0dXeb0aq6mbFRvNizgfFKlZsqY Message-ID: Subject: Re: Skipping schema changes in publication To: shveta malik Cc: Peter Smith , Amit Kapila , "Zhijie Hou (Fujitsu)" , vignesh C , YeXiu <1518981153@qq.com>, Ian Lawrence Barwick , Bharath Rupireddy , PostgreSQL Hackers Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, 22 Jul 2025 at 15:57, shveta malik wrote: > > Shlok, I was trying to validate the interaction of > 'publish_via_partition_root' with 'EXCEPT". Found some unexpected > behaviour, can you please review: > > Pub: > --------- > CREATE TABLE tab_root (range_col int,i int,j int) PARTITION BY RANGE > (range_col); > CREATE TABLE tab_part_1 PARTITION OF tab_root FOR VALUES FROM (1) to (1000); > CREATE TABLE tab_part_2 PARTITION OF tab_root FOR VALUES FROM (1000) to (2000); > create publication pub2 for all tables except tab_part_2 WITH > (publish_via_partition_root=true); > > Sub (tables without partition): > -------- > CREATE TABLE tab_root (range_col int,i int,j int); > CREATE TABLE tab_part_1(range_col int,i int,j int); > CREATE TABLE tab_part_2(range_col int,i int,j int); > create subscription sub2 connection '...' publication pub2; > > Pub: > -------- > insert into tab_part_2 values(1001,1,1); > > On Sub, the above row is replicated as expected in tab_root due to > publish_via_partition_root=true on pub. > > Now on Pub: > -------- > alter publication pub2 set (publish_via_partition_root=false); > insert into tab_part_2 values(1002,2,2); > > Now with publish_via_partition_root=false and 'except tab_part_2', the > above row is correctly ignored and not replicated on sub. > > But when I try this: > insert into tab_part_1 values(1,1,1); > insert into tab_root values(5,5,5); > > Expectation was that the above rows are replicated but that is not the > case. Can you please review? Please let me know if my understanding is > wrong. Hi Shveta, I checked this behaviour on HEAD and found that it is the same behaviour as HEAD. I think if we alter the parameter 'publish_via_partition_root', we should do ALTER SUBSCRIPTION .. REFRESH PUBLICATION on subscriber. I reviewed your behaviour and saw that after the 'alter publication pub2 set (publish_via_partition_root=false)', the changes are still being replicated to 'tab_root' on subscriber. And this behaviour is similar to HEAD. For example: Pub: --------- CREATE TABLE tab_root (range_col int,i int,j int) PARTITION BY RANGE (range_col); CREATE TABLE tab_part_1 PARTITION OF tab_root FOR VALUES FROM (1) to (1000); CREATE TABLE tab_part_2 PARTITION OF tab_root FOR VALUES FROM (1000) to (2000); create publication pub2 for table tab_root WITH (publish_via_partition_root=true); Sub (tables without partition): -------- CREATE TABLE tab_root (range_col int,i int,j int); CREATE TABLE tab_part_1(range_col int,i int,j int); CREATE TABLE tab_part_2(range_col int,i int,j int); create subscription sub2 connection '...' publication pub2; Pub: -------- insert into tab_part_2 values(1001,1,1); On Sub, the above row is replicated as expected in tab_root. Now on Pub: -------- alter publication pub2 set (publish_via_partition_root=false); when I try this the data: insert into tab_part_2 values(1002,2,2); insert into tab_part_1 values(1,1,1); insert into tab_root values(5,5,5); The data is being replicated to tab_root on the subscriber. After I do ALTER SUBSCRIPTION .. REFRESH PUBLICATION on subscriber, replication happens as expected. Also I found following documentation: "Altering the publish_via_partition_root parameter can lead to data loss or duplication at the subscriber because it changes the identity and schema of the published tables. Note this happens only when a partition root table is specified as the replication target." Thanks, Shlok Kyal