Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1psAgK-0007Px-Q9 for pgsql-bugs@arkaria.postgresql.org; Thu, 27 Apr 2023 23:05:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1psAgJ-0001cu-IJ for pgsql-bugs@arkaria.postgresql.org; Thu, 27 Apr 2023 23:05:43 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1psAgI-0001ch-Ru for pgsql-bugs@lists.postgresql.org; Thu, 27 Apr 2023 23:05:43 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1psAg7-005Sv0-Fo for pgsql-bugs@lists.postgresql.org; Thu, 27 Apr 2023 23:05:42 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 2D4AD5C01AE; Thu, 27 Apr 2023 19:05:30 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Thu, 27 Apr 2023 19:05:30 -0400 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:sender :subject:subject:to:to; s=fm3; t=1682636730; x=1682723130; bh=XM 1EJq75F+Fg98IIhB4ebZvtwFuZtmbC8n12Dkov34A=; b=xaMgl7fZlgWQDiT1Ey kp6mzEUVofnz+hT7QdgtF5llLw8jdyxLxrNQEmpcTiUWWHiqR/GaTtBzm4BPTQ15 zeuZBRYmYvOvi7J+a3zFGMWEgw4Ih0PaGz6bAVlnIUHgAB3qEaHOvnMTcUcbKIHa V3lYbe9yPvsSeMZonb8FLJp5615pIyVrNIiaT93T7jQu/wDzC9mtT/ZGGzLtEa+H bvcLEWbiNwgcyWmHwe2mJFfXuGVBZVklUW0FLvbRxUKyGMKt/GNjiSLrc+dyPX/V JjndUbY7KB55FWITWeCUuISB1z8jQNt6qCxmEGFTreK/N4zwi6MB9ih6P0nKlPwe q/mA== 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:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; t=1682636730; x=1682723130; bh=XM1EJq75F+Fg9 8IIhB4ebZvtwFuZtmbC8n12Dkov34A=; b=c14/uY1SOWtkZDp7fxKn786nEgliT L9I498rIvZuZva1b0yftZYwZPxW8vsN3is8viI16UhED4JBPx9OQwSROEpG1vCCQ 4FZk0c4KWQyl+/WC8L8CIvC04DX3XMVYnhg/YU2owigEV0W0BZvvEJIriSqG1zVL MjaCgmZI6T4VChCHZAopgG4F5kYRj24XMeGKxbsaEJddeU5G5hp1bzKChAYu4eMo xX4Y9QPatXfwBmFNxH+MRWyzNevy1Fkp8g8NKnKvRNoKSd+7beHmcHeRtxbIbE9B ufsCXA0ZiBzYVTKbvFwIjQDAl84edcywEGUwaUbkp9+lPSlh8lVgeHfgQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfedujedgudekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucgfrhhlucfvnfffucdljedtmdenucfjughrpeffhf fvvefukfhfgggtuggjsehgtderredttddvnecuhfhrohhmpefoihgthhgrvghlucfrrghq uhhivghruceomhhitghhrggvlhesphgrqhhuihgvrhdrgiihiieqnecuggftrfgrthhtvg hrnhepteelieefudffhffhtdetleeggeegfffhkeeuveetiefgudduvedutefggeeivdej necuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepmhhitg hhrggvlhesphgrqhhuihgvrhdrgiihii X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 27 Apr 2023 19:05:27 -0400 (EDT) Date: Fri, 28 Apr 2023 08:05:22 +0900 From: Michael Paquier To: Richard Guo Cc: hysong0101@163.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #17909: CREATE SCHEMA AUTHORIZATION sch CREATE TABLE foo ( id INT ) will coredump Message-ID: References: <17909-f65c12dfc5f0451d@postgresql.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="OwadXfNbpl6ejhd1" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --OwadXfNbpl6ejhd1 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Apr 27, 2023 at 06:28:28PM +0800, Richard Guo wrote: > I noticed that in CreateSchemaCommand there is logic that fills schema > name with the role name if it is not specified. Do you think we can > save the new-filled schema name into CreateSchemaStmt.schemaname there? It's actually much trickier than that, on second look, as a RoleSpec is embedded in this portion of a query because we need to support CURRENT_ROLE, CURRENT_SESSION and SESSION_USER. For example, this query assigns neither role name nor schema name we could rely on at transformation for the objects: create schema authorization current_role create table aa (a int); Anyway, semantically, something could go very wrong if we decide to enforce a schema name for the objects based on the RoleSpec at the time of transformation, because we may finish by executing the CREATE SCHEMA command under an entirely different context than what we could assign. So, I think that we should do the following in the transformation path if an object is schema-qualified: - Fail immediately if there is no schema and no role name at hand, just give up. This needs a new error message, say: "CREATE specifies a schema (%object_schema) without providing a schema name." - If there is a role name, aka RoleSpec points to a ROLESPEC_CSTRING, use it as a comparison with the objects schema-qualified. Note that there is no case for public, because we would fail on get_rolespec_oid() when the schema is created. There is also a very fancy case, if "foo" matches to the role that would be assigned by GetUserIdAndSecContext() when executing the schema command: create schema authorization session_role create table foo.aa (a int); One could say that this should work, and my proposal would cause an error to make the query more predictible at an earlier step. IMO, I think that this is just saner. And this case crashes today like the others. Any thoughts or objections about doing that? -- Michael --OwadXfNbpl6ejhd1 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmRK/7IACgkQnvQgOdby QH1fKA//eTbEvCpAiznNaXbU2Mv53Y03aeR28uKEbJ349OWEWwuY2WRKewL2HEJ4 cEw/HtEc/qwfKYvZX7iRbsC1f2/ASqtZsIjaZTAqNZDJ1GktfyXeZqLvoSiaMQIM YUQEU0PfwAE8xUjSUyJ1pOKdCL+jmVuKj/IrtqVkShQqkY9Xx+TFohjy2XZSscMH eifoDUe7Ez2Jz1FT2YUJlXsObUybqGsCHlDMfSHeBRLSzBZifYiEfza7GatWUojY VICDpt3tFIr+zVIOWAKlEb2h935NSZKFTS6J5CVqQurQlOACWITPzIHf7MwM2tHP MzGLPlVxfHQo7u3rREqmycWYgBgB7A3p82kRZeNk0LCDHW08xuLsx0TGGFaKW8Ms PWhy90yMVDtXZerNr6+1g+YRvRfAaGlnVvKAQN9Hx8HWDPMms2bzx77Kh+WHBQUK AA4lsUjO4LOPpFf1upKwuOLUW2iMN1PqADtIAmguCeKq+CVZbf+foQ/IdUjBVRjJ 0bJVKFNnxqDr6yF5F5mT5hIpaL30+H0ST4wnSWAORVakfzVu0FEb2wn2HnOacvMt D30Ky8qI2e5Ra1ZqFEESZEAxn9mMnmD0KeSj9Ru0QwTp5mqUf9GQhofWFvkiCj2w dzTO+0GrwzNm+vrbat0JhwvVFOfyTgI6dq2zwkhpD7dwr84kkFU= =Dofh -----END PGP SIGNATURE----- --OwadXfNbpl6ejhd1--