MySQL :: MySQL 8.0 Reference Manual :: 28.7.7.6 mysql_commit() https://dev.mysql.com/doc/refman/8.0/en/mysql-commit.html

MySQL 8.0 Reference Manual  /  ...  /  mysql_commit()

28.7.7.6 mysql_commit()

bool mysql_commit(MYSQL *mysql)

Description

Commits the current transaction.

The action of this function is subject to the value of the completion_type system variable. In particular, if the value of completion_type isRELEASE (or 2), the server performs a release after terminating a transaction and closes the client connection. Call mysql_close() from the client program to close the connection from the client side.

Return Values

Zero for success. Nonzero if an error occurred.

Errors

None.

MySQL :: MySQL 8.0 Reference Manual :: 5.1.8 Server System Variables https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_completion_type

completion_type

Property Value
Command-Line Format --completion-type=#
System Variable completion_type
Scope Global, Session
Dynamic Yes
SET_VAR Hint Applies No
Type Enumeration
Default Value NO_CHAIN
Valid Values

NO_CHAIN

CHAIN

RELEASE

0

1

2

The transaction completion type. This variable can take the values shown in the following table. The variable can be assigned using either the name values or corresponding integer values.

Value Description
NO_CHAIN (or 0) COMMIT and ROLLBACK are unaffected. This is the default value.
CHAIN (or 1) COMMIT and ROLLBACK are equivalent to COMMIT AND CHAIN and ROLLBACK AND CHAIN, respectively. (A new transaction starts immediately with the same isolation level as the just-terminated transaction.)
RELEASE (or 2) COMMIT and ROLLBACK are equivalent to COMMIT RELEASE and ROLLBACK RELEASE, respectively. (The server disconnects after terminating the transaction.)

completion_type affects transactions that begin with START TRANSACTION or BEGIN and end with COMMIT or ROLLBACK. It does not apply to implicit commits resulting from execution of the statements listed in Section 13.3.3, “Statements That Cause an Implicit Commit”. It also does not apply for XA COMMITXA ROLLBACK, or when autocommit=1.

理解commit

13.3.1 START TRANSACTION, COMMIT, and ROLLBACK Syntax

START TRANSACTION
[transaction_characteristic [, transaction_characteristic] ...] transaction_characteristic: {
WITH CONSISTENT SNAPSHOT
| READ WRITE
| READ ONLY
} BEGIN [WORK]
COMMIT [WORK] [AND [NO] CHAIN] [[NO] RELEASE]
ROLLBACK [WORK] [AND [NO] CHAIN] [[NO] RELEASE]
SET autocommit = {0 | 1}

These statements provide control over use of transactions:

  • START TRANSACTION or BEGIN start a new transaction.

  • COMMIT commits the current transaction, making its changes permanent.

  • ROLLBACK rolls back the current transaction, canceling its changes.

  • SET autocommit disables or enables the default autocommit mode for the current session.

MySQL :: MySQL 8.0 Reference Manual :: 13.3.1 START TRANSACTION, COMMIT, and ROLLBACK Syntax https://dev.mysql.com/doc/refman/8.0/en/commit.html

【如果在select读的情况下,假如认为对数据库无影响无烙印的操作,那么commit提交,就没有必要】

【连接的关闭:分为客户端、mysql服务端,都可以发起关闭】

mysql_commit() COMMIT ROLLBACK 提交 回滚 连接释放的更多相关文章

  1. SVN 提交回滚

    取消对代码的修改分为两种情况:   第一种情况:改动没有被提交(commit). 这种情况下,使用svn revert就能取消之前的修改. svn revert用法如下: # svn revert [ ...

  2. sourceTree"重置提交"和"提交回滚"的区别

    相信用过sourceTree的伙伴们都认识这两,但是不一定用过这两个功能,甚至是不能很好的把握它两的区别,根据自己最近亲身测试,总算是能小小的总结一下了 首先这儿假如,历史版本已经出现了1.2.3.4 ...

  3. 分布式系统的Raft算法——在失联阶段这个老Leader的任何更新都不能算commit,都回滚,接受新的Leader的新的更新 意味着还是可能丢数据!!!

    过去, Paxos一直是分布式协议的标准,但是Paxos难于理解,更难以实现,Google的分布式锁系统Chubby作为Paxos实现曾经遭遇到很多坑. 来自Stanford的新的分布式协议研究称为R ...

  4. Jfinal中手动提交/回滚 事物

    在Jfinal中有个Tx类为事物声明类 在方法或controller上面加@Before({Tx.class})即可,可是这样并不能满足有的业务场景 下面是今天写的手动提交的事物处理方法,希望对大家有 ...

  5. C#代码启用事务锁Transaction进行一系列提交回滚操作

    一.前言 因为很多人一般进行一系列相关数据库操作都是在存储过程里面,而且在存储过程用锁的写法也是很简单的,在这篇文章主要介绍一下C#后台代码用锁进行一系列事务操作,我建立一个简单的winform程序, ...

  6. JDBC事务提交/回滚实例

    以下是使用事务教程中描述的提交和回滚的代码示例. 此示例代码是基于前面章节中完成的环境和数据库设置编写的. 复制并将以下示例代码保存到:CommitAndRollback.java 中,编译并运行如下 ...

  7. cascading rollback 级联回滚

    Computer Science An Overview _J. Glenn Brookshear _11th Edition To emphasize the delicate nature of ...

  8. 对mysql事务提交、回滚的错误理解

    一.起因 begin或者START TRANSACTION开始一个事务 rollback事务回滚 commit 事务确认 人们对事务的解释如下:事务由作为一个单独单元的一个或多个SQL语句组成,如果其 ...

  9. spring5 源码深度解析----- 事务的回滚和提交(100%理解事务)

    上一篇文章讲解了获取事务,并且通过获取的connection设置只读.隔离级别等,这篇文章讲解剩下的事务的回滚和提交 回滚处理 之前已经完成了目标方法运行前的事务准备工作,而这些准备工作最大的目的无非 ...

随机推荐

  1. linux -- Ubuntu 安装搜狗输入法

    在Ubuntu Kylin系统中,默认安装搜狗拼音输入法,但是在原生Ubuntu系统中则不是.这可以理解,毕竟搜狗输入法的Linux版有Kylin团队的不小功劳.由于搜狗输入法确实比Linux系统下其 ...

  2. html中可以自定义属性,,,妈的竟然才知道..

    html中可以自定义属性,,,妈的竟然才知道.. <input userinfo="没见过帅哥呀" />

  3. 用IFrame作预览pdf,图片

    <iframe id="my_img" src="@ViewBag.path" width="100%" frameborder=&q ...

  4. redis的学习使用(ubuntu系统下)

    1.安装redis,/usr/local/redis-4.0.1/src/redis-server启动服务,若想启动后自动退出redis控制台进行其他操作,可配置redis.config中  daem ...

  5. 【Java 线程的深入研究2】常用函数说明

    ①sleep(long millis): 在指定的毫秒数内让当前正在执行的线程休眠(暂停执行) ②join():指等待t线程终止. 使用方式. join是Thread类的一个方法,启动线程后直接调用, ...

  6. SharePoint 沙盒无法启动新的解决方案服务的SPUserCodeV4

    开发部署时报错: 错误原因:没有启动该服务: 解决方式:打开管理中心—应用程序管理—服务应用程序--管理服务器上的服务,启动该服务即可.

  7. 【python】通过代理安装包

    1.安装setuptools 支持 pip install 或easy_install 2.在终端执行 set HTTP_PROXY=http://your.proxy.com:yourPort se ...

  8. MathType编辑指数的方法

    利用MathType编辑公式使得在文档中编辑理工类的论文工作减轻了不少,它所包含的符号与模板基本都可以满足我们日常工作学习中对公式的需要.在文档中编辑数学物理符号或者是函数表达式,都是用word公式编 ...

  9. js 小数取整,js 小数向上取整,js小数向下取整

    js 小数取整,js 小数向上取整,js小数向下取整 >>>>>>>>>>>>>>>>>>& ...

  10. Linux之MySQL

    一:卸载旧版本 使用下面的命令检查是否安装有MySQL Server rpm -qa | grep mysql 有的话通过下面的命令来卸载掉 rpm -e mysql //普通删除模式 rpm -e ...