zoukankan      html  css  js  c++  java
  • why does txid_current() assign new transaction-id?

    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 

    NameReturn TypeDescription
    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

    NameDescription
    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

  • 相关阅读:
    js关于页面坐标api
    js面向对象之创建对象
    Web前端安全问题
    js操作cookie
    css清除浮动
    块级格式化上下文(block formatting context)
    《python核心编程》笔记——系统限制
    《python核心编程》笔记——文件的创建、读取和显示
    黑客们的故事连载十二 “蠕虫来袭”:莫里斯
    黑客们的故事连载十一 下村努—虚拟战争追逐
  • 原文地址:https://www.cnblogs.com/xiaotengyi/p/4728710.html
Copyright © 2011-2022 走看看