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 1vqYIy-00Cz1y-34 for pgsql-hackers@arkaria.postgresql.org; Thu, 12 Feb 2026 15:08:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vqYIx-009Xe7-39 for pgsql-hackers@arkaria.postgresql.org; Thu, 12 Feb 2026 15:08:32 +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 1vqYIx-009Xdr-2B for pgsql-hackers@lists.postgresql.org; Thu, 12 Feb 2026 15:08:32 +0000 Received: from mail-oo1-xc2c.google.com ([2607:f8b0:4864:20::c2c]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vqYIv-00000000Irc-3VNB for pgsql-hackers@lists.postgresql.org; Thu, 12 Feb 2026 15:08:31 +0000 Received: by mail-oo1-xc2c.google.com with SMTP id 006d021491bc7-662f5c5507cso5305632eaf.3 for ; Thu, 12 Feb 2026 07:08:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1770908910; cv=none; d=google.com; s=arc-20240605; b=OFPu8HBESYEjfC12oRfUKajgKwF0MKWE23fKsz9kWMyM/JUieXEFI8DQ6xqJM56Egm 4v5tvdd8FSe42AHCKkZTH+5I3CC6pZx2kAUW+HY+96QHdryeGvfwhDxhc/JsUH6IaQtz UwO+SvClGbAmhJ3gqIi4YCmDZFAO7YzFmXRmXH1fyP2hdgG5aRMJxLRHhjJLWn4iA1rw 0GMCHGZ7bHoG8tjuEN5vqA/uhotPrAzurNadXdP8TgP/7TnwL+x7yGDHBQ7NGkK6pG4V FdHnEuI/kYeLekDkgUJM9i5XqTmK3EPHc8pp+Qoao6gn7RgYvyuedNPqI5fuBi+zrkM5 YlQw== 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=iR78oqMjKPySL9SYlnh6xbciJjGdFxriHedId2KrUk0=; fh=MH05y6uSHhX9GvjXOKKd2j15H0TyY6LnXDRV6vQeEWo=; b=lmb4xGl6ObVGs5/9AfNel0nYOOfDNEzjrHAYqvIkZk/7z4lLS+avw2lnUIoouedMF0 xtlPsFCftlUS9M6CyfabC2Jqo9QAjQsg9LgrE5OWnJBNVEa+3zdj6ED7mRJr5NUKNHz/ fsqbUVOYfebzqEa19MFVc+hOBaipdKqnqJLV+cQtxfBqVgHFs076o342l2uOeMBrLm7H 7nJorw5iPKXb49A4J5W95AvJaVVPRPpYQ1ngG2SiHjXy9sEsb096GTQAF6O712t+rDfJ mYDmnCvFNqjMCzamSBL0TxC/zdlMGXTnzofPus9B6rS97P/CKM2QxGjJC8VWUYBUarTY gkJA==; 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=gmail.com; s=20230601; t=1770908910; x=1771513710; 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=iR78oqMjKPySL9SYlnh6xbciJjGdFxriHedId2KrUk0=; b=YRnEPelXSl4W89yN4Ui3C/WAwB8cEqGdCdcGHCb5nIkAoL0zJKODrwC5euZGPojLEu AS0FGMv7k89uNf9PVPwa6lzmdvc59p329nErviqFnYLplYXMB9bEDLHv3+6ekZdO9ExX AE5C4ouHZdp4ECsURxznGFwoPidA0Iwsda9ICkvDP5wKn+gt06PM1O180c5CgRmdSop7 6fMpJhYBXIXLMzUavTYSRQvQlSzBidq27fhqWp6jtSqbS/I9Hiw0HB6yJ1CbsTOoapg1 MLThgAtu+8t0A0Cueqg+AOpYSuQ8klVRb9gn889ebsFq7q6K3JQ1kJZgSbRXlZt2erj8 zVxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770908910; x=1771513710; 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=iR78oqMjKPySL9SYlnh6xbciJjGdFxriHedId2KrUk0=; b=qZ0Y9gjrT6DLyf6YRBl5zrfHYFbQ2yNQh45SrDyjY4RWefVN7N3xVQ6zgGVNeIetQk xKC6YW6L7H6tLRv7C2M08Rc+juaSogj2KiB+ZAvnoRbYc2lqYftQPmz/YkpISwHRhVJh skNXqrY0m7FhSbRWVPQDZrz0ShMgtxQifanh8itGoYMcWRin+/TJFPJHRfDq9qFvVbGW lq+5HuxIS4x5rdVuz+ykJDLLvO2KbUKWcwUr4SkXQ0YQMdI9OAXpVcXd2KsJKvHx0Jbg ZL22cl+NZggyLfzmiVYMAChXtrPjLKOGdhRqwbrWPYYgN7uTkJNnaiBjOXVvvV4u1pyx ZPfw== X-Forwarded-Encrypted: i=1; AJvYcCVN+vP+i4QbopO+Qxt4KbKb0NeSMdPY8I0uISoAA+2Ur8+tuhUnPLbUvB1DPjJvQN2H59u9JsQDYWaBATYw@lists.postgresql.org X-Gm-Message-State: AOJu0Yw4c3PV3n1QMmt5hoMnG/X9cri6uAeRYP52g9A68EtyZ2J/QpUX YZc51fG3suRcv0G03249qfJET2MvYhA3XW+o/UJ14g69qvPYrG7ZElfsL2VTwjtSAU1vSPCgcUM 5KmEAJFQIAErVN+405yoq37y0/yj8XU0= X-Gm-Gg: AZuq6aLFbCrO9JozUkDv8F7n1BaUzY4kvLYXxt6WQ1tRZBoUeplSe2AWVMUG6sb1tq1 wCnwnjAUWe8T1HjsbpoqEewMMynM07FVau5jOkK1eAjtGkz/i0jXmTvgRBTAYJSeWOF7TZgxEOM HQJQUUzKbKbsMezWp6lU3F3+Lkg8sZTXvgjMtWbWiJ7/Dhhshzt9xGG0LIjT1RB0916n2Kf1rFg iqZIynxb2IF0DD1VI7FqNm3WgKpxxhH8nWsxmb0kL9bzZCcoE2AAP8NBXVyI/7zHY9uiLrHf46P hG3GLDNLayHprVnh+coPHvpBWPlL9syGkt8/emNy/hlZ8zW9YHmP X-Received: by 2002:a4a:e902:0:b0:663:43d:b5fd with SMTP id 006d021491bc7-6759a74b057mr1330578eaf.45.1770908909226; Thu, 12 Feb 2026 07:08:29 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Fujii Masao Date: Fri, 13 Feb 2026 00:08:16 +0900 X-Gm-Features: AZwV_QhBvOD-qatf6I_Vg0_7ddBsMdcLDXM9nyveNN6ictm9Vvip3LShHkyB_QY Message-ID: Subject: Re: COMMENTS are not being copied in CREATE TABLE LIKE To: Matheus Alcantara Cc: Jim Jones , "pgsql-hackers@lists.postgresql.org" 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, Feb 12, 2026 at 11:36=E2=80=AFPM Matheus Alcantara wrote: > > Hi, thanks for checking this. > > On Thu Feb 12, 2026 at 7:11 AM -03, Jim Jones wrote: > > Hi, > > > > While reviewing another patch[1] I saw that COMMENTS on tables are bein= g > > ignored in CREATE TABLE LIKE: > > > > psql (18.1 (Debian 18.1-1.pgdg13+2)) > > Type "help" for help. > > > > postgres=3D# \pset null '(null)' > > Null display is "(null)". > > postgres=3D# CREATE TABLE t1 (id int, name text); > > COMMENT ON TABLE t1 IS 'table comment'; > > CREATE TABLE t2 (LIKE t1 INCLUDING ALL); > > CREATE TABLE t3 (LIKE t1 INCLUDING COMMENTS); > > > > SELECT > > obj_description('t1'::regclass, 'pg_class') AS t1_comment, > > obj_description('t2'::regclass, 'pg_class') AS t2_comment, > > obj_description('t3'::regclass, 'pg_class') AS t3_comment; > > CREATE TABLE > > COMMENT > > CREATE TABLE > > CREATE TABLE > > t1_comment | t2_comment | t3_comment > > ---------------+------------+------------ > > table comment | (null) | (null) > > (1 row) > > > > > > v1 attached attempts to fix it by expanding expandTableLikeClause() to > > retrieve and copy the table-level comment when the INCLUDING COMMENTS > > [ALL] option is specified: > > > > The patch fix the issue and it seems correct to me. > > This bug seems to also happen on 14.20: > postgres=3D# select version(); > version > -------------------------------------------------------------------------= ----------------------------------------------------- > PostgreSQL 14.20 (Homebrew) on aarch64-apple-darwin24.6.0, compiled by A= pple clang version 17.0.0 (clang-1700.4.4.1), 64-bit > (1 row) > > postgres=3D# CREATE TABLE t(a int, b text); > CREATE TABLE > postgres=3D# COMMENT ON TABLE t IS 'foo'; > COMMENT > postgres=3D# CREATE TABLE t2(LIKE t INCLUDING ALL); > CREATE TABLE > postgres=3D# SELECT obj_description('t'::regclass, 'pg_class') as t_comme= nt, obj_description('t2'::regclass, 'pg_class') AS t2_comment; > t_comment | t2_comment > -----------+------------ > foo | > (1 row) > > So I think that we need to backport. The documentation [1] states that INCLUDING COMMENTS copies comments for the copied columns, constraints, and indexes. It does not mention copying comments on the table itself. Therefore, not copying table comments with INCLUDING COMMENTS does not appear to be a bug. That is, the proposed patch seems more like an improvement than a bug fix. Regards, [1] https://www.postgresql.org/docs/devel/sql-createtable.html#SQL-CREATETABLE-= PARMS-LIKE-OPT-COMMENTS --=20 Fujii Masao