ROW_COUNT() not returning expected result in MariaDB

Answered

Hi, when I try running the following insert query in the datagrip console, I am getting 0 for ROW_COUNT().

START TRANSACTION; 
INSERT INTO user_account ( user_role_id ) VALUES ( '2' );
SELECT ROW_COUNT();
COMMIT;

[EDIT]Here is the Output log:

sql> INSERT INTO user_account ( user_role_id ) VALUES ( '2' )
[2018-08-19 11:43:40] 1 row affected in 4 ms
sql> select database()
[2018-08-19 11:43:40] completed in 59 ms
sql> SELECT ROW_COUNT()
[2018-08-19 11:43:40] 1 row retrieved starting from 1 in 29 ms (execution: 5 ms, fetching: 24 ms)

I noticed that there is an additional "select database()" query being sent before the row_count() sql being sent.

I also tried entering through the mariadb command line client, it return 1:

MariaDB [demo]> START TRANSACTION; 
Query OK, 0 rows affected (0.00 sec)

MariaDB [demo]> INSERT INTO user_account ( user_role_id ) VALUES ( '2' );
Query OK, 1 row affected (0.00 sec)

MariaDB [demo]> SELECT ROW_COUNT();
+-------------+
| ROW_COUNT() |
+-------------+
|           1 |
+-------------+
1 row in set (0.00 sec)

MariaDB [demo]> COMMIT;
Query OK, 0 rows affected (0.00 sec)

I just started using datagrip, maybe I am missing something in the configuration?

3 comments
Comment actions Permalink

Could you specify MariaDB jdbc driver version?

0
Comment actions Permalink

It is MariaDB Connector J ver. 2.2.1 [latest].

0

Please sign in to leave a comment.