why does txid_current() assign new transaction-id?
Hi,hackers!
I have a question about txid_current().
it is "Why does txid_current() assign new transaction-id?".
When we executes txid_current() outside of transaction block, it assigns new transaction-id.
I guess it doesn't need to assign a new txid because txid_current() is just a read-only function.
I found a replaceable function by walking through pg-code, that is GetStableLatestTransactionId(void).
I attached a patch which changing just 1-line.
Could you please check the code?
Regards,
Naoya
txid_current has had the behavior of assigning a new transaction XID
when one is not assigned since its introduction. I don't think that it
is wise to change it now the way you do as many applications surely
rely on this assumption. Perhaps we could make the documentation
clearer about those things though, changing the description of this
function to "get current transaction ID, and assign a new one if one
is not assigned yet":
http://www.postgresql.org/docs/devel/static/functions-info.html
Regards,
--
Michael
Thank you for comments.
I understand your points.
For only to read a current transaction-id, I know we just have to use
txid_current_snapshot and that is a best way, but I feel a little bit
hassle to explain columns of txid_current_snapshot for my supporting customers..
(Xmin is .... and Xmax is ....) ..
I think that a description of txid_current is too rough and it might
be confused some users.
txid_current is a different operation depending on session situations,
I feel if detail of txid_current is documented then it will be better.
For example...
Inside of the transaction-block(begin..end), returns a transaction-id used by this block.
Outside of the transaction-block, returns a next transaction-id(but it is consumed by this function).
Regards,
Naoya
Attached is a doc patch among those lines.
--
Michael
Name | Return Type | Description |
---|---|---|
txid_current() | bigint | get current transaction ID, assigning a new one if the current transaction does not have one |
txid_current_snapshot() | txid_snapshot | get current snapshot |
Snapshot Components
Name | Description |
---|---|
xmin | Earliest transaction ID (txid) that is still active. All earlier transactions will either be committed and visible, or rolled back and dead. |
xmax | First as-yet-unassigned txid. All txids greater than or equal to this are not yet started as of the time of the snapshot, and thus invisible. |
xip_list | Active txids at the time of the snapshot. The list includes only those active txids between xmin and xmax; there might be active txids higher thanxmax. A txid that is xmin <= txid < xmax and not in this list was already completed at the time of the snapshot, and thus either visible or dead according to its commit status. The list does not include txids of subtransactions. |
txid_snapshot's textual representation is xmin:xmax:xip_list. For example 10:20:10,14,15 means xmin=10, xmax=20, xip_list=10, 14, 15.
参考:
http://postgresql.nabble.com/why-does-txid-current-assign-new-transaction-id-td5851159.html
http://www.postgresql.org/docs/devel/static/functions-info.html
why does txid_current() assign new transaction-id?的更多相关文章
- Postgresql 锁查看
之前版本 PostgreSQL 的 pg_stat_activity 视图的 waiting 字段判断会话是否等待锁资源(通俗地讲, waiting 值为true表示申请不到锁资源处于等待状态),但是 ...
- FAQ – Automatic Undo Management (AUM) / System Managed Undo (SMU) (Doc ID 461480.1)
FAQ – Automatic Undo Management (AUM) / System Managed Undo (SMU) (Doc ID 461480.1) APPLIES TO: Orac ...
- Transaction recovery: lock conflict caught and ignored
Transaction recovery: lock conflict caught and ignored环境:RAC 4节点.oracle 11.2.0.4.redhat 5.9 64bit 问题 ...
- iOS内存管理retain,assign,copy,strong,weak
转自:http://www.cnblogs.com/nonato/archive/2013/11/28/3447162.html iOS的对象都继承于NSObject, 该对象有一个方法:retain ...
- Ehcache(2.9.x) - API Developer Guide, Transaction Support
About Transaction Support Transactions are supported in versions of Ehcache 2.0 and higher. The 2.3. ...
- ios中strong, weak, assign, copy
copy 和 strong(retain) 区别 1. http://blog.csdn.net/itianyi/article/details/9018567 大部分的时候NSString的属性都是 ...
- 总账:日记账导入流程(文档 ID 1591640.1)
文档内容 概要 历史记录 详细信息 GL_INTERFACE_CONTROL GL_INTERFACE_HISTORY GL_IMPORT_REFERENCES 摘要 ...
- Xcode工程编译错误:“Cannot assign to 'self' outside of a method in the init family”
#import <Foundation/Foundation.h> @interface EOCRectangle : NSObject<NSCoding> @property ...
- 全局ID的重要性
全局ID的重要性 体现在sharding的时候 gtid MySQL:global transaction id uuid:universally unique identifier guid:glo ...
随机推荐
- 树莓派安装kali后的简单配置
树莓派可以说是极客的最爱,可以根据不同的需求去做定制. 前文<使用树莓派和kali Linux打造便携式渗透套件>讲了一些使用树莓派的基础,主要侧重于将树莓派当作一个物理后门使用.我则更喜 ...
- php大力力 [033节] 随便看看:PHP程序员学习C++
php大力力 [033节] 随便看看:PHP程序员学习C++ 2014 兄弟连高洛峰 PHP教程14.1.7 在PHP脚本中操作MySQL数据库4 观看 - 56.com http://www.med ...
- 数据结构《10》----二叉树 Morris 中序遍历
无论是二叉树的中序遍历还是用 stack 模拟递归, 都需要 O(n)的空间复杂度. Morris 遍历是一种 常数空间 的遍历方法,其本质是 线索二叉树(Threaded Binary Tree), ...
- SWUST0249 (凸包面积)
type node=record x,y:longint; end; ; var k,q,qq:longint; sum:double; f,g:..maxn] of node; m,i,j,a,b: ...
- DBImg: 图片文件-二进制文件的转换
using System; using System.IO; using System.Drawing; //using System.Collections.Generic; //using Sys ...
- Selenium Waits
Selenium高级功能包含查找等待, Selenium的查找等待有两种方式, 隐式等待(Implicit Waits)和显示等待(Explicit Waits): 这里写下我对两者的理解, 1. 隐 ...
- MINIX3 内核时钟分析
MINIX3 内核时钟分析 4.1 内核时钟概要 先想想为什么 OS 需要时钟?时钟是异步的一个非常重要的标志,设想一下,如 果我们的应用程序需要在多少秒后将触发某个程序或者进程,我们该怎么做到? ...
- Java中生成随机字符的方法总结
package learnExercise; public class RandomCharacter { public static char getRandomCharacter(char ch1 ...
- Core Java Volume I — 4.6. Object Construction
4.6. Object ConstructionYou have seen how to write simple constructors that define the initial state ...
- Android中GC_EXTERNAL_ALLOC的含义
GC_FOR_MALLOC means that the GC was triggered because there wasn't enough memory left on the heap to ...