(query string)
| 136 | } |
| 137 | |
| 138 | func (c *Cursor) handleSpecialQuery(query string) (r *my.Result, processed bool, err error) { |
| 139 | if emptyResultQuery.MatchString(query) { // send empty result for variables query/table listing |
| 140 | // return empty result |
| 141 | r = &my.Result{ |
| 142 | Status: 0, |
| 143 | InsertId: 0, |
| 144 | AffectedRows: 0, |
| 145 | Resultset: nil, |
| 146 | } |
| 147 | processed = true |
| 148 | } else if emptyResultWithResultSetQuery.MatchString(query) { // send empty result include non-nil result set |
| 149 | // return empty result with empty result set |
| 150 | var resultSet *my.Resultset |
| 151 | var columns []string |
| 152 | var row []interface{} |
| 153 | |
| 154 | for k, v := range mysqlServerVariables { |
| 155 | if strings.Contains(query, k) { |
| 156 | columns = append(columns, k) |
| 157 | row = append(row, v) |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | if len(columns) == 0 { |
| 162 | columns = append(columns, "_") |
| 163 | } |
| 164 | |
| 165 | if row != nil { |
| 166 | resultSet, _ = my.BuildSimpleTextResultset(columns, [][]interface{}{row}) |
| 167 | } else { |
| 168 | resultSet, _ = my.BuildSimpleTextResultset(columns, [][]interface{}{}) |
| 169 | } |
| 170 | |
| 171 | if resultSet.RowDatas == nil { |
| 172 | // force non-empty result set |
| 173 | resultSet.RowDatas = make([]my.RowData, 0) |
| 174 | } |
| 175 | |
| 176 | r = &my.Result{ |
| 177 | Status: 0, |
| 178 | InsertId: 0, |
| 179 | AffectedRows: 0, |
| 180 | Resultset: resultSet, |
| 181 | } |
| 182 | processed = true |
| 183 | } else if showVariablesQuery.MatchString(query) { // send show variables result with custom config |
| 184 | var rows [][]interface{} |
| 185 | |
| 186 | for k, v := range mysqlServerVariables { |
| 187 | rows = append(rows, []interface{}{k, v}) |
| 188 | } |
| 189 | |
| 190 | resultSet, _ := my.BuildSimpleTextResultset([]string{"Variable_name", "Value"}, rows) |
| 191 | r = &my.Result{ |
| 192 | Status: 0, |
| 193 | InsertId: 0, |
| 194 | AffectedRows: 0, |
| 195 | Resultset: resultSet, |
no test coverage detected