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

add database name to _vt.views table #12368

Merged
merged 1 commit into from
Feb 15, 2023
Merged
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
18 changes: 10 additions & 8 deletions go/mysql/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,30 +88,32 @@ order by table_name, ordinal_position`

// Views
InsertIntoViewsTable = `insert into _vt.views (
table_schema,
table_name,
view_definition,
create_statement) values (:table_name, :view_definition, :create_statement)`
create_statement) values (database(), :table_name, :view_definition, :create_statement)`

ReplaceIntoViewsTable = `replace into _vt.views (
table_schema,
table_name,
view_definition,
create_statement) values (:table_name, :view_definition, :create_statement)`
create_statement) values (database(), :table_name, :view_definition, :create_statement)`

UpdateViewsTable = `update _vt.views
set view_definition = :view_definition, create_statement = :create_statement
where table_name = :table_name`
where table_schema = database() and table_name = :table_name`

DeleteFromViewsTable = `delete from _vt.views where table_name in ::table_name`
DeleteFromViewsTable = `delete from _vt.views where table_schema = database() and table_name in ::table_name`

SelectFromViewsTable = `select table_name from _vt.views where table_name in ::table_name`
SelectFromViewsTable = `select table_name from _vt.views where table_schema = database() and table_name in ::table_name`

SelectAllViews = `select table_name, updated_at from _vt.views`
SelectAllViews = `select table_name, updated_at from _vt.views where table_schema = database()`

// FetchUpdatedViews queries fetches information about updated views
FetchUpdatedViews = `select table_name, view_definition, create_statement from _vt.views where table_name in ::viewnames`
FetchUpdatedViews = `select table_name, view_definition, create_statement from _vt.views where table_schema = database() and table_name in ::viewnames`

// FetchViews queries fetches all views
FetchViews = `select table_name, view_definition, create_statement from _vt.views`
FetchViews = `select table_name, view_definition, create_statement from _vt.views where table_schema = database()`
)

// BaseShowTablesFields contains the fields returned by a BaseShowTables or a BaseShowTablesForTable command.
Expand Down
3 changes: 2 additions & 1 deletion go/vt/sidecardb/schema/misc/views.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ limitations under the License.

CREATE TABLE IF NOT EXISTS _vt.views
(
TABLE_SCHEMA varchar(64) NOT NULL,
TABLE_NAME varchar(64) NOT NULL,
VIEW_DEFINITION longtext NOT NULL,
CREATE_STATEMENT longtext NOT NULL,
UPDATED_AT TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (TABLE_NAME)
PRIMARY KEY (TABLE_SCHEMA, TABLE_NAME)
) engine = InnoDB