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

model

package
v0.13.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

type Result struct {
	Conn      string        // connection name the statement ran on
	Query     string        // the statement text
	Columns   []string      // column names
	Rows      [][]string    // display-ready values (NULL rendered as "NULL")
	Raw       [][]any       // typed values, used for JSON export
	Duration  time.Duration // wall time for the statement
	Truncated bool          // true when the row limit was hit
	IsExec    bool          // true for non-query statements (INSERT/UPDATE/...)
	Affected  int64         // rows affected, when IsExec

	// Transposed marks a result turned on its side (export.Transpose): each
	// row is one of the source's columns, its name in column 0, so the HTML
	// renderings draw that column as row headers rather than as data.
	Transposed bool
}

Result holds one tabular result set from a query or exec statement.

func (*Result) RowCount

func (r *Result) RowCount() int

RowCount returns the number of data rows.

type Routine added in v0.10.0

type Routine struct {
	Schema string
	Name   string
	Kind   RoutineKind
	// Args is the argument list as declared, without its parentheses:
	// "customer integer, since date DEFAULT now()"; "" for none.
	Args string
	// Result is what a function returns: "integer", "SETOF orders",
	// "TABLE(id integer, total numeric)"; "" for a procedure.
	Result string
	// ID tells one overload from another when the routine's definition is
	// asked for (db.Manager.RoutineDDL): Postgres's pg_proc oid, as text.
	// "" on MySQL, which has no overloads — schema, name and kind are
	// enough there.
	ID string
}

Routine is a function or procedure stored in a database, as its catalog lists it: what completion offers beside the dialect's built-in functions. It lives here, not in db or sqlcomplete, because both use it — db reads it, sqlcomplete suggests it — and neither should import the other.

Args and Result are the engine's own rendering, kept as text: completion shows them and never parses them, so a structured form would be work for nothing.

func (Routine) Callable added in v0.10.0

func (r Routine) Callable() bool

Callable reports whether the routine can be called in an expression.

func (Routine) QName added in v0.11.0

func (r Routine) QName() string

QName is the routine's name qualified by its schema, as a sidebar and a log line show it: "public.order_total". A routine read without a schema is its bare name.

type RoutineKind added in v0.10.0

type RoutineKind string

RoutineKind says how a routine is called.

const (
	RoutineFunction  RoutineKind = "function"  // in an expression: f(x)
	RoutineProcedure RoutineKind = "procedure" // in a CALL statement
	RoutineAggregate RoutineKind = "aggregate" // in an expression, over rows
	RoutineWindow    RoutineKind = "window"    // in an expression, with OVER
	// RoutineTrigger is a function returning trigger or event_trigger:
	// it runs only from CREATE TRIGGER … EXECUTE FUNCTION, never in an
	// expression, so completion offers it after FUNCTION alone.
	RoutineTrigger RoutineKind = "trigger"
)

Jump to

Keyboard shortcuts

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