Compare commits

...

4 Commits

Author SHA1 Message Date
Shlomi Noach
c636dfdd55 Merge branch 'master' into utf8-in-latin1 2016-11-07 09:39:09 +01:00
Shlomi Noach
294c71c4d5 Merge branch 'master' into utf8-in-latin1 2016-11-04 09:43:38 +01:00
Shlomi Noach
c6df7aa016 WIP: looking into double-charset problems 2016-11-02 12:15:36 +01:00
Shlomi Noach
8b4a32cedd adding tests for latin1 charset column that has utf8 characters 2016-11-01 15:04:14 +01:00
4 changed files with 44 additions and 0 deletions

View File

@ -152,6 +152,10 @@ func (this *Inspector) inspectOriginalAndGhostTables() (err error) {
if column.Name == mappedColumn.Name && column.Type == sql.DateTimeColumnType && mappedColumn.Type == sql.TimestampColumnType {
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() {

View File

@ -38,6 +38,12 @@ func buildColumnsPreparedValues(columns *ColumnList) []string {
var token string
if column.timezoneConversion != nil {
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 {
token = "?"
}

View File

@ -10,6 +10,8 @@ import (
"reflect"
"strconv"
"strings"
"github.com/outbrain/golib/log"
)
type ColumnType int
@ -29,15 +31,23 @@ type Column struct {
Name string
IsUnsigned bool
Charset string
CharsetUnchanged bool
Type ColumnType
timezoneConversion *TimezoneConvertion
}
func (this *Column) convertArg(arg interface{}) interface{} {
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
if encoding, ok := charsetEncodingMap[this.Charset]; ok {
arg, _ = encoding.NewDecoder().String(s)
log.Errorf("============== charset converted for %+v: %+v, <%+v>", this.Name, this.Charset, arg)
}
return arg
}
@ -142,6 +152,10 @@ func (this *ColumnList) IsUnsigned(columnName string) bool {
return this.GetColumn(columnName).IsUnsigned
}
func (this *ColumnList) SetCharsetUnchanged(columnName string) {
this.GetColumn(columnName).CharsetUnchanged = true
}
func (this *ColumnList) SetCharset(columnName string, charset string) {
this.GetColumn(columnName).Charset = charset
}

View 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 ;;