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 1tkBo0-0016vq-CK for pgsql-hackers@arkaria.postgresql.org; Tue, 18 Feb 2025 00:49:44 +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 1tkBnx-005HWM-6g for pgsql-hackers@arkaria.postgresql.org; Tue, 18 Feb 2025 00:49:41 +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 1tkBnv-005HVk-U4 for pgsql-hackers@lists.postgresql.org; Tue, 18 Feb 2025 00:49:40 +0000 Received: from fout-a3-smtp.messagingengine.com ([103.168.172.146]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tkBns-001SQX-0N for pgsql-hackers@lists.postgresql.org; Tue, 18 Feb 2025 00:49:39 +0000 Received: from phl-compute-07.internal (phl-compute-07.phl.internal [10.202.2.47]) by mailfout.phl.internal (Postfix) with ESMTP id 21D3813809C1; Mon, 17 Feb 2025 19:49:34 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-07.internal (MEProxy); Mon, 17 Feb 2025 19:49:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1739839774; x=1739926174; bh=R4a4frVj/6 kmAjhMiwvV2UBD125Zd4Ml9Qvz/FUADhM=; b=hv+m+hY7L2vH3lqFRPS3e+TY5P I7UTovBnAmt88B4p2FBi84ASrJjBo+iU1GAjlfnZ95S6PJrzFHK2GMynimaFNtxY 7POJrAMUrk9KQC+ear+kyO2KAmme+OfDHgjJ77PZTwLpPLdbt64oZVuq/1btDGD5 SAB5+wijf7WRLu6/TpKswEMtMthjkPULASEuwSF3JEXOWmplEuIp2G/nCQVCc0I0 idrWvEusrk7OoJX03ZSL2VZ3Gj9/0T45AD4/9BIo9LkwICYCaPQj5kfde4+K+rJZ l10PuNoPZM2irttg9udpOYhwxVS3oBns7MBTO7mWzlV3sKifqiR2M288ZGvw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1739839774; x=1739926174; bh=R4a4frVj/6kmAjhMiwvV2UBD125Zd4Ml9Qv z/FUADhM=; b=DRKzT9AJSCCdGVSExdFgKW68pDnGS8f67pSqmvARi7XzFhF7h57 TS+fXH04xJRiP4xITQQiokmFOWWE91k1om9D2WI0cLqFJQdjhy3APrq7qTrQetxM Ff9fVmA3AsASHatJvpk3KsVothmxP7w+tlEC2ihv2mnS2zaWBs3EyAEELOkzxUVK bBtX0HvlW4weaUQ31YMmmwied6lIPGkIKrRgUcvCyIW94C76sYwWkxGziDY6o2Wr RcRZU/KxxJ/4wJHQ+DYlLduoqc2bo2/av3W8GBjM90UHS7FR2ISVomj2lj07K7zo s3EjvKvGP3nw9x9l/YJna2fxX7BtBRNtKvw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdehleeklecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenfghrlhcuvffnffculdejtddmnecujfgurhepfffhvfevuffk fhggtggujgesghdtreertddtjeenucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgvrh cuoehmihgthhgrvghlsehprghquhhivghrrdighiiiqeenucggtffrrghtthgvrhhnpeev teejgfejveegudekheeiueeiueeiveeuiedugeehveeugffgudeuleegleeiteenucevlh hushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehmihgthhgrvghl sehprghquhhivghrrdighiiipdhnsggprhgtphhtthhopeegpdhmohguvgepshhmthhpoh huthdprhgtphhtthhopeiimhhlphhoshhtghhrvghssehgmhgrihhlrdgtohhmpdhrtghp thhtohepshgrmhhimhhsvghihhesghhmrghilhdrtghomhdprhgtphhtthhopegrlhhvhh gvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhgpdhrtghpthhtohepphhgshhqlhdqhhgr tghkvghrsheslhhishhtshdrphhoshhtghhrvghsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 17 Feb 2025 19:49:31 -0500 (EST) Date: Tue, 18 Feb 2025 09:49:22 +0900 From: Michael Paquier To: Zhang Mingli Cc: Sami Imseih , =?iso-8859-1?Q?=C1lvaro?= Herrera , PostgreSQL Hackers Subject: Re: Proposal to CREATE FOREIGN TABLE LIKE Message-ID: References: <9324b4d3-d49f-463e-984a-2725fe36cb2b@Spark> <3ded6d8c-c417-4812-8861-12cbb7f8e182@Spark> <3904c689-2801-4916-99ed-7a7e1d86da3e@Spark> <532c4759-52d4-46c9-8eb2-6a836e3ece22@Spark> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="Nvjg+FFtaF8e722I" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Nvjg+FFtaF8e722I Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Feb 17, 2025 at 07:14:59PM +0800, Zhang Mingli wrote: > On Feb 17, 2025 at 15:24 +0800, Michael Paquier , wr= ote: >> + * For foreign tables, they have no storage in Postgres. >> + * Inapplicable options are ignored. >> >> Wording is a bit strange here. >=20 > =C2=A0* Foreign tables do not store data in Postgres. > =C2=A0* Any options that are not applicable for foreign tables will be ig= nored: I would do something like that, perhaps, though I could get that people don't like this suggestion: "Some options are ignored. For example, as foreign tables have no storage, these options have no effect: storage, compression, identity and indexes. Similarly, INCLUDING INDEXES is ignored from a view." > I usually follow the cases within the same file; for each > independent option, it becomes easier to identify which options are > valid or invalid. However, if you believe consolidating them into > one is better, I=E2=80=99m fine with that. Updated. It does not matter much in this case, IMO, what matters is to make sure that the four additional checks you are adding in the post-parsing paths are correctly ignored. Passing down an INCLUDING ALL does that just fine as you double-check the state of the table with a \d+ meta-command. > I also didn't realize this until I wrote this patch. This could be > useful for the planner=EF=BC=9F Constraints can be used as hints in the planner when working on foreign tables. I'm pretty sure that this is the same reason here, seeing that this is supported since v10 where statistics have been introduced. I would need to dig more into the code, but that's not really the point for this thread.. >> expandTableLikeClause() depends on the "constr" built in the first >> phase of transformTableLikeClause() to bypass the parts related to >> generated, default and constraints properties. This dependency >> between both routines should be documented, I guess. Hmm.. Not sure >> where. > > Comments are addressed except for this one, it might be worth > considering another patch. Yeah, not entirely sure. It does not prevent your patch to work, and it is already documented that the "expand" part is done as-is because it depends on the "transform". So perhaps it's just OK like this. I withdraw my comment. + Inapplicable options: INCLUDING INDEXES, INCLUDING STORAGE, + INCLUDING COMPRESSION, INCLUDING IDENTIT= Y are ignored. I would remove this paragraph, actually. The options supported are listed by your patch, and that would be one area less to update if a new INCLUDING flavor is added. Copy-pasting the details of how the LIKE options work to the create_foreign_table.sgml page is OK for me, and perhaps this will diverge a bit from the CREATE TABLE part. One thing is that LIKE is not part of the SQL specification for CREATE FOREIGN TABLE. Perhaps this should be mentioned at the bottom of the page under the "compatibility" section? -- Michael --Nvjg+FFtaF8e722I Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmez2RIACgkQnvQgOdby QH2Yqg/+JNsIZAMcO/Hzie8ZBATzo0lQDXxciP2t3E7vn2tSk9gckKvk/weLaYae xzbtLWXIwXCBSk+drxHDdDzZh9FYMW/JotZIXxB5aKeEOAm4NHTO7rWLzSTWSCyQ 0uJ6PW04LtlFKnAa4K5AuhAU1xIHERHXQV2BN6h79bOzAr/BzpLrTGPKqOX1Xe6r TKUnLpHYzerNyv6LbBJsd7W+SdDoAMO2+1mIEindlnbOd7wnAR1CPvbHS/E1RzlS w1q1dKZ8XzlugSgv2f9BdSH3iQmXq62UeSpFIGbV3A6PPfaonCjr4u/LNoPv/o8M c3iN43Euurn0mM+F5hxm7H8nZTeyWHEFp44RiAKh5yhBqe4fCjf+LidBhJRsG4Em anhnAv9i74H7zEsRvoSwjqES+Z99fZoxa7MZZ2o7U5oFUBkHhVM4LZZuE40ZZYMM 0kR4gVWiKspOoOziseTIzJdKHYRlvxfuj3xPszIQyAC7DyC3fmJ26xN25G+d5wwe Sv5Qn+dKq5Ue0Mr4HRtCmWfGsJS+oNtybXq6HgPiTyDs5gDiHfkm4SGEp2ns6V1w Uqn0NNHGl+o0t0Hh66ULG4VHdTToMRaHhuoBhUaR2omd0hvqdf6RXCEgAy0lHdOz eQDWljRzm206vca9fBpg+bKXG4TiraHGb/+f9WQ0swa+gx6BcS4= =Gdzo -----END PGP SIGNATURE----- --Nvjg+FFtaF8e722I--