![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hello, I think, I found a bug, but maybe it's just my stupidity. Granted: What I did was an error on my part, but I still think, PostgreSQL should not do what it does. |
|
popscan_light=> select aliasa.name, aliasb.name2 from a aliasa left join b aliasb using (id) order by b.name2; NOTICE: adding missing FROM-clause entry for table "b" name | name2 -------+----------- gnegg | gnegglink blepp | blepplink gnegg | gnegglink blepp | blepplink (4 rows) |
|
Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a tool for doing 5% of the work and then sitting around waiting for someone else to do the other 95% so you can sue them. |
#3
| |||
| |||
|
|
popscan_light=> select aliasa.name, aliasb.name2 from a aliasa left join b aliasb using (id) order by b.name2; NOTICE: adding missing FROM-clause entry for table "b" name | name2 -------+----------- gnegg | gnegglink blepp | blepplink gnegg | gnegglink blepp | blepplink (4 rows) See that NOTIVCE? It's telling you that it's converted your query to: |
|
select aliasa.name, aliasb.name2 from b, a aliasa left join b aliasb using (id) order by b.name2; Since you now have an unconstrained join on the B table, you get twice as many rows. |
|
As for what's SQL standard, I think by a strict definition your query shouldn't be allowed at all, referencing an undefined table. |
#4
| |||
| |||
|
|
As for what's SQL standard, I think by a strict definition your query shouldn't be allowed at all, referencing an undefined table. This is exactly what I think too. I mean: I know I made an error in my query. It would just have been easier to find if PostgreSQL actually had told me so (I'm not getting those NOTICEs from PHP...). If it's wrong, it should be disallowed, not made worse by assuming a completely wrong thing. |
|
Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a tool for doing 5% of the work and then sitting around waiting for someone else to do the other 95% so you can sue them. |
#5
| |||
| |||
|
|
As for what's SQL standard, I think by a strict definition your query shouldn't be allowed at all, referencing an undefined table. This is exactly what I think too. I mean: I know I made an error in my query. It would just have been easier to find if PostgreSQL actually had told me so (I'm not getting those NOTICEs from PHP...). If it's wrong, it should be disallowed, not made worse by assuming a completely wrong thing. |
#6
| |||
| |||
|
|
snip> It would just have been easier to find if PostgreSQL actually had told me so (I'm not getting those NOTICEs from PHP...). |
#7
| |||
| |||
|
|
It's enabled in large part for backwards compatibility. There's a runtime option that controls the behavior (add_missing_from). IMHO, it would be a more natural choice to have the add_missing_from |
#8
| |||
| |||
|
|
IMHO, it would be a more natural choice to have the add_missing_from disabled by default. Why would anyone *ever* want faulty SQL being magically "patched up" by the dbms? |
#9
| |||
| |||
|
|
Stephan Szabo wrote: It's enabled in large part for backwards compatibility. There's a runtime option that controls the behavior (add_missing_from). IMHO, it would be a more natural choice to have the add_missing_from disabled by default. Why would anyone *ever* want faulty SQL being |
|
magically "patched up" by the dbms? |
#10
| |||
| |||
|
|
That assumes that developers will implement queries in their code without testing them. Unfortunately, that's probably not too far from reality. I've thought of it as a nice "debugging" feature while I'm trying to hammer out a complicated query for the first time. |
![]() |
| Thread Tools | |
| Display Modes | |
| |