Help us shape the future of Go! Take the 2026 Go Developer Survey

plan

package
v0.0.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 1, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package plan is what executors run: SQL text with bind slots and an assembly spec. Plans are value-independent so clients cache them by IR shape.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FulltextBoolean added in v0.0.19

func FulltextBoolean(s string) string

FulltextBoolean is the transform fulltext_boolean (DIA-6): the search text of a MySQL boolean-mode match. It splits the value on whitespace, removes the MySQL boolean operator characters from each term and drops the terms that are empty, prefixes every term with +, suffixes the last term with *, and joins the terms with single spaces. A value with no term is "", which the executor refuses with IR_INVALID.

Types

type Assemble

type Assemble struct {
	Entity  string   `json:"entity"`
	Alias   string   `json:"alias"`
	Columns []OutCol `json:"columns"`
	// AESVersion is the position, among Columns, of the column that holds the key version when the node reads
	// an AES column. If it is a selected column, it is that column as is; otherwise it is a hidden column.
	AESVersion *int     `json:"aes_version,omitempty"`
	Children   []*Child `json:"children,omitempty"`
	Key        []KeyRef `json:"key"`
}

Assemble maps result columns positionally and describes how rows attach.

type BindSlot

type BindSlot struct {
	From      string `json:"from"`
	Param     int    `json:"param"`
	Transform string `json:"transform,omitempty"`
	Name      string `json:"name,omitempty"`
	Step      int    `json:"step,omitempty"`
	Column    string `json:"column,omitempty"`
	// HostStyles: style stages the dialect leaves to the executor for this
	// value (aes/hex/ip on PostgreSQL/SQLite): the executor applies them to
	// the bound value before sending it (write order). Empty on MySQL.
	HostStyles []string `json:"host_styles,omitempty"`
	// ColType is the dbspec type of the value that a placeholder takes. A value compared with, or
	// assigned to, a column has that column's type (a value passed through a host style is stored in the column,
	// so it is the same). The value a SQL-side style function takes is the type of that function's input;
	// a value compared with a function is the type of its result; a secret is text; config is the type of the
	// column that stores the value; now is datetime; and audit is the type of the audit column. A parent
	// slot carries KeyTypes instead of ColType. A slot with no type does not exist.
	ColType string `json:"col_type,omitempty"`
	// KeyTypes are the dbspec types of the key values that a parent slot expands, in key column order.
	KeyTypes  []string `json:"key_types,omitempty"`
	Precision int      `json:"precision,omitempty"`
	Scale     int      `json:"scale,omitempty"`
	// Length is the n of a varchar(n) slot: a value has at most n characters.
	Length int `json:"length,omitempty"`
	// NotNull marks a param slot that assigns the non-null column Column (set, rows,
	// on_duplicate, the restore set): a NULL value is CODEC_ENCODE before any statement.
	NotNull bool `json:"not_null,omitempty"`
}

BindSlot tells the executor where the value for one placeholder comes from.

  • param: Params[Param] of the request, optionally passed through Transform
  • secret: a key from executor config (Name = "aes")
  • parent: the distinct values described by the step's ParentRef (relation IN lists; expands to N placeholders)
  • now: the executor's current UTC time as "YYYY-MM-DD HH:MM:SS.ffffff" truncated to Precision digits (dialects whose ORM clock is the executor clock, HostNow)
  • audit: the audit record key of the transaction. The inserts and updates of the audit table write it to the audit column. Name is the audit record table.

Transform (executor-side, value-level): "" | "like_contains" (escape % _ \ then wrap in %) | "fulltext_boolean" (DIA-6).

type Child

type Child struct {
	Rel        string   `json:"rel"`
	Kind       string   `json:"kind"` // join | one | many
	Step       int      `json:"step,omitempty"`
	ParentKeys []KeyRef `json:"parent_keys,omitempty"`
	ChildKeys  []KeyRef `json:"child_keys,omitempty"`
	Key        []KeyRef `json:"key,omitempty"`
	Flatten    bool     `json:"flatten,omitempty"`
	// Cascade: the related rows belong to this row (their FK points here) and
	// no_cascade_delete was not set — deleteCascade removes them first.
	Cascade  bool      `json:"cascade,omitempty"`
	Assemble *Assemble `json:"assemble,omitempty"`
}

Child is a joined entity's slice of the same row (kind join, Assemble set) or a relation step's rows attached by key (kind one/many: the rows of Steps[Step] whose value at ChildIndex equals the parent row's value at ParentIndex; their assembly is Steps[Step].Assemble).

  • one: the first matching row (child ORDER BY decides), else null
  • many: a collection keyed by KeyIndex in row order, else empty
  • Flatten: the child's columns also appear as the parent's in array/JSON forms

type IfParent

type IfParent struct {
	Column string `json:"column"`
	Index  int    `json:"index"`
	Param  int    `json:"param"`
}

IfParent loads children only for parent rows whose value at Index equals Params[Param].

type KeyRef

type KeyRef struct {
	Column string `json:"column"`
	Index  int    `json:"index"`
}

KeyRef identifies one ordered component of a row key.

type OutCol

type OutCol struct {
	Index  int      `json:"index"`
	Name   string   `json:"name"`             // output name (column or alias)
	Column string   `json:"column,omitempty"` // source column, "" for expr
	Type   string   `json:"type"`
	Styles []string `json:"styles,omitempty"` // remaining client-side decode stages
	Hidden bool     `json:"hidden,omitempty"` // selected for writing only (the AES key version): left out of array/JSON forms
}

type ParentRef

type ParentRef struct {
	Step     int       `json:"step"`
	Keys     []KeyRef  `json:"keys"`
	IfParent *IfParent `json:"if_parent,omitempty"`
}

ParentRef binds a relation step to the rows of an earlier step. The executor collects distinct non-null key tuples in Keys order and skips the step when no parent key remains.

type Plan

type Plan struct {
	ManifestHash string `json:"manifest_hash"`
	Kind         string `json:"kind"`
	Steps        []Step `json:"steps"`
}

type Step

type Step struct {
	ID   int    `json:"id"`
	Role string `json:"role"` // main | count | relation
	SQL  string `json:"sql"`
	// Tables are the tables that the statement names: physical table names, sorted and deduplicated.
	Tables    []string   `json:"tables"`
	Lock      string     `json:"lock,omitempty"` // adapter lock mode for a root row select
	BindSlots []BindSlot `json:"bind_slots"`
	Assemble  *Assemble  `json:"assemble,omitempty"`
	Parent    *ParentRef `json:"parent,omitempty"` // relation steps: where the IN values come from
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL