Published poroperty TMySQL50Connection.CharSet does not work.
Original Reporter info from Mantis: taka_jp
-
Reporter name: removed
Original Reporter info from Mantis: taka_jp
- Reporter name: removed
Description:
fpcsrc/packages/fcl-db/src/sqldb/mysql/mysqlconn.inc
Published poroperty TMySQL50Connection.CharSet does not work.
MySQL server (version 4.1 and later) support
SQL command : SET CHARACTER SET charset_name
When MySQL client default charset is differrent from Application charset,MySQL couse various error often.
at design time
- can not view tables named by non ascii.
resolution : [modify procedure ConnectMySQL]
at run time
- can not create and remove Database named by non ascii.
procedure TConnectionName.CreateDB TConnectionName.DropDB
resolution : [modify procedure ConnectMySQL]
- can not view and edit tables because of char is broken by diffrent charset is setting.
resolution : [AfterConnect event] or [modify procedure ConnectMySQL]
- TConnectionName.ExecuteDirectMySQL couse various error when sqltext is non ascii charset.
resolution : [modify procedure ConnectMySQL]
Additional information:
suggestion
--- fpcsrc/packages/fcl-db/src/sqldb/mysql/mysqlconn.inc.orig 2008-11-15 01:04:16.000000000 +0900
+++ fpcsrc/packages/fcl-db/src/sqldb/mysql/mysqlconn.inc 2009-04-25 09:10:43.828125000 +0900
@@ -232,6 +232,15 @@
HMySQL:=mysql_real_connect(HMySQL,PChar(H),PChar(U),Pchar(P),Nil,APort,Nil,0);
If (HMySQL=Nil) then
MySQlError(Nil,SErrServerConnectFailed,Self);
+
+ (* MySQL version 4.1 and later *)
+ (* major_version*10000 + minor_version *100 + sub_version *)
+ if (HMySQL <> Nil)
+ and (4*10000 + 1*100 <= mysql_get_server_version(HMySQL))
+ and (trim(CharSet) <> '') then
+// if (mysql_set_character_set(HMySQL, PChar(CharSet)) <> 0) then
+ if mysql_query(FMySQL,PChar('SET CHARACTER SET ' + QuotedStr(CharSet) ))<>0 then
+ MySQLError(HMySQL,Format(SErrExecuting,[StrPas(mysql_error(HMySQL))]),Self);
end;
function TConnectionName.GetAsSQLText(Field : TField) : string;
Mantis conversion info:
- Mantis ID: 13588
- Version: 2.2.4
- Fixed in version: 2.4.0
- Fixed in revision: 13189 (#2435a4a4)
- Target version: 2.4.0