Documentation
¶
Index ¶
- Constants
- Variables
- type AndOp
- type CompOp
- type Field
- type NotOp
- type OrOp
- type OutputFormat
- type RangeOp
- type SelectParser
- type SqlAny
- type SqlBigInt
- type SqlBool
- type SqlDatetime
- type SqlField
- type SqlFieldGetter
- type SqlFieldGetters
- type SqlFieldPrinter
- type SqlFunc
- type SqlFuncAddTime
- type SqlFuncCall
- type SqlFuncFrame
- type SqlFuncLogRow
- type SqlFuncNow
- type SqlFuncSubTime
- type SqlGoFuncRow
- type SqlGoModuleRow
- type SqlGoroutineRow
- type SqlRow
- type SqlString
- type Table
Constants ¶
View Source
const ( BoolType = "bool" BigIntType = "bigint" StringType = "string" DatetimeType = "datetime" )
Variables ¶
View Source
var ( ErrDistinct = errors.New("DISTINCT is not supported") ErrNotFoundTable = errors.New("not found table") ErrJoin = errors.New("JOIN is not supported") ErrTableAlias = errors.New("table alias is not supported") ErrTableQualifier = errors.New("table qualifier is not supported") ErrDBQualifier = errors.New("database name qualifier is not supported") ErrSubquery = errors.New("subquery is not supported") ErrStar = errors.New("\"*\" and other columns are exclusive") ErrColumnAlias = errors.New("column alias is not supported") ErrColumnQualifier = errors.New("column qualifier is not supported") ErrColumnList = errors.New("column list MUST NOT contain anything other than field names") ErrUnsupportedStmt = errors.New("this statement is not supported") ErrGroupBy = errors.New("GROUP BY is not supported") ErrHaving = errors.New("HAVING is not supported") ErrOrderBy = errors.New("ORDER BY is not supported") ErrLimit = errors.New("LIMIT is not supported") ErrFunctionQualifier = errors.New("function qualifier is not supported") )
Functions ¶
This section is empty.
Types ¶
type CompOp ¶
type Field ¶
type SelectParser ¶
func ParseSelect ¶
func ParseSelect(sql string) (*SelectParser, error)
ParseSelect parses the SELECT statement.
func (*SelectParser) ColNames ¶
func (s *SelectParser) ColNames() []string
func (*SelectParser) Cols ¶
func (s *SelectParser) Cols() []Field
func (*SelectParser) From ¶
func (s *SelectParser) From() string
func (*SelectParser) Limit ¶
func (s *SelectParser) Limit() (offset, rows int64)
func (*SelectParser) Parse ¶
func (s *SelectParser) Parse() error
parseSelect parses a "SELECT" statement.
func (*SelectParser) Where ¶
func (s *SelectParser) Where() SqlAny
type SqlAny ¶
type SqlAny interface {
Bool() bool
BigInt() int64
String() string
Datetime() types.Time
// 定数として扱えるならtrueを返す。
Const() bool
// データ型を文字列として返す。
Type() string
// row には *types.FuncLog のような特定のデータ型のポインタを格納する。
// 処理対象の行を変更したい場合は、ここで渡したポインタの先を書き換える。
// Const() がtrueを返すなら、これを設定する必要ない。
// 不正なフィールド名などが指定されていた場合、これはpanicする場合がある。
// 呼び出し元は適切にrecover()などで適切にハンドルする必要がある。
WithRow(row SqlRow)
}
このシステム内で扱う全てのデータ型
type SqlDatetime ¶
func (SqlDatetime) BigInt ¶
func (d SqlDatetime) BigInt() int64
func (SqlDatetime) Bool ¶
func (d SqlDatetime) Bool() bool
func (SqlDatetime) Const ¶
func (d SqlDatetime) Const() bool
func (SqlDatetime) Datetime ¶
func (d SqlDatetime) Datetime() types.Time
func (SqlDatetime) String ¶
func (d SqlDatetime) String() string
func (SqlDatetime) Type ¶
func (d SqlDatetime) Type() string
func (SqlDatetime) WithRow ¶
func (d SqlDatetime) WithRow(row SqlRow)
type SqlField ¶
type SqlField struct {
Field Field
// contains filtered or unexported fields
}
テーブルの1つのフィールドを表す。 これの値を取得するときは、先にWithRow()で処理対象の行を指定すること。
type SqlFieldGetter ¶
type SqlFieldGetter func() SqlAny
SqlFieldGetter は SqlAny.WithRow() で指定した行の特定のフィールドを返す。 対象の行やoffsetが変更になった場合、既存の SqlFieldGetter も変更後のフィールドを返す。
func (SqlFieldGetter) Printer ¶
func (g SqlFieldGetter) Printer(format OutputFormat) SqlFieldPrinter
type SqlFieldGetters ¶
type SqlFieldGetters []SqlFieldGetter
func (SqlFieldGetters) Printer ¶
func (gs SqlFieldGetters) Printer(format OutputFormat) (p SqlFieldPrinter)
type SqlFieldPrinter ¶
SqlFieldPrinter は SqlAny.WithRow() で指定した行を特定の文字列フォーマットに変換する。 引数で指定したバッファに変換後の文字列を書き込み、書き込んだバイト数を戻り地として返す。 バッファサイズが足りない場合、この関数はpanicする。 SqlFieldGetter 同様に、処理対象の行が変更になると既存の SqlFieldPrinter も変更後の文字列を返す。
type SqlFuncAddTime ¶
func (*SqlFuncAddTime) BigInt ¶
func (d *SqlFuncAddTime) BigInt() int64
func (*SqlFuncAddTime) Bool ¶
func (d *SqlFuncAddTime) Bool() bool
func (*SqlFuncAddTime) Const ¶
func (d *SqlFuncAddTime) Const() bool
func (*SqlFuncAddTime) Datetime ¶
func (d *SqlFuncAddTime) Datetime() types.Time
func (*SqlFuncAddTime) String ¶
func (d *SqlFuncAddTime) String() string
func (*SqlFuncAddTime) Type ¶
func (d *SqlFuncAddTime) Type() string
func (*SqlFuncAddTime) WithRow ¶
func (d *SqlFuncAddTime) WithRow(row SqlRow)
type SqlFuncCall ¶
type SqlFuncCall struct {
Expr SqlAny
// contains filtered or unexported fields
}
func (*SqlFuncCall) BigInt ¶
func (d *SqlFuncCall) BigInt() int64
func (*SqlFuncCall) Bool ¶
func (d *SqlFuncCall) Bool() bool
func (*SqlFuncCall) Const ¶
func (d *SqlFuncCall) Const() bool
func (*SqlFuncCall) Datetime ¶
func (d *SqlFuncCall) Datetime() types.Time
func (*SqlFuncCall) String ¶
func (d *SqlFuncCall) String() string
func (*SqlFuncCall) Type ¶
func (d *SqlFuncCall) Type() string
func (*SqlFuncCall) WithRow ¶
func (d *SqlFuncCall) WithRow(row SqlRow)
type SqlFuncFrame ¶
type SqlFuncFrame struct {
Expr SqlAny
// contains filtered or unexported fields
}
func (*SqlFuncFrame) BigInt ¶
func (d *SqlFuncFrame) BigInt() int64
func (*SqlFuncFrame) Bool ¶
func (d *SqlFuncFrame) Bool() bool
func (*SqlFuncFrame) Const ¶
func (d *SqlFuncFrame) Const() bool
func (*SqlFuncFrame) Datetime ¶
func (d *SqlFuncFrame) Datetime() types.Time
func (*SqlFuncFrame) String ¶
func (d *SqlFuncFrame) String() string
func (*SqlFuncFrame) Type ¶
func (d *SqlFuncFrame) Type() string
func (*SqlFuncFrame) WithRow ¶
func (d *SqlFuncFrame) WithRow(row SqlRow)
type SqlFuncLogRow ¶
type SqlFuncLogRow struct {
// 処理対象の FuncLog へのポインタ。
// このポインタ、またはその先のデータを書き換えることで、 SqlFieldGetter が返す値を変更できる。
FuncLog *types.FuncLog
Symbols *types.Symbols
// contains filtered or unexported fields
}
func (*SqlFuncLogRow) Field ¶
func (r *SqlFuncLogRow) Field(field Field) SqlFieldGetter
func (*SqlFuncLogRow) Fields ¶
func (r *SqlFuncLogRow) Fields(fields []Field) SqlFieldGetters
func (*SqlFuncLogRow) MaxOffset ¶
func (r *SqlFuncLogRow) MaxOffset() int
func (*SqlFuncLogRow) SetOffset ¶
func (r *SqlFuncLogRow) SetOffset(offset int)
type SqlFuncNow ¶
type SqlFuncNow struct {
}
func (*SqlFuncNow) BigInt ¶
func (d *SqlFuncNow) BigInt() int64
func (*SqlFuncNow) Bool ¶
func (d *SqlFuncNow) Bool() bool
func (*SqlFuncNow) Const ¶
func (d *SqlFuncNow) Const() bool
func (*SqlFuncNow) Datetime ¶
func (d *SqlFuncNow) Datetime() types.Time
func (*SqlFuncNow) String ¶
func (d *SqlFuncNow) String() string
func (*SqlFuncNow) Type ¶
func (d *SqlFuncNow) Type() string
func (*SqlFuncNow) WithRow ¶
func (d *SqlFuncNow) WithRow(row SqlRow)
type SqlFuncSubTime ¶
func (*SqlFuncSubTime) BigInt ¶
func (d *SqlFuncSubTime) BigInt() int64
func (*SqlFuncSubTime) Bool ¶
func (d *SqlFuncSubTime) Bool() bool
func (*SqlFuncSubTime) Const ¶
func (d *SqlFuncSubTime) Const() bool
func (*SqlFuncSubTime) Datetime ¶
func (d *SqlFuncSubTime) Datetime() types.Time
func (*SqlFuncSubTime) String ¶
func (d *SqlFuncSubTime) String() string
func (*SqlFuncSubTime) Type ¶
func (d *SqlFuncSubTime) Type() string
func (*SqlFuncSubTime) WithRow ¶
func (d *SqlFuncSubTime) WithRow(row SqlRow)
type SqlGoFuncRow ¶
func (*SqlGoFuncRow) Field ¶
func (r *SqlGoFuncRow) Field(field Field) SqlFieldGetter
func (*SqlGoFuncRow) Fields ¶
func (r *SqlGoFuncRow) Fields(fields []Field) SqlFieldGetters
func (*SqlGoFuncRow) MaxOffset ¶
func (r *SqlGoFuncRow) MaxOffset() int
func (*SqlGoFuncRow) SetOffset ¶
func (r *SqlGoFuncRow) SetOffset(offset int)
type SqlGoModuleRow ¶
func (*SqlGoModuleRow) Field ¶
func (r *SqlGoModuleRow) Field(field Field) SqlFieldGetter
func (*SqlGoModuleRow) Fields ¶
func (r *SqlGoModuleRow) Fields(fields []Field) SqlFieldGetters
func (*SqlGoModuleRow) MaxOffset ¶
func (r *SqlGoModuleRow) MaxOffset() int
func (*SqlGoModuleRow) SetOffset ¶
func (r *SqlGoModuleRow) SetOffset(offset int)
type SqlGoroutineRow ¶
func (*SqlGoroutineRow) Field ¶
func (r *SqlGoroutineRow) Field(field Field) SqlFieldGetter
func (*SqlGoroutineRow) Fields ¶
func (r *SqlGoroutineRow) Fields(fields []Field) SqlFieldGetters
func (*SqlGoroutineRow) MaxOffset ¶
func (r *SqlGoroutineRow) MaxOffset() int
func (*SqlGoroutineRow) SetOffset ¶
func (r *SqlGoroutineRow) SetOffset(offset int)
type SqlRow ¶
type SqlRow interface {
// 指定したフィールドを返す SqlFieldGetter を作成して返す。
// 指定したテーブルや列が存在しない場合はpanicする。
// 複数行を処理する場合は、パフォーマンス向上のために SqlFieldGetter を再利用するべき。
Field(field Field) SqlFieldGetter
// 指定したフィールドの SqlFieldGetter を全て返す。
Fields(fields []Field) SqlFieldGetters
// 対象となる types.FuncLog.Frames のインデックスを指定する。
SetOffset(offset int)
// 現時点での types.FuncLog.Frames の長さを返す。
MaxOffset() int
}
SqlRow は処理対象の1つの行を表すデータ型。
Click to show internal directories.
Click to hide internal directories.