Skip to content

Commit 581e3c7

Browse files
authored
Merge pull request #2196 from codeaucafe/codeaucafe/dolthub-dolt-#5862-dolt-status-ignored-adapter
dolthub/dolt#10227: add dolt_status_ignored dolt system table
2 parents 7b964ac + 9ede170 commit 581e3c7

6 files changed

Lines changed: 171 additions & 2 deletions

File tree

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,3 +202,5 @@ require (
202202
gopkg.in/go-jose/go-jose.v2 v2.6.3 // indirect
203203
gopkg.in/yaml.v3 v3.0.1 // indirect
204204
)
205+
206+
replace github.com/dolthub/dolt/go => github.com/codeaucafe/dolt/go v0.0.0-20260112072202-5155e81a0941

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ github.com/cockroachdb/redact v1.0.6 h1:W34uRRyNR4dlZFd0MibhNELsZSgMkl52uRV/tA1x
201201
github.com/cockroachdb/redact v1.0.6/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg=
202202
github.com/cockroachdb/sentry-go v0.6.1-cockroachdb.2 h1:IKgmqgMQlVJIZj19CdocBeSfSaiCbEBZGKODaixqtHM=
203203
github.com/cockroachdb/sentry-go v0.6.1-cockroachdb.2/go.mod h1:8BT+cPK6xvFOcRlk0R8eg+OTkcqI6baNH4xAkpiYVvQ=
204+
github.com/codeaucafe/dolt/go v0.0.0-20260112072202-5155e81a0941 h1:97xLoYXXXgsPUk0EpUF97VxISn16kEWwnpld+X2Srjc=
205+
github.com/codeaucafe/dolt/go v0.0.0-20260112072202-5155e81a0941/go.mod h1:JqA5M1sKCGWpeXiLaap4JUGRloJ8KGVec6C6A2K6ZrY=
204206
github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0/go.mod h1:4Zcjuz89kmFXt9morQgcfYZAYZ5n8WHjt81YYWIwtTM=
205207
github.com/colinmarc/hdfs/v2 v2.1.1/go.mod h1:M3x+k8UKKmxtFu++uAZ0OtDU8jR3jnaZIAc6yK4Ue0c=
206208
github.com/containerd/continuity v0.0.0-20190827140505-75bee3e2ccb6/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y=
@@ -228,8 +230,6 @@ github.com/dolthub/aws-sdk-go-ini-parser v0.0.0-20250305001723-2821c37f6c12 h1:I
228230
github.com/dolthub/aws-sdk-go-ini-parser v0.0.0-20250305001723-2821c37f6c12/go.mod h1:rN7X8BHwkjPcfMQQ2QTAq/xM3leUSGLfb+1Js7Y6TVo=
229231
github.com/dolthub/dolt-mcp v0.2.2 h1:bpROmam74n95uU4EA3BpOIVlTDT0pzeFMBwe/YRq2mI=
230232
github.com/dolthub/dolt-mcp v0.2.2/go.mod h1:S++DJ4QWTAXq+0TNzFa7Oq3IhoT456DJHwAINFAHgDQ=
231-
github.com/dolthub/dolt/go v0.40.5-0.20260108000424-ed62ee89285b h1:2DTDLbZwltHrge1NSe8EWkv9f+oCs4QCAE1OVVEF1gw=
232-
github.com/dolthub/dolt/go v0.40.5-0.20260108000424-ed62ee89285b/go.mod h1:z5e06zwixH1wM1gOwBsp4yMllZyZ8PnmXKdnjTf1Vcs=
233233
github.com/dolthub/eventsapi_schema v0.0.0-20250915094920-eadfd39051ca h1:BGFz/0OlKIuC6qHIZQbvPapFvdAJkeEyGXWVgL5clmE=
234234
github.com/dolthub/eventsapi_schema v0.0.0-20250915094920-eadfd39051ca/go.mod h1:CoDLfgPqHyBtth0Cp+fi/CmC4R81zJNX4wPjShdZ+Bw=
235235
github.com/dolthub/flatbuffers/v23 v23.3.3-dh.2 h1:u3PMzfF8RkKd3lB9pZ2bfn0qEG+1Gms9599cr0REMww=

server/tables/dtables/init.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
// Init handles initialization of all Postgres-specific and Doltgres-specific Dolt system tables.
2727
func Init() {
2828
adapters.DoltTableAdapterRegistry.AddAdapter(doltdb.StatusTableName, DoltgresDoltStatusTableAdapter{}, DoltgresDoltStatusTableName)
29+
adapters.DoltTableAdapterRegistry.AddAdapter(doltdb.StatusIgnoredTableName, DoltgresDoltStatusIgnoredTableAdapter{}, DoltgresDoltStatusIgnoredTableName)
2930

3031
// Table names
3132
doltdb.GetBranchesTableName = getBranchesTableName
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
// Copyright 2026 Dolthub, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package dtables
16+
17+
import (
18+
"fmt"
19+
20+
"github.com/dolthub/dolt/go/libraries/doltcore/doltdb"
21+
"github.com/dolthub/dolt/go/libraries/doltcore/env"
22+
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/adapters"
23+
doltdtables "github.com/dolthub/dolt/go/libraries/doltcore/sqle/dtables"
24+
"github.com/dolthub/go-mysql-server/sql"
25+
26+
pgtypes "github.com/dolthub/doltgresql/server/types"
27+
)
28+
29+
// DoltgresDoltStatusIgnoredTableAdapter adapts the [doltdtables.StatusIgnoredTable] into a Doltgres-compatible version.
30+
//
31+
// DoltgresDoltStatusIgnoredTableAdapter implements the [adapters.TableAdapter] interface.
32+
type DoltgresDoltStatusIgnoredTableAdapter struct{}
33+
34+
var _ adapters.TableAdapter = DoltgresDoltStatusIgnoredTableAdapter{}
35+
36+
// NewTable returns a new [sql.Table] for Doltgres' version of [doltdtables.StatusIgnoredTable].
37+
func (a DoltgresDoltStatusIgnoredTableAdapter) NewTable(ctx *sql.Context, tableName string, ddb *doltdb.DoltDB, ws *doltdb.WorkingSet, rp env.RootsProvider[*sql.Context]) sql.Table {
38+
doltTable := doltdtables.NewStatusIgnoredTableWithNoAdapter(ctx, tableName, ddb, ws, rp)
39+
return &doltgresDoltStatusIgnoredTable{
40+
srcDoltStatusIgnored: doltTable.(*doltdtables.StatusIgnoredTable),
41+
}
42+
}
43+
44+
// TableName returns the table name for Doltgres' version of [doltdtables.StatusIgnoredTable].
45+
func (a DoltgresDoltStatusIgnoredTableAdapter) TableName() string {
46+
return DoltgresDoltStatusIgnoredTableName
47+
}
48+
49+
// DoltgresDoltStatusIgnoredTableName is the name of Dolt's status_ignored table following Doltgres' naming conventions.
50+
const DoltgresDoltStatusIgnoredTableName = "status_ignored"
51+
52+
// doltgresDoltStatusIgnoredTable translates the [doltdtables.StatusIgnoredTable] into a Doltgres-compatible version.
53+
//
54+
// doltgresDoltStatusIgnoredTable implements the [sql.Table] and [sql.StatisticsTable] interfaces.
55+
type doltgresDoltStatusIgnoredTable struct {
56+
srcDoltStatusIgnored *doltdtables.StatusIgnoredTable
57+
}
58+
59+
var _ sql.Table = (*doltgresDoltStatusIgnoredTable)(nil)
60+
var _ sql.StatisticsTable = (*doltgresDoltStatusIgnoredTable)(nil)
61+
62+
// Name returns the name of Doltgres' version of the Dolt status_ignored table.
63+
func (w *doltgresDoltStatusIgnoredTable) Name() string {
64+
return w.srcDoltStatusIgnored.Name()
65+
}
66+
67+
// Schema returns the schema for Doltgres' version of the Dolt status_ignored table.
68+
func (w *doltgresDoltStatusIgnoredTable) Schema() sql.Schema {
69+
return []*sql.Column{
70+
{Name: "table_name", Type: pgtypes.Text, Source: DoltgresDoltStatusIgnoredTableName, PrimaryKey: true, Nullable: false},
71+
{Name: "staged", Type: pgtypes.Bool, Source: DoltgresDoltStatusIgnoredTableName, PrimaryKey: true, Nullable: false},
72+
{Name: "status", Type: pgtypes.Text, Source: DoltgresDoltStatusIgnoredTableName, PrimaryKey: true, Nullable: false},
73+
{Name: "ignored", Type: pgtypes.Bool, Source: DoltgresDoltStatusIgnoredTableName, PrimaryKey: false, Nullable: false},
74+
}
75+
}
76+
77+
// String returns the string representation of [doltdtables.StatusIgnoredTable].
78+
func (w *doltgresDoltStatusIgnoredTable) String() string {
79+
return w.srcDoltStatusIgnored.String()
80+
}
81+
82+
// Collation returns the [sql.CollationID] from [doltdtables.StatusIgnoredTable].
83+
func (w *doltgresDoltStatusIgnoredTable) Collation() sql.CollationID {
84+
return w.srcDoltStatusIgnored.Collation()
85+
}
86+
87+
// Partitions returns a [sql.PartitionIter] on the partitions of [doltdtables.StatusIgnoredTable].
88+
func (w *doltgresDoltStatusIgnoredTable) Partitions(ctx *sql.Context) (sql.PartitionIter, error) {
89+
return w.srcDoltStatusIgnored.Partitions(ctx)
90+
}
91+
92+
// PartitionRows returns a wrapped [sql.RowIter] for the rows in |partition| from
93+
// [doltdtables.StatusIgnoredTable.PartitionRows] to later apply column transformations that match Doltgres' version of the
94+
// Dolt status_ignored table schema.
95+
func (w *doltgresDoltStatusIgnoredTable) PartitionRows(ctx *sql.Context, partition sql.Partition) (sql.RowIter, error) {
96+
iter, err := w.srcDoltStatusIgnored.PartitionRows(ctx, partition)
97+
if err != nil {
98+
return nil, err
99+
}
100+
return &doltgresDoltStatusIgnoredRowIter{w, iter}, nil
101+
}
102+
103+
// DataLength returns the length of the data in bytes from [doltdtables.StatusIgnoredTable].
104+
func (w *doltgresDoltStatusIgnoredTable) DataLength(ctx *sql.Context) (uint64, error) {
105+
return w.srcDoltStatusIgnored.DataLength(ctx)
106+
}
107+
108+
// RowCount returns exact (true) or estimate (false) number of rows from [doltdtables.StatusIgnoredTable].
109+
func (w *doltgresDoltStatusIgnoredTable) RowCount(ctx *sql.Context) (uint64, bool, error) {
110+
return w.srcDoltStatusIgnored.RowCount(ctx)
111+
}
112+
113+
// doltgresDoltStatusIgnoredRowIter wraps [doltdtables.StatusIgnoredTable] [sql.RowIter] and applies transformations before returning
114+
// its rows to make sure they're compatible with Doltgres' version of Dolt's status_ignored table.
115+
type doltgresDoltStatusIgnoredRowIter struct {
116+
doltStatusIgnoredTable sql.Table
117+
rowIter sql.RowIter
118+
}
119+
120+
var _ sql.RowIter = (*doltgresDoltStatusIgnoredRowIter)(nil)
121+
122+
// Next converts the 'staged' column from [doltdtables.StatusIgnoredTable.Schema] from byte into bool since,
123+
// unlike the MySQL wire protocol, Doltgres has a real bool type.
124+
func (i *doltgresDoltStatusIgnoredRowIter) Next(ctx *sql.Context) (sql.Row, error) {
125+
row, err := i.rowIter.Next(ctx)
126+
if err != nil {
127+
return nil, err
128+
}
129+
130+
// Dolt uses byte to avoid MySQL wire protocol ambiguity on tinyint(1) and bool.
131+
// See: https://github.com/dolthub/dolt/pull/10117
132+
stagedIndex := i.doltStatusIgnoredTable.Schema().IndexOfColName("staged")
133+
stagedVal, ok := row[stagedIndex].(byte)
134+
if !ok {
135+
return nil, fmt.Errorf("expected staged column at index %d to be byte, got %T", stagedIndex, row[stagedIndex])
136+
}
137+
row[stagedIndex] = stagedVal != 0
138+
139+
return row, nil
140+
}
141+
142+
// Close closes the wrapped [doltdtables.StatusIgnoredTable] [sql.RowIter].
143+
func (i *doltgresDoltStatusIgnoredRowIter) Close(ctx *sql.Context) error {
144+
return i.rowIter.Close(ctx)
145+
}

testing/go/pgcatalog_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4318,6 +4318,7 @@ func TestPgTables(t *testing.T) {
43184318
{"public", "dolt_remotes"},
43194319
{"public", "dolt_schema_conflicts"},
43204320
{"public", "dolt_status"},
4321+
{"public", "dolt_status_ignored"},
43214322
{"public", "dolt_tags"},
43224323
{"public", "dolt_workspace_t1"},
43234324
{"public", "dolt_workspace_t2"},
@@ -4341,6 +4342,7 @@ func TestPgTables(t *testing.T) {
43414342
{"dolt", "remote_branches"},
43424343
{"dolt", "remotes"},
43434344
{"dolt", "status"},
4345+
{"dolt", "status_ignored"},
43444346
},
43454347
},
43464348
},
@@ -5698,6 +5700,7 @@ func TestSystemTablesInPgcatalog(t *testing.T) {
56985700
{"dolt", "remote_branches", "postgres", nil, "f", "f", "f", "f"},
56995701
{"dolt", "remotes", "postgres", nil, "f", "f", "f", "f"},
57005702
{"dolt", "status", "postgres", nil, "f", "f", "f", "f"},
5703+
{"dolt", "status_ignored", "postgres", nil, "f", "f", "f", "f"},
57015704
{"public", "dolt_branches", "postgres", nil, "f", "f", "f", "f"},
57025705
{"public", "dolt_column_diff", "postgres", nil, "f", "f", "f", "f"},
57035706
{"public", "dolt_commit_ancestors", "postgres", nil, "f", "f", "f", "f"},
@@ -5711,6 +5714,7 @@ func TestSystemTablesInPgcatalog(t *testing.T) {
57115714
{"public", "dolt_remotes", "postgres", nil, "f", "f", "f", "f"},
57125715
{"public", "dolt_schema_conflicts", "postgres", nil, "f", "f", "f", "f"},
57135716
{"public", "dolt_status", "postgres", nil, "f", "f", "f", "f"},
5717+
{"public", "dolt_status_ignored", "postgres", nil, "f", "f", "f", "f"},
57145718
{"public", "dolt_tags", "postgres", nil, "f", "f", "f", "f"},
57155719
{"s1", "dolt_branches", "postgres", nil, "f", "f", "f", "f"},
57165720
{"s1", "dolt_column_diff", "postgres", nil, "f", "f", "f", "f"},
@@ -5730,6 +5734,7 @@ func TestSystemTablesInPgcatalog(t *testing.T) {
57305734
{"s1", "dolt_remotes", "postgres", nil, "f", "f", "f", "f"},
57315735
{"s1", "dolt_schema_conflicts", "postgres", nil, "f", "f", "f", "f"},
57325736
{"s1", "dolt_status", "postgres", nil, "f", "f", "f", "f"},
5737+
{"s1", "dolt_status_ignored", "postgres", nil, "f", "f", "f", "f"},
57335738
{"s1", "dolt_tags", "postgres", nil, "f", "f", "f", "f"},
57345739
{"s1", "dolt_workspace_t1", "postgres", nil, "f", "f", "f", "f"},
57355740
{"s1", "t1", "postgres", nil, "t", "f", "f", "f"},
@@ -5761,6 +5766,7 @@ func TestSystemTablesInPgcatalog(t *testing.T) {
57615766
{341706375, "dolt_remotes", 2200, "r"},
57625767
{3210116770, "dolt_schema_conflicts", 2200, "r"},
57635768
{1060579466, "dolt_status", 2200, "r"},
5769+
{1523309269, "dolt_status_ignored", 2200, "r"},
57645770
{1807684176, "dolt_tags", 2200, "r"},
57655771
{1763579892, "dolt_branches", 1634633383, "r"},
57665772
{1212681264, "dolt_column_diff", 1634633383, "r"},
@@ -5780,6 +5786,7 @@ func TestSystemTablesInPgcatalog(t *testing.T) {
57805786
{373092098, "dolt_remotes", 1634633383, "r"},
57815787
{225426095, "dolt_schema_conflicts", 1634633383, "r"},
57825788
{3554775706, "dolt_status", 1634633383, "r"},
5789+
{1227149778, "dolt_status_ignored", 1634633383, "r"},
57835790
{3246414078, "dolt_tags", 1634633383, "r"},
57845791
{1640933374, "dolt_workspace_t1", 1634633383, "r"},
57855792
{2849341124, "t1", 1634633383, "r"},
@@ -5797,6 +5804,7 @@ func TestSystemTablesInPgcatalog(t *testing.T) {
57975804
{148630507, "remote_branches", 1882653564, "r"},
57985805
{1670572237, "remotes", 1882653564, "r"},
57995806
{3431637196, "status", 1882653564, "r"},
5807+
{3418072419, "status_ignored", 1882653564, "r"},
58005808
},
58015809
},
58025810
},
@@ -5921,13 +5929,21 @@ func TestSystemTablesInPgcatalog(t *testing.T) {
59215929
{1212681264, "diff_type", 25, 8, "t", "f", "f"},
59225930
{1218627310, "table", 25, 1, "t", "f", "f"},
59235931
{1218627310, "num_conflicts", 20, 2, "t", "f", "f"},
5932+
{1227149778, "table_name", 25, 1, "t", "f", "f"},
5933+
{1227149778, "staged", 16, 2, "t", "f", "f"},
5934+
{1227149778, "status", 25, 3, "t", "f", "f"},
5935+
{1227149778, "ignored", 16, 4, "t", "f", "f"},
59245936
{1322753784, "table", 25, 1, "t", "f", "f"},
59255937
{1322753784, "num_violations", 20, 2, "t", "f", "f"},
59265938
{1384122262, "name", 25, 1, "t", "f", "f"},
59275939
{1384122262, "stash_id", 25, 2, "t", "f", "f"},
59285940
{1384122262, "branch", 25, 3, "t", "f", "f"},
59295941
{1384122262, "hash", 25, 4, "t", "f", "f"},
59305942
{1384122262, "commit_message", 25, 5, "f", "f", "f"},
5943+
{1523309269, "table_name", 25, 1, "t", "f", "f"},
5944+
{1523309269, "staged", 16, 2, "t", "f", "f"},
5945+
{1523309269, "status", 25, 3, "t", "f", "f"},
5946+
{1523309269, "ignored", 16, 4, "t", "f", "f"},
59315947
{1555944102, "commit_hash", 25, 1, "t", "f", "f"},
59325948
{1555944102, "parent_hash", 25, 2, "t", "f", "f"},
59335949
{1555944102, "parent_index", 23, 3, "t", "f", "f"},
@@ -6023,6 +6039,10 @@ func TestSystemTablesInPgcatalog(t *testing.T) {
60236039
{3390577184, "pk", 23, 3, "t", "f", "f"},
60246040
{3390577184, "v1", 23, 4, "f", "f", "f"},
60256041
{3390577184, "violation_info", 114, 5, "f", "f", "f"},
6042+
{3418072419, "table_name", 25, 1, "t", "f", "f"},
6043+
{3418072419, "staged", 16, 2, "t", "f", "f"},
6044+
{3418072419, "status", 25, 3, "t", "f", "f"},
6045+
{3418072419, "ignored", 16, 4, "t", "f", "f"},
60266046
{3422698383, "pk", 23, 1, "t", "f", "f"},
60276047
{3422698383, "v1", 23, 2, "f", "f", "f"},
60286048
{3422698383, "commit_hash", 25, 3, "t", "f", "f"},

testing/go/sequences_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,6 +1234,7 @@ ORDER BY 1,2;`,
12341234
{"public", "dolt_remotes", "table", "postgres"},
12351235
{"public", "dolt_schema_conflicts", "table", "postgres"},
12361236
{"public", "dolt_status", "table", "postgres"},
1237+
{"public", "dolt_status_ignored", "table", "postgres"},
12371238
{"public", "dolt_tags", "table", "postgres"},
12381239
{"public", "dolt_workspace_call", "table", "postgres"},
12391240
{"public", "dolt_workspace_user", "table", "postgres"},

0 commit comments

Comments
 (0)