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

Correct FROM of some queries to the right schema #1295

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

### Fixed
- Use GMP version with leading zero for feed dirs [#1287](https://github.com/greenbone/gvmd/pull/1287)
- Correct FROM of some queries to the right schema [#1295](https://github.com/greenbone/gvmd/pull/1295)

### Removed
- Reduce Severity Classes [#1285](https://github.com/greenbone/gvmd/pull/1285)
Expand Down
2 changes: 1 addition & 1 deletion src/manage_pg.c
Original file line number Diff line number Diff line change
Expand Up @@ -3133,7 +3133,7 @@ manage_db_init (const gchar *name)
sql ("CREATE OR REPLACE FUNCTION cert.cert_delete_bund_adv ()"
" RETURNS TRIGGER AS $$"
" BEGIN"
" DELETE FROM cert_bund_cves where adv_id = old.id;"
" DELETE FROM cert.cert_bund_cves where adv_id = old.id;"
" RETURN old;"
" END;"
"$$ LANGUAGE plpgsql;");
Expand Down
10 changes: 5 additions & 5 deletions src/manage_sql.c
Original file line number Diff line number Diff line change
Expand Up @@ -32440,7 +32440,7 @@ check_for_new_cert ()
if (manage_cert_loaded ())
{
if (sql_int ("SELECT EXISTS"
" (SELECT * FROM cert_bund_advs"
" (SELECT * FROM cert.cert_bund_advs"
" WHERE creation_time"
" > coalesce (CAST ((SELECT value FROM meta"
" WHERE name"
Expand Down Expand Up @@ -32811,11 +32811,11 @@ new_cert_bunds_list (event_t event, const void* event_data, alert_t alert,
count = 0;
if (example)
init_iterator (&rows,
"SELECT uuid, name, title FROM cert_bund_advs"
"SELECT uuid, name, title FROM cert.cert_bund_advs"
" LIMIT 4;");
else if (event == EVENT_NEW_SECINFO)
init_iterator (&rows,
"SELECT uuid, name, title FROM cert_bund_advs"
"SELECT uuid, name, title FROM cert.cert_bund_advs"
" WHERE creation_time"
" > coalesce (CAST ((SELECT value FROM meta"
" WHERE name"
Expand All @@ -32825,7 +32825,7 @@ new_cert_bunds_list (event_t event, const void* event_data, alert_t alert,
" ORDER BY creation_time DESC;");
else
init_iterator (&rows,
"SELECT uuid, name, title FROM cert_bund_advs"
"SELECT uuid, name, title FROM cert.cert_bund_advs"
" WHERE modification_time"
" > coalesce (CAST ((SELECT value FROM meta"
" WHERE name"
Expand Down Expand Up @@ -33218,7 +33218,7 @@ check_for_updated_cert ()
if (manage_cert_loaded ())
{
if (sql_int ("SELECT EXISTS"
" (SELECT * FROM cert_bund_advs"
" (SELECT * FROM cert.cert_bund_advs"
" WHERE modification_time"
" > coalesce (CAST ((SELECT value FROM meta"
" WHERE name"
Expand Down
10 changes: 5 additions & 5 deletions src/manage_sql_secinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -1292,8 +1292,8 @@ init_cve_cert_bund_adv_iterator (iterator_t *iterator, const char *cve,
columns = columns_build_select (select_columns);
init_iterator (iterator,
"SELECT %s"
" FROM cert_bund_advs"
" WHERE id IN (SELECT adv_id FROM cert_bund_cves"
" FROM cert.cert_bund_advs"
" WHERE id IN (SELECT adv_id FROM cert.cert_bund_cves"
" WHERE cve_name = '%s')"
" ORDER BY %s %s;",
columns,
Expand All @@ -1316,8 +1316,8 @@ init_nvt_cert_bund_adv_iterator (iterator_t *iterator, const char *oid)

init_iterator (iterator,
"SELECT name"
" FROM cert_bund_advs"
" WHERE id IN (SELECT adv_id FROM cert_bund_cves"
" FROM cert.cert_bund_advs"
" WHERE id IN (SELECT adv_id FROM cert.cert_bund_cves"
" WHERE cve_name IN (SELECT ref_id"
" FROM vt_refs"
" WHERE vt_oid = '%s'"
Expand Down Expand Up @@ -2112,7 +2112,7 @@ update_bund_xml (const gchar *xml_path, int last_cert_update,
sql ("INSERT INTO cert_bund_cves"
" (adv_id, cve_name)"
" VALUES"
" ((SELECT id FROM cert_bund_advs"
" ((SELECT id FROM cert.cert_bund_advs"
" WHERE name = '%s'),"
" '%s')",
quoted_refnum,
Expand Down
6 changes: 3 additions & 3 deletions src/manage_sql_secinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* @brief SQL to check if a result has CERT Bunds.
*/
#define SECINFO_SQL_RESULT_HAS_CERT_BUNDS \
"(SELECT EXISTS (SELECT * FROM cert_bund_cves" \
"(SELECT EXISTS (SELECT * FROM cert.cert_bund_cves" \
" WHERE cve_name IN (SELECT ref_id" \
" FROM vt_refs" \
" WHERE vt_oid = results.nvt" \
Expand All @@ -40,8 +40,8 @@
*/
#define SECINFO_SQL_RESULT_CERT_BUNDS \
"(ARRAY (SELECT name::text" \
" FROM cert_bund_advs" \
" WHERE id IN (SELECT adv_id FROM cert_bund_cves" \
" FROM cert.cert_bund_advs" \
" WHERE id IN (SELECT adv_id FROM cert.cert_bund_cves" \
" WHERE cve_name IN (SELECT ref_id" \
" FROM vt_refs" \
" WHERE vt_oid = results.nvt" \
Expand Down