forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit1345cc6
committed
Use standard casting mechanism to convert types in plpgsql, when possible.
plpgsql's historical method for converting datatypes during assignments wasto apply the source type's output function and then the destination type'sinput function. Aside from being miserably inefficient in most cases, thismethod failed outright in many cases where a user might expect it to work;an example is that "declare x int; ... x := 3.9;" would fail, not round thevalue to 4.Instead, let's convert by applying the appropriate assignment cast wheneverthere is one. To avoid breaking compatibility unnecessarily, fall back tothe I/O conversion method if there is no assignment cast.So far as I can tell, there is just one case where this method produces adifferent result than the old code in a case where the old code would nothave thrown an error. That is assignment of a boolean value to a stringvariable (type text, varchar, or bpchar); the old way gave boolean's outputrepresentation, ie 't'/'f', while the new way follows the behavior of thebool-to-text cast and so gives 'true' or 'false'. This will need to becalled out as an incompatibility in the 9.5 release notes.Aside from handling many conversion cases more sanely, this method isoften significantly faster than the old way. In part that's becauseof more effective caching of the conversion info.1 parentb989619 commit1345cc6
File tree
5 files changed
+241
-131
lines changed- doc/src/sgml
- src/pl/plpgsql/src
5 files changed
+241
-131
lines changedLines changed: 8 additions & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
881 | 881 |
| |
882 | 882 |
| |
883 | 883 |
| |
884 |
| - | |
885 |
| - | |
886 |
| - | |
887 |
| - | |
888 |
| - | |
889 |
| - | |
890 |
| - | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
891 | 892 |
| |
892 | 893 |
| |
893 | 894 |
| |
|
Lines changed: 4 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
844 | 844 |
| |
845 | 845 |
| |
846 | 846 |
| |
847 |
| - | |
848 |
| - | |
849 |
| - | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
850 | 851 |
| |
851 | 852 |
| |
852 | 853 |
| |
|
Lines changed: 1 addition & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
559 | 559 |
| |
560 | 560 |
| |
561 | 561 |
| |
562 |
| - | |
563 |
| - | |
564 | 562 |
| |
565 | 563 |
| |
566 | 564 |
| |
| |||
803 | 801 |
| |
804 | 802 |
| |
805 | 803 |
| |
806 |
| - | |
807 | 804 |
| |
808 | 805 |
| |
809 | 806 |
| |
| |||
876 | 873 |
| |
877 | 874 |
| |
878 | 875 |
| |
879 |
| - | |
880 |
| - | |
881 | 876 |
| |
882 | 877 |
| |
883 | 878 |
| |
| |||
2200 | 2195 |
| |
2201 | 2196 |
| |
2202 | 2197 |
| |
| 2198 | + | |
2203 | 2199 |
| |
2204 |
| - | |
2205 | 2200 |
| |
2206 | 2201 |
| |
2207 | 2202 |
| |
2208 |
| - | |
2209 | 2203 |
| |
2210 | 2204 |
| |
2211 | 2205 |
| |
|
0 commit comments
Comments
(0)