jackc / pgx

PostgreSQL driver and toolkit for Go
MIT License
10.83k stars 845 forks source link

PGX returns no data instead of Error if user doesn't have select permission #2143

Closed abdelaziz-ouhammou closed 1 month ago

abdelaziz-ouhammou commented 1 month ago

Describe the bug If a user doesn't have select permission on a table. the driver returns an empty result instead of an error

To Reproduce Steps to reproduce the behavior:

  1. Create a table in PostgreSQL 15 using postgres user
  2. Run a select query using another user that was not explicitly granted permissions
  3. The query result will be empty instead of an error

Expected behavior expected to receive an error.

Actual behavior empty result with no error

Version

jackc commented 1 month ago

I would guess not checking the rows.Err() is the problem. From the docs:

Query sends a query to the server and returns a Rows to read the results. Only errors encountered sending the query and initializing Rows will be returned. Err() on the returned Rows must be checked after the Rows is closed to determine if the query executed successfully.

abdelaziz-ouhammou commented 1 month ago

Thank you very much for your support.