summaryrefslogtreecommitdiff
path: root/sql/sql_show.cc
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 /sql/sql_show.cc
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 'sql/sql_show.cc')
-rw-r--r--sql/sql_show.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index b1cc696e9fe..b4d91b050bc 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -6867,6 +6867,10 @@ static int get_schema_views_record(THD *thd, TABLE_LIST *tables,
table->field[10]->store(view_algorithm(tables), cs);
+ if (tables->allowed_show)
+ table->field[11]->store(tables->source.str, tables->source.length,
+ tables->view_creation_ctx->get_client_cs());
+
if (schema_table_store_record(thd, table))
DBUG_RETURN(1);
if (unlikely(res && thd->is_error()))
@@ -9125,6 +9129,7 @@ ST_FIELD_INFO view_fields_info[]=
Column("CHARACTER_SET_CLIENT", CSName(), NOT_NULL, OPEN_FRM_ONLY),
Column("COLLATION_CONNECTION", CSName(), NOT_NULL, OPEN_FRM_ONLY),
Column("ALGORITHM", Varchar(10),NOT_NULL, OPEN_FRM_ONLY),
+ Column("SOURCE", Longtext(65535), NOT_NULL, OPEN_FRM_ONLY),
CEnd()
};