MCPcopy Create free account
hub / github.com/bytebase/bytebase / extractUpdateColumns

Function extractUpdateColumns

backend/plugin/parser/mysql/restore.go:195–223  ·  view source on GitHub ↗

extractUpdateColumns extracts column names from SET assignments that belong to the original table.

(setList []*ast.Assignment, database, _ string, matchedTable *TableReference, normalColumns []string)

Source from the content-addressed store, hash-verified

193// extractUpdateColumns extracts column names from SET assignments that belong
194// to the original table.
195func extractUpdateColumns(setList []*ast.Assignment, database, _ string, matchedTable *TableReference, normalColumns []string) []string {
196 var result []string
197 for _, assignment := range setList {
198 col := assignment.Column
199 if col == nil {
200 continue
201 }
202
203 if col.Schema != "" && !strings.EqualFold(col.Schema, database) {
204 continue
205 }
206
207 if col.Table == "" {
208 // Unqualified column: check if it belongs to the normalColumns set.
209 for _, c := range normalColumns {
210 if strings.EqualFold(c, col.Column) {
211 result = append(result, col.Column)
212 break
213 }
214 }
215 continue
216 }
217
218 if matchedTable != nil && (col.Table == matchedTable.Alias || strings.EqualFold(col.Table, matchedTable.Table)) {
219 result = append(result, col.Column)
220 }
221 }
222 return result
223}
224
225func hasDisjointUniqueKey(ctx context.Context, rCtx base.RestoreContext, originalDatabase, originalTable string, updateColumns []string) (bool, error) {
226 columnMap := make(map[string]bool)

Callers 1

generateUpdateRestoreFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected