Thread: Remove unneeded left joins from psql

Remove unneeded left joins from psql

From
Greg Sabino Mullane
Date:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


In response to Bruce's recent question, and remembering the recent
scolding received about removing a "LEFT" from an unrelated patch :),
here's a patch that does that and nothing more: removes all
unnecessary left joins from psql. Done in the theory that we often
point people to psql -E, so our queries there should be as correct
as possible: if the joining column is not null, then we don't need
a left join.

- --
Greg Sabino Mullane greg@turnstep.com
PGP Key: 0x14964AC8 200504112254
http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8
-----BEGIN PGP SIGNATURE-----

iD8DBQFCWzjVvJuQZxSWSsgRAkwLAKDRMAV3GK/mYEMYEkP4SGC6CWqGNgCg1yIf
oQf+YvYkHJRK1WDz11Hw1Oc=
=oZDp
-----END PGP SIGNATURE-----


Attachment

Re: Remove unneeded left joins from psql

From
Tom Lane
Date:
Greg Sabino Mullane <greg@turnstep.com> writes:
> here's a patch that does that and nothing more: removes all
> unnecessary left joins from psql. Done in the theory that we often
> point people to psql -E, so our queries there should be as correct
> as possible: if the joining column is not null, then we don't need
> a left join.

I'm still not happy about this.  "Joining column is not null" has
nothing to do with it --- what is at issue is whether there is certain
to be a match.  Since we do not have foreign-key enforcement on the
system catalog interrelationships, it is possible for system bugs or
manual intervention to create non-matching situations.

We have seen enough failures associated with "can't happen" missing
links that I think it's just folly to remove error tolerance like this.
I mean, there are *many* thousands of lines of code that we can remove
if the only criterion is readability and robustness means nothing...
who needs WAL for example?

            regards, tom lane

Re: Remove unneeded left joins from psql

From
"Greg Sabino Mullane"
Date:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


> I'm still not happy about this.  "Joining column is not null" has
> nothing to do with it --- what is at issue is whether there is certain
> to be a match.  Since we do not have foreign-key enforcement on the
> system catalog interrelationships, it is possible for system bugs or
> manual intervention to create non-matching situations.

Yes, you are right about this: we should fail in a way that puts a null
schema rather than not matching at all. Must get more sleep before
blindly patching next time. :)

- --
Greg Sabino Mullane greg@turnstep.com
PGP Key: 0x14964AC8 200504122121
http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8

-----BEGIN PGP SIGNATURE-----

iD8DBQFCXHRhvJuQZxSWSsgRAv8yAJ97xvvNVJ5Tvcwlr7f5mIDqtXBqpACgkvro
pvWsWqanqcTnfO9thU8n0j4=
=aYbU
-----END PGP SIGNATURE-----