-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d9b0023
commit f7b9b90
Showing
6 changed files
with
255 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
use anyhow::{anyhow, Error, Result}; | ||
|
||
#[derive(Debug, Clone, Copy, PartialEq, Eq)] | ||
pub enum InnoDBCharset { | ||
Armscii8, | ||
Ascii, | ||
Big5, | ||
Binary, | ||
Cp1250, | ||
Cp1251, | ||
Cp1256, | ||
Cp1257, | ||
Cp850, | ||
Cp852, | ||
Cp866, | ||
Cp932, | ||
Dec8, | ||
Eucjpms, | ||
Euckr, | ||
Gb18030, | ||
Gb2312, | ||
Gbk, | ||
Geostd8, | ||
Greek, | ||
Hebrew, | ||
Hp8, | ||
Keybcs2, | ||
Koi8r, | ||
Koi8u, | ||
Latin1, | ||
Latin2, | ||
Latin5, | ||
Latin7, | ||
Macce, | ||
Macroman, | ||
Sjis, | ||
Swe7, | ||
Tis620, | ||
Ucs2, | ||
Ujis, | ||
Utf16, | ||
Utf16le, | ||
Utf32, | ||
Utf8mb3, | ||
Utf8mb4, | ||
} | ||
|
||
impl InnoDBCharset { | ||
pub fn with_name(name: &str) -> Result<Self> { | ||
match name { | ||
"armscii8" => Ok(Self::Armscii8), | ||
"ascii" => Ok(Self::Ascii), | ||
"big5" => Ok(Self::Big5), | ||
"binary" => Ok(Self::Binary), | ||
"cp1250" => Ok(Self::Cp1250), | ||
"cp1251" => Ok(Self::Cp1251), | ||
"cp1256" => Ok(Self::Cp1256), | ||
"cp1257" => Ok(Self::Cp1257), | ||
"cp850" => Ok(Self::Cp850), | ||
"cp852" => Ok(Self::Cp852), | ||
"cp866" => Ok(Self::Cp866), | ||
"cp932" => Ok(Self::Cp932), | ||
"dec8" => Ok(Self::Dec8), | ||
"eucjpms" => Ok(Self::Eucjpms), | ||
"euckr" => Ok(Self::Euckr), | ||
"gb18030" => Ok(Self::Gb18030), | ||
"gb2312" => Ok(Self::Gb2312), | ||
"gbk" => Ok(Self::Gbk), | ||
"geostd8" => Ok(Self::Geostd8), | ||
"greek" => Ok(Self::Greek), | ||
"hebrew" => Ok(Self::Hebrew), | ||
"hp8" => Ok(Self::Hp8), | ||
"keybcs2" => Ok(Self::Keybcs2), | ||
"koi8r" => Ok(Self::Koi8r), | ||
"koi8u" => Ok(Self::Koi8u), | ||
"latin1" => Ok(Self::Latin1), | ||
"latin2" => Ok(Self::Latin2), | ||
"latin5" => Ok(Self::Latin5), | ||
"latin7" => Ok(Self::Latin7), | ||
"macce" => Ok(Self::Macce), | ||
"macroman" => Ok(Self::Macroman), | ||
"sjis" => Ok(Self::Sjis), | ||
"swe7" => Ok(Self::Swe7), | ||
"tis620" => Ok(Self::Tis620), | ||
"ucs2" => Ok(Self::Ucs2), | ||
"ujis" => Ok(Self::Ujis), | ||
"utf16" => Ok(Self::Utf16), | ||
"utf16le" => Ok(Self::Utf16le), | ||
"utf32" => Ok(Self::Utf32), | ||
"utf8mb3" => Ok(Self::Utf8mb3), | ||
"utf8mb4" => Ok(Self::Utf8mb4), | ||
_ => Err(Error::msg(format!("Unknown charset: {}", name))), | ||
} | ||
} | ||
|
||
pub fn max_len(&self) -> u8 { | ||
match self { | ||
InnoDBCharset::Armscii8 => 1, | ||
InnoDBCharset::Ascii => 1, | ||
InnoDBCharset::Big5 => 2, | ||
InnoDBCharset::Binary => 1, | ||
InnoDBCharset::Cp1250 => 1, | ||
InnoDBCharset::Cp1251 => 1, | ||
InnoDBCharset::Cp1256 => 1, | ||
InnoDBCharset::Cp1257 => 1, | ||
InnoDBCharset::Cp850 => 1, | ||
InnoDBCharset::Cp852 => 1, | ||
InnoDBCharset::Cp866 => 1, | ||
InnoDBCharset::Cp932 => 2, | ||
InnoDBCharset::Dec8 => 1, | ||
InnoDBCharset::Eucjpms => 3, | ||
InnoDBCharset::Euckr => 2, | ||
InnoDBCharset::Gb18030 => 4, | ||
InnoDBCharset::Gb2312 => 2, | ||
InnoDBCharset::Gbk => 2, | ||
InnoDBCharset::Geostd8 => 1, | ||
InnoDBCharset::Greek => 1, | ||
InnoDBCharset::Hebrew => 1, | ||
InnoDBCharset::Hp8 => 1, | ||
InnoDBCharset::Keybcs2 => 1, | ||
InnoDBCharset::Koi8r => 1, | ||
InnoDBCharset::Koi8u => 1, | ||
InnoDBCharset::Latin1 => 1, | ||
InnoDBCharset::Latin2 => 1, | ||
InnoDBCharset::Latin5 => 1, | ||
InnoDBCharset::Latin7 => 1, | ||
InnoDBCharset::Macce => 1, | ||
InnoDBCharset::Macroman => 1, | ||
InnoDBCharset::Sjis => 2, | ||
InnoDBCharset::Swe7 => 1, | ||
InnoDBCharset::Tis620 => 1, | ||
InnoDBCharset::Ucs2 => 2, | ||
InnoDBCharset::Ujis => 3, | ||
InnoDBCharset::Utf16 => 4, | ||
InnoDBCharset::Utf16le => 4, | ||
InnoDBCharset::Utf32 => 4, | ||
InnoDBCharset::Utf8mb3 => 3, | ||
InnoDBCharset::Utf8mb4 => 4, | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
CREATE TABLE `pre_ucenter_members` ( | ||
`uid` mediumint unsigned NOT NULL AUTO_INCREMENT, | ||
`username` char(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', | ||
`password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', | ||
`secmobicc` varchar(3) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', | ||
`secmobile` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', | ||
`email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', | ||
`myid` char(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', | ||
`myidkey` char(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', | ||
`regip` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', | ||
`regdate` int unsigned NOT NULL DEFAULT '0', | ||
`lastloginip` int NOT NULL DEFAULT '0', | ||
`lastlogintime` int unsigned NOT NULL DEFAULT '0', | ||
`salt` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', | ||
`secques` char(8) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', | ||
PRIMARY KEY (`uid`), | ||
UNIQUE KEY `username` (`username`) | ||
) ENGINE=InnoDB AUTO_INCREMENT=477152 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; |