Fix oid index for postgres

This commit is contained in:
Lunny Xiao 2022-06-03 15:12:10 +08:00
parent f9a6990ecb
commit 49d3dca1ac
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
1 changed files with 5 additions and 12 deletions

View File

@ -862,11 +862,11 @@ func (db *postgres) needQuote(name string) bool {
func (db *postgres) SetQuotePolicy(quotePolicy QuotePolicy) { func (db *postgres) SetQuotePolicy(quotePolicy QuotePolicy) {
switch quotePolicy { switch quotePolicy {
case QuotePolicyNone: case QuotePolicyNone:
var q = postgresQuoter q := postgresQuoter
q.IsReserved = schemas.AlwaysNoReserve q.IsReserved = schemas.AlwaysNoReserve
db.quoter = q db.quoter = q
case QuotePolicyReserved: case QuotePolicyReserved:
var q = postgresQuoter q := postgresQuoter
q.IsReserved = db.needQuote q.IsReserved = db.needQuote
db.quoter = q db.quoter = q
case QuotePolicyAlways: case QuotePolicyAlways:
@ -1125,7 +1125,7 @@ WHERE n.nspname= s.table_schema AND c.relkind = 'r'::char AND c.relname = $1%s A
col.Name = strings.Trim(colName, `" `) col.Name = strings.Trim(colName, `" `)
if colDefault != nil { if colDefault != nil {
var theDefault = *colDefault theDefault := *colDefault
// cockroach has type with the default value with ::: // cockroach has type with the default value with :::
// and postgres with ::, we should remove them before store them // and postgres with ::, we should remove them before store them
idx := strings.Index(theDefault, ":::") idx := strings.Index(theDefault, ":::")
@ -1301,15 +1301,8 @@ func (db *postgres) GetIndexes(queryer core.Queryer, ctx context.Context, tableN
} }
colNames = getIndexColName(indexdef) colNames = getIndexColName(indexdef)
isSkip := false // Oid It's a special index. You can't put it in. TODO: This is not perfect.
//Oid It's a special index. You can't put it in if indexName == tableName+"_oid_index" && len(colNames) == 1 && colNames[0] == "oid" {
for _, element := range colNames {
if "oid" == element {
isSkip = true
break
}
}
if isSkip {
continue continue
} }