Files
zeekay 0c90ebe02e debrand: finish the rename across source, docs and dev infra
Source: the unexported clickhouse struct becomes client, the ch receiver and
chproto import alias follow, error message prefixes read datastore, and the
JSON serializer interface drops the vendor infix. resources' metadata key and
its accessor are renamed together, with a test proving the embedded YAML still
unmarshals — a silent drift there would have made every connection take the
unsupported-server-version branch.

Codegen: all three templates still emitted the upstream module paths, so
regenerating would have quietly undone the rename. Note the templates have
drifted from the files they produce (regenerating today drops QBit and
scanTypeDuration), so the generated files are left as tracked and only the
templates are corrected.

Dead links: an earlier mechanical pass invented URLs that do not resolve —
github.com/ClickHouse/datastore-go, hanzo-ds/driver issue numbers that belong to
upstream, and mangled names of independent projects (mailru, uptrace, nikepan,
EpicStep). Third-party names are not ours to rewrite, so those directories are
removed rather than repaired, and provenance comments now point at real files.

Dev infra: compose runs our own server image at the tag production runs, since
the vendor's alpine tag does not exist in our registry. Cluster hostnames,
nginx upstreams and server configs are renamed as one set.

CHANGELOG.md is upstream's release history for versions this module never
released; rewriting it would fabricate a lineage, so it is dropped and the
upstream base recorded in README instead.

The two long-standing vet findings are fixed by keying the struct literals
rather than suppressed. LICENSE and contributors/list keep the vendor name on
purpose: one is the copyright notice Apache-2.0 requires, the other is real
people's names. CI now enforces build, vet, test, gofmt and a grep gate.
2026-07-26 11:46:39 -07:00

87 lines
1.9 KiB
Go

package column
import (
"fmt"
"github.com/hanzo-ds/native/proto"
"reflect"
"regexp"
"strings"
"time"
)
// column names which match this must be escaped - see https://docs.hanzo.ai/datastore/sql-reference/syntax/#identifiers
var escapeColRegex = regexp.MustCompile("^[a-zA-Z_][0-9a-zA-Z_]*$")
// to escape and unescape special chars
var colEscape = strings.NewReplacer("`", "\\`", "\\", "\\\\")
var colUnEscape = strings.NewReplacer("\\`", "`", "\\\\", "\\")
type Type string
func (t Type) params() string {
switch start, end := strings.Index(string(t), "("), strings.LastIndex(string(t), ")"); {
case len(t) == 0, start <= 0, end <= 0, end < start:
return ""
default:
return string(t[start+1 : end])
}
}
type Error struct {
ColumnType string
Err error
}
func (e *Error) Error() string {
return fmt.Sprintf("%s: %s", e.ColumnType, e.Err)
}
type ColumnConverterError struct {
Op string
Hint string
From, To string
}
func (e *ColumnConverterError) Error() string {
var hint string
if len(e.Hint) != 0 {
hint += ". " + e.Hint
}
return fmt.Sprintf("datastore [%s]: converting %s to %s is unsupported%s", e.Op, e.From, e.To, hint)
}
type UnsupportedColumnTypeError struct {
t Type
}
func (e *UnsupportedColumnTypeError) Error() string {
return fmt.Sprintf("datastore: unsupported column type %q", e.t)
}
type Interface interface {
Name() string
Type() Type
Rows() int
Row(i int, ptr bool) any
ScanRow(dest any, row int) error
Append(v any) (nulls []uint8, err error)
AppendRow(v any) error
Decode(reader *proto.Reader, rows int) error
Encode(buffer *proto.Buffer)
ScanType() reflect.Type
Reset()
}
type CustomSerialization interface {
ReadStatePrefix(*proto.Reader) error
WriteStatePrefix(*proto.Buffer) error
}
type ServerContext struct {
Revision uint64
VersionMajor uint64
VersionMinor uint64
VersionPatch uint64
Timezone *time.Location
}