Compare commits
4 Commits
master
...
utf8-in-la
Author | SHA1 | Date | |
---|---|---|---|
|
c636dfdd55 | ||
|
294c71c4d5 | ||
|
c6df7aa016 | ||
|
8b4a32cedd |
@ -152,6 +152,10 @@ func (this *Inspector) inspectOriginalAndGhostTables() (err error) {
|
|||||||
if column.Name == mappedColumn.Name && column.Type == sql.DateTimeColumnType && mappedColumn.Type == sql.TimestampColumnType {
|
if column.Name == mappedColumn.Name && column.Type == sql.DateTimeColumnType && mappedColumn.Type == sql.TimestampColumnType {
|
||||||
this.migrationContext.MappedSharedColumns.SetConvertDatetimeToTimestamp(column.Name, this.migrationContext.ApplierTimeZone)
|
this.migrationContext.MappedSharedColumns.SetConvertDatetimeToTimestamp(column.Name, this.migrationContext.ApplierTimeZone)
|
||||||
}
|
}
|
||||||
|
if column.Name == mappedColumn.Name && column.Charset != "" && column.Charset == mappedColumn.Charset {
|
||||||
|
this.migrationContext.SharedColumns.SetCharsetUnchanged(column.Name)
|
||||||
|
this.migrationContext.MappedSharedColumns.SetCharsetUnchanged(column.Name)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, column := range this.migrationContext.UniqueKey.Columns.Columns() {
|
for _, column := range this.migrationContext.UniqueKey.Columns.Columns() {
|
||||||
|
@ -38,6 +38,12 @@ func buildColumnsPreparedValues(columns *ColumnList) []string {
|
|||||||
var token string
|
var token string
|
||||||
if column.timezoneConversion != nil {
|
if column.timezoneConversion != nil {
|
||||||
token = fmt.Sprintf("convert_tz(?, '%s', '%s')", column.timezoneConversion.ToTimezone, "+00:00")
|
token = fmt.Sprintf("convert_tz(?, '%s', '%s')", column.timezoneConversion.ToTimezone, "+00:00")
|
||||||
|
} else if column.CharsetUnchanged {
|
||||||
|
token = "?"
|
||||||
|
// token = fmt.Sprintf("BINARY ?")
|
||||||
|
//token = fmt.Sprintf("_%s ?", column.Charset)
|
||||||
|
// token = fmt.Sprintf("convert(? using %s)", column.Charset)
|
||||||
|
// token = fmt.Sprintf("convert(?, char character set %s)", column.Charset)
|
||||||
} else {
|
} else {
|
||||||
token = "?"
|
token = "?"
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,8 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/outbrain/golib/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ColumnType int
|
type ColumnType int
|
||||||
@ -29,15 +31,23 @@ type Column struct {
|
|||||||
Name string
|
Name string
|
||||||
IsUnsigned bool
|
IsUnsigned bool
|
||||||
Charset string
|
Charset string
|
||||||
|
CharsetUnchanged bool
|
||||||
Type ColumnType
|
Type ColumnType
|
||||||
timezoneConversion *TimezoneConvertion
|
timezoneConversion *TimezoneConvertion
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Column) convertArg(arg interface{}) interface{} {
|
func (this *Column) convertArg(arg interface{}) interface{} {
|
||||||
if s, ok := arg.(string); ok {
|
if s, ok := arg.(string); ok {
|
||||||
|
if this.CharsetUnchanged {
|
||||||
|
log.Errorf("============== charset unchanged for %+v: %+v, <%+v>", this.Name, this.Charset, arg)
|
||||||
|
// return []byte(s)
|
||||||
|
//return s
|
||||||
|
}
|
||||||
|
log.Errorf("============== charset for %+v: %+v, <%+v>", this.Name, this.Charset, arg)
|
||||||
// string, charset conversion
|
// string, charset conversion
|
||||||
if encoding, ok := charsetEncodingMap[this.Charset]; ok {
|
if encoding, ok := charsetEncodingMap[this.Charset]; ok {
|
||||||
arg, _ = encoding.NewDecoder().String(s)
|
arg, _ = encoding.NewDecoder().String(s)
|
||||||
|
log.Errorf("============== charset converted for %+v: %+v, <%+v>", this.Name, this.Charset, arg)
|
||||||
}
|
}
|
||||||
return arg
|
return arg
|
||||||
}
|
}
|
||||||
@ -142,6 +152,10 @@ func (this *ColumnList) IsUnsigned(columnName string) bool {
|
|||||||
return this.GetColumn(columnName).IsUnsigned
|
return this.GetColumn(columnName).IsUnsigned
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *ColumnList) SetCharsetUnchanged(columnName string) {
|
||||||
|
this.GetColumn(columnName).CharsetUnchanged = true
|
||||||
|
}
|
||||||
|
|
||||||
func (this *ColumnList) SetCharset(columnName string, charset string) {
|
func (this *ColumnList) SetCharset(columnName string, charset string) {
|
||||||
this.GetColumn(columnName).Charset = charset
|
this.GetColumn(columnName).Charset = charset
|
||||||
}
|
}
|
||||||
|
20
localtests/utf8-in-latin1/create.sql
Normal file
20
localtests/utf8-in-latin1/create.sql
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
drop table if exists gh_ost_test;
|
||||||
|
create table gh_ost_test (
|
||||||
|
id int auto_increment,
|
||||||
|
t varchar(128) charset latin1 collate latin1_swedish_ci,
|
||||||
|
primary key(id)
|
||||||
|
) auto_increment=1 charset utf8;
|
||||||
|
|
||||||
|
drop event if exists gh_ost_test;
|
||||||
|
delimiter ;;
|
||||||
|
create event gh_ost_test
|
||||||
|
on schedule every 1 second
|
||||||
|
starts current_timestamp
|
||||||
|
ends current_timestamp + interval 60 second
|
||||||
|
on completion not preserve
|
||||||
|
enable
|
||||||
|
do
|
||||||
|
begin
|
||||||
|
set names latin1;
|
||||||
|
insert into gh_ost_test values (null, 'א') ;
|
||||||
|
end ;;
|
Loading…
Reference in New Issue
Block a user