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.96) (envelope-from ) id 1wIRz0-0086u5-1W for pgsql-hackers@arkaria.postgresql.org; Thu, 30 Apr 2026 14:03:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wIRyy-007hpK-1N for pgsql-hackers@arkaria.postgresql.org; Thu, 30 Apr 2026 14:03:12 +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.96) (envelope-from ) id 1wIRyy-007hpB-04 for pgsql-hackers@lists.postgresql.org; Thu, 30 Apr 2026 14:03:12 +0000 Received: from mail-qt1-x835.google.com ([2607:f8b0:4864:20::835]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wIRyv-000000040cs-3jJW for pgsql-hackers@lists.postgresql.org; Thu, 30 Apr 2026 14:03:11 +0000 Received: by mail-qt1-x835.google.com with SMTP id d75a77b69052e-50d6b393d60so757451cf.0 for ; Thu, 30 Apr 2026 07:03:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1777557788; cv=none; d=google.com; s=arc-20240605; b=MBQapYwInNbzb52Ent7jQDv4Kixey+YptM5POfqQEIuecnxwPCUIerKXe570EGEw1Z gyWs60W7fVhxXR+8m5iUoNh9m2rxa3nfm869jBRxE7/S1dKI7RBFWczpitpM8zzl3RTw IrvQQEJUPwDp4qnbtkyFg+2EmdP/mM5SgEePr721PqBj/JC5Lz2Jk8U6hdr8ckyrTTUD fqNJG4aGYQmwWL/NURAn11HXxHojkb4yMX4y7Eg9h+tVJx8f1YfSG/XISfCwVJwXWpsq T6jWwzfy5q0XKlDVxwl/rkFbDbaYrXRy3Xx1y5kBJig+D2aXMKdLA98PJZC7R4Trk42F 28TQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=yJrKtjh7DUugylauQHdk8i/E7Uq+wlOZZWCJ9azfV8E=; fh=tdJQgnZAlVewhPZGwBOd8V0KeyzbvchOMQ5tDJ6orDY=; b=KKAIz+1tw8CgoroEkMyLlEkXcXcC25/1HtGvE5M7EjP2U/iqbBqgDTv3adzCLiPHLE kzBOkA1gKSPXfb2os4NjP00/jEXle/DJuc38p6wxjZeov2WT/8unqEKdxqYPN4KNTbgK G5xuJuIQxQKRhhY0x5xeoP7rIUF9WMfnVtpMOYsqKE5Z84XkvRj7e/ut1lcjrc4MQ3F3 zfuDd4NaLTsuPo57B0e8CV0URpnRli3j4KS18oB8YQz5lgCAxxXc6E1NnnQ9EUqP9+mu naZUjntttXHMF/cTkEGrHz4d4UeI1eI9Y0qCTJj97NoXCCy5c4QbDMGSJw9AY5/MFS5M nDgQ==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1777557788; x=1778162588; 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=yJrKtjh7DUugylauQHdk8i/E7Uq+wlOZZWCJ9azfV8E=; b=JpcQArE/Q8TtKmflWI6bJbjN5jhRvCNsORYhrR03oXhT3k0vmLnVsCE0+20psksuvl 6Yt9EEoXsf0yIN0u9HuDvpSLusMTCKhLh4FGAqFp2jNDCI1qQ7MUNewn1uvaxyGsOiRq q3RfAeT8B1i8Nc88mjPuTdUS42cyCp2t2FlwVtJk+xDNIOwdvTBnNffGYOFgofZGzsFv rrrBIlOGHepw0t6xzP7+xwBiHxkGFOl4S61Sx8xcqfS3kFl+dbGHgObBOjkHArD8dsZK CqzYJx0foeqozaOVSxAIK3Ji5tc6n5UOXASkSXB+ORMP1IUuJ/nsBBcls4AiIMGzIf4n IRZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777557788; x=1778162588; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=yJrKtjh7DUugylauQHdk8i/E7Uq+wlOZZWCJ9azfV8E=; b=KHV5cUjgVru66BZj6UNCDv7L8INhMUEOH4BNMzDQnoh3GECNi9rDZpm9qb4qnIFuUT x8LULRcpO4NoHkeTgPKlGbT823zebMB+RWmpUWZ77sqCVZSs5ifGOdiiweXl2RmsnI4d sKGz424ciJeU4yvvAw4bGM7SKJ3sj9pv4qWXAZVwG7t7cs0IdhQmpDjc0VOACBzYZ2Am ax7e+Ej2ERTx9MQekv5nyTsxiEE58NoM0QyiF1vO9jkZ4qEjgcNdY6Jo1MNa3aEWQ/Nu 6WDqwFwDv5Q9qgTZPvyp5fcvyDyOnyRg7yj0yu1wRAwQrMoSI3QgwMvqb0WWNIkHE0oD K96w== X-Forwarded-Encrypted: i=1; AFNElJ/+XfuczXDcKfuUv+wEIDv6B43YZbLXHaIVq3Va3/8gPXzkdHyP2Bsstw0iWPWtqhq8O2JSRG7dLataJaSU@lists.postgresql.org X-Gm-Message-State: AOJu0YyZpd6s/vVqJ35J1YI1UWMcPBwwlKzqRX4HgqAiTYmFbo8sIggs Tf+2gyLhb7cZ3GRnqnflQua1H5Y+4EC9GxQSlUbQUyD3U9yb/iF/XipKzu9r3F3qkDtdhRBwi3j UrXnqZFkfXfreGMWoLcsKfG39vgvXsEK2Ivqty3fHMZnu3H5M6e6htfonIGk= X-Gm-Gg: AeBDieudFUiaCIUyPnrqqHdlZZl1naBhPbXE/krVPpCldvsGZRuf6S+L+pIUc0QxUfv C09AHXhBmq5fqfrefLVW9X69EDmQHCu53vHNZtXEUGQtQEiF+783ik0iBL7mBidVHo7CnvIN9wK u+LUBW1YlqeFGPidTFWXeU5iTlTl/bYtuIRVIQg6VBaA3bw4PEWAya4dmsfApL02GXRYy41pD0D 3Gd26i9GMwYkMpdDkTTrvOXA/rw+ryfiPzeJJyd6/NntbpZ/fb26B7gQuTbYm3ThyYA8XIwpnny pRS3ITJQnjJpNgaSJIRyJjbZd/cI4TlGB//Ama6LphZ0fG1mheHZUmORZtdkimy0NSiJVN/5xJ+ biVDA3QCus1eMgSqZ4g== X-Received: by 2002:a05:622a:aa0a:10b0:50e:41f3:6467 with SMTP id d75a77b69052e-5102860d4c4mr14983501cf.12.1777557787499; Thu, 30 Apr 2026 07:03:07 -0700 (PDT) MIME-Version: 1.0 References: <38690b0e-f91b-46fa-b72a-57775612e463@postgrespro.ru> <2oh4o4zvj2jreituesxgglmnseo2m2brffms3lvao6mseemto6@32v67ejhxlht> In-Reply-To: <2oh4o4zvj2jreituesxgglmnseo2m2brffms3lvao6mseemto6@32v67ejhxlht> From: Hannu Krosing Date: Thu, 30 Apr 2026 16:02:56 +0200 X-Gm-Features: AVHnY4IF9FA4WJYxFuCi_9goxJsFn4j6DOBgyy35e947-S9JWJDukyTmgAJdS24 Message-ID: Subject: Re: Support logical replication of DDLs, take2 To: Andres Freund Cc: Dilip Kumar , Amit Kapila , Masahiko Sawada , Vitaly Davydov , Ashutosh Bapat , 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 Wed, Apr 29, 2026 at 2:10=E2=80=AFPM Andres Freund = wrote: > > Hi, > > On 2026-04-29 10:07:04 +0200, Hannu Krosing wrote: > > On Wed, Apr 29, 2026 at 5:39=E2=80=AFAM Dilip Kumar wrote: > > > > > I am trying to understand your idea. If we are trying to deparse from > > > an actual system table using a snapshot, why don't we just use the > > > WAL? I mean, the WAL should contain the actual catalog modifications > > > it has made. > > > > We have the full data in the catalog and we would likely need catalog > > queries for any change, even when de-parsing the tree. > > > > And we should not add the extra load on the original DDL side, just as > > we don't for DML. > > That can't be a relevant cost compared to everything else. Probably not. But unless we somehow encode "everything" at that point we will make building different DDL decoders harder down the line. So why not just save the normally serialised parse tree at this point and let the decoders decide to do whatever they need. > > At most we could just serialize the statement tree into the WAL, > > though even that may be an overkill if we can get the change from > > existing records. > > > > - insert new row in pg_class --> extract the CREATE TABLE (or INDEX, or= ...) > > - update row in pg_class or insert, update or delete a row in > > pg_attribute --> extract ALTER TABLE > > - except when it just updates relfilenod --> extract TRUNCATE > > - delete row in pg_class --> DROP TABLE > > - dml on pg_constraint --> ALTER TABLE > > > > ... etc > > That doesn't work in the general case, think of > ALTER TABLE ... ALTER COLUMN ... TYPE foo USING (...) > > There's a big difference between USING(foo::int8) and USING (pg_size_byte= s(foo)) > but it's nowhere visible in the WAL. It can't be a big difference if it is not visible in the WAL. Currently, we do treat DML exactly this way (or arguably worse). In the following all the updates are decoded exactly the same CREATE TABLE t(id int primary key, data text); INSERT INTO t VALUES(1, 'one'); UPDATE t SET data=3D'one' where id=3D1; UPDATE t SET id=3Did; UPDATE t SET id=3D10-9; UPDATE t SET data=3D'one'; ALL of the above get decoded as "UPDATE t SET data=3D'one' where id=3D1;" That is, we do not care how the values got there, as long as the end result is the same. And we do not track which fields were actually changed The only reasons I see why we could not do the same for DDL are 1. it would be significantly more expensive to do so or 2. we plan to fix some of that for DML as well and to start tracking more of the intent in DML by extracting that from the statement trees. -- Hannu