forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit74c9669
committed
SQL/JSON: Some fixes to JsonBehavior expression casting
1. Remove the special case handling when casting the JsonBehavior expressions to types with typmod, like86d3398 did for the casting of SQL/JSON constructor functions.2. Fix casting for fixed-length character and bit string types by using assignment-level casts. This is again similar to what86d3398 did, but for ON ERROR / EMPTY expressions.3. Use runtime coercion for the boolean ON ERROR constants so that using fixed-length character string types, for example, for an EXISTS column doesn't cause a "value too long for type character(n)" when the parser tries to coerce the default ON ERROR value "false" to that type, that is, even when clause is not specified.4. Simplify the conditions of when to use runtime coercion vs creating the cast expression in the parser itself. jsonb-valued expressions are now always coerced at runtime and boolean expressions too if the target type is a string type for the reasons mentioned above.Tests are taken from a patch that Jian He posted.Reported-by: Jian He <jian.universality@gmail.com>Author: Jian He <jian.universality@gmail.com>Author: Amit Langote <amitlangote09@gmail.com>Discussion:https://postgr.es/m/CACJufxEo4sUjKCYtda0_qt9tazqqKPmF1cqhW9KBOUeJFqQd2g@mail.gmail.comBackpatch-through: 171 parent8240401 commit74c9669
File tree
5 files changed
+164
-52
lines changed- src
- backend/parser
- test/regress
- expected
- sql
5 files changed
+164
-52
lines changedLines changed: 70 additions & 30 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
4685 | 4685 |
| |
4686 | 4686 |
| |
4687 | 4687 |
| |
4688 |
| - | |
| 4688 | + | |
| 4689 | + | |
| 4690 | + | |
| 4691 | + | |
| 4692 | + | |
| 4693 | + | |
| 4694 | + | |
| 4695 | + | |
| 4696 | + | |
| 4697 | + | |
| 4698 | + | |
| 4699 | + | |
4689 | 4700 |
| |
4690 |
| - | |
4691 | 4701 |
| |
4692 | 4702 |
| |
4693 |
| - | |
4694 |
| - | |
4695 |
| - | |
4696 |
| - | |
4697 |
| - | |
4698 |
| - | |
4699 |
| - | |
4700 | 4703 |
| |
4701 |
| - | |
4702 |
| - | |
| 4704 | + | |
| 4705 | + | |
| 4706 | + | |
| 4707 | + | |
4703 | 4708 |
| |
| 4709 | + | |
| 4710 | + | |
| 4711 | + | |
| 4712 | + | |
| 4713 | + | |
| 4714 | + | |
| 4715 | + | |
| 4716 | + | |
| 4717 | + | |
| 4718 | + | |
| 4719 | + | |
| 4720 | + | |
| 4721 | + | |
| 4722 | + | |
| 4723 | + | |
| 4724 | + | |
| 4725 | + | |
4704 | 4726 |
| |
4705 | 4727 |
| |
4706 |
| - | |
| 4728 | + | |
| 4729 | + | |
4707 | 4730 |
| |
4708 |
| - | |
4709 |
| - | |
4710 |
| - | |
4711 |
| - | |
4712 |
| - | |
4713 |
| - | |
| 4731 | + | |
| 4732 | + | |
| 4733 | + | |
| 4734 | + | |
| 4735 | + | |
| 4736 | + | |
4714 | 4737 |
| |
4715 | 4738 |
| |
4716 |
| - | |
4717 |
| - | |
| 4739 | + | |
| 4740 | + | |
| 4741 | + | |
| 4742 | + | |
4718 | 4743 |
| |
4719 |
| - | |
4720 | 4744 |
| |
4721 | 4745 |
| |
4722 |
| - | |
4723 | 4746 |
| |
4724 |
| - | |
4725 |
| - | |
4726 |
| - | |
4727 |
| - | |
4728 |
| - | |
4729 |
| - | |
4730 |
| - | |
4731 |
| - | |
| 4747 | + | |
| 4748 | + | |
| 4749 | + | |
| 4750 | + | |
| 4751 | + | |
| 4752 | + | |
| 4753 | + | |
| 4754 | + | |
| 4755 | + | |
| 4756 | + | |
| 4757 | + | |
| 4758 | + | |
| 4759 | + | |
| 4760 | + | |
| 4761 | + | |
| 4762 | + | |
| 4763 | + | |
| 4764 | + | |
| 4765 | + | |
| 4766 | + | |
| 4767 | + | |
| 4768 | + | |
| 4769 | + | |
| 4770 | + | |
4732 | 4771 |
| |
| 4772 | + | |
4733 | 4773 |
| |
4734 | 4774 |
| |
4735 | 4775 |
| |
|
Lines changed: 23 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
556 | 556 |
| |
557 | 557 |
| |
558 | 558 |
| |
559 |
| - | |
| 559 | + | |
| 560 | + | |
560 | 561 |
| |
561 |
| - | |
| 562 | + | |
| 563 | + | |
562 | 564 |
| |
563 |
| - | |
564 |
| - | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
565 | 574 |
| |
566 | 575 |
| |
567 | 576 |
| |
568 | 577 |
| |
569 | 578 |
| |
570 | 579 |
| |
571 |
| - | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
572 | 585 |
| |
573 |
| - | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
574 | 591 |
| |
575 | 592 |
| |
576 | 593 |
| |
|
Lines changed: 52 additions & 14 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
662 | 662 |
| |
663 | 663 |
| |
664 | 664 |
| |
665 |
| - | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
666 | 670 |
| |
667 | 671 |
| |
668 | 672 |
| |
| |||
865 | 869 |
| |
866 | 870 |
| |
867 | 871 |
| |
868 |
| - | |
869 |
| - | |
870 |
| - | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
871 | 877 |
| |
872 |
| - | |
873 |
| - | |
874 |
| - | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
875 | 883 |
| |
876 | 884 |
| |
877 | 885 |
| |
| |||
885 | 893 |
| |
886 | 894 |
| |
887 | 895 |
| |
888 |
| - | |
889 |
| - | |
890 |
| - | |
| 896 | + | |
| 897 | + | |
891 | 898 |
| |
892 |
| - | |
893 |
| - | |
894 |
| - | |
| 899 | + | |
| 900 | + | |
895 | 901 |
| |
896 | 902 |
| |
897 | 903 |
| |
| |||
1379 | 1385 |
| |
1380 | 1386 |
| |
1381 | 1387 |
| |
1382 |
| - | |
| 1388 | + | |
| 1389 | + | |
1383 | 1390 |
| |
1384 | 1391 |
| |
1385 | 1392 |
| |
| |||
1415 | 1422 |
| |
1416 | 1423 |
| |
1417 | 1424 |
| |
| 1425 | + | |
| 1426 | + | |
| 1427 | + | |
| 1428 | + | |
| 1429 | + | |
| 1430 | + | |
| 1431 | + | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
| 1439 | + | |
| 1440 | + | |
| 1441 | + | |
| 1442 | + | |
| 1443 | + | |
| 1444 | + | |
| 1445 | + | |
| 1446 | + | |
| 1447 | + | |
| 1448 | + | |
| 1449 | + | |
| 1450 | + | |
| 1451 | + | |
| 1452 | + | |
| 1453 | + | |
| 1454 | + | |
| 1455 | + |
Lines changed: 4 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
266 | 266 |
| |
267 | 267 |
| |
268 | 268 |
| |
269 |
| - | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
270 | 273 |
| |
271 | 274 |
| |
272 | 275 |
| |
|
Lines changed: 15 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
472 | 472 |
| |
473 | 473 |
| |
474 | 474 |
| |
475 |
| - | |
| 475 | + | |
| 476 | + | |
476 | 477 |
| |
477 | 478 |
| |
478 | 479 |
| |
| |||
484 | 485 |
| |
485 | 486 |
| |
486 | 487 |
| |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + |
0 commit comments
Comments
(0)