WriteSetStatement execute sql
()
| 759 | |
| 760 | // WriteSetStatement execute sql |
| 761 | func (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 |
| 792 | func (dc *DirectConnection) FieldList(table string, wildcard string) ([]*mysql.Field, error) { |
no test coverage detected