Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix TiDB DEFAULT_GENERATED #290

Merged
merged 2 commits into from Jun 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion pkg/schema_store/utils.go
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") ||
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better to cache the result of "IsTidb" , and use that to identiry tidb.

Copy link
Collaborator Author

@Ryan-Git Ryan-Git Jun 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IsTiDB does not help here.
It distinguishes whether a column is generated or not, rather than TiDB or not.

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
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