forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitc7aba7c
committed
Support subscripting of arbitrary types, not only arrays.
This patch generalizes the subscripting infrastructure so that anydata type can be subscripted, if it provides a handler function todefine what that means. Traditional variable-length (varlena) arraysall use array_subscript_handler(), while the existing fixed-lengthtypes that support subscripting use raw_array_subscript_handler().It's expected that other types that want to use subscripting notationwill define their own handlers. (This patch provides no such newfeatures, though; it only lays the foundation for them.)To do this, move the parser's semantic processing of subscripts(including coercion to whatever data type is required) into amethod callback supplied by the handler. On the execution side,replace the ExecEvalSubscriptingRef* layer of functions with directcalls to callback-supplied execution routines. (Thus, essentiallyno new run-time overhead should be caused by this patch. Indeed,there is room to remove some overhead by supplying specializedexecution routines. This patch does a little bit in that line,but more could be done.)Additional work is required here and there to remove formerlyhard-wired assumptions about the result type, collation, etcof a SubscriptingRef expression node; and to remove assumptionsthat the subscript values must be integers.One useful side-effect of this is that we now have a less squishymechanism for identifying whether a data type is a "true" array:instead of wiring in weird rules about typlen, we can look to seeif pg_type.typsubscript == F_ARRAY_SUBSCRIPT_HANDLER. For thisto be bulletproof, we have to forbid user-defined types from usingthat handler directly; but there seems no good reason for them todo so.This patch also removes assumptions that the number of subscriptsis limited to MAXDIM (6), or indeed has any hard-wired limit.That limit still applies to types handled by array_subscript_handleror raw_array_subscript_handler, but to discourage other dependencieson this constant, I've moved it from c.h to utils/array.h.Dmitry Dolgov, reviewed at various times by Tom Lane, Arthur Zakirov,Peter Eisentraut, Pavel StehuleDiscussion:https://postgr.es/m/CA+q6zcVDuGBv=M0FqBYX8DPebS3F_0KQ6OVFobGJPM507_SZ_w@mail.gmail.comDiscussion:https://postgr.es/m/CA+q6zcVovR+XY4mfk-7oNk-rF91gH0PebnNfuUjuuDsyHjOcVA@mail.gmail.com1 parent8b069ef commitc7aba7c
File tree
52 files changed
+1552
-711
lines changed- contrib/postgres_fdw
- doc/src/sgml
- ref
- src
- backend
- catalog
- commands
- executor
- jit/llvm
- nodes
- optimizer/util
- parser
- utils
- adt
- cache
- bin/pg_dump
- include
- catalog
- executor
- nodes
- parser
- utils
- pl
- plperl
- plpgsql/src
- plpython
- test/regress
- expected
- sql
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
52 files changed
+1552
-711
lines changedLines changed: 10 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
426 | 426 |
| |
427 | 427 |
| |
428 | 428 |
| |
429 |
| - | |
430 |
| - | |
431 |
| - | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
432 | 432 |
| |
433 | 433 |
| |
434 | 434 |
| |
435 | 435 |
| |
| 436 | + | |
| 437 | + | |
436 | 438 |
| |
437 | 439 |
| |
438 | 440 |
| |
| 441 | + | |
| 442 | + | |
439 | 443 |
| |
440 | 444 |
| |
441 | 445 |
| |
442 | 446 |
| |
443 | 447 |
| |
444 |
| - | |
445 |
| - | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
446 | 451 |
| |
447 | 452 |
| |
448 | 453 |
| |
|
Lines changed: 25 additions & 13 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
8740 | 8740 |
| |
8741 | 8741 |
| |
8742 | 8742 |
| |
| 8743 | + | |
| 8744 | + | |
| 8745 | + | |
| 8746 | + | |
| 8747 | + | |
| 8748 | + | |
| 8749 | + | |
| 8750 | + | |
| 8751 | + | |
| 8752 | + | |
| 8753 | + | |
| 8754 | + | |
| 8755 | + | |
| 8756 | + | |
| 8757 | + | |
8743 | 8758 |
| |
8744 | 8759 |
| |
8745 | 8760 |
| |
8746 | 8761 |
| |
8747 | 8762 |
| |
8748 | 8763 |
| |
8749 | 8764 |
| |
8750 |
| - | |
8751 |
| - | |
8752 |
| - | |
8753 |
| - | |
8754 |
| - | |
8755 |
| - | |
8756 |
| - | |
8757 |
| - | |
8758 |
| - | |
8759 |
| - | |
8760 |
| - | |
8761 |
| - | |
8762 |
| - | |
| 8765 | + | |
| 8766 | + | |
| 8767 | + | |
| 8768 | + | |
| 8769 | + | |
| 8770 | + | |
| 8771 | + | |
| 8772 | + | |
| 8773 | + | |
| 8774 | + | |
8763 | 8775 |
| |
8764 | 8776 |
| |
8765 | 8777 |
| |
|
Lines changed: 65 additions & 11 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
43 | 43 |
| |
44 | 44 |
| |
45 | 45 |
| |
| 46 | + | |
46 | 47 |
| |
47 | 48 |
| |
48 | 49 |
| |
| |||
196 | 197 |
| |
197 | 198 |
| |
198 | 199 |
| |
199 |
| - | |
200 |
| - | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
201 | 203 |
| |
202 | 204 |
| |
203 | 205 |
| |
| |||
318 | 320 |
| |
319 | 321 |
| |
320 | 322 |
| |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
321 | 343 |
| |
322 | 344 |
| |
323 | 345 |
| |
| |||
428 | 450 |
| |
429 | 451 |
| |
430 | 452 |
| |
431 |
| - | |
| 453 | + | |
| 454 | + | |
432 | 455 |
| |
433 | 456 |
| |
434 |
| - | |
435 |
| - | |
| 457 | + | |
| 458 | + | |
436 | 459 |
| |
437 | 460 |
| |
438 | 461 |
| |
| |||
456 | 479 |
| |
457 | 480 |
| |
458 | 481 |
| |
459 |
| - | |
| 482 | + | |
460 | 483 |
| |
461 | 484 |
| |
462 | 485 |
| |
| |||
469 | 492 |
| |
470 | 493 |
| |
471 | 494 |
| |
472 |
| - | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
473 | 498 |
| |
474 | 499 |
| |
475 | 500 |
| |
476 | 501 |
| |
477 | 502 |
| |
478 | 503 |
| |
479 |
| - | |
| 504 | + | |
480 | 505 |
| |
481 | 506 |
| |
482 | 507 |
| |
| |||
485 | 510 |
| |
486 | 511 |
| |
487 | 512 |
| |
488 |
| - | |
489 |
| - | |
490 |
| - | |
| 513 | + | |
491 | 514 |
| |
492 | 515 |
| |
493 | 516 |
| |
494 | 517 |
| |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
495 | 539 |
| |
496 | 540 |
| |
497 | 541 |
| |
| |||
654 | 698 |
| |
655 | 699 |
| |
656 | 700 |
| |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
657 | 711 |
| |
658 | 712 |
| |
659 | 713 |
| |
|
Lines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3114 | 3114 |
| |
3115 | 3115 |
| |
3116 | 3116 |
| |
3117 |
| - | |
| 3117 | + | |
3118 | 3118 |
| |
3119 | 3119 |
| |
3120 | 3120 |
| |
| |||
4392 | 4392 |
| |
4393 | 4393 |
| |
4394 | 4394 |
| |
4395 |
| - | |
| 4395 | + | |
4396 | 4396 |
| |
4397 | 4397 |
| |
4398 | 4398 |
| |
|
Lines changed: 16 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2074 | 2074 |
| |
2075 | 2075 |
| |
2076 | 2076 |
| |
| 2077 | + | |
| 2078 | + | |
| 2079 | + | |
| 2080 | + | |
| 2081 | + | |
| 2082 | + | |
| 2083 | + | |
| 2084 | + | |
| 2085 | + | |
| 2086 | + | |
| 2087 | + | |
| 2088 | + | |
| 2089 | + | |
| 2090 | + | |
| 2091 | + | |
| 2092 | + | |
2077 | 2093 |
| |
2078 | 2094 |
| |
2079 | 2095 |
| |
|
Lines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1079 | 1079 |
| |
1080 | 1080 |
| |
1081 | 1081 |
| |
| 1082 | + | |
1082 | 1083 |
| |
1083 | 1084 |
| |
1084 | 1085 |
| |
| |||
1358 | 1359 |
| |
1359 | 1360 |
| |
1360 | 1361 |
| |
| 1362 | + | |
1361 | 1363 |
| |
1362 | 1364 |
| |
1363 | 1365 |
| |
|
Lines changed: 10 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
103 | 103 |
| |
104 | 104 |
| |
105 | 105 |
| |
| 106 | + | |
106 | 107 |
| |
107 | 108 |
| |
108 | 109 |
| |
| |||
208 | 209 |
| |
209 | 210 |
| |
210 | 211 |
| |
| 212 | + | |
211 | 213 |
| |
212 | 214 |
| |
213 | 215 |
| |
| |||
357 | 359 |
| |
358 | 360 |
| |
359 | 361 |
| |
| 362 | + | |
360 | 363 |
| |
361 | 364 |
| |
362 | 365 |
| |
| |||
667 | 670 |
| |
668 | 671 |
| |
669 | 672 |
| |
670 |
| - | |
| 673 | + | |
671 | 674 |
| |
672 | 675 |
| |
673 | 676 |
| |
| |||
710 | 713 |
| |
711 | 714 |
| |
712 | 715 |
| |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
713 | 722 |
| |
714 | 723 |
| |
715 | 724 |
| |
|
0 commit comments
Comments
(0)