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

Method CreateView

pkg/ddl/executor.go:1475–1512  ·  view source on GitHub ↗
(ctx sessionctx.Context, s *ast.CreateViewStmt)

Source from the content-addressed store, hash-verified

1473}
1474
1475func (e *executor) CreateView(ctx sessionctx.Context, s *ast.CreateViewStmt) (err error) {
1476 viewInfo, err := BuildViewInfo(s)
1477 if err != nil {
1478 return err
1479 }
1480
1481 cols := make([]*table.Column, len(s.Cols))
1482 for i, v := range s.Cols {
1483 cols[i] = table.ToColumn(&model.ColumnInfo{
1484 Name: v,
1485 ID: int64(i),
1486 Offset: i,
1487 State: model.StatePublic,
1488 })
1489 }
1490
1491 tblCharset := ""
1492 tblCollate := ""
1493 if v, ok := ctx.GetSessionVars().GetSystemVar(variable.CharacterSetConnection); ok {
1494 tblCharset = v
1495 }
1496 if v, ok := ctx.GetSessionVars().GetSystemVar(variable.CollationConnection); ok {
1497 tblCollate = v
1498 }
1499
1500 tbInfo, err := BuildTableInfo(NewMetaBuildContextWithSctx(ctx), s.ViewName.Name, cols, nil, tblCharset, tblCollate)
1501 if err != nil {
1502 return err
1503 }
1504 tbInfo.View = viewInfo
1505
1506 onExist := OnExistError
1507 if s.OrReplace {
1508 onExist = OnExistReplace
1509 }
1510
1511 return e.CreateTableWithInfo(ctx, s.ViewName.Schema, tbInfo, nil, WithOnExist(onExist))
1512}
1513
1514func checkCharsetAndCollation(cs string, co string) error {
1515 if !charset.ValidCharsetAndCollation(cs, co) {

Callers

nothing calls this directly

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 8

CreateTableWithInfoMethod · 0.95
ToColumnFunction · 0.92
BuildViewInfoFunction · 0.85
BuildTableInfoFunction · 0.85
WithOnExistFunction · 0.85
GetSystemVarMethod · 0.80
GetSessionVarsMethod · 0.65

Tested by

no test coverage detected