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 1vfijv-004SQb-0p for pgsql-hackers@arkaria.postgresql.org; Tue, 13 Jan 2026 18:03:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vfijs-0060Gd-1o for pgsql-hackers@arkaria.postgresql.org; Tue, 13 Jan 2026 18:03:32 +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 1vfijs-0060GN-0Y for pgsql-hackers@lists.postgresql.org; Tue, 13 Jan 2026 18:03:32 +0000 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vfijp-000H4W-2n for pgsql-hackers@postgresql.org; Tue, 13 Jan 2026 18:03:31 +0000 Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-b872cf905d3so336195466b.2 for ; Tue, 13 Jan 2026 10:03:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768327408; x=1768932208; 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=xZJ8KrrmI66Zi42/lSmOWbsRiIqaKu91aakZFXHfvDE=; b=I6GqPZhYbxa3hZTRWGQR0Azf07TYxGhRJwsUyEG78wyvQ7zmnrVuGK2od0uB88mKmC /yo3AGwE9znjQT3TTPufeV5NQ/AANkXmKjbzQFQlj+dIYWWD6XBoD+NrDOKVmalhY2Gu KUB5d3gE6flZbAfF4l7dbro2EkJnmfNUe3F/2xL58VKj7XN3leBOGPVlbzgxoWQFZd5S QKr3e2Hlm1poLTlweaKL30w1zMl662YjuUdB2KHMvzRf44btXsnSFccg/C3s9uOgZbrj +TrRZmd1OP+Tsdpx47uCnBj3C/VgKOM6AvTvLxGN/EKZc/xkx+xI0tOpAm8QCWpd/6Lw 0sAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768327408; x=1768932208; 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=xZJ8KrrmI66Zi42/lSmOWbsRiIqaKu91aakZFXHfvDE=; b=kwjVxxOeVj6Kh4qnDelIhAAP0Mabv0WjbNXoFjJ439Vh8snENTYprrgpSGCxDmMG1s CRdnqzIx6Ng/qe/YRW3WXgwESUKTUDrRv8UoNlVvhBnw9FYDuz5apqfCdKVMvPjhCF8F pSrFnwJkOgPB5moYu6BsIl9vk94Ro2aKM3bLj1e1ZM1/4PGKgxnIDd509XwnCc6QutWB nUsCTZ5rHAqLuSMX6xsh6Won1A14eokUJPJHuQhrMS6NChlraq5ZdDfxHufztJk/SCs5 uz4l/FWKnpH/SWmiaKHAhxWz7nQ6eJk07rbxPGmlVNLyPAjH5jAj8SrSsAoc/52gktYh 1DuQ== X-Forwarded-Encrypted: i=1; AJvYcCVbWI1XQrsXH4GP2nUw7WJFeNLkBFandlLFGx8NsUHa+lQlMFtOV2RuBtI4ZN0CojxYBuyDMoQVEtC8RvyX@postgresql.org X-Gm-Message-State: AOJu0YxjwmtF9T1QkHAvLf8jRL+eMDbAVSn951JvCqjE916t619HKc0n dEmzG7PpeXEJArLqzen7lsbY1GWevcwbgFgSjx5EhShvWsbgUMtn/apKY/XDjMZd7sNBOJbucd/ pzBIv2mBRU6oaRZRU4m82wR6BUSGzbAc= X-Gm-Gg: AY/fxX6uN2gsoAeANX6uZ5JFDquQfciwkgyuiYZv21fCAYAlAaCQrImTpza8nR1e7ON DiZQqhlJl7X1VkZG/MhqnMp4JZSJKkYRPH4YB8ZJQpjR3fsa9YYkt2xqZR8wnroedVM2hJeET8I NgFoK/9/0ffJYUs5VsxWcVghRCZRaMFmezuj1FX47GfV52lvCnajk4N2PfYn+SH6gK6xqlpVj5d ENmzTH6iI5IeOjWFce0jzUiD1EctXxiDhj+Yk0TKOtCywKRn3K5UzFwb2j4O45QQMMxeElmcdwo aNdojO2W3iAQ1by2bQm/aHY9LsO0 X-Google-Smtp-Source: AGHT+IE9aX12ZNmaYPzdSaDsUy4dCoCjCooJhZOplRiv7kn9tguD39Jz84l1Ifoobes6ZeB07UB6Hv95WhNiLDrQC/0= X-Received: by 2002:a17:907:784a:b0:b87:173f:631 with SMTP id a640c23a62f3a-b87173f2ba5mr617554666b.25.1768327408066; Tue, 13 Jan 2026 10:03:28 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Robert Haas Date: Tue, 13 Jan 2026 13:03:15 -0500 X-Gm-Features: AZwV_Qgw4mdig_JuVzRcAZ_VpDH6t4FOEJzo-IRxTxOlw5o-XRBSV3GD_I-MwAI Message-ID: Subject: Re: CREATE TABLE LIKE INCLUDING TRIGGERS To: Andrey Borodin Cc: jian he , 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 Fri, Jan 2, 2026 at 4:25=E2=80=AFAM Andrey Borodin wrote: > First two steps seems to add Oids along with RangeVars. It seems suspicio= us to me. > Parse Nodes seem to use "textual" identifiers without resolving them to O= ids. Oids are specific to session catalog snapshot, but parse nodes > By adding Oid fields we will have to check both RangeVars and Oids all ov= er the code. > Other INCLUDING options (indexes, constraints) don't modify their stateme= nt nodes this way - they create fresh nodes with resolved references. It seems like what generateClonedIndexStmt() does for the relation name is = just: index->relation =3D heapRel; This is not a "resolved reference", which I would understand to mean an OID in this context. In fact, if heapRel->schemaname were ever NULL here, this would be at least a bug and possibly a security issue. However, I don't think that ever happens. ProcessUtilitySlow() calls transformCreateStmt(), which forces the RangeVar to be fully-qualified, and then ProcessUtilitySlow() fishes out the transformed RangeVar so that it gets passed through to expandTableLikeClause(), which in turn passes it through to generateClonedIndexStmt() and generateClonedExtStatsStmt(). Similarly constraints are handled by using that same transformed (i.e. forcibly schema-qualified) RangeVar in the AlterTableStmt we construct. To be honest, I find this all incredibly ugly. I think that translating from names to OIDs and back to names so that we can later translate back to OIDs is a horrendous, bug-prone mess. Nor is the problem confined to table names. For example, generateClonedIndexStmt() needs to translate the AM name and tablespace name and any column names back to textual format so that when we actually create the index we can redo the translation in the forward direction and hopefully get the right answer. But having said that it's incredibly ugly and I don't like anything about it, it also does seem to be the established pattern. As you say, it seems as though the patch makes CREATE LIKE ... (INCLUDING TRIGGERS) work differently from other cases, and I'm guessing that's not what we want to do. It's better to use the same ugly hack consistently than to use different ugly hacks in different places. Then if somebody ever decides to try to clean this up, they can clean up all the cases in the same way. --=20 Robert Haas EDB: http://www.enterprisedb.com