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
MDEV-31125 Add option for default local schema when I_S is queried #2628
Conversation
0eed573
to
848b0e8
Compare
This adds the additional system variable `information_schema_local_database`. When this variable is enabled it will cause built-in `INFORMATION_SCHEMA` tables to use the current database as the `TABLE_SCHEMA` when one has not been explicitly set in a query. This is so that for hosting companies with thousands of databases, these queries that are in applications they cannot control do not hit the disk hard scanning all FRM files. These would not be relevant to the application anyway. `SHOW DATABASES` will still show all databases and if there is no default database currently set then these commands will behave as normal.
This patch: * Adds description code comments to a couple of functions * Explicitly marks a function as static * Uses LEX_CSTRING to remove the usage of `strlen()`
|
Has been reviewed by @montywi. Amendments made:
|
This is weird. Normally, if such an application simply shouldn't have privileges on other schemas, then I_S automatically will only show one schema. Couldn't they do that instead? |
As far as I can tell the privilege check happens at a table level, after the tables have been scanned. So, whilst it only shows a filtered list, it is scanning the FRMs. If the way I'm reading it is true, then that would not solve the problem. |
privileges on databases happen before tables are read. Or should happen, if they don't — we'll fix it. |
Having run some tests and looked through the permissions section better, you are correct, but only at a table level. This patch still solves two problems:
There may be some smart privilege check you can do for part 1 here but I suspect it will be complicated to code up as the privileges system gets more complicated. |
I don't see how these two are "problems". Looks to me like "works as expected". Otherwise I can point out to few more problems:
Back to the PR, why on Earth a user who runs a SELECT with a clear and well defined WHERE clause, gets the result limited by some user variable that he has to set beforehand? |
Closing as we are going to do this a little differently |
This adds the additional system variable
information_schema_local_database
. When this variable is enabled it will cause built-inINFORMATION_SCHEMA
tables andSHOW
commands to use the current database as theTABLE_SCHEMA
when one has not been explicitly set in a query.This is so that for hosting companies with thousands of databases, these queries that are in applications they cannot control do not hit the disk hard scanning all FRM files. These would not be relevant to the application anyway.
SHOW DATABASES
will still show all databases and if there is no default database currently set then these commands will behave as normal.How can this PR be tested?
Regression suite test added.
Basing the PR against the correct MariaDB version
Backward compatibility
New behaviour is off by default.
PR quality check