Documentation ¶
Overview ¶
Package withddl allows you to automatically ensure the tables against which you want to apply statements are up-to-date.
Index ¶
Constants ¶
const QueryToTriggerWithDDL = "SELECT _vt_no_such_column__init_schema FROM _vt.vreplication LIMIT 1"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type WithDDL ¶
type WithDDL struct {
// contains filtered or unexported fields
}
WithDDL allows you to execute statements against tables whose schema may not be up-to-date. If the tables don't exist or result in a schema error, it can apply a series of idempotent DDLs that will create or bring the tables to the desired state and retry.
func (*WithDDL) Exec ¶
func (wd *WithDDL) Exec(ctx context.Context, query string, fQuery any, fDDL any) (*sqltypes.Result, error)
Exec executes the query using the supplied function. If there are any schema errors, it applies the DDLs and retries. It takes 2 functions, one to run the query and the other to run the DDL commands. This is generally needed so that different users can be used to run the commands. i.e. AllPrivs user for DDLs and App user for query commands. Funcs can be any of these types: func(query string) (*sqltypes.Result, error) func(query string, maxrows int) (*sqltypes.Result, error) func(query string, maxrows int, wantfields bool) (*sqltypes.Result, error) func(ctx context.Context, query string, maxrows int, wantfields bool) (*sqltypes.Result, error)