Repository navigation
Commit 7eb8516
compiler: only count keeps an expression in a scalar subquery never null
The commit before last kept a scalar subquery's column never null when an
aggregate sat anywhere in its expression. That is right for count, which is
never NULL, and wrong for the rest: `(SELECT max(x)::int FROM ...)` yields
one row, and that row is NULL when nothing matched, but a cast reports its
column as never null.
Keep the column never null only for an expression whose aggregates are all
count.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>1 parent 540c5b9 commit 7eb8516
3 files changed
Lines changed: 93 additions & 8 deletions
File tree
- internal
- compiler
- endtoend/testdata/nullable_scalar_subquery_aggregate/postgresql/pgx
- go
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
826 | 826 | | |
827 | 827 | | |
828 | 828 | | |
829 | | - | |
830 | | - | |
831 | | - | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
832 | 832 | | |
833 | 833 | | |
834 | 834 | | |
| |||
848 | 848 | | |
849 | 849 | | |
850 | 850 | | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
851 | 861 | | |
852 | 862 | | |
853 | | - | |
| 863 | + | |
854 | 864 | | |
855 | 865 | | |
856 | 866 | | |
857 | 867 | | |
858 | 868 | | |
859 | 869 | | |
860 | | - | |
| 870 | + | |
861 | 871 | | |
862 | 872 | | |
863 | 873 | | |
864 | | - | |
| 874 | + | |
| 875 | + | |
865 | 876 | | |
866 | 877 | | |
867 | 878 | | |
868 | 879 | | |
869 | 880 | | |
870 | 881 | | |
871 | 882 | | |
872 | | - | |
873 | | - | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
874 | 891 | | |
875 | 892 | | |
876 | 893 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
0 commit comments