Skip to content

Commit

Permalink
v1.12.1
Browse files Browse the repository at this point in the history
  • Loading branch information
stfnmllr committed Sep 6, 2024
1 parent 2dc8699 commit 55417c6
Show file tree
Hide file tree
Showing 26 changed files with 158 additions and 145 deletions.
1 change: 1 addition & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ linters:
- execinquery
- rowserrcheck
- mnd
- exportloopref
#enable-all: false
#enable:
# - ...
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ all:
go test ./...
go test ./... -race
# @echo execute tests on older supported go versions
GOTOOLCHAIN=go1.22.6 go1.22.6 test ./...
GOTOOLCHAIN=go1.22.6 go1.22.6 test ./... -race
GOTOOLCHAIN=go1.22.7 go1.22.7 test ./...
GOTOOLCHAIN=go1.22.7 go1.22.7 test ./... -race
# @echo execute tests on future supported go versions

#see fsfe reuse tool (https://git.fsfe.org/reuse/tool)
Expand Down Expand Up @@ -44,5 +44,5 @@ tools:

#install additional go versions
go:
go install golang.org/dl/go1.22.6@latest
go1.22.6 download
go install golang.org/dl/go1.22.7@latest
go1.22.7 download
6 changes: 6 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ Release Notes

## v1.12.0

### Minor revisions

#### v1.12.1
- updated dependencies
- support of additional linter checks

### Changes

- Changed 'prometheus' into own go module to reduce dependencies on go-hdb.
Expand Down
6 changes: 3 additions & 3 deletions driver/columntype_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestColumnType(t *testing.T) {
return string(buf)
}

compareColumnTypes := func(ct ColumnType, c types.Column, version, dfv int) error {
compareColumnTypes := func(ct ColumnType, c types.Column, version uint64, dfv int) error {
if ct.DatabaseTypeName() != c.DatabaseTypeName(version, dfv) {
return fmt.Errorf("sql type %s type name %s - expected %s", c.TypeName(), ct.DatabaseTypeName(), c.DatabaseTypeName(version, dfv))
}
Expand Down Expand Up @@ -75,7 +75,7 @@ func TestColumnType(t *testing.T) {
return nil
}

testColumnType := func(t *testing.T, db *sql.DB, version, dfv int, types []types.Column, values []any) {
testColumnType := func(t *testing.T, db *sql.DB, version uint64, dfv int, types []types.Column, values []any) {

tableName := RandomIdentifier("%s_" + t.Name())

Expand Down Expand Up @@ -202,7 +202,7 @@ func TestColumnType(t *testing.T) {
}
}

version := int(MT.Version().Major())
version := MT.Version().Major()

for _, dfv := range p.SupportedDfvs(testing.Short()) {
name := fmt.Sprintf("dfv %d", dfv)
Expand Down
2 changes: 1 addition & 1 deletion driver/datatype_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ func TestDataType(t *testing.T) {
)
}

version := int(MT.Version().Major())
version := MT.Version().Major()

for _, dfv := range p.SupportedDfvs(testing.Short()) {
name := fmt.Sprintf("dfv %d", dfv)
Expand Down
2 changes: 1 addition & 1 deletion driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

// DriverVersion is the version number of the hdb driver.
const DriverVersion = "1.12.0"
const DriverVersion = "1.12.1"

// DriverName is the driver name to use with sql.Open for hdb databases.
const DriverName = "hdb"
Expand Down
5 changes: 3 additions & 2 deletions driver/internal/protocol/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ func (s subPrmsSize) encode(e *encoding.Encoder) error {
e.Byte(byte(s))
case s <= math.MaxUint16:
e.Byte(subPrmsSize2ByteIndicator)
e.Uint16ByteOrder(uint16(s), binary.BigEndian) // big endian
// big endian
e.Uint16ByteOrder(uint16(s), binary.BigEndian) //nolint: gosec
default:
return fmt.Errorf("invalid subparameter size %d - maximum %d", s, 42)
}
Expand Down Expand Up @@ -192,7 +193,7 @@ func (p *Prms) Encode(enc *encoding.Encoder) error {
if numPrms > math.MaxInt16 {
return fmt.Errorf("invalid number of parameters %d - maximum %d", numPrms, math.MaxInt16)
}
enc.Int16(int16(numPrms))
enc.Int16(int16(numPrms)) //nolint: gosec

for _, e := range p.prms {
switch e := e.(type) {
Expand Down
8 changes: 4 additions & 4 deletions driver/internal/protocol/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func convertInteger(v any, minI64, maxI64 int64) (any, error) { //nolint: gocycl
if u64 > math.MaxInt64 {
return nil, errUint64OutOfRange
}
i64 := int64(u64)
i64 := int64(u64) //nolint: gosec
if i64 > maxI64 || i64 < minI64 {
return nil, errIntegerOutOfRange
}
Expand All @@ -179,7 +179,7 @@ func convertInteger(v any, minI64, maxI64 int64) (any, error) { //nolint: gocycl
if v > math.MaxInt64 {
return nil, errUint64OutOfRange
}
i64 := int64(v)
i64 := int64(v) //nolint: gosec
if i64 > maxI64 || i64 < minI64 {
return nil, errIntegerOutOfRange
}
Expand Down Expand Up @@ -227,7 +227,7 @@ func convertInteger(v any, minI64, maxI64 int64) (any, error) { //nolint: gocycl
}
return i64, nil
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32:
i64 := int64(rv.Uint())
i64 := int64(rv.Uint()) //nolint: gosec
if i64 > maxI64 || i64 < minI64 {
return nil, errIntegerOutOfRange
}
Expand All @@ -237,7 +237,7 @@ func convertInteger(v any, minI64, maxI64 int64) (any, error) { //nolint: gocycl
if u64 > math.MaxInt64 {
return nil, errUint64OutOfRange
}
i64 := int64(u64)
i64 := int64(u64) //nolint: gosec
if i64 > maxI64 || i64 < minI64 {
return nil, errIntegerOutOfRange
}
Expand Down
2 changes: 1 addition & 1 deletion driver/internal/protocol/convert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func assertEqualInt(t *testing.T, tc typeCode, v any, r int64) { //nolint:unpara
t.Fatalf("assert equal int failed %v - %d expected", cv, r)
}
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
if int64(rv.Uint()) != r {
if int64(rv.Uint()) != r { //nolint: gosec
t.Fatalf("assert equal int failed %v - %d expected", cv, r)
}
default:
Expand Down
60 changes: 26 additions & 34 deletions driver/internal/protocol/encoding/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,38 +58,30 @@ func (d *Decoder) Error() error { return d.err }
func (d *Decoder) ResetError() { d.err = nil }

// readFull reads data from reader + read counter and error handling.
func (d *Decoder) readFull(buf []byte) (int, error) {
func (d *Decoder) readFull(buf []byte) error {
if d.err != nil {
return 0, d.err
return d.err
}
var n int
n, d.err = io.ReadFull(d.rd, buf)
d.cnt += n
if d.err != nil {
return n, d.err
}
return n, nil
return d.err
}

// Skip skips cnt bytes from reading.
func (d *Decoder) Skip(cnt int) {
var n int
for n < cnt {
to := cnt - n
if to > readScratchSize {
to = readScratchSize
}
m, err := d.readFull(d.b[:to])
n += m
if err != nil {
return
}
if cnt <= readScratchSize {
d.readFull(d.b[:cnt]) //nolint: errcheck
return
}
var n int64
n, d.err = io.CopyN(io.Discard, d.rd, int64(cnt))
d.cnt += int(n)
}

// Byte decodes a byte.
func (d *Decoder) Byte() byte {
if _, err := d.readFull(d.b[:1]); err != nil {
if err := d.readFull(d.b[:1]); err != nil {
return 0
}
return d.b[0]
Expand All @@ -112,71 +104,71 @@ func (d *Decoder) Int8() int8 {

// Int16 decodes an int16.
func (d *Decoder) Int16() int16 {
if _, err := d.readFull(d.b[:2]); err != nil {
if err := d.readFull(d.b[:2]); err != nil {
return 0
}
return int16(binary.LittleEndian.Uint16(d.b[:2]))
return int16(binary.LittleEndian.Uint16(d.b[:2])) //nolint: gosec
}

// Uint16 decodes an uint16.
func (d *Decoder) Uint16() uint16 {
if _, err := d.readFull(d.b[:2]); err != nil {
if err := d.readFull(d.b[:2]); err != nil {
return 0
}
return binary.LittleEndian.Uint16(d.b[:2])
}

// Uint16ByteOrder decodes an uint16 in given byte order.
func (d *Decoder) Uint16ByteOrder(byteOrder binary.ByteOrder) uint16 {
if _, err := d.readFull(d.b[:2]); err != nil {
if err := d.readFull(d.b[:2]); err != nil {
return 0
}
return byteOrder.Uint16(d.b[:2])
}

// Int32 decodes an int32.
func (d *Decoder) Int32() int32 {
if _, err := d.readFull(d.b[:4]); err != nil {
if err := d.readFull(d.b[:4]); err != nil {
return 0
}
return int32(binary.LittleEndian.Uint32(d.b[:4]))
return int32(binary.LittleEndian.Uint32(d.b[:4])) //nolint: gosec
}

// Uint32 decodes an uint32.
func (d *Decoder) Uint32() uint32 {
if _, err := d.readFull(d.b[:4]); err != nil {
if err := d.readFull(d.b[:4]); err != nil {
return 0
}
return binary.LittleEndian.Uint32(d.b[:4])
}

// Uint32ByteOrder decodes an uint32 in given byte order.
func (d *Decoder) Uint32ByteOrder(byteOrder binary.ByteOrder) uint32 {
if _, err := d.readFull(d.b[:4]); err != nil {
if err := d.readFull(d.b[:4]); err != nil {
return 0
}
return byteOrder.Uint32(d.b[:4])
}

// Int64 decodes an int64.
func (d *Decoder) Int64() int64 {
if _, err := d.readFull(d.b[:8]); err != nil {
if err := d.readFull(d.b[:8]); err != nil {
return 0
}
return int64(binary.LittleEndian.Uint64(d.b[:8]))
return int64(binary.LittleEndian.Uint64(d.b[:8])) //nolint: gosec
}

// Uint64 decodes an uint64.
func (d *Decoder) Uint64() uint64 {
if _, err := d.readFull(d.b[:8]); err != nil {
if err := d.readFull(d.b[:8]); err != nil {
return 0
}
return binary.LittleEndian.Uint64(d.b[:8])
}

// Float32 decodes a float32.
func (d *Decoder) Float32() float32 {
if _, err := d.readFull(d.b[:4]); err != nil {
if err := d.readFull(d.b[:4]); err != nil {
return 0
}
bits := binary.LittleEndian.Uint32(d.b[:4])
Expand All @@ -185,7 +177,7 @@ func (d *Decoder) Float32() float32 {

// Float64 decodes a float64.
func (d *Decoder) Float64() float64 {
if _, err := d.readFull(d.b[:8]); err != nil {
if err := d.readFull(d.b[:8]); err != nil {
return 0
}
bits := binary.LittleEndian.Uint64(d.b[:8])
Expand All @@ -197,7 +189,7 @@ func (d *Decoder) Float64() float64 {
func (d *Decoder) Decimal() (*big.Int, int, error) { // m, exp
bs := d.b[:decSize]

if _, err := d.readFull(bs); err != nil {
if err := d.readFull(bs); err != nil {
return nil, 0, nil
}

Expand Down Expand Up @@ -241,7 +233,7 @@ func (d *Decoder) Decimal() (*big.Int, int, error) { // m, exp
func (d *Decoder) Fixed(size int) *big.Int { // m, exp
bs := d.b[:size]

if _, err := d.readFull(bs); err != nil {
if err := d.readFull(bs); err != nil {
return nil
}

Expand Down Expand Up @@ -289,7 +281,7 @@ func (d *Decoder) CESU8Bytes(size int) ([]byte, error) {
p = d.b[:size]
}

if _, err := d.readFull(p); err != nil {
if err := d.readFull(p); err != nil {
return nil, nil
}

Expand Down
20 changes: 10 additions & 10 deletions driver/internal/protocol/encoding/encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func (e *Encoder) Decimal(m *big.Int, exp int) {

exp += dec128Bias
b[14] |= (byte(exp) << 1)
b[15] = byte(uint16(exp) >> 7)
b[15] = byte(uint16(exp) >> 7) //nolint: gosec

if m.Sign() == -1 {
b[15] |= 0x80
Expand Down Expand Up @@ -246,10 +246,10 @@ func (e *Encoder) varFieldInd(size int) error {
e.Byte(byte(size))
case size <= math.MaxInt16:
e.Byte(bytesLenIndMedium)
e.Int16(int16(size))
e.Int16(int16(size)) //nolint: gosec
case size <= math.MaxInt32:
e.Byte(bytesLenIndBig)
e.Int32(int32(size))
e.Int32(int32(size)) //nolint: gosec
}
return nil
}
Expand Down Expand Up @@ -376,9 +376,9 @@ func (e *Encoder) encodeDate(t time.Time) {
// year: set most sig bit
// month 0 based
year, month, day := t.Date()
e.Uint16(uint16(year) | 0x8000)
e.Int8(int8(month) - 1)
e.Int8(int8(day))
e.Uint16(uint16(year) | 0x8000) //nolint: gosec
e.Int8(int8(month) - 1) //nolint: gosec
e.Int8(int8(day)) //nolint: gosec
}

// DateField encodes a dayte field.
Expand All @@ -389,9 +389,9 @@ func (e *Encoder) DateField(v any) error {

func (e *Encoder) encodeTime(t time.Time) {
e.Byte(byte(t.Hour()) | 0x80)
e.Int8(int8(t.Minute()))
e.Int8(int8(t.Minute())) //nolint: gosec
msec := t.Second()*1000 + t.Nanosecond()/1000000
e.Uint16(uint16(msec))
e.Uint16(uint16(msec)) //nolint: gosec
}

// TimeField encodes a time field.
Expand Down Expand Up @@ -422,7 +422,7 @@ func (e *Encoder) SeconddateField(v any) error {

// DaydateField encodes a daydate field.
func (e *Encoder) DaydateField(v any) error {
e.Int32(int32(convertTimeToDayDate(asTime(v))))
e.Int32(int32(convertTimeToDayDate(asTime(v)))) //nolint: gosec
return nil
}

Expand All @@ -432,7 +432,7 @@ func (e *Encoder) SecondtimeField(v any) error {
e.Int32(secondtimeNullValue)
return nil
}
e.Int32(int32(convertTimeToSecondtime(asTime(v))))
e.Int32(int32(convertTimeToSecondtime(asTime(v)))) //nolint: gosec
return nil
}

Expand Down
3 changes: 2 additions & 1 deletion driver/internal/protocol/fieldnames.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ func (fn *fieldNames) decode(dec *encoding.Decoder) (err error) {
var s string
n, s, err = dec.CESU8LIString()
fn.items[i].name = s
pos += uint32(n + diff) // len byte + size + diff
// len byte + size + diff
pos += uint32(n + diff) //nolint: gosec
}
return err
}
Loading

0 comments on commit 55417c6

Please sign in to comment.