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

PostgreSQL platform returns system views #6586

Open
aimeos opened this issue Nov 5, 2024 · 0 comments
Open

PostgreSQL platform returns system views #6586

aimeos opened this issue Nov 5, 2024 · 0 comments

Comments

@aimeos
Copy link
Contributor

aimeos commented Nov 5, 2024

Bug Report

Q A
Version 4.2.1/3.9.3

Summary

PostgreSQL platform can return system/internal views when using SQL returned by getListViewsSQL() depending on the privileges of the connected user:
https://github.com/doctrine/dbal/blob/4.2.x/src/Platforms/PostgreSQLPlatform.php#L162-L169

Current behavior

Views from information_schema and pg_catalog are returned by the used query. This behavior is different to other platforms.

Expected behavior

Only user created views from the current database should be returned like done by all other platforms.

How to reproduce

With enough privileges of the connected user, the current SQL SELECT statement will return pg_catalog and information_schema views too:

SELECT quote_ident(table_name) AS viewname,
       table_schema AS schemaname,
       view_definition AS definition
FROM   information_schema.views
WHERE  view_definition IS NOT NULL

To return only user defined views, this SQL SELECT statement must be used:

SELECT quote_ident(table_name) AS viewname,
       table_schema AS schemaname,
       view_definition AS definition
FROM   information_schema.views
WHERE  view_definition IS NOT NULL AND table_schema = ANY(current_schemas(false))

The solution is described here:
https://dba.stackexchange.com/questions/23836/how-to-list-all-views-in-sql-in-postgresql

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

No branches or pull requests

1 participant