Skip to content

Commit

Permalink
Merge branch 'master' of ssh://192.168.100.3:/var/services/homes/samy…
Browse files Browse the repository at this point in the history
…/projects/git/go/go-ora
  • Loading branch information
sijms committed Mar 26, 2023
2 parents 20b830a + b53ccab commit 0f0eb1c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 113 deletions.
8 changes: 6 additions & 2 deletions v2/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ func (stmt *defaultStmt) basicWrite(exeOp int, parse, define bool) error {
//}
// we use here int.MaxValue
if stmt.connection.connOption.Lob == 0 {
session.PutInt(1, 4, true, true)
session.PutInt(0x3FFFFFFF, 4, true, true)
//session.PutUint(0, 4, true, true)
} else {
session.PutUint(0x7FFFFFFF, 4, true, true)
}
Expand Down Expand Up @@ -250,6 +251,9 @@ func (stmt *defaultStmt) writeDefine() error {
temp.MaxCharLen = 0x8000
}
}
//if temp.DataType == LONG || temp.DataType == LongRaw {
// temp.MaxCharLen = 0x4000
//}
temp.Flag = 3
temp.MaxLen = num
err := temp.write(session)
Expand Down Expand Up @@ -1757,7 +1761,7 @@ func (stmt *Stmt) _query() (driver.Rows, error) {
return nil, err
}
// deal with lobs
if stmt._hasBLOB || stmt._hasLONG {
if stmt._hasBLOB {
if stmt.connection.connOption.Lob == 0 {
stmt.define = true
stmt.execute = false
Expand Down
124 changes: 13 additions & 111 deletions v2/data_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,106 +255,6 @@ func (dataSet DataSet) setObjectValue(obj reflect.Value, colIndex int) (bool, er
} else {
return false, fmt.Errorf("go-ora: column %d require type []byte", colIndex)
}
//case reflect.TypeOf(sql.NullTime{}):
// if field == nil {
// obj.Set(reflect.ValueOf(sql.NullTime{Valid: false}))
// } else {
// switch tempField := field.(type) {
// case time.Time:
// obj.Set(reflect.ValueOf(sql.NullTime{Valid: true, Time: tempField}))
// case TimeStamp:
// obj.Set(reflect.ValueOf(sql.NullTime{Valid: true, Time: time.Time(tempField)}))
// default:
// return false, fmt.Errorf("go-ora: column %d require type time.Time or null", colIndex)
// }
// }
//case reflect.TypeOf(NullTimeStamp{}):
// if field == nil {
// obj.Set(reflect.ValueOf(NullTimeStamp{Valid: false}))
// } else {
// switch tempField := field.(type) {
// case time.Time:
// obj.Set(reflect.ValueOf(NullTimeStamp{Valid: true, TimeStamp: TimeStamp(tempField)}))
// case TimeStamp:
// obj.Set(reflect.ValueOf(NullTimeStamp{Valid: true, TimeStamp: tempField}))
// default:
// return false, fmt.Errorf("go-ora: column %d require type time.Time or null", colIndex)
// }
// }
//case reflect.TypeOf(sql.NullString{}):
// if field == nil {
// obj.Set(reflect.ValueOf(sql.NullString{Valid: false}))
// } else {
// obj.Set(reflect.ValueOf(sql.NullString{Valid: true, String: getString(field)}))
// }
//case reflect.TypeOf(NullNVarChar{}):
// if field == nil {
// obj.Set(reflect.ValueOf(NullNVarChar{Valid: false}))
// } else {
// obj.Set(reflect.ValueOf(NullNVarChar{Valid: true, NVarChar: NVarChar(getString(field))}))
// }
//case reflect.TypeOf(sql.NullBool{}):
// if field == nil {
// obj.Set(reflect.ValueOf(sql.NullBool{Valid: false}))
// } else {
// tempInt, err := getInt(field)
// if err != nil {
// return false, err
// }
// obj.Set(reflect.ValueOf(sql.NullBool{Valid: true, Bool: tempInt != 0}))
// }
//case reflect.TypeOf(sql.NullFloat64{}):
// if field == nil {
// obj.Set(reflect.ValueOf(sql.NullFloat64{Valid: false}))
// } else {
// tempFloat, err := getFloat(field)
// if err != nil {
// return false, err
// }
// obj.Set(reflect.ValueOf(sql.NullFloat64{Valid: true, Float64: tempFloat}))
// }
//case reflect.TypeOf(sql.NullInt64{}):
// if field == nil {
// obj.Set(reflect.ValueOf(sql.NullInt64{Valid: false}))
// } else {
// tempInt, err := getInt(field)
// if err != nil {
// return false, err
// }
// obj.Set(reflect.ValueOf(sql.NullInt64{Valid: true, Int64: tempInt}))
// }
//case reflect.TypeOf(sql.NullInt32{}):
// if field == nil {
// obj.Set(reflect.ValueOf(sql.NullInt32{Valid: false}))
// } else {
// tempInt, err := getInt(field)
// if err != nil {
// return false, err
// }
// obj.Set(reflect.ValueOf(sql.NullInt32{Valid: true, Int32: int32(tempInt)}))
// }
//case reflect.TypeOf(sql.NullInt16{}):
// if field == nil {
// obj.Set(reflect.ValueOf(sql.NullInt16{Valid: false}))
// } else {
// tempInt, err := getInt(field)
// if err != nil {
// return false, err
// }
// obj.Set(reflect.ValueOf(sql.NullInt16{Valid: true, Int16: int16(tempInt)}))
// }
//case reflect.TypeOf(sql.NullByte{}):
// if field == nil {
// obj.Set(reflect.ValueOf(sql.NullByte{Valid: false}))
// } else {
// tempInt, err := getInt(field)
// if err != nil {
// return false, err
// }
// obj.Set(reflect.ValueOf(sql.NullByte{Valid: true, Byte: uint8(tempInt)}))
// }
//case reflect.TypeOf(BFile{}):
// obj.Set(reflect.ValueOf(field))
default:
return false, nil
}
Expand Down Expand Up @@ -419,14 +319,21 @@ func (dataSet *DataSet) Err() error {
func (dataSet *DataSet) Next(dest []driver.Value) error {
hasMoreRows := dataSet.parent.hasMoreRows()
noOfRowsToFetch := len(dataSet.rows) // dataSet.parent.noOfRowsToFetch()
if noOfRowsToFetch == 0 {
return io.EOF
}
//hasBLOB := dataSet.parent.hasBLOB()
//hasLONG := dataSet.parent.hasLONG()
//if noOfRowsToFetch == 0 {
// return io.EOF
//}
hasBLOB := dataSet.parent.hasBLOB()
hasLONG := dataSet.parent.hasLONG()
if !hasMoreRows && noOfRowsToFetch == 0 {
return io.EOF
}
if hasMoreRows && (hasBLOB || hasLONG) && dataSet.index == 0 {
//dataSet.rows = make([]Row, 0, dataSet.parent.noOfRowsToFetch())
if err := dataSet.parent.fetch(dataSet); err != nil {
return err
}
noOfRowsToFetch = len(dataSet.rows)
}
if dataSet.index > 0 && dataSet.index%len(dataSet.rows) == 0 {
if hasMoreRows {
dataSet.rows = make([]Row, 0, dataSet.parent.noOfRowsToFetch())
Expand All @@ -444,12 +351,7 @@ func (dataSet *DataSet) Next(dest []driver.Value) error {
return io.EOF
}
}
//if hasMoreRows && (hasBLOB || hasLONG) && dataSet.index == 0 {
// //dataSet.rows = make([]Row, 0, dataSet.parent.noOfRowsToFetch())
// if err := dataSet.parent.fetch(dataSet); err != nil {
// return err
// }
//}

if dataSet.index%noOfRowsToFetch < len(dataSet.rows) {
for x := 0; x < len(dataSet.rows[dataSet.index%noOfRowsToFetch]); x++ {
dest[x] = dataSet.rows[dataSet.index%noOfRowsToFetch][x]
Expand Down

0 comments on commit 0f0eb1c

Please sign in to comment.