-
Notifications
You must be signed in to change notification settings - Fork 3
Select information_schema using a nested query to support WHERE, ORDER BY, and AS #3
Select information_schema using a nested query to support WHERE, ORDER BY, and AS #3
Conversation
TODO: - support WHERE, ORDER... - support AS - ensure all schema fields are correct
/** | ||
* TODO: Return real values for hardcoded column values. | ||
*/ | ||
"(SELECT | ||
'def' as TABLE_CATALOG, | ||
'database' as TABLE_SCHEMA, | ||
name as TABLE_NAME, | ||
CASE type | ||
WHEN 'table' THEN 'BASE TABLE' | ||
WHEN 'view' THEN 'VIEW' | ||
ELSE type | ||
END as TABLE_TYPE, | ||
'InnoDB' as ENGINE, | ||
10 as VERSION, | ||
'Dynamic' as ROW_FORMAT, | ||
0 as TABLE_ROWS, | ||
0 as AVG_ROW_LENGTH, | ||
0 as DATA_LENGTH, | ||
0 as MAX_DATA_LENGTH, | ||
0 as INDEX_LENGTH, | ||
0 as DATA_FREE, | ||
NULL as AUTO_INCREMENT, | ||
NULL as CREATE_TIME, | ||
NULL as UPDATE_TIME, | ||
NULL as CHECK_TIME, | ||
'utf8mb4_general_ci' as TABLE_COLLATION, | ||
NULL as CHECKSUM, | ||
'' as CREATE_OPTIONS, | ||
'' as TABLE_COMMENT | ||
FROM sqlite_master | ||
WHERE type IN ('table', 'view'))", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just left a TODO here instead of working on a way to get real values for hardcoded columns.
@JanJakes I assumed that the work you are doing with AST will resolve this longterm, so I didn't invest extra time in working on it as this is already an improvement that will allow queries to execute correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bgrgicak Yes, it will. The AST driver already store all this information and uses it for SHOW and other statements, but it doesn't yet translate information_schema.tables
to the correct table name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, left a comment about a check that I am doubtful about.
Before this PR information schema queries always executed hardcoded queries, which made it impossible to use WHERE, ORDER, and AS in information schema queries.
This PR adds support for executing information schema queries instead of running hardcoded queries defined by this plugin. This means we can use WHERE, ORDER, AS, and other select query clauses.
Thanks @ashfame for working with me on this PR!
Testing