MCPcopy
hub / github.com/XiaoMi/Gaea / WriteSetStatement

Method WriteSetStatement

backend/direct_connection.go:761–789  ·  view source on GitHub ↗

WriteSetStatement execute sql

()

Source from the content-addressed store, hash-verified

759
760// WriteSetStatement execute sql
761func (dc *DirectConnection) WriteSetStatement() error {
762 var setVariableSQL bytes.Buffer
763 collation, ok := mysql.Collations[dc.collation]
764 if !ok {
765 return fmt.Errorf("invalid collationId: %v", dc.collation)
766 }
767 appendSetCharset(&setVariableSQL, dc.charset, collation)
768
769 for _, v := range dc.sessionVariables.GetAll() {
770 if v.Name() == mysql.TxReadOnly && dc.versionCompare != nil && !dc.versionCompare.LessThanMySQLVersion803 {
771 appendSetVariable(&setVariableSQL, mysql.TransactionReadOnly, v.Get())
772 continue
773 }
774 appendSetVariable(&setVariableSQL, v.Name(), v.Get())
775 }
776
777 for _, v := range dc.sessionVariables.GetUnusedAndClear() {
778 appendSetVariableToDefault(&setVariableSQL, v.Name())
779 }
780
781 setSQL := setVariableSQL.String()
782 if setSQL == "" {
783 return nil
784 }
785 if _, err := dc.exec(setSQL, 0); err != nil {
786 return err
787 }
788 return nil
789}
790
791// FieldList send ComFieldList to backend mysql
792func (dc *DirectConnection) FieldList(table string, wildcard string) ([]*mysql.Field, error) {

Callers 1

SyncSessionVariablesMethod · 0.95

Calls 10

execMethod · 0.95
appendSetCharsetFunction · 0.85
appendSetVariableFunction · 0.85
GetAllMethod · 0.80
NameMethod · 0.80
GetUnusedAndClearMethod · 0.80
ErrorfMethod · 0.65
GetMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected