update vendor 20240303 (#19606)

Co-authored-by: Qiu Jian <qiujian@yunionyun.com>
This commit is contained in:
Jian Qiu
2024-03-03 11:46:54 +08:00
committed by GitHub
parent 43e5df853e
commit 46d603eece
10 changed files with 137 additions and 27 deletions

4
go.mod
View File

@@ -88,14 +88,14 @@ require (
k8s.io/client-go v0.19.3
k8s.io/cluster-bootstrap v0.19.3
moul.io/http2curl/v2 v2.3.0
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240301021153-0cecebd78ccd
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240301072022-cd69313f84bb
yunion.io/x/executor v0.0.0-20230705125604-c5ac3141db32
yunion.io/x/jsonutils v1.0.1-0.20240203102553-4096f103b401
yunion.io/x/log v1.0.1-0.20230411060016-feb3f46ab361
yunion.io/x/ovsdb v0.0.0-20230306173834-f164f413a900
yunion.io/x/pkg v1.10.1-0.20240127153242-cdf9dc071f4f
yunion.io/x/s3cli v0.0.0-20190917004522-13ac36d8687e
yunion.io/x/sqlchemy v1.1.3-0.20240228104732-b8924f0c2e81
yunion.io/x/sqlchemy v1.1.3-0.20240303023826-a40d7fe1f0a9
yunion.io/x/structarg v0.0.0-20231017124457-df4d5009457c
)

8
go.sum
View File

@@ -1204,8 +1204,8 @@ sigs.k8s.io/structured-merge-diff/v4 v4.0.1/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q=
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240301021153-0cecebd78ccd h1:qbqDsgliE8ft8P2AFMqlLEv8nslOKik3BScINGbp0mM=
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240301021153-0cecebd78ccd/go.mod h1:dsUESXIbXJ+/ywbNClhldOrbPOiBi2udrgOnB/ffoWk=
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240301072022-cd69313f84bb h1:3hqidOcvZ61fMdKcIAixwvsCSF4ThPLAC0yJYH0wzi0=
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240301072022-cd69313f84bb/go.mod h1:dsUESXIbXJ+/ywbNClhldOrbPOiBi2udrgOnB/ffoWk=
yunion.io/x/executor v0.0.0-20230705125604-c5ac3141db32 h1:v7POYkQwo1XzOxBoIoRVr/k0V9Y5JyjpshlIFa9raug=
yunion.io/x/executor v0.0.0-20230705125604-c5ac3141db32/go.mod h1:Uxuou9WQIeJXNpy7t2fPLL0BYLvLiMvGQwY7Qc6aSws=
yunion.io/x/jsonutils v0.0.0-20190625054549-a964e1e8a051/go.mod h1:4N0/RVzsYL3kH3WE/H1BjUQdFiWu50JGCFQuuy+Z634=
@@ -1223,7 +1223,7 @@ yunion.io/x/pkg v1.10.1-0.20240127153242-cdf9dc071f4f h1:nLMBj8S3/ev2pB1wzGSi6hO
yunion.io/x/pkg v1.10.1-0.20240127153242-cdf9dc071f4f/go.mod h1:ksCJVQ+DwKrJ5QBEoU8pzrDFfDaZVAFH/iJ6yQCYxJk=
yunion.io/x/s3cli v0.0.0-20190917004522-13ac36d8687e h1:v+EzIadodSwkdZ/7bremd7J8J50Cise/HCylsOJngmo=
yunion.io/x/s3cli v0.0.0-20190917004522-13ac36d8687e/go.mod h1:0iFKpOs1y4lbCxeOmq3Xx/0AcQoewVPwj62eRluioEo=
yunion.io/x/sqlchemy v1.1.3-0.20240228104732-b8924f0c2e81 h1:0QocM63F8k9EDkf1Zx/sWX27hGYplbq+CBXBF2k1ev4=
yunion.io/x/sqlchemy v1.1.3-0.20240228104732-b8924f0c2e81/go.mod h1:5W8ghvJ4TNt/r2yDjjD3i4QsZgIiJX45dhRQBGWPHsQ=
yunion.io/x/sqlchemy v1.1.3-0.20240303023826-a40d7fe1f0a9 h1:xN6mwwOtbeGGMeVb7UC+a26T/jJNsrxyb6gL3rUWwF4=
yunion.io/x/sqlchemy v1.1.3-0.20240303023826-a40d7fe1f0a9/go.mod h1:5W8ghvJ4TNt/r2yDjjD3i4QsZgIiJX45dhRQBGWPHsQ=
yunion.io/x/structarg v0.0.0-20231017124457-df4d5009457c h1:QuLab2kSRECZRxo4Lo2KcYn6XjQFDGaZ1+x0pYDVVwQ=
yunion.io/x/structarg v0.0.0-20231017124457-df4d5009457c/go.mod h1:EP6NSv2C0zzqBDTKumv8hPWLb3XvgMZDHQRfyuOrQng=

4
vendor/modules.txt vendored
View File

@@ -1473,7 +1473,7 @@ sigs.k8s.io/structured-merge-diff/v4/value
# sigs.k8s.io/yaml v1.2.0
## explicit; go 1.12
sigs.k8s.io/yaml
# yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240301021153-0cecebd78ccd
# yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240301072022-cd69313f84bb
## explicit; go 1.18
yunion.io/x/cloudmux/pkg/apis
yunion.io/x/cloudmux/pkg/apis/billing
@@ -1626,7 +1626,7 @@ yunion.io/x/pkg/utils
# yunion.io/x/s3cli v0.0.0-20190917004522-13ac36d8687e
## explicit; go 1.12
yunion.io/x/s3cli
# yunion.io/x/sqlchemy v1.1.3-0.20240228104732-b8924f0c2e81
# yunion.io/x/sqlchemy v1.1.3-0.20240303023826-a40d7fe1f0a9
## explicit; go 1.17
yunion.io/x/sqlchemy
yunion.io/x/sqlchemy/backends

View File

@@ -0,0 +1,79 @@
// Copyright 2019 Yunion
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package ctyun
import "yunion.io/x/pkg/errors"
type GetPriceOptions struct {
ResourceType string `default:"VM" choices:"VM|EBS"`
OnDemand bool `default:"true" negative:"non-demand"`
FlavorName string
DiskType string
}
type SPrice struct {
TotalPrice float64
SubOrderPrices []struct {
OrderItemPrices []struct {
ItemId string
ResourceType string
TotalPrice float64
FinalPrice float64
}
}
}
func (r *SRegion) GetPrice(opts *GetPriceOptions) (*SPrice, error) {
params := map[string]interface{}{
"regionID": r.RegionId,
"resourceType": opts.ResourceType,
"count": 1,
"onDemand": opts.OnDemand,
}
if !opts.OnDemand {
params["cycleType"] = "MONTH"
params["cycleCount"] = 1
}
switch opts.ResourceType {
case "VM":
params["flavorName"] = opts.FlavorName
params["sysDiskType"] = "SATA"
params["sysDiskSize"] = 40
images, err := r.GetImages("public")
if err != nil {
return nil, err
}
for _, image := range images {
if image.OsType == "linux" {
params["imageUUID"] = image.ImageId
break
}
}
case "EBS":
params["diskMode"] = "VBD"
params["diskSize"] = 10
params["diskType"] = opts.DiskType
}
resp, err := r.post(SERVICE_ECS, "/v4/new-order/query-price", params)
if err != nil {
return nil, err
}
ret := &SPrice{}
err = resp.Unmarshal(ret, "returnObj")
if err != nil {
return nil, errors.Wrapf(err, "Unmarshal")
}
return ret, nil
}

View File

@@ -605,6 +605,12 @@ type SDateTimeColumn struct {
isUpdatedAt bool
}
// DefinitionString implementation of SDateTimeColumn for IColumnSpec
func (c *SDateTimeColumn) DefinitionString() string {
buf := columnDefinitionBuffer(c)
return buf.String()
}
func (c *SDateTimeColumn) IsCreatedAt() bool {
return c.isCreatedAt
}

View File

@@ -1,54 +1,69 @@
达梦数据库驱动
==================
官方驱动地址:
https://gitee.com/chunanyong/dm
```golang
import https://gitee.com/chunanyong/dm
```
初始化要求UTF-8字符编码,不区分大小写,建表语句的字段名不要带""双引号
```bash
./dminit path=/opt/dmdbms/data page_size=32 extent_size=16 log_size=2048 port_num=5236 charset=1 case_sensitive=0 LENGTH_IN_CHAR=1 db_name=DAMENG instance_name=DMSERVER
```
注册服务
```bash
cd /opt/dmdbms/script/root
./dm_service_installer.sh -t dmserver -dm_ini /opt/dmdbms/data/DAMENG/dm.ini -p DMSERVER
```
修改 /opt/dmdbms/data/DAMENG/dm.ini 的
```bash
COMPATIBLE_MODE 为4 (0:none, 1:SQL92, 2:Oracle, 3:MS SQL Server, 4:MySQL, 5:DM6, 6:Teradata)
ENABLE_BLOB_CMP_FLAG = 1 允许对TEXT, BLOB等长字段进行比较和排序
```
启停服务
```bash
systemctl enable DmServiceDMSERVER
systemctl start DmServiceDMSERVER
systemctl stop DmServiceDMSERVER
```
卸载:
```bash
/opt/dmdbms/script/root/dm_service_uninstaller.sh -n DmServiceDMSERVER
```
访问数据库:
```bash
./disql
用户名sysdba 密码SYSDBA
```
创建用户
```sql
create user "yunioncloud" identified by "passw0rd";
grant resource,public to yunioncloud;
```
创建用户的同时会自动创建一个同名的 schema (模式)达梦的模式类似其他数据库的database
数据迁移:
找一台Windows主机下载达梦windows版本仅安装客户端则会包含达梦的数据库迁移工具DTS使用DTS将mysql的数据迁移到达梦。
## 达梦与MySQL的兼容问题
1. LENGTH('')返回的是NULL
1. LENGTH('')返回的是NULLMySQL是0
2. 查询的一行数据长度超过page的一半会报错因此把page设置为最大32k如果还是出现则可以设置表属性为允许超过page的一半大小
```sql
alter table table_name enable using long row;

View File

@@ -48,12 +48,6 @@ func columnDefinitionBuffer(c sqlchemy.IColumnSpec) bytes.Buffer {
def := c.Default()
if hasDefault(c) {
// if c is NOT NULL, default value must be set
if !c.IsSupportDefault() {
panic(fmt.Errorf("column %q type %q does not support having default value: %q",
c.Name(), c.ColType(), def,
))
}
def = sqlchemy.GetStringValue(c.ConvertFromString(def))
buf.WriteString(" DEFAULT ")
if c.IsText() {
@@ -73,7 +67,9 @@ func columnDefinitionBuffer(c sqlchemy.IColumnSpec) bytes.Buffer {
}
func hasDefault(c sqlchemy.IColumnSpec) bool {
return (c.Default() != "" || !c.IsNullable()) && !c.IsAutoIncrement()
// if c is NOT NULL, default value must be set
// if datetime, empty default value is allowed for not null
return (c.Default() != "" || (!c.IsNullable() && !c.IsDateTime())) && !c.IsAutoIncrement()
}
// SBooleanColumn represents a boolean type column, which is a int(1) for mysql, with value of true or false
@@ -421,11 +417,6 @@ type STextColumn struct {
sqlchemy.SBaseWidthColumn
}
// IsSupportDefault implementation of STextColumn for IColumnSpec
func (c *STextColumn) IsSupportDefault() bool {
return true // c.SBaseColumn.ColType() == "VARCHAR"
}
// IsText implementation of STextColumn for IColumnSpec
func (c *STextColumn) IsText() bool {
return true
@@ -533,13 +524,19 @@ func NewTimeTypeColumn(name string, typeStr string, tagmap map[string]string, is
type SDateTimeColumn struct {
STimeTypeColumn
// Is this column a 'created_at' field, whichi records the time of create this record
// Is this column a 'created_at' field, which records the time of create this record
isCreatedAt bool
// Is this column a 'updated_at' field, whichi records the time when this record was updated
// Is this column a 'updated_at' field, which records the time when this record was updated
isUpdatedAt bool
}
// DefinitionString implementation of SDateTimeColumn for IColumnSpec
func (c *SDateTimeColumn) DefinitionString() string {
buf := columnDefinitionBuffer(c)
return buf.String()
}
func (c *SDateTimeColumn) IsCreatedAt() bool {
return c.isCreatedAt
}

View File

@@ -135,6 +135,7 @@ func (mysql *SDamengBackend) CommitTableChangeSQL(ts sqlchemy.ITableSpec, change
if hasDefault(cols.NewCol) && cols.OldCol.Default() != cols.NewCol.Default() {
defStr := cols.NewCol.Default()
defStr = sqlchemy.GetStringValue(cols.NewCol.ConvertFromString(defStr))
if cols.NewCol.IsText() {
defStr = "'" + defStr + "'"
}

View File

@@ -564,6 +564,12 @@ type SDateTimeColumn struct {
isUpdatedAt bool
}
// DefinitionString implementation of SDateTimeColumn for IColumnSpec
func (c *SDateTimeColumn) DefinitionString() string {
buf := columnDefinitionBuffer(c)
return buf.String()
}
func (c *SDateTimeColumn) IsCreatedAt() bool {
return c.isCreatedAt
}

View File

@@ -426,6 +426,12 @@ type SDateTimeColumn struct {
isUpdatedAt bool
}
// DefinitionString implementation of SDateTimeColumn for IColumnSpec
func (c *SDateTimeColumn) DefinitionString() string {
buf := columnDefinitionBuffer(c)
return buf.String()
}
func (c *SDateTimeColumn) IsCreatedAt() bool {
return c.isCreatedAt
}