这在 Postgresql 中有什么作用:xmax::text::int > 0

What does this do in Postgresql: xmax::text::int > 0

Postgres 中以下语句的含义和用途是什么:

xmax::text::int > 0

这看起来像是转换为文本,然后再次转换为整数 ???

Postgres 中的每个 table 都有几个 system columns. 它们是 non-standard,Postgres 特定的功能,使用它需要对 Postgres 内部结构有基本的了解。

xmax 列基本上包含 0 或一些交易编号。但是不能将该值直接与数字进行比较,因为该列的类型为 xid,尚未为其定义相应的运算符。为此,有必要使用casting。

比较也可以写成

xmax::text <> '0'

表达式的含义可以从列描述中推断出来:

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.