Repository: src-d/go-mysql-server (go)

Issue:
information_schema.columns data_type has uppercase values
I was trying to use the Grafana MySQL data source with this library, and it makes the following query to get autocomplete results for a column dropdown:

```
SELECT column_name FROM information_schema.columns WHERE table_schema = database() AND table_name = 'mytable' AND data_type IN ('timestamp','datetime','bigint','int','double','float') ORDER BY column_name
```

This works on real MySQL servers (at least the one I tested), but returns no results for the information_schema database provided by this library. I believe the reason is that the information_schema from this library uses uppercase values for the data_type column (e.g 'DOUBLE', 'BIGINT', etc.), so no results come back. Would it make sense to make the values in this column lowercase?

Pull request description:
sql: information schema column types should be lowercase
Fixes #849


Patch:
diff --git a/sql/information_schema.go b/sql/information_schema.go
index d888047..48147c7 100644
--- a/sql/information_schema.go
+++ b/sql/information_schema.go
@@ -4,6 +4,7 @@ import (
 	"bytes"
 	"fmt"
 	"io"
+	"strings"
 )
 
 const (
@@ -214,27 +215,27 @@ func columnsRowIter(cat *Catalog) RowIter {
 					collName = "utf8_bin"
 				}
 				rows = append(rows, Row{
-					"def",                 // table_catalog
-					db.Name(),             // table_schema
-					t.Name(),              // table_name
-					c.Name,                // column_name
-					uint64(i),             // ordinal_position
-					c.Default,             // column_default
-					nullable,              // is_nullable
-					MySQLTypeName(c.Type), // data_type
-					nil,                   // character_maximum_length
-					nil,                   // character_octet_length
-					nil,                   // numeric_precision
-					nil,                   // numeric_scale
-					nil,                   // datetime_precision
-					charName,              // character_set_name
-					collName,              // collation_name
-					MySQLTypeName(c.Type), // column_type
-					"",                    // column_key
-					"",                    // extra
-					"select",              // privileges
-					"",                    // column_comment
-					"",                    // generation_expression
+					"def",                                  // table_catalog
+					db.Name(),                              // table_schema
+					t.Name(),                               // table_name
+					c.Name,                                 // column_name
+					uint64(i),                              // ordinal_position
+					c.Default,                              // column_default
+					nullable,                               // is_nullable
+					strings.ToLower(MySQLTypeName(c.Type)), // data_type
+					nil,                                    // character_maximum_length
+					nil,                                    // character_octet_length
+					nil,                                    // numeric_precision
+					nil,                                    // numeric_scale
+					nil,                                    // datetime_precision
+					charName,                               // character_set_name
+					collName,                               // collation_name
+					strings.ToLower(MySQLTypeName(c.Type)), // column_type
+					"",                                     // column_key
+					"",                                     // extra
+					"select",                               // privileges
+					"",                                     // column_comment
+					"",                                     // generation_expression
 				})
 			}
 		}


Test patch:
diff --git a/engine_test.go b/engine_test.go
index 5070589..0c3f480 100644
--- a/engine_test.go
+++ b/engine_test.go
@@ -18,7 +18,6 @@ import (
 	"github.com/src-d/go-mysql-server/sql/plan"
 	"github.com/src-d/go-mysql-server/test"
 
-
 	"github.com/stretchr/testify/require"
 )
 
@@ -867,8 +866,8 @@ var queries = []struct {
 		WHERE TABLE_SCHEMA='mydb' AND TABLE_NAME='mytable'
 		`,
 		[]sql.Row{
-			{"s", "TEXT"},
-			{"i", "BIGINT"},
+			{"s", "text"},
+			{"i", "bigint"},
 		},
 	},
 	{
@@ -2250,8 +2249,8 @@ func TestUpdate(t *testing.T) {
 	var updates = []struct {
 		updateQuery    string
 		expectedUpdate []sql.Row
-		selectQuery     string
-		expectedSelect  []sql.Row
+		selectQuery    string
+		expectedSelect []sql.Row
 	}{
 		{
 			"UPDATE mytable SET s = 'updated';",
@@ -2275,7 +2274,7 @@ func TestUpdate(t *testing.T) {
 			"UPDATE mytable SET s = 'updated' WHERE i <> 9999;",
 			[]sql.Row{{int64(3), int64(3)}},
 			"SELECT * FROM mytable;",
-			[]sql.Row{{int64(1), "updated"},{int64(2), "updated"},{int64(3), "updated"}},
+			[]sql.Row{{int64(1), "updated"}, {int64(2), "updated"}, {int64(3), "updated"}},
 		},
 		{
 			"UPDATE floattable SET f32 = f32 + f32, f64 = f32 * f64 WHERE i = 2;",
@@ -2477,7 +2476,7 @@ func TestCreateTable(t *testing.T) {
 
 	testQuery(t, e,
 		"CREATE TABLE t2 (a INTEGER NOT NULL PRIMARY KEY, "+
-				"b VARCHAR(10) NOT NULL)",
+			"b VARCHAR(10) NOT NULL)",
 		[]sql.Row(nil),
 	)
 
@@ -2496,8 +2495,8 @@ func TestCreateTable(t *testing.T) {
 
 	testQuery(t, e,
 		"CREATE TABLE t3(a INTEGER NOT NULL,"+
-				"b TEXT NOT NULL,"+
-				"c bool, primary key (a,b))",
+			"b TEXT NOT NULL,"+
+			"c bool, primary key (a,b))",
 		[]sql.Row(nil),
 	)