mysql_autocommit
mysql_autocommit enables or disables autocommit mode for the current database connection, returning zero on success or nonzero on failure.
Last updated
Was this helpful?
Was this helpful?
# Turn off autocommit
SET AUTOCOMMIT=0;
# Retrieve autocommit
SELECT @@autocommit;
+--------------+
| @@autocommit |
+--------------+
| 0 |
+--------------+static int test_autocommit(MYSQL *mysql)
{
int rc;
unsigned int server_status;
/* Turn autocommit off */
rc= mysql_autocommit(mysql, 0);
if (rc)
return rc; /* Error */
/* If autocommit = 0 succeeded, the last OK packet updated the server status */
rc= mariadb_get_infov(mysql, MARIADB_CONNECTION_SERVER_STATUS, &server_status);
if (rc)
return rc; /* Error */
if (server_status & SERVER_STATUS_AUTOCOMMIT)
{
printf("Error: autocommit is on\n");
return 1;
}
printf("OK: autocommit is off\n");
return 0;
}