Naoya:

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

Michael:

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

Naoya:

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

Michael:

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?的更多相关文章

  1. Postgresql 锁查看

    之前版本 PostgreSQL 的 pg_stat_activity 视图的 waiting 字段判断会话是否等待锁资源(通俗地讲, waiting 值为true表示申请不到锁资源处于等待状态),但是 ...

  2. 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 ...

  3. 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 问题 ...

  4. iOS内存管理retain,assign,copy,strong,weak

    转自:http://www.cnblogs.com/nonato/archive/2013/11/28/3447162.html iOS的对象都继承于NSObject, 该对象有一个方法:retain ...

  5. 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. ...

  6. ios中strong, weak, assign, copy

    copy 和 strong(retain) 区别 1. http://blog.csdn.net/itianyi/article/details/9018567 大部分的时候NSString的属性都是 ...

  7. 总账:日记账导入流程(文档 ID 1591640.1)

    文档内容   概要   历史记录   详细信息   GL_INTERFACE_CONTROL   GL_INTERFACE_HISTORY   GL_IMPORT_REFERENCES   摘要   ...

  8. Xcode工程编译错误:“Cannot assign to 'self' outside of a method in the init family”

    #import <Foundation/Foundation.h> @interface EOCRectangle : NSObject<NSCoding> @property ...

  9. 全局ID的重要性

    全局ID的重要性 体现在sharding的时候 gtid MySQL:global transaction id uuid:universally unique identifier guid:glo ...

随机推荐

  1. vc设置按钮文字颜色

    设置按钮文字颜色使用 CMFCBUTTON即可 在OnInitDialog函数加入如下内容即可 ((CMFCButton*)GetDlgItem(IDC_MFCBUTTON1))->SetTex ...

  2. Note_Master-Detail Application(iOS template)_05_ YJYMasterViewController.m

    //  YJYMasterViewController.m #import "YJYMasterViewController.h" #import "YJYDetailV ...

  3. 关于RecyclerView中Viewholder和View的缓存机制的探究

    关于RecyclerView中Viewholder和View的缓存机制的探究 http://www.cnblogs.com/littlepanpc/p/4241575.html

  4. openstack中运行定时任务的两种方法及源代码分析

    启动一个进程,如要想要这个进程的某个方法定时得进行执行的话,在openstack有两种方式: 一种是通过继承 periodic_task.PeriodicTasks,另一种是使用loopingcall ...

  5. Ettus Research USRP B200/B210 simple case

  6. HTML的表单

    HTML表单 <!-- <form></form>标签对用来创建一个表单,即定义表单的开始和结束位置,<form>表单具有下面等属性 1.action属性用来 ...

  7. Mac环境下装node.js,npm,express

    1. 下载node.js for Mac 地址: http://nodejs.org/ 直接下载 pkg的,双击安装,一路点next,很容易就搞定了. 安装完会提醒注意 node和npm的路径是 /u ...

  8. Android消息推送

    1.引言 所谓的消息推送就是从服务器端向移动终端发送连接,传输一定的信息.比如一些新闻客户端,每隔一段时间收到一条或者多条通知,这就是从服务器端传来的推送消息:还比如常用的一些IM软件如微信.GTal ...

  9. Intent的简介以及属性详解

    一.Intent的介绍 Intent的中文意思是“意图,意向”,在Android中提供了Intent机制来协助应用间的交互与通讯,Intent负责对应用中一次操作的动作.动作涉及数据.附加数据进行描述 ...

  10. JS删除HTML元素问题

    <div id='one'> <div>1</div> <div>2</div> </div> <div id=" ...