Skip to content

Commit 991a506

Browse files
Merge branch 'main' into crash-sqlite
2 parents d980943 + d7f56e8 commit 991a506

17 files changed

+1020
-204
lines changed

src/ast/helpers/stmt_create_database.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,14 @@ pub struct CreateDatabaseBuilder {
8585
pub storage_serialization_policy: Option<StorageSerializationPolicy>,
8686
/// Optional comment attached to the database.
8787
pub comment: Option<String>,
88+
/// Optional default character set (MySQL).
89+
///
90+
/// <https://dev.mysql.com/doc/refman/8.4/en/create-database.html>
91+
pub default_charset: Option<String>,
92+
/// Optional default collation (MySQL).
93+
///
94+
/// <https://dev.mysql.com/doc/refman/8.4/en/create-database.html>
95+
pub default_collation: Option<String>,
8896
/// Optional catalog sync configuration.
8997
pub catalog_sync: Option<String>,
9098
/// Optional catalog sync namespace mode.
@@ -120,6 +128,8 @@ impl CreateDatabaseBuilder {
120128
default_ddl_collation: None,
121129
storage_serialization_policy: None,
122130
comment: None,
131+
default_charset: None,
132+
default_collation: None,
123133
catalog_sync: None,
124134
catalog_sync_namespace_mode: None,
125135
catalog_sync_namespace_flatten_delimiter: None,
@@ -218,6 +228,18 @@ impl CreateDatabaseBuilder {
218228
self
219229
}
220230

231+
/// Set the default character set for the database.
232+
pub fn default_charset(mut self, default_charset: Option<String>) -> Self {
233+
self.default_charset = default_charset;
234+
self
235+
}
236+
237+
/// Set the default collation for the database.
238+
pub fn default_collation(mut self, default_collation: Option<String>) -> Self {
239+
self.default_collation = default_collation;
240+
self
241+
}
242+
221243
/// Set the catalog sync for the database.
222244
pub fn catalog_sync(mut self, catalog_sync: Option<String>) -> Self {
223245
self.catalog_sync = catalog_sync;
@@ -272,6 +294,8 @@ impl CreateDatabaseBuilder {
272294
default_ddl_collation: self.default_ddl_collation,
273295
storage_serialization_policy: self.storage_serialization_policy,
274296
comment: self.comment,
297+
default_charset: self.default_charset,
298+
default_collation: self.default_collation,
275299
catalog_sync: self.catalog_sync,
276300
catalog_sync_namespace_mode: self.catalog_sync_namespace_mode,
277301
catalog_sync_namespace_flatten_delimiter: self.catalog_sync_namespace_flatten_delimiter,
@@ -302,6 +326,8 @@ impl TryFrom<Statement> for CreateDatabaseBuilder {
302326
default_ddl_collation,
303327
storage_serialization_policy,
304328
comment,
329+
default_charset,
330+
default_collation,
305331
catalog_sync,
306332
catalog_sync_namespace_mode,
307333
catalog_sync_namespace_flatten_delimiter,
@@ -323,6 +349,8 @@ impl TryFrom<Statement> for CreateDatabaseBuilder {
323349
default_ddl_collation,
324350
storage_serialization_policy,
325351
comment,
352+
default_charset,
353+
default_collation,
326354
catalog_sync,
327355
catalog_sync_namespace_mode,
328356
catalog_sync_namespace_flatten_delimiter,

src/ast/mod.rs

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ pub use self::dml::{
8787
};
8888
pub use self::operator::{BinaryOperator, UnaryOperator};
8989
pub use self::query::{
90-
AfterMatchSkip, ConnectBy, Cte, CteAsMaterialized, Distinct, EmptyMatchesMode,
90+
AfterMatchSkip, ConnectByKind, Cte, CteAsMaterialized, Distinct, EmptyMatchesMode,
9191
ExceptSelectItem, ExcludeSelectItem, ExprWithAlias, ExprWithAliasAndOrderBy, Fetch, ForClause,
9292
ForJson, ForXml, FormatClause, GroupByExpr, GroupByWithModifier, IdentWithAlias,
9393
IlikeSelectItem, InputFormatClause, Interpolate, InterpolateExpr, Join, JoinConstraint,
@@ -97,14 +97,15 @@ pub use self::query::{
9797
OffsetRows, OpenJsonTableColumn, OrderBy, OrderByExpr, OrderByKind, OrderByOptions,
9898
PipeOperator, PivotValueSource, ProjectionSelect, Query, RenameSelectItem,
9999
RepetitionQuantifier, ReplaceSelectElement, ReplaceSelectItem, RowsPerMatch, Select,
100-
SelectFlavor, SelectInto, SelectItem, SelectItemQualifiedWildcardKind, SetExpr, SetOperator,
101-
SetQuantifier, Setting, SymbolDefinition, Table, TableAlias, TableAliasColumnDef, TableFactor,
102-
TableFunctionArgs, TableIndexHintForClause, TableIndexHintType, TableIndexHints,
103-
TableIndexType, TableSample, TableSampleBucket, TableSampleKind, TableSampleMethod,
104-
TableSampleModifier, TableSampleQuantity, TableSampleSeed, TableSampleSeedModifier,
105-
TableSampleUnit, TableVersion, TableWithJoins, Top, TopQuantity, UpdateTableFromKind,
106-
ValueTableMode, Values, WildcardAdditionalOptions, With, WithFill, XmlNamespaceDefinition,
107-
XmlPassingArgument, XmlPassingClause, XmlTableColumn, XmlTableColumnOption,
100+
SelectFlavor, SelectInto, SelectItem, SelectItemQualifiedWildcardKind, SelectModifiers,
101+
SetExpr, SetOperator, SetQuantifier, Setting, SymbolDefinition, Table, TableAlias,
102+
TableAliasColumnDef, TableFactor, TableFunctionArgs, TableIndexHintForClause,
103+
TableIndexHintType, TableIndexHints, TableIndexType, TableSample, TableSampleBucket,
104+
TableSampleKind, TableSampleMethod, TableSampleModifier, TableSampleQuantity, TableSampleSeed,
105+
TableSampleSeedModifier, TableSampleUnit, TableVersion, TableWithJoins, Top, TopQuantity,
106+
UpdateTableFromKind, ValueTableMode, Values, WildcardAdditionalOptions, With, WithFill,
107+
XmlNamespaceDefinition, XmlPassingArgument, XmlPassingClause, XmlTableColumn,
108+
XmlTableColumnOption,
108109
};
109110

110111
pub use self::trigger::{
@@ -4226,6 +4227,10 @@ pub enum Statement {
42264227
storage_serialization_policy: Option<StorageSerializationPolicy>,
42274228
/// Optional comment.
42284229
comment: Option<String>,
4230+
/// Optional default character set (MySQL).
4231+
default_charset: Option<String>,
4232+
/// Optional default collation (MySQL).
4233+
default_collation: Option<String>,
42294234
/// Optional catalog sync identifier.
42304235
catalog_sync: Option<String>,
42314236
/// Catalog sync namespace mode.
@@ -5080,6 +5085,8 @@ impl fmt::Display for Statement {
50805085
default_ddl_collation,
50815086
storage_serialization_policy,
50825087
comment,
5088+
default_charset,
5089+
default_collation,
50835090
catalog_sync,
50845091
catalog_sync_namespace_mode,
50855092
catalog_sync_namespace_flatten_delimiter,
@@ -5139,6 +5146,14 @@ impl fmt::Display for Statement {
51395146
write!(f, " COMMENT = '{comment}'")?;
51405147
}
51415148

5149+
if let Some(charset) = default_charset {
5150+
write!(f, " DEFAULT CHARACTER SET {charset}")?;
5151+
}
5152+
5153+
if let Some(collation) = default_collation {
5154+
write!(f, " DEFAULT COLLATE {collation}")?;
5155+
}
5156+
51425157
if let Some(sync) = catalog_sync {
51435158
write!(f, " CATALOG_SYNC = '{sync}'")?;
51445159
}

0 commit comments

Comments
 (0)