forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit15cb32d
committed
This is the final state of the rule system for 6.4 after the
patch is applied:Rewrite rules on relation level work fine now.Event qualifications on insert/update/delete rules workfine now.I added the new keyword OLD to reference the CURRENTtuple. CURRENT will be removed in 6.5.Update rules can reference NEW and OLD in the rulequalification and the actions.Insert/update/delete rules on views can be established tolet them behave like real tables.For insert/update/delete rules multiple actions aresupported now. The actions can also be surrounded byparantheses to make psql happy. Multiple actions arerequired if update to a view requires updates to multipletables.Regular users are permitted to create/drop rules ontables they have RULE permissions for(DefineQueryRewrite() is now able to get around theaccess restrictions on pg_rewrite). This enables viewcreation for regular users too. This required an extraboolean parameter to pg_parse_and_plan() that tells toset skipAcl on all rangetable entries of the resultingqueries. There is a new functionpg_exec_query_acl_override() that could be used bybackend utilities to use this facility.All rule actions (not only views) inherit the permissionsof the event relations owner. Sample: User A createstables T1 and T2, creates rules that logINSERT/UPDATE/DELETE on T1 in T2 (like in the regressiontests for rules I created) and grants ALL but RULE on T1to user B. User B can now fully access T1 and thelogging happens in T2. But user B cannot access T2 atall, only the rule actions can. And due to missing RULEpermissions on T1, user B cannot disable logging.Rules on the attribute level are disabled (they don'twork properly and since regular users are now permittedto create rules I decided to disable them).Rules on select must have exactly one action that is aselect (so select rules must be a view definition).UPDATE NEW/OLD rules are disabled (still broken, buttriggers can do it).There are two new system views (pg_rule and pg_view) thatshow the definition of the rules or views so the db admincan see what the users do. They use two new functionspg_get_ruledef() and pg_get_viewdef() that are builtins.The functions pg_get_ruledef() and pg_get_viewdef() couldbe used to implement rule and view support in pg_dump.PostgreSQL is now the only database system I know, thathas rewrite rules on the query level. All others (where Ifound a rule statement at all) use stored databaseprocedures or the like (triggers as we call them) foractive rules (as some call them). Future of the rule system:The now disabled parts of the rule system (attributelevel, multiple actions on select and update new stuff)require a complete new rewrite handler from scratch. Theold one is too badly wired up.After 6.4 I'll start to work on a new rewrite handler,that fully supports the attribute level rules, multipleactions on select and update new. This will be availablefor 6.5 so we get full rewrite rule capabilities.Jan1 parentf92994b commit15cb32d
File tree
17 files changed
+1719
-125
lines changed- src
- backend
- catalog
- executor
- libpq
- optimizer/path
- parser
- rewrite
- tcop
- utils/adt
- bin/initdb
- include
- catalog
- tcop
17 files changed
+1719
-125
lines changedLines changed: 3 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
7 | 7 |
| |
8 | 8 |
| |
9 | 9 |
| |
10 |
| - | |
| 10 | + | |
11 | 11 |
| |
12 | 12 |
| |
13 | 13 |
| |
| |||
1448 | 1448 |
| |
1449 | 1449 |
| |
1450 | 1450 |
| |
1451 |
| - | |
| 1451 | + | |
1452 | 1452 |
| |
1453 | 1453 |
| |
1454 | 1454 |
| |
| |||
1519 | 1519 |
| |
1520 | 1520 |
| |
1521 | 1521 |
| |
1522 |
| - | |
| 1522 | + | |
1523 | 1523 |
| |
1524 | 1524 |
| |
1525 | 1525 |
| |
|
Lines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
7 | 7 |
| |
8 | 8 |
| |
9 | 9 |
| |
10 |
| - | |
| 10 | + | |
11 | 11 |
| |
12 | 12 |
| |
13 | 13 |
| |
| |||
214 | 214 |
| |
215 | 215 |
| |
216 | 216 |
| |
217 |
| - | |
| 217 | + | |
218 | 218 |
| |
219 | 219 |
| |
220 | 220 |
| |
|
Lines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
8 | 8 |
| |
9 | 9 |
| |
10 | 10 |
| |
11 |
| - | |
| 11 | + | |
12 | 12 |
| |
13 | 13 |
| |
14 | 14 |
| |
| |||
113 | 113 |
| |
114 | 114 |
| |
115 | 115 |
| |
116 |
| - | |
| 116 | + | |
117 | 117 |
| |
118 | 118 |
| |
119 | 119 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
642 | 642 |
| |
643 | 643 |
| |
644 | 644 |
| |
645 |
| - | |
| 645 | + | |
646 | 646 |
| |
647 | 647 |
| |
648 | 648 |
| |
|
Lines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
8 | 8 |
| |
9 | 9 |
| |
10 | 10 |
| |
11 |
| - | |
| 11 | + | |
12 | 12 |
| |
13 | 13 |
| |
14 | 14 |
| |
| |||
137 | 137 |
| |
138 | 138 |
| |
139 | 139 |
| |
140 |
| - | |
| 140 | + | |
141 | 141 |
| |
142 | 142 |
| |
143 | 143 |
| |
|
Lines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
9 | 9 |
| |
10 | 10 |
| |
11 | 11 |
| |
12 |
| - | |
| 12 | + | |
13 | 13 |
| |
14 | 14 |
| |
15 | 15 |
| |
| |||
528 | 528 |
| |
529 | 529 |
| |
530 | 530 |
| |
531 |
| - | |
| 531 | + | |
532 | 532 |
| |
533 | 533 |
| |
534 | 534 |
| |
|
Lines changed: 8 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
7 | 7 |
| |
8 | 8 |
| |
9 | 9 |
| |
10 |
| - | |
| 10 | + | |
11 | 11 |
| |
12 | 12 |
| |
13 | 13 |
| |
| |||
66 | 66 |
| |
67 | 67 |
| |
68 | 68 |
| |
69 |
| - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
70 | 75 |
| |
71 | 76 |
| |
72 | 77 |
| |
| |||
152 | 157 |
| |
153 | 158 |
| |
154 | 159 |
| |
| 160 | + | |
155 | 161 |
| |
156 | 162 |
| |
157 | 163 |
| |
|
Lines changed: 102 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
6 | 6 |
| |
7 | 7 |
| |
8 | 8 |
| |
9 |
| - | |
| 9 | + | |
10 | 10 |
| |
11 | 11 |
| |
12 | 12 |
| |
| |||
18 | 18 |
| |
19 | 19 |
| |
20 | 20 |
| |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
21 | 29 |
| |
22 | 30 |
| |
23 | 31 |
| |
| |||
156 | 164 |
| |
157 | 165 |
| |
158 | 166 |
| |
| 167 | + | |
| 168 | + | |
159 | 169 |
| |
160 | 170 |
| |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + |
Lines changed: 52 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
7 | 7 |
| |
8 | 8 |
| |
9 | 9 |
| |
10 |
| - | |
| 10 | + | |
11 | 11 |
| |
12 | 12 |
| |
13 | 13 |
| |
| |||
131 | 131 |
| |
132 | 132 |
| |
133 | 133 |
| |
134 |
| - | |
| 134 | + | |
135 | 135 |
| |
136 | 136 |
| |
137 | 137 |
| |
| |||
192 | 192 |
| |
193 | 193 |
| |
194 | 194 |
| |
195 |
| - | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
196 | 210 |
| |
| 211 | + | |
| 212 | + | |
197 | 213 |
| |
| 214 | + | |
198 | 215 |
| |
199 | 216 |
| |
200 | 217 |
| |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
201 | 250 |
| |
202 | 251 |
| |
203 | 252 |
| |
|
0 commit comments
Comments
(0)