Re: BUG #17909: CREATE SCHEMA AUTHORIZATION sch CREATE TABLE foo ( id INT ) will coredump
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Richard Guo <guofenglinux@gmail.com>
Cc: hysong0101@163.com, pgsql-bugs@lists.postgresql.org
Date: 2023-04-27T09:31:01Z
Lists: pgsql-bugs
On Thu, Apr 27, 2023 at 04:59:13PM +0800, Richard Guo wrote: > In this case the CreateSchemaStmtContext.schemaname is NULL since it is > not explicitly specified, while the schemaname in the schema element is > not NULL as it is specified, and setSchemaName cannot copy with such > situation. Maybe we should check against RoleSpec.rolename in this case > since that is also the schema's name? In this case, it is cleaner to just set the schema name in CreateSchemaStmtContext.schemaname to the role in the RoleSpec if there is no schema set in the query, because the schema name will have the same name as the role. That also makes the handling of each element in schemaElts simpler. The regression tests cruelly lacks of checks here. This is not a pattern of CREATE SCHEMA known a lot, but we should do better. -- Michael
Commits
-
Fix crashes with CREATE SCHEMA AUTHORIZATION and schema elements
- a9212716b3bf 11.20 landed
- 63f7e91ecf9f 12.15 landed
- 7e95a33b42e7 13.11 landed
- d29eba1987cb 14.8 landed
- b9ad73ad250b 15.3 landed
- 4dadd660f071 16.0 landed