You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.markdown
+5-1Lines changed: 5 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ Revision History
7
7
8
8
0.3.x series [testing]
9
9
10
-
* 0.3.0-RC - Fixed SimpleTest unit test.
10
+
* 0.3.0-RC - Fixed SimpleTest unit test. Fixed and variable length strings for normal queries now return string types not []byte, text/blobs are indistinguishable so are left in []byte format. All integer values in prepared statements are stored as either int64 or uint64 depending on the unsigned flag, this simplifies conversion greatly when binding the result. Added ParamCount() and RowCount() methods to statements. The built in Date, Time and DateTime types can now be bound as strings in statements.
11
11
* 0.3.0-beta-1 - Added full statement and functions. Refactored packet handlers into generic functions. Added new BindResult/Fetch method to get result data from prepared statements. Added type conversions for similar types to populate the result pointers with values from the row data. Added simple type conversion to standard queries. Added automatic reconnect for a select number of operations. Added greater number of client errors from the MySQL manual. Added date/time types to allow date/time elements to be stored as integers and ints, making them more useful.
12
12
* 0.3.0-alpha-3 - Added new error structs ClientError and ServerError. Replaced majority of os.Error/os.NewError functionality with MySQL specific ClientError objects. Server error responses now return a ServerError. Removed Client.Errno and Client.Error. Added deferred error processing to reader, writer and packets to catch and errors and always return a ClientError. Rewrote auto reconnect to check for specific MySQL error codes.
13
13
* 0.3.0-alpha-2 - Added transaction wrappers, Added auto-reconnect functionality to repeatable methods. Removed mutex lock/unlocking, as it is now more appropriate that the application decides when thread safe functions are required and it's considerably safer to have a sequence such as Client.Lock(), Client.Query(...), Client.Unlock(). Added a new test which performs create, drop, select, insert and update queries on a simple demo table to test the majority of the library functionality. Added additional error messages to places where an error could be returned but there was no error number/string set. Many small changes and general improvements.
@@ -236,6 +236,8 @@ Statement methods
236
236
237
237
**Statement.Prepare(sql string) (err os.Error)** - Prepare a new statement using the supplied query.
238
238
239
+
**Statement.ParamCount() uint16** - Get the number of parameters.
240
+
239
241
**Statement.BindParams(params ...interface{}) (err os.Error)** - Bind parameters to the statement.
240
242
241
243
**Statement.SendLongData(num int, data []byte) (err os.Error)** - Send a parameter as long data. The data can be > than the maximum packet size and will be split automatically.
@@ -250,6 +252,8 @@ Statement methods
250
252
251
253
**Statement.BindResult(params ...interface{}) (err os.Error)** - Bind the result, parameters passed to this functions should be pointers to variables which will be populated with the data from the fetched row. If a column value is not needed a nil can be used. Parameters should be of a "similar" type to the actual column value in the MySQL table, e.g. for an INT field, the parameter can be any integer type or a string and the relevant conversion is performed. Using integer sizes smaller than the size in the table is not recommended. The number of parameters bound can be equal or less than the number of fields in the table, providing more parameters than actual columns will result in a crash.
252
254
255
+
**Statement.RowCount() uint64** - Get the number of rows in the result set, works for stored results only, otherwise returns 0.
256
+
253
257
**Statement.Fetch() (eof bool, err os.Error)** - Fetch the next row in the result, values are populated into parameters bound using BindResult.
254
258
255
259
**Statement.StoreResult() (err os.Error)** - Store all rows for a result set,
Copy file name to clipboardExpand all lines: mysql_test.go
+68-7Lines changed: 68 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -35,11 +35,13 @@ const (
35
35
TEST_DBNAMEBAD="gomysql_bad"// This is a nonexistant database
36
36
37
37
// Simple table queries
38
-
CREATE_SIMPLE="CREATE TABLE `simple` (`id` SERIAL NOT NULL, `number` BIGINT NOT NULL, `string` VARCHAR(32) NOT NULL, `text` TEXT NOT NULL, `datetime` DATETIME NOT NULL) ENGINE = InnoDB CHARACTER SET utf8 COLLATE utf8_unicode_ci COMMENT = 'GoMySQL Test Suite Simple Table';"
39
-
SELECT_SIMPLE="SELECT * FROM simple"
40
-
INSERT_SIMPLE="INSERT INTO simple VALUES (null, %d, '%s', '%s', NOW())"
41
-
UPDATE_SIMPLE="UPDATE simple SET `text` = '%s', `datetime` = NOW() WHERE id = %d"
42
-
DROP_SIMPLE="DROP TABLE `simple`"
38
+
CREATE_SIMPLE="CREATE TABLE `simple` (`id` SERIAL NOT NULL, `number` BIGINT NOT NULL, `string` VARCHAR(32) NOT NULL, `text` TEXT NOT NULL, `datetime` DATETIME NOT NULL) ENGINE = InnoDB CHARACTER SET utf8 COLLATE utf8_unicode_ci COMMENT = 'GoMySQL Test Suite Simple Table';"
39
+
SELECT_SIMPLE="SELECT * FROM simple"
40
+
INSERT_SIMPLE="INSERT INTO simple VALUES (null, %d, '%s', '%s', NOW())"
41
+
INSERT_SIMPLE_STMT="INSERT INTO simple VALUES (null, ?, ?, ?, NOW())"
42
+
UPDATE_SIMPLE="UPDATE simple SET `text` = '%s', `datetime` = NOW() WHERE id = %d"
43
+
UPDATE_SIMPLE_STMT="UPDATE simple SET `text` = ?, `datetime` = NOW() WHERE id = ?"
44
+
DROP_SIMPLE="DROP TABLE `simple`"
43
45
44
46
// All types table queries
45
47
CREATE_ALLTYPES="CREATE TABLE `all_types` (`id` SERIAL NOT NULL, `tiny_int` TINYINT NOT NULL, `tiny_uint` TINYINT UNSIGNED NOT NULL, `small_int` SMALLINT NOT NULL, `small_uint` SMALLINT UNSIGNED NOT NULL, `medium_int` MEDIUMINT NOT NULL, `medium_uint` MEDIUMINT UNSIGNED NOT NULL, `int` INT NOT NULL, `uint` INT UNSIGNED NOT NULL, `big_int` BIGINT NOT NULL, `big_uint` BIGINT UNSIGNED NOT NULL, `decimal` DECIMAL(10,4) NOT NULL, `float` FLOAT NOT NULL, `double` DOUBLE NOT NULL, `real` REAL NOT NULL, `bit` BIT(32) NOT NULL, `boolean` BOOLEAN NOT NULL, `date` DATE NOT NULL, `datetime` DATETIME NOT NULL, `timestamp` TIMESTAMP NOT NULL, `time` TIME NOT NULL, `year` YEAR NOT NULL, `char` CHAR(32) NOT NULL, `varchar` VARCHAR(32) NOT NULL, `tiny_text` TINYTEXT NOT NULL, `text` TEXT NOT NULL, `medium_text` MEDIUMTEXT NOT NULL, `long_text` LONGTEXT NOT NULL, `binary` BINARY(32) NOT NULL, `var_binary` VARBINARY(32) NOT NULL, `tiny_blob` TINYBLOB NOT NULL, `medium_blob` MEDIUMBLOB NOT NULL, `blob` BLOB NOT NULL, `long_blob` LONGBLOB NOT NULL, `enum` ENUM('a','b','c','d','e') NOT NULL, `set` SET('a','b','c','d','e') NOT NULL, `geometry` GEOMETRY NOT NULL) ENGINE = InnoDB CHARACTER SET utf8 COLLATE utf8_unicode_ci COMMENT = 'GoMySQL Test Suite All Types Table'"
@@ -51,6 +53,14 @@ var (
51
53
err os.Error
52
54
)
53
55
56
+
typeSimpleRowstruct {
57
+
Iduint64
58
+
Numberint64
59
+
Stringstring
60
+
Textstring
61
+
DateDate
62
+
}
63
+
54
64
// Test connect to server via TCP
55
65
funcTestDialTCP(t*testing.T) {
56
66
t.Logf("Running DialTCP test to %s:%s", TEST_HOST, TEST_PORT)
0 commit comments