- Notifications
You must be signed in to change notification settings - Fork5k
Commit52e4f0c

Amit Kapila
Allow specifying row filters for logical replication of tables.
This feature adds row filtering for publication tables. When a publicationis defined or modified, an optional WHERE clause can be specified. Rowsthat don't satisfy this WHERE clause will be filtered out. This allows aset of tables to be partially replicated. The row filter is per table. Anew row filter can be added simply by specifying a WHERE clause after thetable name. The WHERE clause must be enclosed by parentheses.The row filter WHERE clause for a table added to a publication thatpublishes UPDATE and/or DELETE operations must contain only columns thatare covered by REPLICA IDENTITY. The row filter WHERE clause for a tableadded to a publication that publishes INSERT can use any column. If therow filter evaluates to NULL, it is regarded as "false". The WHERE clauseonly allows simple expressions that don't have user-defined functions,user-defined operators, user-defined types, user-defined collations,non-immutable built-in functions, or references to system columns. Theserestrictions could be addressed in the future.If you choose to do the initial table synchronization, only data thatsatisfies the row filters is copied to the subscriber. If the subscriptionhas several publications in which a table has been published withdifferent WHERE clauses, rows that satisfy ANY of the expressions will becopied. If a subscriber is a pre-15 version, the initial tablesynchronization won't use row filters even if they are defined in thepublisher.The row filters are applied before publishing the changes. If thesubscription has several publications in which the same table has beenpublished with different filters (for the same publish operation), thoseexpressions get OR'ed together so that rows satisfying any of theexpressions will be replicated.This means all the other filters become redundant if (a) one of thepublications have no filter at all, (b) one of the publications wascreated using FOR ALL TABLES, (c) one of the publications was createdusing FOR ALL TABLES IN SCHEMA and the table belongs to that same schema.If your publication contains a partitioned table, the publicationparameter publish_via_partition_root determines if it uses the partition'srow filter (if the parameter is false, the default) or the rootpartitioned table's row filter.Psql commands \dRp+ and \d <table-name> will display any row filters.Author: Hou Zhijie, Euler Taveira, Peter Smith, Ajin CherianReviewed-by: Greg Nancarrow, Haiying Tang, Amit Kapila, Tomas Vondra, Dilip Kumar, Vignesh C, Alvaro Herrera, Andres Freund, Wei WangDiscussion:https://www.postgresql.org/message-id/flat/CAHE3wggb715X%2BmK_DitLXF25B%3DjE6xyNCH4YOwM860JR7HarGQ%40mail.gmail.com1 parentebf6c52 commit52e4f0c
File tree
33 files changed
+3113
-236
lines changed- doc/src/sgml
- ref
- src
- backend
- catalog
- commands
- executor
- nodes
- parser
- replication
- logical
- pgoutput
- utils/cache
- bin
- pg_dump
- psql
- include
- catalog
- commands
- nodes
- replication
- utils
- test
- regress
- expected
- sql
- subscription/t
- tools/pgindent
33 files changed
+3113
-236
lines changedLines changed: 9 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
6325 | 6325 |
| |
6326 | 6326 |
| |
6327 | 6327 |
| |
| 6328 | + | |
| 6329 | + | |
| 6330 | + | |
| 6331 | + | |
| 6332 | + | |
| 6333 | + | |
| 6334 | + | |
| 6335 | + | |
| 6336 | + | |
6328 | 6337 |
| |
6329 | 6338 |
| |
6330 | 6339 |
| |
|
Lines changed: 10 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
30 | 30 |
| |
31 | 31 |
| |
32 | 32 |
| |
33 |
| - | |
| 33 | + | |
34 | 34 |
| |
35 | 35 |
| |
36 | 36 |
| |
| |||
52 | 52 |
| |
53 | 53 |
| |
54 | 54 |
| |
55 |
| - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
56 | 58 |
| |
57 | 59 |
| |
58 | 60 |
| |
| |||
110 | 112 |
| |
111 | 113 |
| |
112 | 114 |
| |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
113 | 121 |
| |
114 | 122 |
| |
115 | 123 |
| |
|
Lines changed: 5 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
163 | 163 |
| |
164 | 164 |
| |
165 | 165 |
| |
166 |
| - | |
167 |
| - | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
168 | 171 |
| |
169 | 172 |
| |
170 | 173 |
| |
|
Lines changed: 37 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
28 | 28 |
| |
29 | 29 |
| |
30 | 30 |
| |
31 |
| - | |
| 31 | + | |
32 | 32 |
| |
33 | 33 |
| |
34 | 34 |
| |
| |||
78 | 78 |
| |
79 | 79 |
| |
80 | 80 |
| |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
81 | 89 |
| |
82 | 90 |
| |
83 | 91 |
| |
| |||
225 | 233 |
| |
226 | 234 |
| |
227 | 235 |
| |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
228 | 252 |
| |
229 | 253 |
| |
230 | 254 |
| |
| |||
247 | 271 |
| |
248 | 272 |
| |
249 | 273 |
| |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
250 | 279 |
| |
251 | 280 |
| |
252 | 281 |
| |
| |||
259 | 288 |
| |
260 | 289 |
| |
261 | 290 |
| |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
262 | 298 |
| |
263 | 299 |
| |
264 | 300 |
| |
|
Lines changed: 26 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
208 | 208 |
| |
209 | 209 |
| |
210 | 210 |
| |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
211 | 216 |
| |
212 | 217 |
| |
213 | 218 |
| |
| |||
293 | 298 |
| |
294 | 299 |
| |
295 | 300 |
| |
296 |
| - | |
| 301 | + | |
297 | 302 |
| |
298 | 303 |
| |
299 | 304 |
| |
| |||
319 | 324 |
| |
320 | 325 |
| |
321 | 326 |
| |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
322 | 347 |
| |
323 | 348 |
| |
324 | 349 |
| |
|
Lines changed: 55 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
275 | 275 |
| |
276 | 276 |
| |
277 | 277 |
| |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
278 | 316 |
| |
279 | 317 |
| |
280 | 318 |
| |
281 | 319 |
| |
282 |
| - | |
| 320 | + | |
283 | 321 |
| |
284 | 322 |
| |
285 | 323 |
| |
286 | 324 |
| |
287 | 325 |
| |
288 | 326 |
| |
289 |
| - | |
| 327 | + | |
| 328 | + | |
290 | 329 |
| |
291 | 330 |
| |
292 | 331 |
| |
| |||
311 | 350 |
| |
312 | 351 |
| |
313 | 352 |
| |
314 |
| - | |
| 353 | + | |
315 | 354 |
| |
316 | 355 |
| |
317 |
| - | |
| 356 | + | |
318 | 357 |
| |
319 | 358 |
| |
320 | 359 |
| |
| |||
328 | 367 |
| |
329 | 368 |
| |
330 | 369 |
| |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
331 | 376 |
| |
332 | 377 |
| |
333 | 378 |
| |
| |||
345 | 390 |
| |
346 | 391 |
| |
347 | 392 |
| |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
348 | 399 |
| |
349 | 400 |
| |
350 | 401 |
| |
|
0 commit comments
Comments
(0)