2
2
using System ;
3
3
using System . Collections . Generic ;
4
4
using System . Data ;
5
+ using System . Data . Common ;
5
6
using System . Linq ;
6
7
using MySql . Data . MySqlClient ;
7
8
@@ -14,6 +15,7 @@ public SchemaProvider(MySqlConnection connection)
14
15
m_connection = connection ;
15
16
m_schemaCollections = new Dictionary < string , Action < DataTable > >
16
17
{
18
+ { "DataSourceInformation" , FillDataSourceInformation } ,
17
19
{ "MetaDataCollections" , FillMetadataCollections } ,
18
20
{ "CharacterSets" , FillCharacterSets } ,
19
21
{ "Collations" , FillCollations } ,
@@ -58,6 +60,55 @@ public DataTable GetSchema(string collectionName)
58
60
return dataTable ;
59
61
}
60
62
63
+ private void FillDataSourceInformation ( DataTable dataTable )
64
+ {
65
+ dataTable . Columns . AddRange ( new [ ] {
66
+ new DataColumn ( "CompositeIdentifierSeparatorPattern" , typeof ( string ) ) ,
67
+ new DataColumn ( "DataSourceProductName" , typeof ( string ) ) ,
68
+ new DataColumn ( "DataSourceProductVersion" , typeof ( string ) ) ,
69
+ new DataColumn ( "DataSourceProductVersionNormalized" , typeof ( string ) ) ,
70
+ new DataColumn ( "GroupByBehavior" , typeof ( GroupByBehavior ) ) ,
71
+ new DataColumn ( "IdentifierPattern" , typeof ( string ) ) ,
72
+ new DataColumn ( "IdentifierCase" , typeof ( IdentifierCase ) ) ,
73
+ new DataColumn ( "OrderByColumnsInSelect" , typeof ( bool ) ) ,
74
+ new DataColumn ( "ParameterMarkerFormat" , typeof ( string ) ) ,
75
+ new DataColumn ( "ParameterMarkerPattern" , typeof ( string ) ) ,
76
+ new DataColumn ( "ParameterNameMaxLength" , typeof ( int ) ) ,
77
+ new DataColumn ( "QuotedIdentifierPattern" , typeof ( string ) ) ,
78
+ new DataColumn ( "QuotedIdentifierCase" , typeof ( IdentifierCase ) ) ,
79
+ new DataColumn ( "ParameterNamePattern" , typeof ( string ) ) ,
80
+ new DataColumn ( "StatementSeparatorPattern" , typeof ( string ) ) ,
81
+ new DataColumn ( "StringLiteralPattern" , typeof ( string ) ) ,
82
+ new DataColumn ( "SupportedJoinOperators" , typeof ( SupportedJoinOperators ) )
83
+ } ) ;
84
+
85
+ var row = dataTable . NewRow ( ) ;
86
+ row [ "CompositeIdentifierSeparatorPattern" ] = @"\." ;
87
+ row [ "DataSourceProductName" ] = "MySQL" ;
88
+ row [ "DataSourceProductVersion" ] = m_connection . ServerVersion ;
89
+ row [ "DataSourceProductVersionNormalized" ] = GetVersion ( m_connection . Session . ServerVersion . Version ) ;
90
+ row [ "GroupByBehavior" ] = GroupByBehavior . Unrelated ;
91
+ row [ "IdentifierPattern" ] = @"(^\[\p{Lo}\p{Lu}\p{Ll}_@#][\p{Lo}\p{Lu}\p{Ll}\p{Nd}@$#_]*$)|(^\[[^\]\0]|\]\]+\]$)|(^\""[^\""\0]|\""\""+\""$)" ;
92
+ row [ "IdentifierCase" ] = IdentifierCase . Insensitive ;
93
+ row [ "OrderByColumnsInSelect" ] = false ;
94
+ row [ "ParameterMarkerFormat" ] = @"{0}" ;
95
+ row [ "ParameterMarkerPattern" ] = @"(@[A-Za-z0-9_$#]*)" ;
96
+ row [ "ParameterNameMaxLength" ] = 128 ; // For function out parameters
97
+ row [ "QuotedIdentifierPattern" ] = @"(([^\`]|\`\`)*)" ;
98
+ row [ "QuotedIdentifierCase" ] = IdentifierCase . Sensitive ;
99
+ row [ "ParameterNamePattern" ] = @"^[\p{Lo}\p{Lu}\p{Ll}\p{Lm}_@#][\p{Lo}\p{Lu}\p{Ll}\p{Lm}\p{Nd}\uff3f_@#\$]*(?=\s+|$)" ;
100
+ row [ "StatementSeparatorPattern" ] = ";" ;
101
+ row [ "StringLiteralPattern" ] = @"'(([^']|'')*)'" ;
102
+ row [ "SupportedJoinOperators" ] =
103
+ SupportedJoinOperators . FullOuter |
104
+ SupportedJoinOperators . Inner |
105
+ SupportedJoinOperators . LeftOuter |
106
+ SupportedJoinOperators . RightOuter ;
107
+ dataTable . Rows . Add ( row ) ;
108
+ }
109
+
110
+ private string GetVersion ( Version v ) => $ "{ v . Major : 00} .{ v . Minor : 00} .{ v . Build : 0000} ";
111
+
61
112
private void FillMetadataCollections ( DataTable dataTable )
62
113
{
63
114
dataTable . Columns . AddRange ( new [ ] {
0 commit comments