GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
mysql_autocommit(3) MariaDB Connector/C mysql_autocommit(3)

mysql_autocommit - Toggles autocommit mode


#include <mysql.h>
my_bool mysql_autocommit(MYSQL * mysql, my_bool auto_mode);

    

Toggles autocommit mode on or off for the current database connection. Autocommit mode will be set if mode=1 or unset if mode=0.

mysql is a connection identifier, which was previously allocated by mysql_init(3) and connected by mysql_real_connect(3).
auto_mode - whether to turn autocommit on or not.

Autocommit mode only affects operations on transactional table types. To determine the current state of autocommit mode use the SQL command SELECT @@autocommit or check the server status (see example below).
Be aware: the [mysql_rollback()}(mysql_rollback() function will not work if autocommit mode is switched on.


# Turn of autocmmit
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;
}

    
Version 3.2.2

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.