Skip to content

Commit

Permalink
fix TiDB DEFAULT_GENERATED (#290)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan-Git authored Jun 29, 2020
1 parent bfa2230 commit 2176f75
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/schema_store/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,10 @@ func GetTableDefFromDB(db *sql.DB, dbName string, tableName string) (*Table, err
} else {
column.IsPrimaryKey = false
}
if extra.Valid && strings.Contains(strings.ToUpper(extra.String), "GENERATED") {

// TiDB describes certain column as `DEFAULT_GENERATED`
if extra.Valid && (strings.Contains(strings.ToUpper(extra.String), "VIRTUAL GENERATED") ||
strings.Contains(strings.ToUpper(extra.String), "STORED GENERATED")) {
column.IsGenerated = true
}

Expand Down
7 changes: 7 additions & 0 deletions pkg/sql_execution_engine/internal_txn_tagger.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"database/sql"

"github.com/juju/errors"
log "github.com/sirupsen/logrus"

"github.com/moiot/gravity/pkg/utils"
)
Expand Down Expand Up @@ -47,6 +48,9 @@ func ExecWithInternalTxnTag(
}

if !internalTxnTaggerCfg.TagInternalTxn {
if log.IsLevelEnabled(log.DebugLevel) {
log.Debugf("query: %v, args: %v", newQuery, args)
}
_, err := db.Exec(newQuery, args...)
return errors.Annotatef(err, "query: %v, args: %v", query, args)
}
Expand All @@ -64,6 +68,9 @@ func ExecWithInternalTxnTag(
return errors.Trace(err)
}

if log.IsLevelEnabled(log.DebugLevel) {
log.Debugf("query: %v, args: %v", newQuery, args)
}
_, err = txn.Exec(query, args...)
if err != nil {
txn.Rollback()
Expand Down

0 comments on commit 2176f75

Please sign in to comment.