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 1wUxYG-001ZJn-3D for pgsql-hackers@arkaria.postgresql.org; Thu, 04 Jun 2026 02:11:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wUxYF-004Oc4-1W for pgsql-hackers@arkaria.postgresql.org; Thu, 04 Jun 2026 02:11:19 +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.96) (envelope-from ) id 1wUxYF-004Obu-0A for pgsql-hackers@lists.postgresql.org; Thu, 04 Jun 2026 02:11:19 +0000 Received: from mail-ua1-x92a.google.com ([2607:f8b0:4864:20::92a]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wUxYD-0000000109i-05eb for pgsql-hackers@postgresql.org; Thu, 04 Jun 2026 02:11:18 +0000 Received: by mail-ua1-x92a.google.com with SMTP id a1e0cc1a2514c-963b09d5b91so184308241.0 for ; Wed, 03 Jun 2026 19:11:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1780539075; cv=none; d=google.com; s=arc-20240605; b=aFsnFflh3rlV+zQnkjjW0nlXXKITrR+OEjpaipQQnF3zF+liB2Tn3G3aGq9eI2z25s FSiryERwYFbGTwuOoqGlOCg3/NkAj+AbuH/7RuTvxwTDBcCUiMUSI/mdEtVY+2JJLUZP rrpZyqMp7kPv1imHF0NRzljRSLNI79Y+CZl3TYCoF0rAIQgMQL65x+vooYCwqtWgMu+6 9aBWKwU7OrZzmzEStIgwfjpva5weKpYPlV5hNnqkzWu1opZTGPE1UPnIbqV+X6rvyyLl ikbwGHa7VTuv4HWMBV/V2pRHBx6TEtCNjTJsgHa6GBzTdfLZK19ZV8gMpOjMWtxZ+k8r DN4g== 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=va7MuL2jhs/4+8tPNSGPYOIuNOJ2P7uR/CUF6vWq9NQ=; fh=iZwaFRsz6vIgDYLBqRqD/PxUQ9wfVoG3WLWE87Belrk=; b=jsKLWsIE6u5jYHoC6IpXyPc5ypYBS+eA6s4TF0ZXfzZlslzUnJeyj8KmdJWE95gpko xbV8owvjFEaP1Sz5F9loEg8gKEAxlvHuxkeK83GxxpECva6pjYD6GHQyn447FBfuxub1 lhHI6tEl52gHZZhT0NL/FX/x5ynXZN5O1Fxgj9aCajJPkCrFoC73V4QZ+hm7pvVD0/5k TOxH6Xtuqqh6Smdy4En8Zw+G69KnaG6Ykd6THxXVQxpoTQh+bUn+WLo9E8KHc/JzVVj+ NMYaANfSgGQHxWftBy/8QHnQum+VAGlASKlOaGBtXe+QguW//eCB6Skqc1oRpJEwgagH L1ag==; darn=postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780539075; x=1781143875; darn=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=va7MuL2jhs/4+8tPNSGPYOIuNOJ2P7uR/CUF6vWq9NQ=; b=LDW1YJlegpAz15Ail2sbvUqzfnD/llLo4WCRX0wVtaYnyUlw/f9l3I1PHUtM2O8wMH Sqqh2+1SoEiNDRgCwxWwqckmTpewxTgGcyLFKtHkn710J3R1nQb+BNFp6qRDMRb9yCa9 zcTIZ+8RLF8Ezw7NmSpJCFWEQ2SVsdTkvY4NPXB0Vug1ul1CdnTsWatGieLwabJZDmMT orVGhS/0/MZ3C/o9bvHyWSql7hkFiB5UYvecNbyX2UpyyAT+XCqreONGkqLalp/fmmkS g4IzajJZrWMEy1qw0ck/WFWGKd1ILXmnUCNaaLE9hDc+Hizp8R1WCx+S4wpJ/ddk8KES vC6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780539075; x=1781143875; 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=va7MuL2jhs/4+8tPNSGPYOIuNOJ2P7uR/CUF6vWq9NQ=; b=mmW7IigQ59LSaUVJQHkuzFe/NIS8b3+BVupYXD1okCwzd9uZwWUifXeCuk7KD7GHq+ 75dI3wEse3Xj9+P1Zc4YfgKbWOV/9QJqdnoMjjbpyYoYJvHyhbT0XKK6h3J7jF1ZwKqi VlPhu36YJ5AqUqJwMRWBwxqLpAQhyaF0tr3Y3wUaWBfD7/jOec/Jjm5ATi+49QBRFotf YqurvjI3IVBiNHRec33y7kVAhp8LXe4iIq3QwRwZoGApEeaFVWHmIau7Gdb/d2c90DSJ Ue8vKmGzNWYrt0iX944lmi+yx1LA43mFJN3LsF65uhp6xoE7mR4rrGGkOZeXY9H8cPUO tuMA== X-Forwarded-Encrypted: i=1; AFNElJ92ZZ6OQIabzPnU66KVvkvQYXrFLNqGEHn12Q/9vGDH3ZyTlbHurmAUwkqrAjrGB9qD7u7nBc08qmUmpLEf@postgresql.org X-Gm-Message-State: AOJu0YwlVZrLkvdYBTALFT4XH87DCgEi31Aac60WTPArmgYzwci8h6F/ G9h0gNMxn0Gc858juNRUcJclIVqNlUYL0nE1/fBhFBeiXvkrwbxofht4D5GU3yxBs0xC0OjnZ/u 97v8g+HBSzjZzr0VPVS1KST++THPxF/s= X-Gm-Gg: Acq92OFiSDbhswhq2Vxk8R0xjH4HjhiUI5sU7cFf/nno5V6boOngVlhrPmkWolfwKkm ZhnZgQ10+NJOQ9mVqmHpHPUISgoHvH6+K5q0/MfdP1ZLmIx5Gf8NmVIFr1q5HePihbvlMg5s0UD qMw7QMoKHii9hBNCoUq4DPbSW1JzHc/Jk/P/9TJHzX2Ul8rkzL18XkKveJ3ultrlMf0BwxMwtUj BtjrsGAZ6FhpDhcls4GDNxlIZ9N6oUqkB6KBUhzlGCVkBj9Kea0h0Q4JmWjTk0fNVv/rQ/T/TVH zwlGn/14b5BAxoHQQsVaIyjFrSyiR8iYpHFQzGt5pJ7KS+O3kiJDB0l9Ag9JdjD1jXyGnfE2g1V /i5WkJjr1YbxHMy4Bsu8gkdXbgqwAGhi71JIoaNQya24p14Gir0KdJ8DNhe32aKpzEtvJsxafob JSK6vC6PkDsQCGjZ0WM5/4JeFoYQRMVJcB X-Received: by 2002:a05:6102:2b89:b0:632:5db8:f672 with SMTP id ada2fe7eead31-6f54735956cmr963171137.6.1780539074574; Wed, 03 Jun 2026 19:11:14 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: jian he Date: Thu, 4 Jun 2026 10:10:37 +0800 X-Gm-Features: AVHnY4JAmHlViiiyK4aGZNgrSPPBZxmx637r3KT8t8nZgMEvtJ6Wh5nQEmP7sSk Message-ID: Subject: Re: CREATE TABLE LIKE INCLUDING TRIGGERS To: assam258@gmail.com Cc: Zsolt Parragi , Andrey Borodin , PostgreSQL-development 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 Thu, May 7, 2026 at 9:38=E2=80=AFAM Henson Choi wro= te: > > MINOR ISSUES > ------------ > > 1. Test: cross-file dependency on trigger_func (create_table_like.sql) > > create_table_like.sql references trigger_func without creating it, > relying on triggers.sql having run first. The dependency is noted > in a comment, and parallel_schedule guarantees the correct order for > a full "make check" run. However, "make check TESTS=3Dcreate_table_li= ke" > will fail because trigger_func does not exist. > > PostgreSQL convention is that each test file creates and drops the > objects it needs. Please add a local definition of trigger_func in > create_table_like.sql (and drop it at the end of the new block). > OK. > 2. Test: EXCLUDING TRIGGERS not exercised > > The grammar now accepts EXCLUDING TRIGGERS, but no test uses it. > The default (no option) is equivalent, but a one-line smoke test > would confirm the keyword is accepted and has the expected effect: > > CREATE TABLE t_excl (LIKE source_table EXCLUDING TRIGGERS); > OK. > 3. Documentation: create_table.sgml wording inconsistent with > create_foreign_table.sgml > > create_foreign_table.sgml already reads: > > "All non-internal triggers are copied to the new table." > > create_table.sgml reads: > > "All non-internal triggers on the original table will be created > on the new table." > > Recommended wording for create_table.sgml: > > "All non-internal triggers are copied to the new table." > OK. > 4. Code comment: capitalisation in generateClonedTriggerStmt() > (trigger.c) > > /* Reconstruct trigger function String list */ > > "String" should be lowercase "string". > Other places also have "String list", it refers to the T_String node type. > 5. Code comment: overly verbose in expandTableLikeClause() > (parse_utilcmd.c) > > /* We make use of CreateTrigStmt's trigcomment option */ > > The code is self-explanatory. I would recommend removing it or > replacing it with something like: > > /* pass comment through to CreateTrigger */ > Other places in parse_utilcmd.c have: /* * We make use of IndexStmt's idxcomment option, so as not to * need to know now what name the index will have. */ /* * We make use of CreateStatsStmt's stxcomment option, so as * not to need to know now what name the statistics will have. */ We can change it to: /* * We make use of CreateTrigStmt's trigcomment option, so as * not to need to know now what name the triggers will have. */ > > 7. Whole-row reference restriction: implementation gap or deliberate? > > Triggers whose WHEN clause contains a whole-row reference (OLD.*, > NEW.*) are rejected. Is this a deliberate decision, or a known gap > left for a follow-up? If the latter, a XXX comment at the rejection > site would help future contributors: > > /* > * XXX: whole-row Vars could in principle be handled by passing the > * target table's composite type OID as to_rowtype, but > * generateClonedTriggerStmt() currently has no access to it. > */ > Other places already reject it (search found_whole_row in parse_utilcmd.c). It cannot be supported because the source table's whole-row type differs from the target table's whole-row type. The v10 in https://www.postgresql.org/message-id/CACJufxEcKTa5DaDJS%3DZ25xe= zCEyuLbSzORDSmT4%3DjyZymsAK8A%40mail.gmail.com has addressed most of the issues mentioned above. Only issue remaining is changing one of the comments to /* * We make use of CreateTrigStmt's trigcomment option, so as * not to need to know now what name the triggers will have. */