當前位置: 首頁>>代碼示例>>Golang>>正文


Golang charset.GetAllCharsets函數代碼示例

本文整理匯總了Golang中github.com/pingcap/tidb/util/charset.GetAllCharsets函數的典型用法代碼示例。如果您正苦於以下問題:Golang GetAllCharsets函數的具體用法?Golang GetAllCharsets怎麽用?Golang GetAllCharsets使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了GetAllCharsets函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: fetchShowCharset

func (s *ShowPlan) fetchShowCharset(ctx context.Context) error {
	// See: http://dev.mysql.com/doc/refman/5.7/en/show-character-set.html
	descs := charset.GetAllCharsets()
	for _, desc := range descs {
		row := &plan.Row{
			Data: []interface{}{desc.Name, desc.Desc, desc.DefaultCollation, desc.Maxlen},
		}
		s.rows = append(s.rows, row)
	}
	return nil
}
開發者ID:netroby,項目名稱:tidb,代碼行數:11,代碼來源:show.go

示例2: fetchShowCharset

// See http://dev.mysql.com/doc/refman/5.7/en/show-character-set.html
func (e *ShowExec) fetchShowCharset() error {
	descs := charset.GetAllCharsets()
	for _, desc := range descs {
		row := &Row{
			Data: types.MakeDatums(
				desc.Name,
				desc.Desc,
				desc.DefaultCollation,
				desc.Maxlen,
			),
		}
		e.rows = append(e.rows, row)
	}
	return nil
}
開發者ID:jmptrader,項目名稱:tidb,代碼行數:16,代碼來源:show.go

示例3: fetchShowCharset

func (e *ShowExec) fetchShowCharset() error {
	// See: http://dev.mysql.com/doc/refman/5.7/en/show-character-set.html
	descs := charset.GetAllCharsets()
	for _, desc := range descs {
		row := &Row{
			Data: types.MakeDatums(
				desc.Name,
				desc.Desc,
				desc.DefaultCollation,
				desc.Maxlen,
			),
		}
		e.rows = append(e.rows, row)
	}
	return nil
}
開發者ID:anywhy,項目名稱:tidb,代碼行數:16,代碼來源:show.go

示例4: fetchAll

func (s *ShowPlan) fetchAll(ctx context.Context) error {
	// TODO split this function
	switch s.Target {
	case stmt.ShowEngines:
		row := &plan.Row{
			Data: []interface{}{"InnoDB", "DEFAULT", "Supports transactions, row-level locking, and foreign keys", "YES", "YES", "YES"},
		}
		s.rows = append(s.rows, row)
	case stmt.ShowDatabases:
		dbs := sessionctx.GetDomain(ctx).InfoSchema().AllSchemaNames()

		// TODO: let information_schema be the first database
		sort.Strings(dbs)

		for _, d := range dbs {
			s.rows = append(s.rows, &plan.Row{Data: []interface{}{d}})
		}
	case stmt.ShowTables:
		is := sessionctx.GetDomain(ctx).InfoSchema()
		dbName := model.NewCIStr(s.DBName)
		if !is.SchemaExists(dbName) {
			return errors.Errorf("Can not find DB: %s", dbName)
		}

		// sort for tables
		var tableNames []string
		for _, v := range is.SchemaTables(dbName) {
			tableNames = append(tableNames, v.TableName().L)
		}

		sort.Strings(tableNames)

		for _, v := range tableNames {
			s.rows = append(s.rows, &plan.Row{Data: []interface{}{v}})
		}
	case stmt.ShowColumns:
		is := sessionctx.GetDomain(ctx).InfoSchema()
		dbName := model.NewCIStr(s.DBName)
		if !is.SchemaExists(dbName) {
			return errors.Errorf("Can not find DB: %s", dbName)
		}
		tbName := model.NewCIStr(s.TableName)
		tb, err := is.TableByName(dbName, tbName)
		if err != nil {
			return errors.Errorf("Can not find table: %s", s.TableName)
		}
		cols := tb.Cols()

		for _, col := range cols {
			if !s.isColOK(col) {
				continue
			}

			desc := column.NewColDesc(col)

			// The FULL keyword causes the output to include the column collation and comments,
			// as well as the privileges you have for each column.
			row := &plan.Row{}
			if s.Full {
				row.Data = []interface{}{
					desc.Field,
					desc.Type,
					desc.Collation,
					desc.Null,
					desc.Key,
					desc.DefaultValue,
					desc.Extra,
					desc.Privileges,
					desc.Comment,
				}
			} else {
				row.Data = []interface{}{
					desc.Field,
					desc.Type,
					desc.Null,
					desc.Key,
					desc.DefaultValue,
					desc.Extra,
				}
			}
			s.rows = append(s.rows, row)
		}
	case stmt.ShowWarnings:
	// empty result
	case stmt.ShowCharset:
		// See: http://dev.mysql.com/doc/refman/5.7/en/show-character-set.html
		descs := charset.GetAllCharsets()
		for _, desc := range descs {
			row := &plan.Row{
				Data: []interface{}{desc.Name, desc.Desc, desc.DefaultCollation, desc.Maxlen},
			}
			s.rows = append(s.rows, row)
		}
	case stmt.ShowVariables:
		sessionVars := variable.GetSessionVars(ctx)
		for _, v := range variable.SysVars {
			if s.Pattern != nil {
				s.Pattern.Expr = expression.Value{Val: v.Name}
				r, err := s.Pattern.Eval(ctx, nil)
				if err != nil {
//.........這裏部分代碼省略.........
開發者ID:kingland,項目名稱:tidb,代碼行數:101,代碼來源:show.go

示例5: Do

// Do implements plan.Plan Do interface.
func (s *ShowPlan) Do(ctx context.Context, f plan.RowIterFunc) (err error) {
	switch s.Target {
	case stmt.ShowEngines:
		f(0, []interface{}{"InnoDB", "DEFAULT", "Supports transactions, row-level locking, and foreign keys", "YES", "YES", "YES"})
	case stmt.ShowDatabases:
		dbs := sessionctx.GetDomain(ctx).InfoSchema().AllSchemaNames()

		// TODO: let information_schema be the first database
		sort.Strings(dbs)

		for _, d := range dbs {
			f(0, []interface{}{d})
		}
	case stmt.ShowTables:
		is := sessionctx.GetDomain(ctx).InfoSchema()
		dbName := model.NewCIStr(s.DBName)
		if !is.SchemaExists(dbName) {
			return errors.Errorf("Can not find DB: %s", dbName)
		}

		// sort for tables
		var tableNames []string
		for _, v := range is.SchemaTables(dbName) {
			tableNames = append(tableNames, v.TableName().L)
		}

		sort.Strings(tableNames)

		for _, v := range tableNames {
			f(0, []interface{}{v})
		}
	case stmt.ShowColumns:
		is := sessionctx.GetDomain(ctx).InfoSchema()
		dbName := model.NewCIStr(s.DBName)
		if !is.SchemaExists(dbName) {
			return errors.Errorf("Can not find DB: %s", dbName)
		}
		tbName := model.NewCIStr(s.TableName)
		tb, err := is.TableByName(dbName, tbName)
		if err != nil {
			return errors.Errorf("Can not find table: %s", s.TableName)
		}
		cols := tb.Cols()

		for _, col := range cols {
			if !s.isColOK(col) {
				continue
			}

			desc := column.NewColDesc(col)

			// The FULL keyword causes the output to include the column collation and comments,
			// as well as the privileges you have for each column.
			if s.Full {
				f(0, []interface{}{
					desc.Field,
					desc.Type,
					desc.Collation,
					desc.Null,
					desc.Key,
					desc.DefaultValue,
					desc.Extra,
					desc.Privileges,
					desc.Comment,
				})
			} else {
				f(0, []interface{}{
					desc.Field,
					desc.Type,
					desc.Null,
					desc.Key,
					desc.DefaultValue,
					desc.Extra,
				})
			}
		}
	case stmt.ShowWarnings:
		// empty result
	case stmt.ShowCharset:
		// See: http://dev.mysql.com/doc/refman/5.7/en/show-character-set.html
		descs := charset.GetAllCharsets()
		for _, desc := range descs {
			row := []interface{}{desc.Name, desc.Desc, desc.DefaultCollation, desc.Maxlen}
			f(0, row)
		}
	case stmt.ShowVariables:
		sessionVars := variable.GetSessionVars(ctx)
		for _, v := range variable.SysVars {
			if s.Pattern != nil {
				p, ok := s.Pattern.(*expressions.PatternLike)
				if !ok {
					return errors.Errorf("Like should be a PatternLike expression")
				}
				p.Expr = expressions.Value{Val: v.Name}
				r, err := p.Eval(ctx, nil)
				if err != nil {
					return errors.Trace(err)
				}
				match, ok := r.(bool)
//.........這裏部分代碼省略.........
開發者ID:superwood,項目名稱:tidb,代碼行數:101,代碼來源:show.go


注:本文中的github.com/pingcap/tidb/util/charset.GetAllCharsets函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。