forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit4618045
committed
Fix ARRAY_SUBLINK and ARRAY[] for int2vector and oidvector input.
If the given input_type yields valid results from bothget_element_type and get_array_type, initArrayResultAny believed theformer and treated the input as an array type. However this isinconsistent with what get_promoted_array_type does, leading tosituations where the output of an ARRAY() subquery is labeled withthe wrong type: it's labeled as oidvector[] but is really a 2-Darray of OID. That at least results in strange output, and canresult in crashes if further processing such as unnest() is applied.AFAIK this is only possible with the int2vector and oidvectortypes, which are special-cased to be treated mostly as true arrayseven though they aren't quite.Fix by switching the logic to match get_promoted_array_type bytesting get_array_type not get_element_type, and remove an Assertthereby made pointless. (We need not introduce a symmetricalcheck for get_element_type in the other if-branch, becauseinitArrayResultArr will check it.) This restores the behaviorthat existed beforebac2739 introduced initArrayResultAny:the output really is int2vector[] or oidvector[].Comparable confusion exists when an input of an ARRAY[] constructis int2vector or oidvector: transformArrayExpr decides it's dealingwith a multidimensional array constructor, and we end up withsomething that's a multidimensional OID array but is alleged to beof type oidvector. I have not found a crashing case here, but it'seasy to demonstrate totally-wrong results. Adjust that code sothat what you get is an oidvector[] instead, for consistency withARRAY() subqueries. (This change also makes these types work likedomains-over-arrays in this context, which seems correct.)Bug: #18840Reported-by: yang lei <ylshiyu@126.com>Author: Tom Lane <tgl@sss.pgh.pa.us>Discussion:https://postgr.es/m/18840-fbc9505f066e50d6@postgresql.orgBackpatch-through: 131 parentc7fc880 commit4618045
File tree
4 files changed
+166
-8
lines changed- src
- backend
- parser
- utils/adt
- test/regress
- expected
- sql
4 files changed
+166
-8
lines changedLines changed: 11 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2053 | 2053 |
| |
2054 | 2054 |
| |
2055 | 2055 |
| |
2056 |
| - | |
| 2056 | + | |
| 2057 | + | |
| 2058 | + | |
2057 | 2059 |
| |
2058 |
| - | |
2059 |
| - | |
| 2060 | + | |
| 2061 | + | |
| 2062 | + | |
| 2063 | + | |
| 2064 | + | |
| 2065 | + | |
| 2066 | + | |
| 2067 | + | |
2060 | 2068 |
| |
2061 | 2069 |
| |
2062 | 2070 |
| |
|
Lines changed: 7 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
5782 | 5782 |
| |
5783 | 5783 |
| |
5784 | 5784 |
| |
5785 |
| - | |
5786 | 5785 |
| |
5787 |
| - | |
| 5786 | + | |
| 5787 | + | |
| 5788 | + | |
| 5789 | + | |
| 5790 | + | |
| 5791 | + | |
| 5792 | + | |
5788 | 5793 |
| |
5789 | 5794 |
| |
5790 | 5795 |
| |
| |||
5801 | 5806 |
| |
5802 | 5807 |
| |
5803 | 5808 |
| |
5804 |
| - | |
5805 |
| - | |
5806 |
| - | |
5807 | 5809 |
| |
5808 | 5810 |
| |
5809 | 5811 |
| |
|
Lines changed: 126 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2457 | 2457 |
| |
2458 | 2458 |
| |
2459 | 2459 |
| |
| 2460 | + | |
| 2461 | + | |
| 2462 | + | |
| 2463 | + | |
| 2464 | + | |
| 2465 | + | |
| 2466 | + | |
| 2467 | + | |
| 2468 | + | |
| 2469 | + | |
| 2470 | + | |
| 2471 | + | |
| 2472 | + | |
| 2473 | + | |
| 2474 | + | |
| 2475 | + | |
| 2476 | + | |
| 2477 | + | |
| 2478 | + | |
| 2479 | + | |
| 2480 | + | |
| 2481 | + | |
| 2482 | + | |
| 2483 | + | |
| 2484 | + | |
| 2485 | + | |
| 2486 | + | |
| 2487 | + | |
| 2488 | + | |
| 2489 | + | |
| 2490 | + | |
| 2491 | + | |
| 2492 | + | |
| 2493 | + | |
| 2494 | + | |
| 2495 | + | |
| 2496 | + | |
| 2497 | + | |
| 2498 | + | |
| 2499 | + | |
| 2500 | + | |
| 2501 | + | |
| 2502 | + | |
| 2503 | + | |
| 2504 | + | |
| 2505 | + | |
| 2506 | + | |
| 2507 | + | |
| 2508 | + | |
| 2509 | + | |
| 2510 | + | |
| 2511 | + | |
| 2512 | + | |
| 2513 | + | |
| 2514 | + | |
| 2515 | + | |
| 2516 | + | |
| 2517 | + | |
| 2518 | + | |
| 2519 | + | |
| 2520 | + | |
| 2521 | + | |
| 2522 | + | |
| 2523 | + | |
| 2524 | + | |
| 2525 | + | |
| 2526 | + | |
| 2527 | + | |
| 2528 | + | |
| 2529 | + | |
| 2530 | + | |
| 2531 | + | |
| 2532 | + | |
| 2533 | + | |
| 2534 | + | |
| 2535 | + | |
| 2536 | + | |
| 2537 | + | |
| 2538 | + | |
| 2539 | + | |
| 2540 | + | |
| 2541 | + | |
| 2542 | + | |
| 2543 | + | |
| 2544 | + | |
| 2545 | + | |
| 2546 | + | |
| 2547 | + | |
| 2548 | + | |
| 2549 | + | |
| 2550 | + | |
| 2551 | + | |
| 2552 | + | |
| 2553 | + | |
| 2554 | + | |
| 2555 | + | |
| 2556 | + | |
| 2557 | + | |
| 2558 | + | |
| 2559 | + | |
| 2560 | + | |
| 2561 | + | |
| 2562 | + | |
| 2563 | + | |
| 2564 | + | |
| 2565 | + | |
| 2566 | + | |
| 2567 | + | |
| 2568 | + | |
| 2569 | + | |
| 2570 | + | |
| 2571 | + | |
| 2572 | + | |
| 2573 | + | |
| 2574 | + | |
| 2575 | + | |
| 2576 | + | |
| 2577 | + | |
| 2578 | + | |
| 2579 | + | |
| 2580 | + | |
| 2581 | + | |
| 2582 | + | |
| 2583 | + | |
| 2584 | + | |
| 2585 | + | |
2460 | 2586 |
| |
2461 | 2587 |
| |
2462 | 2588 |
| |
|
Lines changed: 22 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
713 | 713 |
| |
714 | 714 |
| |
715 | 715 |
| |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
716 | 738 |
| |
717 | 739 |
| |
718 | 740 |
| |
|
0 commit comments
Comments
(0)