- Notifications
You must be signed in to change notification settings - Fork4.9k
Commiteaccfde
committed
Centralize the logic for detecting misplaced aggregates, window funcs, etc.
Formerly we relied on checking after-the-fact to see if an expressioncontained aggregates, window functions, or sub-selects when it shouldn't.This is grotty, easily forgotten (indeed, we had forgotten to teachDefineIndex about rejecting window functions), and none too efficientsince it requires extra traversals of the parse tree. To improve matters,define an enum type that classifies all SQL sub-expressions, store it inParseState to show what kind of expression we are currently parsing, andmake transformAggregateCall, transformWindowFuncCall, and transformSubLinkcheck the expression type and throw error if the type indicates theconstruct is disallowed. This allows removal of a large number of ad-hocchecks scattered around the code base. The enum type is sufficientlyfine-grained that we can still produce error messages of at least thesame specificity as before.Bringing these error checks together revealed that we'd been none tooconsistent about phrasing of the error messages, so standardize the wordinga bit.Also, rewrite checking of aggregate arguments so that it requires only onetraversal of the arguments, rather than up to three as before.In passing, clean up some more comments left over from add_missing_fromsupport, and annotate some tests that I think are dead code now that that'sgone. (I didn't risk actually removing said dead code, though.)1 parentb3055ab commiteaccfde
File tree
29 files changed
+952
-781
lines changed- src
- backend
- catalog
- commands
- optimizer/util
- parser
- rewrite
- include
- optimizer
- parser
- rewrite
- test/regress
- expected
- sql
29 files changed
+952
-781
lines changedLines changed: 9 additions & 36 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2415 | 2415 |
| |
2416 | 2416 |
| |
2417 | 2417 |
| |
2418 |
| - | |
| 2418 | + | |
2419 | 2419 |
| |
2420 | 2420 |
| |
2421 |
| - | |
| 2421 | + | |
| 2422 | + | |
2422 | 2423 |
| |
2423 | 2424 |
| |
2424 | 2425 |
| |
2425 | 2426 |
| |
2426 | 2427 |
| |
2427 | 2428 |
| |
2428 | 2429 |
| |
| 2430 | + | |
| 2431 | + | |
| 2432 | + | |
2429 | 2433 |
| |
2430 | 2434 |
| |
2431 | 2435 |
| |
2432 | 2436 |
| |
2433 | 2437 |
| |
2434 | 2438 |
| |
2435 | 2439 |
| |
2436 |
| - | |
2437 |
| - | |
2438 |
| - | |
2439 |
| - | |
2440 |
| - | |
2441 |
| - | |
2442 |
| - | |
2443 |
| - | |
2444 |
| - | |
2445 |
| - | |
2446 |
| - | |
2447 |
| - | |
2448 |
| - | |
2449 |
| - | |
2450 |
| - | |
2451 |
| - | |
2452 | 2440 |
| |
2453 | 2441 |
| |
2454 | 2442 |
| |
| |||
2499 | 2487 |
| |
2500 | 2488 |
| |
2501 | 2489 |
| |
2502 |
| - | |
| 2490 | + | |
2503 | 2491 |
| |
2504 | 2492 |
| |
2505 | 2493 |
| |
| |||
2512 | 2500 |
| |
2513 | 2501 |
| |
2514 | 2502 |
| |
2515 |
| - | |
| 2503 | + | |
| 2504 | + | |
2516 | 2505 |
| |
2517 | 2506 |
| |
2518 | 2507 |
| |
2519 | 2508 |
| |
2520 | 2509 |
| |
2521 | 2510 |
| |
2522 | 2511 |
| |
2523 |
| - | |
2524 |
| - | |
2525 |
| - | |
2526 |
| - | |
2527 |
| - | |
2528 |
| - | |
2529 |
| - | |
2530 |
| - | |
2531 |
| - | |
2532 |
| - | |
2533 |
| - | |
2534 |
| - | |
2535 |
| - | |
2536 |
| - | |
2537 |
| - | |
2538 |
| - | |
2539 | 2512 |
| |
2540 | 2513 |
| |
2541 | 2514 |
| |
|
Lines changed: 8 additions & 16 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
344 | 344 |
| |
345 | 345 |
| |
346 | 346 |
| |
347 |
| - | |
| 347 | + | |
| 348 | + | |
348 | 349 |
| |
349 | 350 |
| |
350 | 351 |
| |
351 | 352 |
| |
352 |
| - | |
| 353 | + | |
| 354 | + | |
353 | 355 |
| |
354 | 356 |
| |
355 | 357 |
| |
| |||
358 | 360 |
| |
359 | 361 |
| |
360 | 362 |
| |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
361 | 367 |
| |
362 | 368 |
| |
363 | 369 |
| |
364 |
| - | |
365 |
| - | |
366 | 370 |
| |
367 | 371 |
| |
368 | 372 |
| |
369 | 373 |
| |
370 | 374 |
| |
371 |
| - | |
372 |
| - | |
373 |
| - | |
374 |
| - | |
375 |
| - | |
376 |
| - | |
377 |
| - | |
378 |
| - | |
379 |
| - | |
380 |
| - | |
381 |
| - | |
382 |
| - | |
383 | 375 |
| |
384 | 376 |
| |
385 | 377 |
| |
|
Lines changed: 5 additions & 21 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
941 | 941 |
| |
942 | 942 |
| |
943 | 943 |
| |
944 |
| - | |
945 |
| - | |
| 944 | + | |
| 945 | + | |
946 | 946 |
| |
947 |
| - | |
948 |
| - | |
949 |
| - | |
950 |
| - | |
951 |
| - | |
952 |
| - | |
953 |
| - | |
954 |
| - | |
955 | 947 |
| |
956 | 948 |
| |
957 | 949 |
| |
| |||
1072 | 1064 |
| |
1073 | 1065 |
| |
1074 | 1066 |
| |
1075 |
| - | |
1076 |
| - | |
1077 |
| - | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
1078 | 1070 |
| |
1079 |
| - | |
1080 |
| - | |
1081 |
| - | |
1082 |
| - | |
1083 |
| - | |
1084 |
| - | |
1085 |
| - | |
1086 |
| - | |
1087 | 1071 |
| |
1088 | 1072 |
| |
1089 | 1073 |
| |
|
Lines changed: 1 addition & 15 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
354 | 354 |
| |
355 | 355 |
| |
356 | 356 |
| |
357 |
| - | |
358 |
| - | |
359 |
| - | |
360 |
| - | |
361 |
| - | |
362 |
| - | |
363 |
| - | |
364 |
| - | |
365 |
| - | |
366 |
| - | |
367 |
| - | |
368 |
| - | |
369 |
| - | |
370 |
| - | |
371 |
| - | |
| 357 | + | |
372 | 358 |
| |
373 | 359 |
| |
374 | 360 |
| |
|
Lines changed: 2 additions & 15 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
7178 | 7178 |
| |
7179 | 7179 |
| |
7180 | 7180 |
| |
7181 |
| - | |
| 7181 | + | |
| 7182 | + | |
7182 | 7183 |
| |
7183 | 7184 |
| |
7184 | 7185 |
| |
7185 | 7186 |
| |
7186 | 7187 |
| |
7187 | 7188 |
| |
7188 |
| - | |
7189 |
| - | |
7190 |
| - | |
7191 |
| - | |
7192 |
| - | |
7193 |
| - | |
7194 |
| - | |
7195 |
| - | |
7196 |
| - | |
7197 |
| - | |
7198 |
| - | |
7199 |
| - | |
7200 |
| - | |
7201 |
| - | |
7202 | 7189 |
| |
7203 | 7190 |
| |
7204 | 7191 |
| |
|
Lines changed: 1 addition & 16 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
286 | 286 |
| |
287 | 287 |
| |
288 | 288 |
| |
| 289 | + | |
289 | 290 |
| |
290 | 291 |
| |
291 | 292 |
| |
292 | 293 |
| |
293 |
| - | |
294 |
| - | |
295 |
| - | |
296 |
| - | |
297 |
| - | |
298 |
| - | |
299 |
| - | |
300 |
| - | |
301 |
| - | |
302 |
| - | |
303 |
| - | |
304 |
| - | |
305 |
| - | |
306 |
| - | |
307 |
| - | |
308 |
| - | |
309 | 294 |
| |
310 | 295 |
| |
311 | 296 |
| |
|
Lines changed: 5 additions & 28 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2871 | 2871 |
| |
2872 | 2872 |
| |
2873 | 2873 |
| |
2874 |
| - | |
| 2874 | + | |
2875 | 2875 |
| |
2876 | 2876 |
| |
2877 | 2877 |
| |
| |||
2884 | 2884 |
| |
2885 | 2885 |
| |
2886 | 2886 |
| |
2887 |
| - | |
| 2887 | + | |
| 2888 | + | |
2888 | 2889 |
| |
2889 |
| - | |
| 2890 | + | |
| 2891 | + | |
2890 | 2892 |
| |
2891 | 2893 |
| |
2892 | 2894 |
| |
2893 | 2895 |
| |
2894 |
| - | |
2895 |
| - | |
2896 |
| - | |
2897 |
| - | |
2898 |
| - | |
2899 |
| - | |
2900 |
| - | |
2901 |
| - | |
2902 |
| - | |
2903 |
| - | |
2904 |
| - | |
2905 |
| - | |
2906 |
| - | |
2907 |
| - | |
2908 |
| - | |
2909 |
| - | |
2910 |
| - | |
2911 |
| - | |
2912 |
| - | |
2913 |
| - | |
2914 |
| - | |
2915 |
| - | |
2916 |
| - | |
2917 |
| - | |
2918 |
| - | |
2919 | 2896 |
| |
2920 | 2897 |
| |
2921 | 2898 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
596 | 596 |
| |
597 | 597 |
| |
598 | 598 |
| |
599 |
| - | |
| 599 | + | |
600 | 600 |
| |
601 | 601 |
| |
602 | 602 |
| |
|
0 commit comments
Comments
(0)