Skip to content

Commit f515022

Browse files
committed
Avoid to send commands during connect if not strictly required
1 parent 2f75ff7 commit f515022

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

connection.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ func ParseTlsString(tlsconf string) (secure bool, pem string) {
182182
// Username, Password and Database are ignored.
183183
// If a given value does not fulfill the above criteria's, an error is returned.
184184
func (this *SQCloud) CheckConnectionParameter() error {
185-
186185
if strings.TrimSpace(this.Host) == "" {
187186
return errors.New(fmt.Sprintf("Invalid hostname (%s)", this.Host))
188187
}
@@ -274,7 +273,6 @@ func (this *SQCloud) reset() {
274273
// otherwise, a pointer to the newly established connection is returned.
275274
func Connect(ConnectionString string) (*SQCloud, error) {
276275
config, err := ParseConnectionString(ConnectionString)
277-
278276
if err != nil {
279277
return nil, err
280278
}
@@ -284,10 +282,9 @@ func Connect(ConnectionString string) (*SQCloud, error) {
284282
if err = connection.Connect(); err != nil {
285283
_ = connection.Close()
286284
return nil, err
287-
} else {
288-
err = connection.Compress(connection.CompressMode)
289-
return connection, err
290285
}
286+
287+
return connection, err
291288
}
292289

293290
// Connection Functions
@@ -376,6 +373,10 @@ func (this *SQCloud) reconnect() error {
376373
commands += maxrowsetCommand(this.MaxRowset)
377374
}
378375

376+
if this.CompressMode != "NO" {
377+
commands += compressCommand(this.CompressMode)
378+
}
379+
379380
if commands != "" {
380381
if len(args) > 0 {
381382
if err := this.ExecuteArray(commands, args); err != nil {

0 commit comments

Comments
 (0)