@@ -24,18 +24,9 @@ import (
24
24
"github.com/dolthub/dolt/go/libraries/doltcore/doltdb"
25
25
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/dsess"
26
26
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/index"
27
- "github.com/dolthub/dolt/go/libraries/doltcore/sqle/sqlutil"
28
27
"github.com/dolthub/dolt/go/store/hash"
29
28
)
30
29
31
- var DoltDocsSqlSchema sql.PrimaryKeySchema
32
- var OldDoltDocsSqlSchema sql.PrimaryKeySchema
33
-
34
- func init () {
35
- DoltDocsSqlSchema , _ = sqlutil .FromDoltSchema ("" , doltdb .DocTableName , doltdb .DocsSchema )
36
- OldDoltDocsSqlSchema , _ = sqlutil .FromDoltSchema ("" , doltdb .DocTableName , doltdb .OldDocsSchema )
37
- }
38
-
39
30
var _ sql.Table = (* DocsTable )(nil )
40
31
var _ sql.UpdatableTable = (* DocsTable )(nil )
41
32
var _ sql.DeletableTable = (* DocsTable )(nil )
@@ -48,6 +39,16 @@ type DocsTable struct {
48
39
backingTable VersionableTable
49
40
}
50
41
42
+ // NewDocsTable creates a DocsTable
43
+ func NewDocsTable (_ * sql.Context , backingTable VersionableTable ) sql.Table {
44
+ return & DocsTable {backingTable : backingTable }
45
+ }
46
+
47
+ // NewEmptyDocsTable creates a DocsTable
48
+ func NewEmptyDocsTable (_ * sql.Context ) sql.Table {
49
+ return & DocsTable {}
50
+ }
51
+
51
52
func (dt * DocsTable ) Name () string {
52
53
return doltdb .DocTableName
53
54
}
@@ -58,14 +59,22 @@ func (dt *DocsTable) String() string {
58
59
59
60
const defaultStringsLen = 16383 / 16
60
61
61
- // Schema is a sql.Table interface function that gets the sql.Schema of the dolt_docs system table.
62
- func (dt * DocsTable ) Schema () sql.Schema {
62
+ // GetDocsSchema returns the schema of the dolt_docs system table. This is used
63
+ // by Doltgres to update the dolt_docs schema using Doltgres types.
64
+ var GetDocsSchema = getDoltDocsSchema
65
+
66
+ func getDoltDocsSchema () sql.Schema {
63
67
return []* sql.Column {
64
68
{Name : doltdb .DocPkColumnName , Type : sqlTypes .MustCreateString (sqltypes .VarChar , defaultStringsLen , sql .Collation_Default ), Source : doltdb .DocTableName , PrimaryKey : true , Nullable : false },
65
69
{Name : doltdb .DocTextColumnName , Type : sqlTypes .LongText , Source : doltdb .DocTableName , PrimaryKey : false },
66
70
}
67
71
}
68
72
73
+ // Schema is a sql.Table interface function that gets the sql.Schema of the dolt_docs system table.
74
+ func (dt * DocsTable ) Schema () sql.Schema {
75
+ return GetDocsSchema ()
76
+ }
77
+
69
78
func (dt * DocsTable ) Collation () sql.CollationID {
70
79
return sql .Collation_Default
71
80
}
@@ -88,16 +97,6 @@ func (dt *DocsTable) PartitionRows(context *sql.Context, partition sql.Partition
88
97
return dt .backingTable .PartitionRows (context , partition )
89
98
}
90
99
91
- // NewDocsTable creates a DocsTable
92
- func NewDocsTable (_ * sql.Context , backingTable VersionableTable ) sql.Table {
93
- return & DocsTable {backingTable : backingTable }
94
- }
95
-
96
- // NewEmptyDocsTable creates a DocsTable
97
- func NewEmptyDocsTable (_ * sql.Context ) sql.Table {
98
- return & DocsTable {}
99
- }
100
-
101
100
// Replacer returns a RowReplacer for this table. The RowReplacer will have Insert and optionally Delete called once
102
101
// for each row, followed by a call to Close() when all rows have been processed.
103
102
func (dt * DocsTable ) Replacer (ctx * sql.Context ) sql.RowReplacer {
0 commit comments