mirror of
https://github.com/dolthub/dolt.git
synced 2025-12-30 08:50:01 -06:00
Add pointer for dolt_docs schema so it can be replaced by doltgres
This commit is contained in:
@@ -20,9 +20,8 @@ import (
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/schema/typeinfo"
|
||||
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/schema"
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/schema/typeinfo"
|
||||
"github.com/dolthub/dolt/go/libraries/utils/funcitr"
|
||||
"github.com/dolthub/dolt/go/libraries/utils/set"
|
||||
"github.com/dolthub/dolt/go/store/types"
|
||||
@@ -35,11 +34,6 @@ const (
|
||||
|
||||
var ErrSystemTableCannotBeModified = errors.New("system tables cannot be dropped or altered")
|
||||
|
||||
var OldDocsSchema = schema.MustSchemaFromCols(schema.NewColCollection(
|
||||
schema.NewColumn(DocPkColumnName, schema.DocNameTag, types.StringKind, true, schema.NotNullConstraint{}),
|
||||
schema.NewColumn(DocTextColumnName, schema.DocTextTag, types.StringKind, false),
|
||||
))
|
||||
|
||||
var DocsSchema schema.Schema
|
||||
|
||||
func init() {
|
||||
|
||||
@@ -24,18 +24,9 @@ import (
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/doltdb"
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/dsess"
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/index"
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/sqlutil"
|
||||
"github.com/dolthub/dolt/go/store/hash"
|
||||
)
|
||||
|
||||
var DoltDocsSqlSchema sql.PrimaryKeySchema
|
||||
var OldDoltDocsSqlSchema sql.PrimaryKeySchema
|
||||
|
||||
func init() {
|
||||
DoltDocsSqlSchema, _ = sqlutil.FromDoltSchema("", doltdb.DocTableName, doltdb.DocsSchema)
|
||||
OldDoltDocsSqlSchema, _ = sqlutil.FromDoltSchema("", doltdb.DocTableName, doltdb.OldDocsSchema)
|
||||
}
|
||||
|
||||
var _ sql.Table = (*DocsTable)(nil)
|
||||
var _ sql.UpdatableTable = (*DocsTable)(nil)
|
||||
var _ sql.DeletableTable = (*DocsTable)(nil)
|
||||
@@ -48,6 +39,16 @@ type DocsTable struct {
|
||||
backingTable VersionableTable
|
||||
}
|
||||
|
||||
// NewDocsTable creates a DocsTable
|
||||
func NewDocsTable(_ *sql.Context, backingTable VersionableTable) sql.Table {
|
||||
return &DocsTable{backingTable: backingTable}
|
||||
}
|
||||
|
||||
// NewEmptyDocsTable creates a DocsTable
|
||||
func NewEmptyDocsTable(_ *sql.Context) sql.Table {
|
||||
return &DocsTable{}
|
||||
}
|
||||
|
||||
func (dt *DocsTable) Name() string {
|
||||
return doltdb.DocTableName
|
||||
}
|
||||
@@ -58,14 +59,22 @@ func (dt *DocsTable) String() string {
|
||||
|
||||
const defaultStringsLen = 16383 / 16
|
||||
|
||||
// Schema is a sql.Table interface function that gets the sql.Schema of the dolt_docs system table.
|
||||
func (dt *DocsTable) Schema() sql.Schema {
|
||||
// GetDocsSchema returns the schema of the dolt_docs system table. This is used
|
||||
// by Doltgres to update the dolt_docs schema using Doltgres types.
|
||||
var GetDocsSchema = getDoltDocsSchema
|
||||
|
||||
func getDoltDocsSchema() sql.Schema {
|
||||
return []*sql.Column{
|
||||
{Name: doltdb.DocPkColumnName, Type: sqlTypes.MustCreateString(sqltypes.VarChar, defaultStringsLen, sql.Collation_Default), Source: doltdb.DocTableName, PrimaryKey: true, Nullable: false},
|
||||
{Name: doltdb.DocTextColumnName, Type: sqlTypes.LongText, Source: doltdb.DocTableName, PrimaryKey: false},
|
||||
}
|
||||
}
|
||||
|
||||
// Schema is a sql.Table interface function that gets the sql.Schema of the dolt_docs system table.
|
||||
func (dt *DocsTable) Schema() sql.Schema {
|
||||
return GetDocsSchema()
|
||||
}
|
||||
|
||||
func (dt *DocsTable) Collation() sql.CollationID {
|
||||
return sql.Collation_Default
|
||||
}
|
||||
@@ -88,16 +97,6 @@ func (dt *DocsTable) PartitionRows(context *sql.Context, partition sql.Partition
|
||||
return dt.backingTable.PartitionRows(context, partition)
|
||||
}
|
||||
|
||||
// NewDocsTable creates a DocsTable
|
||||
func NewDocsTable(_ *sql.Context, backingTable VersionableTable) sql.Table {
|
||||
return &DocsTable{backingTable: backingTable}
|
||||
}
|
||||
|
||||
// NewEmptyDocsTable creates a DocsTable
|
||||
func NewEmptyDocsTable(_ *sql.Context) sql.Table {
|
||||
return &DocsTable{}
|
||||
}
|
||||
|
||||
// Replacer returns a RowReplacer for this table. The RowReplacer will have Insert and optionally Delete called once
|
||||
// for each row, followed by a call to Close() when all rows have been processed.
|
||||
func (dt *DocsTable) Replacer(ctx *sql.Context) sql.RowReplacer {
|
||||
|
||||
@@ -11,7 +11,7 @@ export const docsTests = [
|
||||
res: [],
|
||||
},
|
||||
{
|
||||
q: "INSERT INTO dolt_docs VALUES (:docName, :docText) ON DUPLICATE KEY UPDATE doc_text=:docText",
|
||||
q: "REPLACE INTO dolt_docs VALUES (:docName, :docText);",
|
||||
p: {
|
||||
docName: "README.md",
|
||||
docText: readmeText,
|
||||
|
||||
Reference in New Issue
Block a user