Skip to content

Commit de1a434

Browse files
committed
Fix dolt_history table for multiple schemas for doltgres
1 parent 1ecf383 commit de1a434

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

go/libraries/doltcore/sqle/database.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,14 @@ func (db Database) getTableInsensitive(ctx *sql.Context, head *doltdb.Commit, ds
350350
return dt, true, nil
351351

352352
case strings.HasPrefix(lwrName, doltdb.DoltHistoryTablePrefix):
353+
if resolve.UseSearchPath && db.schemaName == "" {
354+
schemaName, err := resolve.FirstExistingSchemaOnSearchPath(ctx, root)
355+
if err != nil {
356+
return nil, false, err
357+
}
358+
db.schemaName = schemaName
359+
}
360+
353361
baseTableName := tblName[len(doltdb.DoltHistoryTablePrefix):]
354362
baseTable, ok, err := db.getTable(ctx, root, baseTableName)
355363
if err != nil {

go/libraries/doltcore/sqle/history_table.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import (
2929
"github.com/dolthub/dolt/go/libraries/doltcore/doltdb"
3030
"github.com/dolthub/dolt/go/libraries/doltcore/schema"
3131
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/index"
32-
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/resolve"
3332
"github.com/dolthub/dolt/go/store/datas"
3433
"github.com/dolthub/dolt/go/store/hash"
3534
)
@@ -498,7 +497,7 @@ func (ht *HistoryTable) newRowItrForTableAtCommit(ctx *sql.Context, table *DoltT
498497
return nil, err
499498
}
500499

501-
_, _, ok, err := resolve.Table(ctx, root, table.Name())
500+
_, ok, err := root.GetTable(ctx, table.TableName())
502501
if err != nil {
503502
return nil, err
504503
}
@@ -521,10 +520,6 @@ func (ht *HistoryTable) newRowItrForTableAtCommit(ctx *sql.Context, table *DoltT
521520
for _, idx := range indexes {
522521
if idx.ID() == lookup.Index.ID() {
523522
histTable = lockedTable.IndexedAccess(lookup)
524-
if err != nil {
525-
return nil, err
526-
}
527-
528523
if histTable != nil {
529524
newLookup := sql.IndexLookup{Index: idx, Ranges: lookup.Ranges}
530525
partIter, err = histTable.(sql.IndexedTable).LookupPartitions(ctx, newLookup)

0 commit comments

Comments
 (0)