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 1sJ5jW-002KS3-Ug for pgsql-hackers@arkaria.postgresql.org; Mon, 17 Jun 2024 06:20:51 +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 1sJ5jU-00Dlmm-O9 for pgsql-hackers@arkaria.postgresql.org; Mon, 17 Jun 2024 06:20:49 +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 1sJ5jU-00DllU-CT for pgsql-hackers@lists.postgresql.org; Mon, 17 Jun 2024 06:20:49 +0000 Received: from mail-yw1-x1129.google.com ([2607:f8b0:4864:20::1129]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sJ5jT-0024qn-2T for pgsql-hackers@lists.postgresql.org; Mon, 17 Jun 2024 06:20:48 +0000 Received: by mail-yw1-x1129.google.com with SMTP id 00721157ae682-62ffc495935so42429667b3.1 for ; Sun, 16 Jun 2024 23:20:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718605245; x=1719210045; 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=Uriscx7Gg9sINOhJZwsmk10uK5gYyElgkps0JO/a53k=; b=cLHsqQScE/pUhk75yy2kI++wHWSiPCoaiX8/7R+otQD5w38tLbED9y6OdNx7aFJYbC vrDFkc/cac2B3zMQDK6EJpphLnNsygKno/fWMWiLgdR8gJ9kQb9xOQdXzuxMVLm8oCs2 6OnmnEYt2VsVLVRfn6offA3881VGa84K3QM4CFz06jRRz6j8DQgTnJW1ZTZ7AIjE4QzV UeZ+x5enBOyVlc6PgGC+WrMN57OYKIvBd1cBisjmxpOW4sXBHhDI8iQcaPEWB33Ey51H DmPOMguASAsQEmBdo1Ptnq3lsOpjZCUjpto6VYQ+LvqhLx5RO8Q5vthsvRtleTuL5Zex gtGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718605245; x=1719210045; 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=Uriscx7Gg9sINOhJZwsmk10uK5gYyElgkps0JO/a53k=; b=fwJOXGmBnBAW7otxIxDdaDkYApW31PsMSkHSkl+6U0frwirYOQYSdAuovb9NWAJNEd LTU7F15g6j5c3xDzl/WnfcX9B2Y/LXoekDf7+t9NcUSkBKxDLTn+nUWCxX/3zWzmkzuC Q+BcWPz38r5LI/1TWDJKXb8hsQsWQhtye6Y4xSrhjrGpGuO8YWqrVZ3M0nPfFI/x2Djj /BOaw367ulzf0kVkdlJ2lT3bf9kTNUefjMDR4A4PC2Kfuap2AhsU+B3j4HQcypqtO8/s qh/4m/WMLcc+qEIFBd48WGR4mAIhUCxVNlE+H7VmKSGkN2jtva4RMiF3sKGsksL+ki3b +EEQ== X-Forwarded-Encrypted: i=1; AJvYcCUhi/XcW3Cr3GFhgEr6anjIpfg06AGzPzYpNMMlPhiT8yl3Qrr7WSnsjQANFFHyZmH//ADLmr5v5AMCzDVuh984Ei2TNrjTK5SQLmACxtmGmgS1 X-Gm-Message-State: AOJu0YxF6wKFYmAbsfFH3fTSlnqzF83aUi8nwAvyT7/LN1LTh2t8LLzF lLyYGrEd3mtTONyz7eBDK5mKgYp52oIGMQdzdzuDosthkjA/sfECIHSIWJwMFav6LXEJZ9Jq8Nh xBjwyXLZ+qu0CjjeDNz78CvvY1VE4YIFV X-Google-Smtp-Source: AGHT+IFpPOaiz8eaX8NtprjrhL8jMnUJFedmAoYoDCCIxtZYSf+OLUNaxAtZFLy9/c9amRQsMkMVWocYu8+C0bBbbO8= X-Received: by 2002:a0d:e401:0:b0:630:36fa:b271 with SMTP id 00721157ae682-6322480eca2mr77835397b3.41.1718605244088; Sun, 16 Jun 2024 23:20:44 -0700 (PDT) MIME-Version: 1.0 References: <60E6ECA4-C5DB-4F87-9557-1BC094A9F051@gmail.com> In-Reply-To: From: Shlok Kyal Date: Mon, 17 Jun 2024 11:50:33 +0530 Message-ID: Subject: Re: Pgoutput not capturing the generated columns To: Shubham Khanna Cc: vignesh C , Peter Smith , Rajendra Kumar Dangwal , pgsql-hackers@lists.postgresql.org, euler@eulerto.com Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, 14 Jun 2024 at 15:52, Shubham Khanna wrote: > > The attached Patch contains the suggested changes. > Hi Shubham, thanks for providing a patch. I have some comments for v6-0001. 1. create_subscription.sgml There is repetition of the same line. + + Specifies whether the generated columns present in the tables + associated with the subscription should be replicated. If the + subscriber-side column is also a generated column then this option + has no effect; the replicated data will be ignored and the subscriber + column will be filled as normal with the subscriber-side computed or + default data. + false. + + + + This parameter can only be set true if copy_data is + set to false. If the subscriber-side column is also a + generated column then this option has no effect; the replicated data will + be ignored and the subscriber column will be filled as normal with the + subscriber-side computed or default data. + ============================== 2. subscriptioncmds.c 2a. The macro name should be in uppercase. We can use a short name like 'SUBOPT_INCLUDE_GEN_COL'. Thought? +#define SUBOPT_include_generated_columns 0x00010000 2b.Update macro name accordingly + if (IsSet(supported_opts, SUBOPT_include_generated_columns)) + opts->include_generated_columns = false; 2c. Update macro name accordingly + else if (IsSet(supported_opts, SUBOPT_include_generated_columns) && + strcmp(defel->defname, "include_generated_columns") == 0) + { + if (IsSet(opts->specified_opts, SUBOPT_include_generated_columns)) + errorConflictingDefElem(defel, pstate); + + opts->specified_opts |= SUBOPT_include_generated_columns; + opts->include_generated_columns = defGetBoolean(defel); + } 2d. Update macro name accordingly + SUBOPT_RUN_AS_OWNER | SUBOPT_FAILOVER | SUBOPT_ORIGIN | + SUBOPT_include_generated_columns); ============================== 3. decoding_into_rel.out 3a. In comment, I think it should be "When 'include-generated-columns' = '1' the generated column 'b' values will be replicated" +-- When 'include-generated-columns' = '1' the generated column 'b' values will not be replicated +INSERT INTO gencoltable (a) VALUES (1), (2), (3); +SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'include-generated-columns', '1'); + data +------------------------------------------------------------- + BEGIN + table public.gencoltable: INSERT: a[integer]:1 b[integer]:2 + table public.gencoltable: INSERT: a[integer]:2 b[integer]:4 + table public.gencoltable: INSERT: a[integer]:3 b[integer]:6 + COMMIT 3b. In comment, I think it should be "When 'include-generated-columns' = '1' the generated column 'b' values will not be replicated" +-- When 'include-generated-columns' = '0' the generated column 'b' values will be replicated +SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'include-generated-columns', '0'); + data +------------------------------------------------ + BEGIN + table public.gencoltable: INSERT: a[integer]:4 + table public.gencoltable: INSERT: a[integer]:5 + table public.gencoltable: INSERT: a[integer]:6 + COMMIT +(5 rows) ========================= 4. Here names for both the tests are the same. I think we should use different names. +$result = $node_subscriber->safe_psql('postgres', "SELECT * FROM tab2"); +is( $result, qq(4|8 +5|10), 'generated columns replicated to non-generated column on subscriber'); + +$node_publisher->safe_psql('postgres', "INSERT INTO tab3 VALUES (4), (5)"); + +$node_publisher->wait_for_catchup('sub3'); + +$result = $node_subscriber->safe_psql('postgres', "SELECT * FROM tab3"); +is( $result, qq(4|24 +5|25), 'generated columns replicated to non-generated column on subscriber'); Thanks and Regards, Shlok Kyal