why does txid_current() assign new transaction-id?
2015-08-13 23:04
417 查看
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
Snapshot Components
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
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 |
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. |
参考:
http://postgresql.nabble.com/why-does-txid-current-assign-new-transaction-id-td5851159.html http://www.postgresql.org/docs/devel/static/functions-info.html
相关文章推荐
- 平台+插件软件设计思想及基于COM的原型实现
- 2、如何理解self = [super init]
- Bitmap与Drawable、byte[]、图片资源、图片文件的转换(二)
- 不规则物体形状匹配综述
- 博客的开始
- Android dx工具错误 解决
- nginx中http核心模块的配置指令2
- 组合数学 codefoeces300C Beautiful Numbers
- KMP算法详解
- hdu 5289 Assignment
- Nginx模块开发(4)————使用subrequest访问第三方服务
- boost enable_shared_from_this
- 生成new, old的 shell script
- OC中protocol、category和继承的区别
- hbase shell中log4j重复问题
- CrossApp 项目导入Eclipse的生成Android客户端
- HDU 1873 看病要排队 (优先队列)
- iOS 面试题(二)
- lua学习记录
- JQuery中wrap,wrapAll,wrapInner的区别