Thread: SQL Debugging Aide

SQL Debugging Aide

From
Mike Mascari
Date:
Is there any option that one might set to have PostgreSQL emit a
NOTICE when it encounters a SELECT statement having a table not
involved in any join condition?

For example, if I do:

SELECT employees.name
FROM employees, salaries;

It would aide debugging application development a bit if there was a
way to have PostgreSQL emit a NOTICE like:

NOTICE: Cartesian product generated for table 'salaries'

in the same manner that it now adds a notice for missing FROM clause
entries.

I realize that there are queries like the above where the results
are as expected, which is why it would be nice for it to be some
option. The above is obvious, but some of my queries contain joins
with > 15 tables. In development, when some of the tables are empty
or only contain 1 record, the results may appear to work. Only until
later would I discover a missing join condition when more then 1 row
is added.

Just a thought,

Mike Mascari
mascarm@mascari.com