MCPcopy
hub / github.com/pingcap/tidb / CreateTableWithInfo

Method CreateTableWithInfo

pkg/ddl/executor.go:1169–1205  ·  view source on GitHub ↗
(
	ctx sessionctx.Context,
	dbName pmodel.CIStr,
	tbInfo *model.TableInfo,
	involvingRef []model.InvolvingSchemaInfo,
	cs ...CreateTableOption,
)

Source from the content-addressed store, hash-verified

1167}
1168
1169func (e *executor) CreateTableWithInfo(
1170 ctx sessionctx.Context,
1171 dbName pmodel.CIStr,
1172 tbInfo *model.TableInfo,
1173 involvingRef []model.InvolvingSchemaInfo,
1174 cs ...CreateTableOption,
1175) (err error) {
1176 c := GetCreateTableConfig(cs)
1177
1178 jobW, err := e.createTableWithInfoJob(ctx, dbName, tbInfo, involvingRef, c)
1179 if err != nil {
1180 return err
1181 }
1182 if jobW == nil {
1183 return nil
1184 }
1185
1186 err = e.DoDDLJobWrapper(ctx, jobW)
1187 if err != nil {
1188 // table exists, but if_not_exists flags is true, so we ignore this error.
1189 if c.OnExist == OnExistIgnore && infoschema.ErrTableExists.Equal(err) {
1190 ctx.GetSessionVars().StmtCtx.AppendNote(err)
1191 err = nil
1192 }
1193 } else {
1194 var scatterScope string
1195 if val, ok := jobW.GetSessionVars(variable.TiDBScatterRegion); ok {
1196 scatterScope = val
1197 }
1198
1199 preSplitAndScatterTable(ctx, e.store, tbInfo, scatterScope)
1200 if err := handleAutoIncID(e.getAutoIDRequirement(), jobW.Job, tbInfo); err != nil {
1201 return errors.Trace(err)
1202 }
1203 }
1204 return errors.Trace(err)
1205}
1206
1207func (e *executor) BatchCreateTableWithInfo(ctx sessionctx.Context,
1208 dbName pmodel.CIStr,

Callers 3

CreateTableMethod · 0.95
CreateViewMethod · 0.95
CreateSequenceMethod · 0.95

Implementers 7

tableScanExecpkg/store/mockstore/mockcopr/executor.
indexScanExecpkg/store/mockstore/mockcopr/executor.
selectionExecpkg/store/mockstore/mockcopr/executor.
topNExecpkg/store/mockstore/mockcopr/executor.
limitExecpkg/store/mockstore/mockcopr/executor.
hashAggExecpkg/store/mockstore/mockcopr/aggregate
streamAggExecpkg/store/mockstore/mockcopr/aggregate

Calls 9

DoDDLJobWrapperMethod · 0.95
getAutoIDRequirementMethod · 0.95
GetCreateTableConfigFunction · 0.85
preSplitAndScatterTableFunction · 0.85
handleAutoIncIDFunction · 0.85
EqualMethod · 0.65
AppendNoteMethod · 0.65
GetSessionVarsMethod · 0.65

Tested by

no test coverage detected