Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion go/cmd/dolt/commands/commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,8 @@ func printStagedDiffs(wr io.Writer, stagedRows []sql.Row, printHelp bool) int {

lines := make([]string, 0, len(stagedRows))
for _, row := range stagedRows {
if !doltdb.IsReadOnlySystemTable(row[0].(string)) {
tblName := row[0].(string)
if !doltdb.IsReadOnlySystemTable(tblName, doltdb.HasDoltPrefix(tblName)) {
switch row[1].(string) {
case "new table":
lines = append(lines, fmt.Sprintf(statusFmt, tblDiffTypeToLabel[diff.AddedTable], row[0].(string)))
Expand Down
7 changes: 4 additions & 3 deletions go/cmd/dolt/commands/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,8 @@ func diffUserTables(queryist cli.Queryist, sqlCtx *sql.Context, dArgs *diffArgs)

doltSchemasChanged := false
for _, delta := range deltas {
if doltdb.IsFullTextTable(delta.TableName.Name) {
tableName := delta.TableName.Name
if doltdb.IsFullTextTable(tableName, doltdb.HasDoltPrefix(tableName)) {
continue
}

Expand Down Expand Up @@ -852,7 +853,7 @@ func shouldPrintTableDelta(tablesToPrint *set.StrSet, toTableName, fromTableName
}

func isDoltSchemasTable(toTableName, fromTableName string) bool {
return fromTableName == doltdb.SchemasTableName || toTableName == doltdb.SchemasTableName
return fromTableName == doltdb.GetSchemasTableName() || toTableName == doltdb.GetSchemasTableName()
}

func getTableInfoAtRef(queryist cli.Queryist, sqlCtx *sql.Context, tableName string, ref string) (diff.TableInfo, error) {
Expand Down Expand Up @@ -1204,7 +1205,7 @@ func diffDoltSchemasTable(
query, err := dbr.InterpolateForDialect("select from_name,to_name,from_type,to_type,from_fragment,to_fragment "+
"from dolt_diff(?, ?, ?) "+
"order by coalesce(from_type, to_type), coalesce(from_name, to_name)",
[]interface{}{dArgs.fromRef, dArgs.toRef, doltdb.SchemasTableName}, dialect.MySQL)
[]interface{}{dArgs.fromRef, dArgs.toRef, doltdb.GetSchemasTableName()}, dialect.MySQL)
if err != nil {
return errhand.BuildDError("Error building diff query").AddCause(err).Build()
}
Expand Down
10 changes: 5 additions & 5 deletions go/cmd/dolt/commands/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func (cmd DumpCmd) Exec(ctx context.Context, commandStr string, args []string, d
return HandleVErrAndExitCode(verr, usage)
}

tblNames, err := doltdb.GetNonSystemTableNames(ctx, root)
tblNames, err := doltdb.GetNonSystemTableNames(ctx, root, doltdb.HasDoltPrefix)
if err != nil {
return HandleVErrAndExitCode(errhand.BuildDError("error: failed to get tables").AddCause(err).Build(), usage)
}
Expand Down Expand Up @@ -325,7 +325,7 @@ func dumpProcedures(sqlCtx *sql.Context, engine *engine.SqlEngine, root doltdb.R
}

func dumpTriggers(sqlCtx *sql.Context, engine *engine.SqlEngine, root doltdb.RootValue, writer io.WriteCloser) (rerr error) {
_, _, ok, err := doltdb.GetTableInsensitive(sqlCtx, root, doltdb.TableName{Name: doltdb.SchemasTableName})
_, _, ok, err := doltdb.GetTableInsensitive(sqlCtx, root, doltdb.TableName{Name: doltdb.GetSchemasTableName()})
if err != nil {
return err
}
Expand All @@ -334,7 +334,7 @@ func dumpTriggers(sqlCtx *sql.Context, engine *engine.SqlEngine, root doltdb.Roo
return nil
}

sch, iter, _, err := engine.Query(sqlCtx, "select * from "+doltdb.SchemasTableName)
sch, iter, _, err := engine.Query(sqlCtx, "select * from "+doltdb.GetSchemasTableName())
if err != nil {
return err
}
Expand Down Expand Up @@ -391,7 +391,7 @@ func dumpTriggers(sqlCtx *sql.Context, engine *engine.SqlEngine, root doltdb.Roo
}

func dumpViews(ctx *sql.Context, engine *engine.SqlEngine, root doltdb.RootValue, writer io.WriteCloser) (rerr error) {
_, _, ok, err := doltdb.GetTableInsensitive(ctx, root, doltdb.TableName{Name: doltdb.SchemasTableName})
_, _, ok, err := doltdb.GetTableInsensitive(ctx, root, doltdb.TableName{Name: doltdb.GetSchemasTableName()})
if err != nil {
return err
}
Expand All @@ -400,7 +400,7 @@ func dumpViews(ctx *sql.Context, engine *engine.SqlEngine, root doltdb.RootValue
return nil
}

sch, iter, _, err := engine.Query(ctx, "select * from "+doltdb.SchemasTableName)
sch, iter, _, err := engine.Query(ctx, "select * from "+doltdb.GetSchemasTableName())
if err != nil {
return err
}
Expand Down
15 changes: 8 additions & 7 deletions go/cmd/dolt/commands/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -478,37 +478,38 @@ func calculateMergeStats(queryist cli.Queryist, sqlCtx *sql.Context, mergeStats
// get table operations
for _, summary := range diffSummaries {
// We want to ignore all statistics for Full-Text tables
if doltdb.IsFullTextTable(summary.TableName.Name) {
tableName := summary.TableName.Name
if doltdb.IsFullTextTable(tableName, doltdb.HasDoltPrefix(tableName)) {
continue
}
// Ignore stats for database collation changes
if strings.HasPrefix(summary.TableName.Name, diff.DBPrefix) {
if strings.HasPrefix(tableName, diff.DBPrefix) {
continue
}
if summary.DiffType == "added" {
allUnmodified = false
mergeStats[summary.TableName.Name] = &merge.MergeStats{
mergeStats[tableName] = &merge.MergeStats{
Operation: merge.TableAdded,
}
} else if summary.DiffType == "dropped" {
allUnmodified = false
mergeStats[summary.TableName.Name] = &merge.MergeStats{
mergeStats[tableName] = &merge.MergeStats{
Operation: merge.TableRemoved,
}
} else if summary.DiffType == "modified" || summary.DiffType == "renamed" {
allUnmodified = false
mergeStats[summary.TableName.Name] = &merge.MergeStats{
mergeStats[tableName] = &merge.MergeStats{
Operation: merge.TableModified,
}
tableStats, err := getTableDiffStats(queryist, sqlCtx, summary.TableName.Name, fromRef, toRef)
tableStats, err := getTableDiffStats(queryist, sqlCtx, tableName, fromRef, toRef)
if err != nil {
return nil, false, err
}
if tableStats != nil && len(tableStats) > 0 {
diffStats[tableStats[0].TableName] = tableStats[0]
}
} else {
mergeStats[summary.TableName.Name] = &merge.MergeStats{
mergeStats[tableName] = &merge.MergeStats{
Operation: merge.TableUnmodified,
}
}
Expand Down
2 changes: 1 addition & 1 deletion go/cmd/dolt/commands/schcmds/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func exportSchemas(ctx context.Context, apr *argparser.ArgParseResults, root dol
}
tablesToExport = []string{tblName}
} else {
tablesToExport, err = doltdb.GetNonSystemTableNames(ctx, root)
tablesToExport, err = doltdb.GetNonSystemTableNames(ctx, root, doltdb.HasDoltPrefix)
if err != nil {
return errhand.BuildDError("error retrieving table names").AddCause(err).Build()
}
Expand Down
2 changes: 1 addition & 1 deletion go/cmd/dolt/commands/schcmds/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func printSchemas(ctx context.Context, apr *argparser.ArgParseResults, dEnv *env

var notFound []string
for _, tblName := range tables {
if doltdb.IsFullTextTable(tblName) {
if doltdb.IsFullTextTable(tblName, doltdb.HasDoltPrefix(tblName)) {
continue
}
ok, err := root.HasTable(ctx, doltdb.TableName{Name: tblName})
Expand Down
4 changes: 2 additions & 2 deletions go/cmd/dolt/commands/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func createPrintData(err error, queryist cli.Queryist, sqlCtx *sql.Context, show
}
shouldIgnoreTable = ignored == doltdb.Ignore
}
shouldIgnoreTable = shouldIgnoreTable || doltdb.IsFullTextTable(tableName)
shouldIgnoreTable = shouldIgnoreTable || doltdb.IsFullTextTable(tableName, doltdb.HasDoltPrefix(tableName))

switch status {
case "renamed":
Expand Down Expand Up @@ -536,7 +536,7 @@ and have %v and %v different commits each, respectively.
cli.Println(stagedHeader)
cli.Println(stagedHeaderHelp)
for tableName, status := range data.stagedTables {
if !doltdb.IsReadOnlySystemTable(tableName) {
if !doltdb.IsReadOnlySystemTable(tableName, doltdb.HasDoltPrefix(tableName)) {
text := fmt.Sprintf(statusFmt, status+":", tableName)
greenText := color.GreenString(text)
cli.Println(greenText)
Expand Down
2 changes: 1 addition & 1 deletion go/cmd/dolt/commands/tblcmds/rm.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (cmd RmCmd) Exec(ctx context.Context, commandStr string, args []string, dEn
}

for _, tableName := range apr.Args {
if doltdb.IsReadOnlySystemTable(tableName) {
if doltdb.IsReadOnlySystemTable(tableName, doltdb.HasDoltPrefix(tableName)) {
return commands.HandleVErrAndExitCode(
errhand.BuildDError("error removing table %s", tableName).AddCause(doltdb.ErrSystemTableCannotBeModified).Build(), usage)
}
Expand Down
2 changes: 1 addition & 1 deletion go/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ require (
github.com/cespare/xxhash/v2 v2.2.0
github.com/creasty/defaults v1.6.0
github.com/dolthub/flatbuffers/v23 v23.3.3-dh.2
github.com/dolthub/go-mysql-server v0.18.2-0.20241113010909-06ed65fb3be6
github.com/dolthub/go-mysql-server v0.18.2-0.20241113232935-587e936f9d69
github.com/dolthub/gozstd v0.0.0-20240423170813-23a2903bca63
github.com/dolthub/swiss v0.1.0
github.com/goccy/go-json v0.10.2
Expand Down
4 changes: 2 additions & 2 deletions go/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ github.com/dolthub/fslock v0.0.3 h1:iLMpUIvJKMKm92+N1fmHVdxJP5NdyDK5bK7z7Ba2s2U=
github.com/dolthub/fslock v0.0.3/go.mod h1:QWql+P17oAAMLnL4HGB5tiovtDuAjdDTPbuqx7bYfa0=
github.com/dolthub/go-icu-regex v0.0.0-20240916130659-0118adc6b662 h1:aC17hZD6iwzBwwfO5M+3oBT5E5gGRiQPdn+vzpDXqIA=
github.com/dolthub/go-icu-regex v0.0.0-20240916130659-0118adc6b662/go.mod h1:KPUcpx070QOfJK1gNe0zx4pA5sicIK1GMikIGLKC168=
github.com/dolthub/go-mysql-server v0.18.2-0.20241113010909-06ed65fb3be6 h1:4YnEVQNV1WrhsC2vfn4LWr3OOpApuXQnNWNB2oGCfsI=
github.com/dolthub/go-mysql-server v0.18.2-0.20241113010909-06ed65fb3be6/go.mod h1:sOMQzWUvHvJECzpcUxjDgV5BR/A7U+hOh596PUO2NPI=
github.com/dolthub/go-mysql-server v0.18.2-0.20241113232935-587e936f9d69 h1:cTpVFZA1YrIRhumayF2YAJr59hl4aB7f20QEM/4nWME=
github.com/dolthub/go-mysql-server v0.18.2-0.20241113232935-587e936f9d69/go.mod h1:sOMQzWUvHvJECzpcUxjDgV5BR/A7U+hOh596PUO2NPI=
github.com/dolthub/gozstd v0.0.0-20240423170813-23a2903bca63 h1:OAsXLAPL4du6tfbBgK0xXHZkOlos63RdKYS3Sgw/dfI=
github.com/dolthub/gozstd v0.0.0-20240423170813-23a2903bca63/go.mod h1:lV7lUeuDhH5thVGDCKXbatwKy2KW80L4rMT46n+Y2/Q=
github.com/dolthub/ishell v0.0.0-20240701202509-2b217167d718 h1:lT7hE5k+0nkBdj/1UOSFwjWpNxf+LCApbRHgnCA17XE=
Expand Down
8 changes: 8 additions & 0 deletions go/libraries/doltcore/diff/table_deltas.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,14 @@ func (td TableDelta) CurName() string {
return td.FromName.String()
}

// CurTableName returns the most recent TableName of the table.
func (td TableDelta) CurTableName() doltdb.TableName {
if td.ToName.Name != "" {
return td.ToName
}
return td.FromName
}

func (td TableDelta) HasFKChanges() bool {
if len(td.FromFks) != len(td.ToFks) {
return true
Expand Down
46 changes: 29 additions & 17 deletions go/libraries/doltcore/doltdb/system_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,48 +93,47 @@ func HasDoltCIPrefix(s string) bool {

// IsFullTextTable returns a boolean stating whether the given table is one of the pseudo-index tables used by Full-Text
// indexes.
// TODO: Schema name
func IsFullTextTable(name string) bool {
return HasDoltPrefix(name) && (strings.HasSuffix(name, "_fts_config") ||
func IsFullTextTable(name string, isSystemTable bool) bool {
return isSystemTable && (strings.HasSuffix(name, "_fts_config") ||
strings.HasSuffix(name, "_fts_position") ||
strings.HasSuffix(name, "_fts_doc_count") ||
strings.HasSuffix(name, "_fts_global_count") ||
strings.HasSuffix(name, "_fts_row_count"))
}

// IsDoltCITable returns whether the table name given is a dolt-ci table
func IsDoltCITable(name string) bool {
return HasDoltCIPrefix(name) && set.NewStrSet(getWriteableSystemTables()).Contains(name) && !IsFullTextTable(name)
func IsDoltCITable(name string, isSystemTable bool) bool {
return HasDoltCIPrefix(name) && set.NewStrSet(getWriteableSystemTables()).Contains(name) && !IsFullTextTable(name, isSystemTable)
}

// IsReadOnlySystemTable returns whether the table name given is a system table that should not be included in command line
// output (e.g. dolt status) by default.
func IsReadOnlySystemTable(name string) bool {
return HasDoltPrefix(name) && !set.NewStrSet(getWriteableSystemTables()).Contains(name) && !IsFullTextTable(name)
func IsReadOnlySystemTable(name string, isSystemTable bool) bool {
return isSystemTable && !set.NewStrSet(getWriteableSystemTables()).Contains(name) && !IsFullTextTable(name, isSystemTable)
}

// IsNonAlterableSystemTable returns whether the table name given is a system table that cannot be dropped or altered
// by the user.
func IsNonAlterableSystemTable(name string) bool {
return (IsReadOnlySystemTable(name) && !IsFullTextTable(name)) || strings.EqualFold(name, SchemasTableName)
func IsNonAlterableSystemTable(name string, isSystemTable bool) bool {
return (IsReadOnlySystemTable(name, isSystemTable) && !IsFullTextTable(name, isSystemTable)) || strings.EqualFold(name, GetSchemasTableName())
}

// GetNonSystemTableNames gets non-system table names
func GetNonSystemTableNames(ctx context.Context, root RootValue) ([]string, error) {
func GetNonSystemTableNames(ctx context.Context, root RootValue, isSystemTableFn func(n string) bool) ([]string, error) {
tn, err := root.GetTableNames(ctx, DefaultSchemaName)
if err != nil {
return nil, err
}
tn = funcitr.FilterStrings(tn, func(n string) bool {
return !HasDoltPrefix(n) && !HasDoltCIPrefix(n)
return !isSystemTableFn(n) && !HasDoltCIPrefix(n)
})
sort.Strings(tn)
return tn, nil
}

// GetSystemTableNames gets system table names
func GetSystemTableNames(ctx context.Context, root RootValue) ([]string, error) {
p, err := GetPersistedSystemTables(ctx, root)
func GetSystemTableNames(ctx context.Context, root RootValue, isSystemTableFn func(n string) bool) ([]string, error) {
p, err := GetPersistedSystemTables(ctx, root, isSystemTableFn)
if err != nil {
return nil, err
}
Expand All @@ -151,13 +150,13 @@ func GetSystemTableNames(ctx context.Context, root RootValue) ([]string, error)
}

// GetPersistedSystemTables returns table names of all persisted system tables.
func GetPersistedSystemTables(ctx context.Context, root RootValue) ([]string, error) {
func GetPersistedSystemTables(ctx context.Context, root RootValue, isSystemTableFn func(n string) bool) ([]string, error) {
tn, err := root.GetTableNames(ctx, DefaultSchemaName)
if err != nil {
return nil, err
}
sort.Strings(tn)
return funcitr.FilterStrings(tn, HasDoltPrefix), nil
return funcitr.FilterStrings(tn, isSystemTableFn), nil
}

// GetGeneratedSystemTables returns table names of all generated system tables.
Expand All @@ -183,8 +182,8 @@ var getWriteableSystemTables = func() []string {
return []string{
GetDocTableName(),
DoltQueryCatalogTableName,
SchemasTableName,
ProceduresTableName,
GetSchemasTableName(),
GetProceduresTableName(),
IgnoreTableName,
RebaseTableName,

Expand Down Expand Up @@ -266,6 +265,11 @@ const (
QueryCatalogDescriptionCol = "description"
)

// GetSchemasTableName returns the name of the dolt schema fragment table
var GetSchemasTableName = func() string {
return SchemasTableName
}

const (
// SchemasTableName is the name of the dolt schema fragment table
SchemasTableName = "dolt_schemas"
Expand All @@ -282,6 +286,9 @@ const (
// SchemasTablesSqlModeCol is the name of the column that stores the SQL_MODE string used when this fragment
// was originally defined. Mode settings, such as ANSI_QUOTES, are needed to correctly parse the fragment.
SchemasTablesSqlModeCol = "sql_mode"
// SchemasTablesSchemaNameCol is the name of the column that stores the name of the schema that the fragment
// is part of. Used by Doltgres only.
SchemasTablesSchemaNameCol = "schema_name"
)

const (
Expand Down Expand Up @@ -424,6 +431,11 @@ const (
StatisticsTableName = "dolt_statistics"
)

// GetProceduresTableName returns the name of the dolt stored procedures table.
var GetProceduresTableName = func() string {
return ProceduresTableName
}

const (
// WorkflowsTableName is the dolt CI workflows system table name
WorkflowsTableName = "dolt_ci_workflows"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ func (d *doltWorkflowManager) validateWorkflowTables(ctx *sql.Context) error {

tableMap := make(map[string]struct{})
for _, table := range tables {
if doltdb.IsDoltCITable(table) {
if doltdb.IsDoltCITable(table, doltdb.HasDoltPrefix(table)) {
tableMap[table] = struct{}{}
}
}
Expand Down
11 changes: 6 additions & 5 deletions go/libraries/doltcore/merge/fulltext_rebuild.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ type rebuildableFulltextTable struct {
Schema schema.Schema
}

// rebuildFullTextIndexes scans the mergedRoot and rebuilds all of the pseudo-index tables that were modified by both
// roots (ours and theirs), or had parents that were modified by both roots.
// rebuildFullTextIndexes scans the mergedRoot and rebuilds all of the
// pseudo-index tables that were modified by both roots (ours and theirs), or
// had parents that were modified by both roots.
func rebuildFullTextIndexes(ctx *sql.Context, mergedRoot, ourRoot, theirRoot doltdb.RootValue, visitedTables map[string]struct{}) (doltdb.RootValue, error) {
// Grab a list of all tables on the root
allTableNames, err := mergedRoot.GetTableNames(ctx, doltdb.DefaultSchemaName)
Expand Down Expand Up @@ -75,7 +76,7 @@ func rebuildFullTextIndexes(ctx *sql.Context, mergedRoot, ourRoot, theirRoot dol
// involved in an actual three-way merge and the full-text index
// pseudo-tables could be out of date.
for _, tblName := range allTableNames {
if doltdb.IsFullTextTable(tblName) {
if doltdb.IsFullTextTable(tblName, doltdb.HasDoltPrefix(tblName)) {
continue
}
// Add this table to the non-deletion set tables, since it's not a pseudo-index table.
Expand Down Expand Up @@ -121,7 +122,7 @@ func rebuildFullTextIndexes(ctx *sql.Context, mergedRoot, ourRoot, theirRoot dol

// Our last loop removes any orphaned pseudo-index tables
for _, tblName := range allTableNames {
if _, doNotDelete := doNotDeleteTables[tblName]; doNotDelete || !doltdb.IsFullTextTable(tblName) {
if _, doNotDelete := doNotDeleteTables[tblName]; doNotDelete || !doltdb.IsFullTextTable(tblName, doltdb.HasDoltPrefix(tblName)) {
continue
}
// TODO: schema name
Expand Down Expand Up @@ -313,7 +314,7 @@ func createRowIterForTable(ctx *sql.Context, t *doltdb.Table, sch schema.Schema)
// Also ignores Full-Text config tables. Returns the updated root with the tables purged.
func purgeFulltextTableData(ctx *sql.Context, root doltdb.RootValue, tableNames ...string) (doltdb.RootValue, error) {
for _, tableName := range tableNames {
if !doltdb.IsFullTextTable(tableName) {
if !doltdb.IsFullTextTable(tableName, doltdb.HasDoltPrefix(tableName)) {
continue
} else if strings.HasSuffix(tableName, "config") {
// We don't want to purge the config table, we'll just roll with whatever is there for now
Expand Down
4 changes: 2 additions & 2 deletions go/libraries/doltcore/merge/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ func MergeRoots(
for _, tblName := range tblNames {
mergedTable, stats, err := merger.MergeTable(ctx, tblName, opts, mergeOpts)

if errors.Is(ErrTableDeletedAndModified, err) && doltdb.IsFullTextTable(tblName.Name) {
if errors.Is(ErrTableDeletedAndModified, err) && doltdb.IsFullTextTable(tblName.Name, doltdb.HasDoltPrefix(tblName.Name)) {
// If a Full-Text table was both modified and deleted, then we want to ignore the deletion.
// If there's a true conflict, then the parent table will catch the conflict.
stats = &MergeStats{Operation: TableModified}
Expand All @@ -277,7 +277,7 @@ func MergeRoots(
if stats.Operation != TableUnmodified {
visitedTables[tblName.Name] = struct{}{}
}
if doltdb.IsFullTextTable(tblName.Name) && (stats.Operation == TableModified || stats.Operation == TableRemoved) {
if doltdb.IsFullTextTable(tblName.Name, doltdb.HasDoltPrefix(tblName.Name)) && (stats.Operation == TableModified || stats.Operation == TableRemoved) {
// We handle removal and modification later in the rebuilding process, so we'll skip those.
// We do not handle adding new tables, so we allow that to proceed.
continue
Expand Down
Loading
Loading