Skip to content
Merged
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
29 changes: 15 additions & 14 deletions core/rootvalue.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ func (root *RootValue) GetTableHash(ctx context.Context, tName doltdb.TableName)
}

// GetTableNames implements the interface doltdb.RootValue.
func (root *RootValue) GetTableNames(ctx context.Context, schemaName string) ([]string, error) {
func (root *RootValue) GetTableNames(ctx context.Context, schemaName string, includeRootObjects bool) ([]string, error) {
tableMap, err := root.getTableMap(ctx, schemaName)
if err != nil {
return nil, err
Expand All @@ -336,22 +336,23 @@ func (root *RootValue) GetTableNames(ctx context.Context, schemaName string) ([]
if err != nil {
return nil, err
}
// Iterate collections
colls, err := rootobject.LoadAllCollections(ctx, root)
if err != nil {
return nil, err
}
for _, coll := range colls {
err = coll.IterIDs(ctx, func(identifier id.Id) (stop bool, err error) {
tName := coll.IDToTableName(identifier)
if tName.Schema == schemaName {
names = append(names, tName.Name)
}
return false, nil
})
if includeRootObjects {
colls, err := rootobject.LoadAllCollections(ctx, root)
if err != nil {
return nil, err
}
for _, coll := range colls {
err = coll.IterIDs(ctx, func(identifier id.Id) (stop bool, err error) {
tName := coll.IDToTableName(identifier)
if tName.Schema == schemaName {
names = append(names, tName.Name)
}
return false, nil
})
if err != nil {
return nil, err
}
}
}
return names, nil
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/PuerkitoBio/goquery v1.8.1
github.com/cockroachdb/apd/v2 v2.0.3-0.20200518165714-d020e156310a
github.com/cockroachdb/errors v1.7.5
github.com/dolthub/dolt/go v0.40.5-0.20250808163615-dfb2b4e5b652
github.com/dolthub/dolt/go v0.40.5-0.20250808223748-f010490a4a9d
github.com/dolthub/eventsapi_schema v0.0.0-20250725194025-a087efa1ee55
github.com/dolthub/flatbuffers/v23 v23.3.3-dh.2
github.com/dolthub/go-icu-regex v0.0.0-20250327004329-6799764f2dad
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,8 @@ github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5Xh
github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
github.com/dolthub/aws-sdk-go-ini-parser v0.0.0-20250305001723-2821c37f6c12 h1:IdqX7J8vi/Kn3T3Ee0VzqnLqwFmgA2hr8WZETPcQjfM=
github.com/dolthub/aws-sdk-go-ini-parser v0.0.0-20250305001723-2821c37f6c12/go.mod h1:rN7X8BHwkjPcfMQQ2QTAq/xM3leUSGLfb+1Js7Y6TVo=
github.com/dolthub/dolt/go v0.40.5-0.20250808163615-dfb2b4e5b652 h1:xRqbUQCeZ+QVN9wDzkWGw8bugMX6AbND7J2QWvVWeDk=
github.com/dolthub/dolt/go v0.40.5-0.20250808163615-dfb2b4e5b652/go.mod h1:pP/jZVfosnKfvpsxx2YZODFkfhtMdGtRHXWmT3rtIW8=
github.com/dolthub/dolt/go v0.40.5-0.20250808223748-f010490a4a9d h1:M/VGXJTV9A4QreZzBPwTK8gSivF6xJstkwbr62/Wrmw=
github.com/dolthub/dolt/go v0.40.5-0.20250808223748-f010490a4a9d/go.mod h1:pP/jZVfosnKfvpsxx2YZODFkfhtMdGtRHXWmT3rtIW8=
github.com/dolthub/eventsapi_schema v0.0.0-20250725194025-a087efa1ee55 h1:LdtiPD8IJ+M2XckvfQ/aLG34lET1shz+WMccGBhZRLM=
github.com/dolthub/eventsapi_schema v0.0.0-20250725194025-a087efa1ee55/go.mod h1:CoDLfgPqHyBtth0Cp+fi/CmC4R81zJNX4wPjShdZ+Bw=
github.com/dolthub/flatbuffers/v23 v23.3.3-dh.2 h1:u3PMzfF8RkKd3lB9pZ2bfn0qEG+1Gms9599cr0REMww=
Expand Down
15 changes: 15 additions & 0 deletions testing/bats/root-objects.bats
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,18 @@ SQL
[ "$status" -eq 0 ]
[[ "$output" =~ "12" ]] || false
}

@test 'root-objects: \d does not break' {
query_server <<SQL
CREATE TABLE "t" ("id" SERIAL);
SQL
run query_server -c "\d"
[ "$status" -eq 0 ]
[[ "$output" =~ "sequence" ]] || false

stop_sql_server
start_sql_server
run query_server -c "\d"
[ "$status" -eq 0 ]
[[ "$output" =~ "sequence" ]] || false
}
85 changes: 85 additions & 0 deletions testing/go/sequences_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1116,5 +1116,90 @@ func TestSequences(t *testing.T) {
},
},
},
{
Name: "Information Schema & DIFF_STAT regression testing",
Assertions: []ScriptTestAssertion{
{
Query: `CREATE TABLE "user" ("id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, PRIMARY KEY ("id"));`,
Expected: []sql.Row{},
},
{
Query: `CREATE TABLE "call" (
"id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
"state" character varying NOT NULL,
"content" jsonb NOT NULL,
"created_at" timestamptz NOT NULL,
"updated_at" timestamptz NOT NULL,
"ended_at" timestamptz NULL,
"user" bigint NOT NULL,
PRIMARY KEY ("id"),
CONSTRAINT "call_user_user_fk" FOREIGN KEY ("user") REFERENCES "user" ("id") ON DELETE NO ACTION
);`,
Expected: []sql.Row{},
},
{
Query: "SELECT * FROM information_schema.key_column_usage;",
Expected: []sql.Row{
{"postgres", "public", "PRIMARY", "postgres", "public", "call", "id", 1, nil, nil, nil, nil},
{"postgres", "public", "PRIMARY", "postgres", "public", "user", "id", 1, nil, nil, nil, nil},
{"postgres", "public", "call_user_user_fk", "postgres", "public", "call", "user", 1, 1, "postgres", "user", "id"},
},
},
{
Query: "SELECT * FROM DOLT_DIFF_STAT('HEAD', 'WORKING');",
Expected: []sql.Row{
{"public.call_id_seq", 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{"public.user_id_seq", 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0},
},
},
{ // This is the same as running "\d" in PSQL
Query: `SELECT n.nspname as "Schema",
c.relname as "Name",
CASE c.relkind WHEN 'r' THEN 'table' WHEN 'v' THEN 'view' WHEN 'm' THEN 'materialized view' WHEN 'i' THEN 'index' WHEN 'S' THEN 'sequence' WHEN 't' THEN 'TOAST table' WHEN 'f' THEN 'foreign table' WHEN 'p' THEN 'partitioned table' WHEN 'I' THEN 'partitioned index' END as "Type",
pg_catalog.pg_get_userbyid(c.relowner) as "Owner"
FROM pg_catalog.pg_class c
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
LEFT JOIN pg_catalog.pg_am am ON am.oid = c.relam
WHERE c.relkind IN ('r','p','v','m','S','f','')
AND n.nspname <> 'pg_catalog'
AND n.nspname !~ '^pg_toast'
AND n.nspname <> 'information_schema'
AND pg_catalog.pg_table_is_visible(c.oid)
ORDER BY 1,2;`,
Expected: []sql.Row{
{"public", "call", "table", "postgres"},
{"public", "call_id_seq", "sequence", "postgres"},
{"public", "dolt_branches", "table", "postgres"},
{"public", "dolt_column_diff", "table", "postgres"},
{"public", "dolt_commit_ancestors", "table", "postgres"},
{"public", "dolt_commit_diff_call", "table", "postgres"},
{"public", "dolt_commit_diff_user", "table", "postgres"},
{"public", "dolt_commits", "table", "postgres"},
{"public", "dolt_conflicts", "table", "postgres"},
{"public", "dolt_conflicts_call", "table", "postgres"},
{"public", "dolt_conflicts_user", "table", "postgres"},
{"public", "dolt_constraint_violations", "table", "postgres"},
{"public", "dolt_constraint_violations_call", "table", "postgres"},
{"public", "dolt_constraint_violations_user", "table", "postgres"},
{"public", "dolt_diff", "table", "postgres"},
{"public", "dolt_diff_call", "table", "postgres"},
{"public", "dolt_diff_user", "table", "postgres"},
{"public", "dolt_history_call", "table", "postgres"},
{"public", "dolt_history_user", "table", "postgres"},
{"public", "dolt_log", "table", "postgres"},
{"public", "dolt_merge_status", "table", "postgres"},
{"public", "dolt_remote_branches", "table", "postgres"},
{"public", "dolt_remotes", "table", "postgres"},
{"public", "dolt_schema_conflicts", "table", "postgres"},
{"public", "dolt_status", "table", "postgres"},
{"public", "dolt_tags", "table", "postgres"},
{"public", "dolt_workspace_call", "table", "postgres"},
{"public", "dolt_workspace_user", "table", "postgres"},
{"public", "user", "table", "postgres"},
{"public", "user_id_seq", "sequence", "postgres"},
},
},
},
},
})
}
Loading