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: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Richard Guo <guofenglinux@gmail.com>, hysong0101@163.com, pgsql-bugs@lists.postgresql.org
Date: 2023-04-28T01:42:54Z
Lists: pgsql-bugs
Attachments
- 0001-Fix-crashes-with-CREATE-SCHEMA-AUTHORIZATION.patch (text/x-diff) patch 0001
On Fri, Apr 28, 2023 at 08:56:27AM +0900, Michael Paquier wrote: > Actually, wait a min.. The transformation of the objects is applied > during the execution of the CREATE SCHEMA command, but nowhere else, > so if you give to transformCreateSchemaStmt() the name of the expected > schema rather than rely on the schema name from the query this should > work OK. So, the source of my confusion is the design currently used for transformCreateSchemaStmt(): - The schema name is extracted from the query itself, but we have a schema compiled from a role specification, depending on how the beginning of CreateSchemaCommand() feels it. - This routine includes a reference to the role specification in the context, but makes no use of it. Perhaps somebody would be interested in this information in the future if the query support is improved, but one could also be tempted to feed the schema name based on the RoleSpec, which I'd rather avoid for the moment. Attached is what I am finishing with, where I have reworked transformCreateSchemaStmt() so as it uses in input the list of elements from CREATE SCHEMA and the schema name computed depending on the security context, documenting requirements on the way (note the extra unconstify for the RangeVars' schemas). I have added a couple of regression tests for all the object types that have schema qualication checks, mixed with role specs and schema names. Thoughts, comments or objections? -- 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