forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit4dadd66
committed
Fix crashes with CREATE SCHEMA AUTHORIZATION and schema elements
CREATE SCHEMA AUTHORIZATION with appended schema elements can lead tocrashes when comparing the schema name of the query with the schemasused in the qualification of some clauses in the elements' queries.The origin of the problem is that the transformation routine for theelements listed in a CREATE SCHEMA query uses as new, expected, schemaname the one listed in CreateSchemaStmt itself. However, depending onthe query, CreateSchemaStmt.schemaname may be NULL, being computedinstead from the role specification of the query given by theAUTHORIZATION clause, that could be either:- A user name string, with the new schema name being set to the samevalue as the role given.- Guessed from CURRENT_ROLE, SESSION_ROLE or CURRENT_ROLE, with a newschema name computed from the security context where CREATE SCHEMA isrunning.Regression tests are added for CREATE SCHEMA with some appended elements(some of them with schema qualifications), covering also some rolespecification patterns.While on it, this simplifies the context structure used during thetransformation of the elements listed in a CREATE SCHEMA query byremoving the fields for the role specification and the role type. Theywere not used, and for the role specification this could be confusing asthe schema name may by extracted from that at the beginning ofCreateSchemaCommand().This issue exists for a long time, so backpatch down to all the versionssupported.Reported-by: Song HongyuAuthor: Michael PaquierReviewed-by: Richard GuoDiscussion:https://postgr.es/m/17909-f65c12dfc5f0451d@postgresql.orgBackpatch-through: 111 parent4a6603c commit4dadd66
File tree
6 files changed
+192
-22
lines changed- src
- backend
- commands
- parser
- include/parser
- test/regress
- expected
- sql
6 files changed
+192
-22
lines changedLines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
179 | 179 |
| |
180 | 180 |
| |
181 | 181 |
| |
182 |
| - | |
| 182 | + | |
| 183 | + | |
183 | 184 |
| |
184 | 185 |
| |
185 | 186 |
| |
|
Lines changed: 19 additions & 19 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
95 | 95 |
| |
96 | 96 |
| |
97 | 97 |
| |
98 |
| - | |
| 98 | + | |
99 | 99 |
| |
100 | 100 |
| |
101 |
| - | |
102 |
| - | |
103 |
| - | |
| 101 | + | |
104 | 102 |
| |
105 | 103 |
| |
106 | 104 |
| |
| |||
134 | 132 |
| |
135 | 133 |
| |
136 | 134 |
| |
137 |
| - | |
| 135 | + | |
138 | 136 |
| |
139 | 137 |
| |
140 | 138 |
| |
| |||
3784 | 3782 |
| |
3785 | 3783 |
| |
3786 | 3784 |
| |
3787 |
| - | |
3788 |
| - | |
| 3785 | + | |
| 3786 | + | |
3789 | 3787 |
| |
3790 |
| - | |
3791 |
| - | |
3792 |
| - | |
3793 |
| - | |
3794 |
| - | |
| 3788 | + | |
| 3789 | + | |
| 3790 | + | |
| 3791 | + | |
| 3792 | + | |
| 3793 | + | |
| 3794 | + | |
| 3795 | + | |
| 3796 | + | |
3795 | 3797 |
| |
3796 | 3798 |
| |
3797 | 3799 |
| |
| |||
3807 | 3809 |
| |
3808 | 3810 |
| |
3809 | 3811 |
| |
3810 |
| - | |
| 3812 | + | |
3811 | 3813 |
| |
3812 | 3814 |
| |
3813 | 3815 |
| |
3814 | 3816 |
| |
3815 | 3817 |
| |
3816 |
| - | |
3817 |
| - | |
3818 |
| - | |
| 3818 | + | |
3819 | 3819 |
| |
3820 | 3820 |
| |
3821 | 3821 |
| |
| |||
3827 | 3827 |
| |
3828 | 3828 |
| |
3829 | 3829 |
| |
3830 |
| - | |
| 3830 | + | |
3831 | 3831 |
| |
3832 | 3832 |
| |
3833 | 3833 |
| |
| |||
3912 | 3912 |
| |
3913 | 3913 |
| |
3914 | 3914 |
| |
3915 |
| - | |
| 3915 | + | |
3916 | 3916 |
| |
3917 | 3917 |
| |
3918 |
| - | |
| 3918 | + | |
3919 | 3919 |
| |
3920 | 3920 |
| |
3921 | 3921 |
| |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
30 | 30 |
| |
31 | 31 |
| |
32 | 32 |
| |
33 |
| - | |
| 33 | + | |
| 34 | + | |
34 | 35 |
| |
35 | 36 |
| |
36 | 37 |
| |
|
Lines changed: 98 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + |
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
42 | 42 |
| |
43 | 43 |
| |
44 | 44 |
| |
45 |
| - | |
| 45 | + | |
46 | 46 |
| |
47 | 47 |
| |
48 | 48 |
| |
|
Lines changed: 70 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + |
0 commit comments
Comments
(0)