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 1ud53z-002nB8-9g for pgsql-hackers@arkaria.postgresql.org; Sat, 19 Jul 2025 10:45:07 +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 1ud53x-005RPf-Dn for pgsql-hackers@arkaria.postgresql.org; Sat, 19 Jul 2025 10:45:06 +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 1ud53x-005RPV-0C for pgsql-hackers@lists.postgresql.org; Sat, 19 Jul 2025 10:45:05 +0000 Received: from mail-ot1-x32c.google.com ([2607:f8b0:4864:20::32c]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1ud53v-0086rH-2U for pgsql-hackers@lists.postgresql.org; Sat, 19 Jul 2025 10:45:04 +0000 Received: by mail-ot1-x32c.google.com with SMTP id 46e09a7af769-73e88bc3891so755550a34.0 for ; Sat, 19 Jul 2025 03:45:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1752921903; x=1753526703; 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=Sc+MSYQYs5VPkEIqp31POs0vKQoeeuVXw9bzTDax/io=; b=fbIkPuL61Y7RFzmD1DJJtJvTByobdDJYhLt5Z+HV2lezk/c1V45xm5IkDbraf27Yow VBErv2turINxL0Z0bQdZoDvFUNu6LFbgx6Dd1NwVRShlH55IY7fJ71my02yA0XOWQUsq B6U0qpkDy/QHz5l2a6J0en/dT0VXp+if56L/jlbBtAU4FOfZ1CW5ji4g4B0VyEuojjA4 9Gm4wotQWMkAk+fhWX3PfAP0nDsI2ojOIYQicj9+2OkaLT5VPTG6CJGRpdEDWjOsuEuc aFQg+h6PdjL5sf2/T+79gtHuib3YXA1n3e1d3nQVbFM/b9kEp9pje9JyG6vjc6BUZPPw BjRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752921903; x=1753526703; 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=Sc+MSYQYs5VPkEIqp31POs0vKQoeeuVXw9bzTDax/io=; b=Q8AVKJXYQtDkecsjYVDAXY9154qXU0PJ9fCoD2YEEJAYIe8nEkbr2+ZynyFTuwdpNQ YlSwi7wAHX9Sz/VlbBR2PXcbiO6D7iZeVLJO9aztrk/OLVigElyUbDhyBEnzScjU0S/f t9IMQrY+nmrB4z0+XhEnWftPw8aHyjAnrsRYLUSAgv1rkVfevVXjuy5fSFP4lJPSEcXW e53+FT1H4zJeSfxZzD8ORp4mJ363jRC0U7WzgU1R8+195/ewQUZRsYxDeTL8wuWIKj91 P2/krd314boSIFf94yq6lUM6JU5p74DA9+ZpnRdeqaZ95YJb3zPqMAwDsY5tD0/xiXNj NpHA== X-Forwarded-Encrypted: i=1; AJvYcCW4dwceC0qmc9FDeurC1irRom7tmLGPve9EO/L4og203lpmtefAZip6Fy9TaaBjJvUJtK6kuhCXcf94n7JY@lists.postgresql.org X-Gm-Message-State: AOJu0Yyo+7fUc/LJL3WBHd8rse1M1oslPpiHJmtLZYmTmiLqrk34Ab2h IzmPh3G9oxSjgQS+3X6ggY2ZnOf/1hVpme7crw+bLeBq3yE2b/wAUHP1bNcbrhDCEfNunfcMrjQ MawnctIDa5S4MlrA0HlHbj+Zypx7NUsnukYmuP/8= X-Gm-Gg: ASbGncu6owKFdTHzui3dRahoqbZf6biZoq8Ey8ZcaHXOwuBoS2uv+MTYRLiyb4yCDj2 IRGHaXRGRWqABmyW1PH9SS5TInXo6XlAaB0FtN25202yJ9DlS3SuuZ4dGKXz+CGOkDVvDukISFG o15xjRRI7ucDhfgm1z759P+L8T2fpjKHDPhGRUvj40H7T4YZnYSh5cvOrPqLztxBYggi2XVBN+t 8YxakEucQ== X-Google-Smtp-Source: AGHT+IF6emqKVC9Fyi99bvDK04fm6JK3ETcAV8J6iGUAN44wJbQIUnqpQbZfd4eHB7J131nP9VCrra8nXxOWsD9hTHQ= X-Received: by 2002:a05:6808:15a6:b0:406:6e89:49ba with SMTP id 5614622812f47-41e46e890edmr6552453b6e.33.1752921902842; Sat, 19 Jul 2025 03:45:02 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Shlok Kyal Date: Sat, 19 Jul 2025 16:14:51 +0530 X-Gm-Features: Ac12FXy_MWWVJohUz9NwBUT2sIVR8TNld-L2HclBBjXHZPFD32ENeW3LDbPtm_0 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" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, 30 Jun 2025 at 12:28, shveta malik wrote: > > On Fri, Jun 27, 2025 at 3:44=E2=80=AFPM Shlok Kyal wrote: > > > > On Thu, 26 Jun 2025 at 15:27, shveta malik wro= te: > > > > > > On Tue, Jun 24, 2025 at 9:48=E2=80=AFAM Shlok Kyal wrote: > > > > > > > > I have included the changes for > > > > it in v14-0003 patch. > > > > > > > Thanks for the patches. I have reviewed patch001 alone, please find > > > few comments: > > > > > > 1) > > > + > > > + The RESET clause will reset the publication to= the > > > + default state which includes resetting the publication parameters= , setting > > > + ALL TABLES flag to false an= d > > > + dropping all relations and schemas that are associated with the > > > + publication. > > > > > > > > > It is misleading, as far as I have understood, we do not drop the > > > tables or schemas associated with the pub; we just remove those from > > > the publication's object list. See previous doc: > > > "The ADD and DROP clauses will add and remove one or more > > > tables/schemas from the publication" > > > > > > Perhaps we want to say the same thing when we speak about the 'drop' > > > aspect of RESET. > > I have updated the document. > > > > > 2) > > > AlterPublicationReset(): > > > > > > + if (!OidIsValid(prid)) > > > + ereport(ERROR, > > > + (errcode(ERRCODE_UNDEFINED_OBJECT), > > > + errmsg("relation \"%s\" is not part of the publication", > > > + get_rel_name(relid)))); > > > > > > Can you please help me understand which scenario will give this error= ? > > > > > > Another question is do we really need this error? IIUC, we generally > > > give errors if a user has explicitly called out a name of an object > > > and that object is not found. Example: > > > > > > postgres=3D# alter publication pubnew drop table t1,tab2; > > > ERROR: relation "t1" is not part of the publication > > > > > > While in a few other cases, we pass missing_okay as true and do not > > > give errors. Please see other callers of performDeletion in > > > publicationcmds.c itself. There we have usage of missing_okay=3Dtrue.= I > > > have not researched myself, but please analyze the cases where > > > missing_okay is passed as true to figure out if those match our RESET > > > case. Try to reproduce if possible and then take a call. > > I thought about the above point and I also think this check is not > > required. Also, the function was calling PublicationDropSchemas with > > missing_ok as false. I have changed it to be true. > > > > Okay. Is there a reason for not using PublicationDropTables() here? We > have rewritten similar code in the Reset flow. > I feel it's better to use the function PublicationDropTables(). Also proper locking would be required on tables while dropping them from publication. Made changes for the same. > > > 3) > > > +ALTER PUBLICATION testpub_reset ADD ALL TABLES IN SCHEMA public; > > > +ERROR: syntax error at or near "ALL" > > > +LINE 1: ALTER PUBLICATION testpub_reset ADD ALL TABLES IN SCHEMA pub= ... > > > > > > There is a problem in syntax, I think the intention of testcase was t= o > > > run this query successfully. > > > > I have fixed it. > > > > Thanks Shveta for reviewing the patch. I have addressed the comments > > and posted an updated version v15 in [1]. > > Thanks for the patches. My review is in progress but please find few > comments on 002: > > 1) > where exception_object is: > [ ONLY ] table_name [ * ] > > We have the above in CREATE and ALTER pub docs, but we do not explain > ONLY with EXCEPT. We do have an explanation of ONLY under 'FOR TABLE'. > But since 'FOR TABLE' and 'EXCEPT' do not go together, it is somewhat > difficult to connect the dots and find the information ONLY in the > context of EXCEPT. We shall have ONLY explained for EXCEPT as well. Or > we can have ONLY defined in a way that both 'FOR TABLE' and 'EXCEPT' > can refer to it. > In create_publication.sgml, added it under "EXCEPT_TABLE'. In alter_publication.sgml, modified the document under item 'table_name' under "Parameters" > 2) > We get tab-completion options in this command: > postgres=3D# create publication pub5 for TABLE tab1 W > WHERE ( WITH ( > > Similarly in this command: > create publication pub5 for TABLES IN SCHEMA s1 > > But once we have 'EXCEPT TABLE', we do not get further tab-completion > option like WITH(...) > create publication pub5 for ALL TABLES EXCEPT TABLE tab1 Fixed > 3) > During tab-expansion, 'EXCEPT TABLE' and 'WITH (' in the below > command looks like they are connecting words. Can the gap be increased > similar to tab-expansion of next command shown below: > > postgres=3D# create publication pub4 for ALL TABLES > EXCEPT TABLE WITH ( > I did not find a place to add any custom space. It is default behaviour to add 2 spaces between different words. See similar: postgres=3D# CREATE PUBLICATION pub1 FOR TABLE t1 W WHERE ( WITH ( > postgres=3D# create publication pub4 for > ALL TABLES TABLE TABLES IN SCHEMA > I observed that the space between word is dependent on the length of longest word. Here the longest word is "TABLES IN SCHEMA". The space between the words are quite noticeable. > 4) > alter_publication.sgml.orig is a left-over in patch002. Fixed I have added the changes in the latest v16 patch [1]. [1]: https://www.postgresql.org/message-id/CANhcyEW2LK4diNeCG862DE40yQoV3VA= gf59kXUq2TuR8fnw5vQ%40mail.gmail.com Thanks and Regards, Shlok Kyal