From 8b1b2501d3cdf111cdd8ccd24a6a11573dd4b4cf Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Sat, 18 Apr 2026 23:55:09 +0300 Subject: [PATCH] mysql: fix tests --- vlib/crypto/sha512/sha512block_generic.v | 2 +- vlib/db/mysql/README.md | 6 +++--- vlib/db/mysql/mysql.c.v | 14 +++++++------- vlib/db/mysql/prepared_stmt_test.v | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/vlib/crypto/sha512/sha512block_generic.v b/vlib/crypto/sha512/sha512block_generic.v index 90e1eff35..0021eab17 100644 --- a/vlib/crypto/sha512/sha512block_generic.v +++ b/vlib/crypto/sha512/sha512block_generic.v @@ -38,7 +38,7 @@ const _k = [ fn block_generic(mut dig Digest, p_ []u8) { unsafe { mut p := p_ - mut w := []u64{len: 80} + mut w := [80]u64{} mut h0 := dig.h[0] mut h1 := dig.h[1] mut h2 := dig.h[2] diff --git a/vlib/db/mysql/README.md b/vlib/db/mysql/README.md index 432f1ff29..9382dd85a 100644 --- a/vlib/db/mysql/README.md +++ b/vlib/db/mysql/README.md @@ -8,12 +8,12 @@ MySQL or MariaDB database servers. To run the mysql module tests, or if you want to just experiment, you can use the following command to start a development version of MySQL using docker: ```sh -docker run -p 3306:3306 --name some-mysql -e MYSQL_ALLOW_EMPTY_PASSWORD=1 -e MYSQL_ROOT_PASSWORD= -d mysql:latest +docker run -p 3306:3306 --name some-mysql -e MYSQL_ROOT_PASSWORD=12345678 -d mysql:latest ``` -The above command will start a server instance without any password for its root account, +The above command will start a server instance with the root password `12345678`, available to mysql client connections, on tcp port 3306. -You can test that it works by doing: `mysql -uroot -h127.0.0.1` . +You can test that it works by doing: `mysql -uroot -p12345678 -h127.0.0.1` . You should see a mysql shell (use `exit` to end the mysql client session). Use `docker container stop some-mysql` to stop the server. diff --git a/vlib/db/mysql/mysql.c.v b/vlib/db/mysql/mysql.c.v index 6fda91948..f0a8405d3 100644 --- a/vlib/db/mysql/mysql.c.v +++ b/vlib/db/mysql/mysql.c.v @@ -218,7 +218,7 @@ pub fn (mut db DB) autocommit(mode bool) ! { } // commit commits the current transaction. -pub fn (mut db DB) commit() ! { +pub fn (db &DB) commit() ! { db.check_connection_is_established()! result := C.mysql_commit(db.conn) @@ -233,7 +233,7 @@ pub struct MySQLTransactionParam { } // begin begins a new transaction. -pub fn (mut db DB) begin(param MySQLTransactionParam) ! { +pub fn (db &DB) begin(param MySQLTransactionParam) ! { db.check_connection_is_established()! db.set_transaction_level(param.transaction_level)! result := db.exec_none('START TRANSACTION') @@ -243,7 +243,7 @@ pub fn (mut db DB) begin(param MySQLTransactionParam) ! { } // set_transaction_level set level for the transaction -pub fn (mut db DB) set_transaction_level(level MySQLTransactionLevel) ! { +pub fn (db &DB) set_transaction_level(level MySQLTransactionLevel) ! { db.check_connection_is_established()! mut sql_stmt := 'SET TRANSACTION ISOLATION LEVEL ' match level { @@ -260,7 +260,7 @@ pub fn (mut db DB) set_transaction_level(level MySQLTransactionLevel) ! { } // rollback rollbacks the current transaction. -pub fn (mut db DB) rollback() ! { +pub fn (db &DB) rollback() ! { db.check_connection_is_established()! result := C.mysql_rollback(db.conn) @@ -270,7 +270,7 @@ pub fn (mut db DB) rollback() ! { } // rollback_to rollbacks to a specified savepoint. -pub fn (mut db DB) rollback_to(savepoint string) ! { +pub fn (db &DB) rollback_to(savepoint string) ! { if !savepoint.is_identifier() { return error('savepoint should be a identifier string') } @@ -282,7 +282,7 @@ pub fn (mut db DB) rollback_to(savepoint string) ! { } // savepoint create a new savepoint. -pub fn (mut db DB) savepoint(savepoint string) ! { +pub fn (db &DB) savepoint(savepoint string) ! { if !savepoint.is_identifier() { return error('savepoint should be a identifier string') } @@ -294,7 +294,7 @@ pub fn (mut db DB) savepoint(savepoint string) ! { } // release_savepoint releases a specified savepoint. -pub fn (mut db DB) release_savepoint(savepoint string) ! { +pub fn (db &DB) release_savepoint(savepoint string) ! { if !savepoint.is_identifier() { return error('savepoint should be a identifier string') } diff --git a/vlib/db/mysql/prepared_stmt_test.v b/vlib/db/mysql/prepared_stmt_test.v index 4ce0f06b8..eb5071339 100644 --- a/vlib/db/mysql/prepared_stmt_test.v +++ b/vlib/db/mysql/prepared_stmt_test.v @@ -111,7 +111,7 @@ fn test_stmt_prepare_returns_mysql_error_code() { host: '127.0.0.1' port: 3306 username: 'root' - password: '' + password: '12345678' dbname: 'mysql' } @@ -141,7 +141,7 @@ fn test_prepare_execute_returns_mysql_error_code() { host: '127.0.0.1' port: 3306 username: 'root' - password: '' + password: '12345678' dbname: 'mysql' } -- 2.39.5