forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit83ea6c5
committed
Virtual generated columns
This adds a new variant of generated columns that are computed on read(like a view, unlike the existing stored generated columns, which arecomputed on write, like a materialized view).The syntax for the column definition is ... GENERATED ALWAYS AS (...) VIRTUALand VIRTUAL is also optional. VIRTUAL is the default rather thanSTORED to match various other SQL products. (The SQL standard makesno specification about this, but it also doesn't know about VIRTUAL orSTORED.) (Also, virtual views are the default, rather thanmaterialized views.)Virtual generated columns are stored in tuples as null values. (Avery early version of this patch had the ambition to not store them atall. But so much stuff breaks or gets confused if you have tupleswhere a column in the middle is completely missing. This is acompromise, and it still saves space over being forced to use storedgenerated columns. If we ever find a way to improve this, a bit ofpg_upgrade cleverness could allow for upgrades to a newer scheme.)The capabilities and restrictions of virtual generated columns aremostly the same as for stored generated columns. In some cases, thispatch keeps virtual generated columns more restricted than they mighttechnically need to be, to keep the two kinds consistent. Some ofthat could maybe be relaxed later after separate carefulconsiderations.Some functionality that is currently not supported, but could possiblybe added as incremental features, some easier than others:- index on or using a virtual column- hence also no unique constraints on virtual columns- extended statistics on virtual columns- foreign-key constraints on virtual columns- not-null constraints on virtual columns (check constraints are supported)- ALTER TABLE / DROP EXPRESSION- virtual column cannot have domain type- virtual columns are not supported in logical replicationThe tests in generated_virtual.sql have been copied over fromgenerated_stored.sql with the keyword replaced. This way we can makesure the behavior is mostly aligned, and the differences can bevisible. Some tests for currently not supported features arecurrently commented out.Reviewed-by: Jian He <jian.universality@gmail.com>Reviewed-by: Dean Rasheed <dean.a.rasheed@gmail.com>Tested-by: Shlok Kyal <shlok.kyal.oss@gmail.com>Discussion:https://www.postgresql.org/message-id/flat/a368248e-69e4-40be-9c07-6c3b5880b0a6@eisentraut.org1 parentcbc1279 commit83ea6c5
File tree
71 files changed
+3225
-209
lines changed- contrib
- pageinspect
- expected
- sql
- postgres_fdw
- expected
- sql
- doc/src/sgml
- ref
- src
- backend
- access
- common
- heap
- catalog
- commands
- executor
- parser
- replication/pgoutput
- rewrite
- utils/cache
- bin
- pg_dump
- t
- psql
- include
- access
- catalog
- executor
- nodes
- parser
- rewrite
- pl
- plperl
- expected
- sql
- plpython
- expected
- sql
- tcl
- expected
- sql
- test
- regress
- expected
- sql
- subscription/t
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
71 files changed
+3225
-209
lines changedLines changed: 37 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
208 | 208 |
| |
209 | 209 |
| |
210 | 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 | + | |
211 | 248 |
| |
212 | 249 |
| |
213 | 250 |
| |
|
Lines changed: 19 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
84 | 84 |
| |
85 | 85 |
| |
86 | 86 |
| |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
87 | 106 |
| |
88 | 107 |
| |
89 | 108 |
| |
|
Lines changed: 42 additions & 39 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
7395 | 7395 |
| |
7396 | 7396 |
| |
7397 | 7397 |
| |
7398 |
| - | |
| 7398 | + | |
| 7399 | + | |
| 7400 | + | |
7399 | 7401 |
| |
7400 | 7402 |
| |
7401 | 7403 |
| |
7402 |
| - | |
7403 |
| - | |
| 7404 | + | |
| 7405 | + | |
| 7406 | + | |
7404 | 7407 |
| |
7405 | 7408 |
| |
7406 |
| - | |
7407 |
| - | |
| 7409 | + | |
| 7410 | + | |
7408 | 7411 |
| |
7409 |
| - | |
| 7412 | + | |
7410 | 7413 |
| |
7411 | 7414 |
| |
7412 |
| - | |
| 7415 | + | |
7413 | 7416 |
| |
7414 | 7417 |
| |
7415 | 7418 |
| |
7416 | 7419 |
| |
7417 | 7420 |
| |
7418 |
| - | |
7419 |
| - | |
| 7421 | + | |
| 7422 | + | |
7420 | 7423 |
| |
7421 |
| - | |
| 7424 | + | |
7422 | 7425 |
| |
7423 | 7426 |
| |
7424 |
| - | |
| 7427 | + | |
7425 | 7428 |
| |
7426 | 7429 |
| |
7427 | 7430 |
| |
7428 | 7431 |
| |
7429 |
| - | |
7430 |
| - | |
7431 |
| - | |
7432 |
| - | |
| 7432 | + | |
| 7433 | + | |
| 7434 | + | |
| 7435 | + | |
7433 | 7436 |
| |
7434 | 7437 |
| |
7435 | 7438 |
| |
7436 |
| - | |
7437 |
| - | |
7438 |
| - | |
7439 |
| - | |
| 7439 | + | |
| 7440 | + | |
| 7441 | + | |
| 7442 | + | |
7440 | 7443 |
| |
7441 | 7444 |
| |
7442 | 7445 |
| |
7443 | 7446 |
| |
7444 | 7447 |
| |
7445 | 7448 |
| |
7446 |
| - | |
7447 |
| - | |
7448 |
| - | |
7449 |
| - | |
| 7449 | + | |
| 7450 | + | |
| 7451 | + | |
| 7452 | + | |
7450 | 7453 |
| |
7451 | 7454 |
| |
7452 | 7455 |
| |
7453 |
| - | |
7454 |
| - | |
7455 |
| - | |
7456 |
| - | |
| 7456 | + | |
| 7457 | + | |
| 7458 | + | |
| 7459 | + | |
7457 | 7460 |
| |
7458 | 7461 |
| |
7459 | 7462 |
| |
7460 | 7463 |
| |
7461 | 7464 |
| |
7462 | 7465 |
| |
7463 | 7466 |
| |
7464 |
| - | |
7465 |
| - | |
| 7467 | + | |
| 7468 | + | |
7466 | 7469 |
| |
7467 |
| - | |
| 7470 | + | |
7468 | 7471 |
| |
7469 | 7472 |
| |
7470 |
| - | |
| 7473 | + | |
7471 | 7474 |
| |
7472 | 7475 |
| |
7473 | 7476 |
| |
7474 | 7477 |
| |
7475 |
| - | |
7476 |
| - | |
7477 |
| - | |
7478 |
| - | |
| 7478 | + | |
| 7479 | + | |
| 7480 | + | |
| 7481 | + | |
7479 | 7482 |
| |
7480 | 7483 |
| |
7481 | 7484 |
| |
7482 |
| - | |
7483 |
| - | |
7484 |
| - | |
7485 |
| - | |
| 7485 | + | |
| 7486 | + | |
| 7487 | + | |
| 7488 | + | |
7486 | 7489 |
| |
7487 | 7490 |
| |
7488 | 7491 |
| |
|
Lines changed: 6 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1859 | 1859 |
| |
1860 | 1860 |
| |
1861 | 1861 |
| |
1862 |
| - | |
| 1862 | + | |
| 1863 | + | |
| 1864 | + | |
1863 | 1865 |
| |
1864 | 1866 |
| |
1865 | 1867 |
| |
1866 |
| - | |
1867 |
| - | |
| 1868 | + | |
| 1869 | + | |
| 1870 | + | |
1868 | 1871 |
| |
1869 | 1872 |
| |
1870 | 1873 |
| |
|
Lines changed: 4 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1307 | 1307 |
| |
1308 | 1308 |
| |
1309 | 1309 |
| |
1310 |
| - | |
1311 |
| - | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
1312 | 1314 |
| |
1313 | 1315 |
| |
1314 | 1316 |
| |
|
Lines changed: 36 additions & 10 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
361 | 361 |
| |
362 | 362 |
| |
363 | 363 |
| |
364 |
| - | |
365 | 364 |
| |
366 | 365 |
| |
367 | 366 |
| |
| |||
371 | 370 |
| |
372 | 371 |
| |
373 | 372 |
| |
374 |
| - | |
| 373 | + | |
375 | 374 |
| |
376 | 375 |
| |
377 |
| - | |
378 |
| - | |
379 |
| - | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
380 | 379 |
| |
381 | 380 |
| |
382 | 381 |
| |
| |||
442 | 441 |
| |
443 | 442 |
| |
444 | 443 |
| |
445 |
| - | |
446 |
| - | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
447 | 450 |
| |
448 |
| - | |
449 |
| - | |
450 |
| - | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
451 | 456 |
| |
452 | 457 |
| |
453 | 458 |
| |
| |||
502 | 507 |
| |
503 | 508 |
| |
504 | 509 |
| |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
505 | 530 |
| |
506 | 531 |
| |
507 | 532 |
| |
| |||
519 | 544 |
| |
520 | 545 |
| |
521 | 546 |
| |
| 547 | + | |
522 | 548 |
| |
523 | 549 |
| |
524 | 550 |
| |
|
Lines changed: 10 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
102 | 102 |
| |
103 | 103 |
| |
104 | 104 |
| |
105 |
| - | |
| 105 | + | |
106 | 106 |
| |
107 | 107 |
| |
108 | 108 |
| |
| |||
264 | 264 |
| |
265 | 265 |
| |
266 | 266 |
| |
267 |
| - | |
268 |
| - | |
| 267 | + | |
| 268 | + | |
269 | 269 |
| |
270 | 270 |
| |
271 | 271 |
| |
| |||
279 | 279 |
| |
280 | 280 |
| |
281 | 281 |
| |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
282 | 287 |
| |
283 | 288 |
| |
284 |
| - | |
285 |
| - | |
| 289 | + | |
| 290 | + | |
286 | 291 |
| |
287 | 292 |
| |
288 | 293 |
| |
|
Lines changed: 7 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
47 | 47 |
| |
48 | 48 |
| |
49 | 49 |
| |
50 |
| - | |
| 50 | + | |
51 | 51 |
| |
52 | 52 |
| |
53 | 53 |
| |
| |||
283 | 283 |
| |
284 | 284 |
| |
285 | 285 |
| |
286 |
| - | |
| 286 | + | |
287 | 287 |
| |
288 | 288 |
| |
289 | 289 |
| |
| |||
292 | 292 |
| |
293 | 293 |
| |
294 | 294 |
| |
295 |
| - | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
296 | 299 |
| |
297 | 300 |
| |
298 |
| - | |
| 301 | + | |
299 | 302 |
| |
300 | 303 |
| |
301 | 304 |
| |
|
0 commit comments
Comments
(0)