Skip to content

Commit

Permalink
Method for reading query results during upgrade modification (#18731)
Browse files Browse the repository at this point in the history
Method for reading query results during upgrade modification
Change from `UnsafeStringAt()` to call `GetStringAt()`

Approved by: @daviszhen, @zhangxu19830126, @sukki37
  • Loading branch information
qingxinhome authored Sep 12, 2024
1 parent 3c6e4c5 commit 60bdf4f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
12 changes: 6 additions & 6 deletions pkg/bootstrap/versions/upgrade_strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,15 +240,15 @@ func CheckTableColumn(txn executor.TxnExecutor,

res.ReadRows(func(rows int, cols []*vector.Vector) bool {
data_type := cols[0].UnsafeGetStringAt(0)
is_nullable := cols[1].UnsafeGetStringAt(0)
is_nullable := cols[1].GetStringAt(0)
character_length := vector.GetFixedAt[int64](cols[2], 0)
numeric_precision := vector.GetFixedAt[int64](cols[3], 0)
numeric_scale := vector.GetFixedAt[int64](cols[4], 0)
datetime_precision := vector.GetFixedAt[int64](cols[5], 0)
ordinal_position := vector.GetFixedAt[int32](cols[6], 0)
column_default := cols[7].UnsafeGetStringAt(0)
extra := cols[8].UnsafeGetStringAt(0)
column_comment := cols[9].UnsafeGetStringAt(0)
column_default := cols[7].GetStringAt(0)
extra := cols[8].GetStringAt(0)
column_comment := cols[9].GetStringAt(0)

colInfo.IsExits = true
colInfo.ColType = data_type
Expand Down Expand Up @@ -284,7 +284,7 @@ func CheckViewDefinition(txn executor.TxnExecutor, accountId uint32, schema stri
loaded := false
n := 0
res.ReadRows(func(rows int, cols []*vector.Vector) bool {
view_def = cols[0].UnsafeGetStringAt(0)
view_def = cols[0].GetStringAt(0)
n++
loaded = true
return false
Expand Down Expand Up @@ -353,7 +353,7 @@ func CheckTableComment(txn executor.TxnExecutor, accountId uint32, schema string
comment := ""
res.ReadRows(func(rows int, cols []*vector.Vector) bool {
loaded = true
comment = cols[3].UnsafeGetStringAt(0)
comment = cols[3].GetStringAt(0)
return false
})

Expand Down
6 changes: 3 additions & 3 deletions pkg/bootstrap/versions/upgrade_tenant_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func GetUpgradeTenantTasks(
res.ReadRows(func(rows int, cols []*vector.Vector) bool {
for i := 0; i < rows; i++ {
tenants = append(tenants, vector.GetFixedAt[int32](cols[0], i))
versions = append(versions, cols[1].UnsafeGetStringAt(i))
versions = append(versions, cols[1].GetStringAt(i))
}
return true
})
Expand All @@ -131,7 +131,7 @@ func GetTenantCreateVersionForUpdate(
defer res.Close()
version := ""
res.ReadRows(func(rows int, cols []*vector.Vector) bool {
version = cols[0].UnsafeGetStringAt(0)
version = cols[0].GetStringAt(0)
return true
})
if version == "" {
Expand Down Expand Up @@ -174,7 +174,7 @@ func GetTenantVersion(
defer res.Close()
version := ""
res.ReadRows(func(rows int, cols []*vector.Vector) bool {
version = cols[0].UnsafeGetStringAt(0)
version = cols[0].GetStringAt(0)
return true
})
if version == "" {
Expand Down
6 changes: 3 additions & 3 deletions pkg/bootstrap/versions/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func GetLatestVersion(txn executor.TxnExecutor) (Version, error) {

var version Version
res.ReadRows(func(rows int, cols []*vector.Vector) bool {
version.Version = cols[0].UnsafeGetStringAt(0)
version.Version = cols[0].GetStringAt(0)
version.VersionOffset = vector.GetFixedAt[uint32](cols[1], 0)
version.State = vector.GetFixedAt[int32](cols[2], 0)
return true
Expand All @@ -102,7 +102,7 @@ func GetLatestUpgradeVersion(txn executor.TxnExecutor) (Version, error) {

var version Version
res.ReadRows(func(rows int, cols []*vector.Vector) bool {
version.Version = cols[0].UnsafeGetStringAt(0)
version.Version = cols[0].GetStringAt(0)
return true
})
return version, nil
Expand All @@ -124,7 +124,7 @@ func MustGetLatestReadyVersion(

version := ""
res.ReadRows(func(rows int, cols []*vector.Vector) bool {
version = cols[0].UnsafeGetStringAt(0)
version = cols[0].GetStringAt(0)
return true
})
if version == "" {
Expand Down
6 changes: 3 additions & 3 deletions pkg/bootstrap/versions/version_upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,9 @@ func getVersionUpgradesBySQL(
for i := 0; i < rows; i++ {
value := VersionUpgrade{}
value.ID = vector.GetFixedAt[uint64](cols[0], i)
value.FromVersion = cols[1].UnsafeGetStringAt(i)
value.ToVersion = cols[2].UnsafeGetStringAt(i)
value.FinalVersion = cols[3].UnsafeGetStringAt(i)
value.FromVersion = cols[1].GetStringAt(i)
value.ToVersion = cols[2].GetStringAt(i)
value.FinalVersion = cols[3].GetStringAt(i)
value.FinalVersionOffset = vector.GetFixedAt[uint32](cols[4], i)
value.State = vector.GetFixedAt[int32](cols[5], i)
value.UpgradeOrder = vector.GetFixedAt[int32](cols[6], i)
Expand Down

0 comments on commit 60bdf4f

Please sign in to comment.