summaryrefslogtreecommitdiff
path: root/mysql-test/main/view_source.test
diff options
context:
space:
mode:
authorVicențiu Ciorbaru <vicentiu@mariadb.org>2021-04-16 23:17:36 +0300
committerVicențiu Ciorbaru <vicentiu@mariadb.org>2021-04-16 23:27:31 +0300
commitda0707cadfbc55ff786632a704b0a58c97c9994c (patch)
treebd4b0937cbfce96e0b354cc50e05c3f317cc4e0f /mysql-test/main/view_source.test
parentf74704c7d963ddcd1109843a5861c6bd76409c8d (diff)
downloadmariadb-git-10.6-mdev-10825.tar.gz
MDEV-10825 Feature Request: Persist exact view definitions DDL10.6-mdev-10825
MDEV-13805 SHOW CREATE VIEW don't provide formating in .frm file This patch extends I_S.views with an extra column called SOURCE. "SOURCE" is a verbatim copy of the view's frm field source=... TODO A few feature details need to be ironed out: * Should we make sure that SOURCE is a verbatim copy of create view? Currently we only present the select statement. https://database.guide/4-ways-to-get-a-view-definition-using-transact-sql/ SQL Server for the "definition" column has the following: SELECT definition FROM sys.sql_modules WHERE object_id = object_id('Website.Customers'); +--------------+ | definition | |--------------| | CREATE VIEW Website.Customers AS SELECT s.CustomerID, s.CustomerName, sc.CustomerCategoryName, pp.FullName AS PrimaryContact, ap.FullName AS AlternateContact, s.PhoneNumber, s.FaxNumber, bg.BuyingGroupName, s.WebsiteURL, dm.DeliveryMethodName AS DeliveryMethod, c.CityName AS CityName, s.DeliveryLocation AS DeliveryLocation, s.DeliveryRun, s.RunPosition FROM Sales.Customers AS s LEFT OUTER JOIN Sales.CustomerCategories AS sc ON s.CustomerCategoryID = sc.CustomerCategoryID LEFT OUTER JOIN [Application].People AS pp ON s.PrimaryContactPersonID = pp.PersonID LEFT OUTER JOIN [Application].People AS ap ON s.AlternateContactPersonID = ap.PersonID LEFT OUTER JOIN Sales.BuyingGroups AS bg ON s.BuyingGroupID = bg.BuyingGroupID LEFT OUTER JOIN [Application].DeliveryMethods AS dm ON s.DeliveryMethodID = dm.DeliveryMethodID LEFT OUTER JOIN [Application].Cities AS c ON s.DeliveryCityID = c.CityID | +--------------+ (1 row affected)
Diffstat (limited to 'mysql-test/main/view_source.test')
-rw-r--r--mysql-test/main/view_source.test24
1 files changed, 24 insertions, 0 deletions
diff --git a/mysql-test/main/view_source.test b/mysql-test/main/view_source.test
new file mode 100644
index 00000000000..a4389ff918a
--- /dev/null
+++ b/mysql-test/main/view_source.test
@@ -0,0 +1,24 @@
+SET NAMES utf8;
+create table t1 (a int);
+insert into t1 values (1), (2), (11), (12);
+
+create view v1 as
+ -- Some comment
+ select a as 'ăș' from t1 where a > 10
+ -- Another comment with ășîț
+ order by a
+;
+
+SET NAMES latin1;
+
+show create view v1;
+
+--vertical_results
+select * from information_schema.views where table_schema = 'test';
+
+SET NAMES utf8;
+--vertical_results
+select * from information_schema.views where table_schema = 'test';
+
+drop table t1;
+drop view v1;