From 08466995e5baadb163adec1f08e0f0062eca6518 Mon Sep 17 00:00:00 2001 From: Harshit Gangal Date: Tue, 14 Feb 2023 17:44:19 +0530 Subject: [PATCH] add database name to _vt.views table Signed-off-by: Harshit Gangal --- go/mysql/schema.go | 18 ++++++++++-------- go/vt/sidecardb/schema/misc/views.sql | 3 ++- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/go/mysql/schema.go b/go/mysql/schema.go index 5029dd86ef7..a85d140fef9 100644 --- a/go/mysql/schema.go +++ b/go/mysql/schema.go @@ -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. diff --git a/go/vt/sidecardb/schema/misc/views.sql b/go/vt/sidecardb/schema/misc/views.sql index 1d31a648a1b..bc14b13e74f 100644 --- a/go/vt/sidecardb/schema/misc/views.sql +++ b/go/vt/sidecardb/schema/misc/views.sql @@ -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