Skip to content

Commit

Permalink
log
Browse files Browse the repository at this point in the history
  • Loading branch information
xiongjiwei committed Dec 21, 2021
1 parent 15676d6 commit 38bd4d1
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions executor/load_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,9 @@ func (e *LoadDataInfo) getValidData(prevData, curData []byte) ([]byte, []byte) {

func (e *LoadDataInfo) isInQuoter(bs []byte) bool {
inQuoter := false
if e.FieldsInfo.Enclosed == byte(0) {
return false
}
for i := 0; i < len(bs); i++ {
switch bs[i] {
case e.FieldsInfo.Enclosed:
Expand Down Expand Up @@ -461,7 +464,7 @@ func (e *LoadDataInfo) IndexOfTerminator(bs []byte, inQuoter bool) int {
atFieldStart := true
loop:
for i := 0; i < len(bs); i++ {
if atFieldStart && bs[i] == e.FieldsInfo.Enclosed {
if atFieldStart && e.FieldsInfo.Enclosed != byte(0) &&bs[i] == e.FieldsInfo.Enclosed {
inQuoter = !inQuoter
atFieldStart = false
continue
Expand Down Expand Up @@ -536,7 +539,7 @@ func (e *LoadDataInfo) getLine(prevData, curData []byte, ignore bool) ([]byte, [
if ignore {
endIdx = strings.Index(string(hack.String(curData[startingLen:])), e.LinesInfo.Terminated)
} else {
endIdx = e.IndexOfTerminator(curData[startingLen:], inquotor)
endIdx = e.IndexOfTerminator(curData[startingLen:], false)
}
if endIdx != -1 {
nextDataIdx := startingLen + endIdx + terminatedLen
Expand All @@ -557,7 +560,7 @@ func (e *LoadDataInfo) getLine(prevData, curData []byte, ignore bool) ([]byte, [
if ignore {
endIdx = strings.Index(string(hack.String(prevData[startingLen:])), e.LinesInfo.Terminated)
} else {
endIdx = e.IndexOfTerminator(prevData[startingLen:], inquotor)
endIdx = e.IndexOfTerminator(prevData[startingLen:], false)
}
if endIdx >= prevLen {
return prevData[startingLen : startingLen+endIdx], curData[nextDataIdx:], true
Expand All @@ -580,9 +583,10 @@ func (e *LoadDataInfo) getLine(prevData, curData []byte, ignore bool) ([]byte, [
zap.Int("nextDataIdx", nextDataIdx),
zap.Bool("inquotor", inquotor),
zap.Bool("ignore", ignore),
zap.ByteString("prevData", prevData),
zap.ByteString("curData", curData),
zap.Bool("prevData-contains-00bytes", bytes.Contains(prevData, []byte{e.FieldsInfo.Enclosed})),
zap.Bool("curData-contains-00bytes", bytes.Contains(curData, []byte{e.FieldsInfo.Enclosed})),
)
panic(r)
}
}()
return prevData[startingLen : startingLen+endIdx], curData[lineLen-prevLen:], true
Expand Down

0 comments on commit 38bd4d1

Please sign in to comment.