Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue #611 #642

Merged
merged 7 commits into from
Aug 13, 2019
Merged

Fix issue #611 #642

merged 7 commits into from
Aug 13, 2019

Conversation

vulnbe
Copy link
Contributor

@vulnbe vulnbe commented Jul 12, 2019

This PR fixes bug described here #611

vulnbe added 2 commits July 12, 2019 15:43
```
STATEMENT:  SELECT table_name, column_name,       pg_get_serial_sequence (table_name, column_name)  FROM information_schema.columns  WHERE table_schema = 'public'    AND pg_get_serial_sequence (table_name, column_name)        IS NOT NULL;
ERROR:  relation "information_schema_catalog_name" does not exist
```
@timopollmeier
Copy link
Member

I don't see why the table_schema = 'public' is evaluated before the pg_get_serial_sequence call in the WITH clause but not the original SELECT, so I'm not sure if it's safe to assume this is always the case.

Wouldn't it be safer to only select table_name and column_name (filtered by table_schema) in the WITH clause and then use pg_get_serial_sequence on those rows?

For example:

WITH table_columns AS (SELECT table_name, column_name FROM information_schema.columns WHERE table_schema = 'public')
SELECT *, pg_get_serial_sequence (table_name, column_name) FROM table_columns
WHERE pg_get_serial_sequence (table_name, column_name) IS NOT NULL;

or maybe

WITH table_columns AS (SELECT table_name, column_name FROM information_schema.columns WHERE table_schema = 'public'),
serial_sequences AS (SELECT *, pg_get_serial_sequence (table_name, column_name) AS p FROM table_columns)
SELECT * FROM serial_sequences WHERE p IS NOT NULL;

@mattmundell
Copy link
Contributor

I presume that WITH clauses are always evaluated before the selected columns, but I did expect a solution like Timo's first example (because it's clearer that the pg_get_serial_sequence is done later).

Don't mind either way, but would like to see a summary of the explanation from #611 in a comment above the statement.

CHANGELOG.md Outdated Show resolved Hide resolved
vulnbe and others added 3 commits August 7, 2019 18:21
Co-Authored-By: Matt Mundell <32057441+mattmundell@users.noreply.github.com>
@mattmundell mattmundell merged commit 489cbcb into greenbone:master Aug 13, 2019
@mattmundell
Copy link
Contributor

Thank you!

@asmaack
Copy link

asmaack commented Aug 13, 2019

Will you merge this into gvmd-8.0 as well?
:-)

@mattmundell mattmundell mentioned this pull request Aug 13, 2019
2 tasks
@mattmundell
Copy link
Contributor

Will you merge this into gvmd-8.0 as well?
:-)

PR for this: #691

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants