(table *model.TableMetadata, fields []string)
| 227 | } |
| 228 | |
| 229 | func findDisjointUniqueKey(table *model.TableMetadata, fields []string) (string, error) { |
| 230 | columnMap := make(map[string]bool) |
| 231 | for _, field := range fields { |
| 232 | columnMap[field] = true |
| 233 | } |
| 234 | pk := table.GetPrimaryKey() |
| 235 | if pk != nil { |
| 236 | if disjoint(pk.GetProto().Expressions, columnMap) { |
| 237 | return pk.GetProto().Name, nil |
| 238 | } |
| 239 | } |
| 240 | for _, index := range table.GetProto().Indexes { |
| 241 | if index.Primary { |
| 242 | continue |
| 243 | } |
| 244 | if !index.Unique { |
| 245 | continue |
| 246 | } |
| 247 | if disjoint(index.Expressions, columnMap) { |
| 248 | return index.Name, nil |
| 249 | } |
| 250 | } |
| 251 | |
| 252 | return "", errors.Errorf("no disjoint unique key found for table") |
| 253 | } |
| 254 | |
| 255 | func extractStatement(statement string, backupItem *storepb.PriorBackupDetail_Item) (string, error) { |
| 256 | if backupItem == nil { |
no test coverage detected