mirror of
https://github.com/dolthub/dolt.git
synced 2026-03-15 11:20:37 -05:00
keyless duplicate update
This commit is contained in:
@@ -160,14 +160,16 @@ func (k prollyKeylessWriter) uniqueKeyError(ctx context.Context, keyStr string,
|
||||
vd := k.valBld.Desc
|
||||
for from := range k.valMap {
|
||||
to := k.valMap.MapOrdinal(from)
|
||||
if existing[to], err = index.GetField(ctx, vd, from, value, k.mut.NodeStore()); err != nil {
|
||||
return err
|
||||
}
|
||||
// always skip first field of keyless, as it's the count?
|
||||
if existing[to], err = index.GetField(ctx, vd, from+1, value, k.mut.NodeStore()); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return
|
||||
})
|
||||
|
||||
return sql.NewUniqueKeyErr(keyStr, isPk, existing)
|
||||
// TODO: skip over the ordinals that are the unique column
|
||||
}
|
||||
|
||||
type secondaryUniqueKeyError struct {
|
||||
|
||||
@@ -133,27 +133,27 @@ func getSecondaryKeylessProllyWriters(ctx context.Context, t *doltdb.Table, sqlS
|
||||
|
||||
// Insert implements TableWriter.
|
||||
func (w *prollyTableWriter) Insert(ctx *sql.Context, sqlRow sql.Row) (err error) {
|
||||
if err := w.primary.ValidateKeyViolations(ctx, sqlRow); err != nil {
|
||||
if err = w.primary.ValidateKeyViolations(ctx, sqlRow); err != nil {
|
||||
return err
|
||||
}
|
||||
for _, wr := range w.secondary {
|
||||
if err := wr.ValidateKeyViolations(ctx, sqlRow); err != nil {
|
||||
if err = wr.ValidateKeyViolations(ctx, sqlRow); err != nil {
|
||||
if uke, ok := err.(secondaryUniqueKeyError); ok {
|
||||
return w.primary.(primaryIndexErrBuilder).errForSecondaryUniqueKeyError(ctx, uke)
|
||||
}
|
||||
}
|
||||
}
|
||||
if err := w.primary.Insert(ctx, sqlRow); err != nil {
|
||||
return err
|
||||
}
|
||||
for _, wr := range w.secondary {
|
||||
if err := wr.Insert(ctx, sqlRow); err != nil {
|
||||
if err = wr.Insert(ctx, sqlRow); err != nil {
|
||||
if uke, ok := err.(secondaryUniqueKeyError); ok {
|
||||
return w.primary.(primaryIndexErrBuilder).errForSecondaryUniqueKeyError(ctx, uke)
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
if err = w.primary.Insert(ctx, sqlRow); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user