What is the meaning and purpose of the following statement in Postgres:
xmax::text::int > 0
This looks like casting to text and then casting again to integer ???
What is the meaning and purpose of the following statement in Postgres:
xmax::text::int > 0
This looks like casting to text and then casting again to integer ???
 
    
     
    
    Every table in Postgres has several system columns. They are non-standard, Postgres specific feature, which use requires basic knowledge about Postgres internals.
The column xmax essentially contains 0 or some transaction number. This value can not be however directly compared to numbers, because the column is of type xid, for which no corresponding operators have been defined. For this reason, it is necessary to use casting.
The comparison can be also written as
xmax::text <> '0'
The meaning of the expression can be inferred from the column description:
xmax
The identity (transaction ID) of the deleting transaction, or zero for an undeleted row version. It is possible for this column to be nonzero in a visible row version. That usually indicates that the deleting transaction hasn't committed yet, or that an attempted deletion was rolled back.
