Skip to content

Commit 934abfa

Browse files
added debug logs
1 parent d835b0a commit 934abfa

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

sql/ydb/diff.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,22 +130,29 @@ func (d *diff) defaultChanged(from *schema.Column, to *schema.Column) bool {
130130
// IndexAttrChanged reports if the index attributes were changed.
131131
func (*diff) IndexAttrChanged(from, to []schema.Attr) bool {
132132
var fromAttrs, toAttrs IndexAttributes
133-
sqlx.Has(from, &fromAttrs)
134-
sqlx.Has(to, &toAttrs)
133+
hasFrom := sqlx.Has(from, &fromAttrs)
134+
hasTo := sqlx.Has(to, &toAttrs)
135+
136+
fmt.Printf("[DIFF] IndexAttrChanged: hasFrom=%v hasTo=%v fromAsync=%v toAsync=%v fromCover=%d toCover=%d\n",
137+
hasFrom, hasTo, fromAttrs.Async, toAttrs.Async, len(fromAttrs.CoverColumns), len(toAttrs.CoverColumns))
135138

136139
if fromAttrs.Async != toAttrs.Async {
140+
fmt.Printf("[DIFF] IndexAttrChanged: Async changed %v -> %v\n", fromAttrs.Async, toAttrs.Async)
137141
return true
138142
}
139143

140144
if len(fromAttrs.CoverColumns) != len(toAttrs.CoverColumns) {
145+
fmt.Printf("[DIFF] IndexAttrChanged: CoverColumns count changed %d -> %d\n", len(fromAttrs.CoverColumns), len(toAttrs.CoverColumns))
141146
return true
142147
}
143148

144149
for i := range fromAttrs.CoverColumns {
145150
if fromAttrs.CoverColumns[i].Name != toAttrs.CoverColumns[i].Name {
151+
fmt.Printf("[DIFF] IndexAttrChanged: CoverColumn[%d] changed %q -> %q\n", i, fromAttrs.CoverColumns[i].Name, toAttrs.CoverColumns[i].Name)
146152
return true
147153
}
148154
}
155+
fmt.Printf("[DIFF] IndexAttrChanged: no change\n")
149156
return false
150157
}
151158

sql/ydb/inspect.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,17 @@ func (i *inspect) indexes(
292292

293293
// secondary indexes
294294
for _, idx := range tableDesc.Indexes {
295+
isUnique := idx.Type == options.GlobalUniqueIndex()
296+
isAsync := idx.Type == options.GlobalAsyncIndex()
297+
298+
fmt.Printf("[INSPECT] index=%q type=%v isUnique=%v isAsync=%v (GlobalUniqueIndex=%v, GlobalAsyncIndex=%v, GlobalIndex=%v)\n",
299+
idx.Name, idx.Type, isUnique, isAsync,
300+
options.GlobalUniqueIndex(), options.GlobalAsyncIndex(), options.GlobalIndex())
301+
295302
atlasIdx := &schema.Index{
296303
Name: idx.Name,
297304
Table: table,
298-
Unique: idx.Type == options.GlobalUniqueIndex(),
305+
Unique: isUnique,
299306
}
300307

301308
for _, columnName := range idx.IndexColumns {
@@ -310,7 +317,7 @@ func (i *inspect) indexes(
310317
}
311318

312319
indexAttrs := &IndexAttributes{
313-
Async: idx.Type == options.GlobalAsyncIndex(),
320+
Async: isAsync,
314321
}
315322

316323
for _, dataCol := range idx.DataColumns {
@@ -323,6 +330,9 @@ func (i *inspect) indexes(
323330

324331
atlasIdx.Attrs = append(atlasIdx.Attrs, indexAttrs)
325332

333+
fmt.Printf("[INSPECT] index=%q final: Unique=%v Async=%v CoverColumns=%d\n",
334+
idx.Name, atlasIdx.Unique, indexAttrs.Async, len(indexAttrs.CoverColumns))
335+
326336
table.AddIndexes(atlasIdx)
327337
}
328338

0 commit comments

Comments
 (0)