Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1np2a2-0007ow-7w for pgsql-hackers@arkaria.postgresql.org; Thu, 12 May 2022 06:45:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1np2a0-0001Sg-64 for pgsql-hackers@arkaria.postgresql.org; Thu, 12 May 2022 06:45:44 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1np2Zz-0001SW-Ro for pgsql-hackers@lists.postgresql.org; Thu, 12 May 2022 06:45:43 +0000 Received: from mail-yw1-x112f.google.com ([2607:f8b0:4864:20::112f]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1np2Zt-0004NX-Fk for pgsql-hackers@lists.postgresql.org; Thu, 12 May 2022 06:45:43 +0000 Received: by mail-yw1-x112f.google.com with SMTP id 00721157ae682-2fb965b34easo45505617b3.1 for ; Wed, 11 May 2022 23:45:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=LhfHFltuYIH3D5pSgHhxEfcznWFSwrlEl4VkiGAJnJk=; b=OM/g2xbD7T+K+2PDZMCvFkcAv+gNycAr6vOCcfRoEy9qIqbBu6PkT6FSHJFGcKMpl/ dbPgYdpXlIMOLPWw0wwamFE2CW+6w2PBs0FyLCv+Ag2nSQ2HKAxZaDB1hnOwPdZcQWuf QFTL27k0OXTtQkMaGIMzkutJWkwETSOTXuSL48LiFZ86DRelvgNlOg/FkYng2aTyWPOq nqItncTH7bImVOR5ijiGe0iFsz+fjWsHdoDQT+ToqG4ZwLxUoq4jxXgSru8rXnKTBo1j bHusOeqqFeesIHC/Jb5kkg3kgh4HdOg+AFs4ROlDL0RXmvp0tflai9WorXzKzbsQert9 Q5+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=LhfHFltuYIH3D5pSgHhxEfcznWFSwrlEl4VkiGAJnJk=; b=4NA8dRRP1EGjctIrod7FEpXE6VNuAB3ROHF/PgZxtIDyuBpqwVsx5dRl8fqMhE4otk InNOgMOvUHvpr41NhzZTHoy0g6VNlyMExnNPi+JZAnxl8OGSpfmsl03giGW+rG3J4TH6 rbXqCjH8omqSXRciStIDFpLF4l4m0TFguyAfpIUowO9IU3NqkN1jEpx0p4BSQiyVhOYz R51WPv8iujNNltpyfBbJwQ/FG6EPJFRCviCr+ng2mY0koENq/pg4RyRDxJG2aFi3L24m vnCbo5nG4IDtTXUJyelDTv11ow9q/+C+xzEZ+AEZKtk8wJZqLM2mGkNAaCZL9wiFvmnF bd4g== X-Gm-Message-State: AOAM5300tEHpx/xujG9UgI7+bC3hz3ZUwRktT5xT1zXMHk7m2xlnrB2L l9/C1HR0vUHldFHVXZ/98USsdlTc9qnCR+upFrc= X-Google-Smtp-Source: ABdhPJwoaPMchmKve6AUV6OA4xQz/8GQ3ByUtPf5PeOXSBlUbkTxQy2SvHI4MKuzkN05T8hEgmtaXJMh9ZaDl989mNo= X-Received: by 2002:a81:2c3:0:b0:2f7:c26e:5790 with SMTP id 186-20020a8102c3000000b002f7c26e5790mr29658631ywc.84.1652337935492; Wed, 11 May 2022 23:45:35 -0700 (PDT) MIME-Version: 1.0 References: <202205021144.zkbvyekn52v7@alvherre.pgsql> In-Reply-To: From: Amit Kapila Date: Thu, 12 May 2022 12:15:24 +0530 Message-ID: Subject: Re: bogus: logical replication rows/cols combinations To: "houzj.fnst@fujitsu.com" Cc: Tomas Vondra , Alvaro Herrera , Peter Eisentraut , Pg 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 Wed, May 11, 2022 at 12:55 PM houzj.fnst@fujitsu.com wrote: > > On Wednesday, May 11, 2022 11:33 AM Amit Kapila wrote: > > > > Fair enough, then we should go with a simpler approach to detect it in > > pgoutput.c (get_rel_sync_entry). > > OK, here is the patch that try to check column list in that way. The patch also > check the column list when CREATE SUBSCRIPTION and when starting initial copy. > Few comments: =============== 1. initStringInfo(&cmd); - appendStringInfoString(&cmd, "SELECT DISTINCT t.schemaname, t.tablename\n" - " FROM pg_catalog.pg_publication_tables t\n" + appendStringInfoString(&cmd, + "SELECT DISTINCT t.schemaname,\n" + " t.tablename,\n" + " (CASE WHEN (array_length(pr.prattrs, 1) = t.relnatts)\n" + " THEN NULL ELSE pr.prattrs END)\n" + " FROM (SELECT P.pubname AS pubname,\n" + " N.nspname AS schemaname,\n" + " C.relname AS tablename,\n" + " P.oid AS pubid,\n" + " C.oid AS reloid,\n" + " C.relnatts\n" + " FROM pg_publication P,\n" + " LATERAL pg_get_publication_tables(P.pubname) GPT,\n" + " pg_class C JOIN pg_namespace N\n" + " ON (N.oid = C.relnamespace)\n" + " WHERE C.oid = GPT.relid) t\n" + " LEFT OUTER JOIN pg_publication_rel pr\n" + " ON (t.pubid = pr.prpubid AND\n" + " pr.prrelid = reloid)\n" Can we modify pg_publication_tables to get the row filter and column list and then use it directly instead of constructing this query? 2. + if (list_member(tablelist, rv)) + ereport(WARNING, + errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("cannot use different column lists for table \"%s.%s\" in different publications", + nspname, relname)); + else Can we write comments to explain why we are using WARNING here instead of ERROR? 3. static void -pgoutput_ensure_entry_cxt(PGOutputData *data, RelationSyncEntry *entry) +pgoutput_ensure_entry_cxt(PGOutputData *data, RelationSyncEntry *entry, + Relation relation) What is the need to change this interface as part of this patch? -- With Regards, Amit Kapila.