getNormalColumnsLower returns a lowercased set of regular (non- generated) column names for the given table. Used by updateMutatesTable to determine whether an unqualified SET column belongs to the target table — without this, multi-table UPDATEs where unqualified SETs reference columns of the joine
(ctx context.Context, rCtx base.RestoreContext, database, table string)
| 92 | // where unqualified SETs reference columns of the joined-but-not- |
| 93 | // target table would be mis-classified as mutating the target. |
| 94 | func getNormalColumnsLower(ctx context.Context, rCtx base.RestoreContext, database, table string) (map[string]bool, error) { |
| 95 | if rCtx.GetDatabaseMetadataFunc == nil { |
| 96 | return nil, errors.Errorf("GetDatabaseMetadataFunc is nil") |
| 97 | } |
| 98 | _, metadata, err := rCtx.GetDatabaseMetadataFunc(ctx, rCtx.InstanceID, database) |
| 99 | if err != nil { |
| 100 | return nil, errors.Wrapf(err, "failed to get database metadata for %s", database) |
| 101 | } |
| 102 | if metadata == nil { |
| 103 | return nil, errors.Errorf("database metadata is nil for %s", database) |
| 104 | } |
| 105 | schema := metadata.GetSchemaMetadata("") |
| 106 | if schema == nil { |
| 107 | return nil, errors.Errorf("schema is nil for %s", database) |
| 108 | } |
| 109 | tableMetadata := schema.GetTable(table) |
| 110 | if tableMetadata == nil { |
| 111 | return nil, errors.Errorf("table metadata is nil for %s.%s", database, table) |
| 112 | } |
| 113 | result := make(map[string]bool) |
| 114 | for _, col := range tableMetadata.GetProto().Columns { |
| 115 | if col == nil || col.Generation != nil { |
| 116 | continue |
| 117 | } |
| 118 | result[strings.ToLower(col.Name)] = true |
| 119 | } |
| 120 | return result, nil |
| 121 | } |
| 122 | |
| 123 | // findMatchingDMLs returns ALL UPDATE/DELETE nodes in the parsed statement |
| 124 | // list that reference the target table. The single-DML form (return-on- |
no test coverage detected