PostgreSQL中'inversion'术语的含义是什么?REL_13_STABLE版本大对象相关代码命名疑问
Great question! Let’s break down what this term means and why PostgreSQL uses it for large objects, especially in the REL_13_STABLE context you referenced.
What is "inversion" here?
In PostgreSQL, inversion is shorthand for Inversion Large Object—it’s the underlying storage mechanism for handling large objects (LOBs, like files or large binary blobs).
The core idea is a "reverse" approach to storing data compared to regular table rows:
- For standard row data, all values are stored directly within the row itself.
- For inversion-based large objects, the actual data is split into small chunks (default 2KB each) and stored in dedicated system tables. The table row only holds an OID (Object Identifier) that acts as a pointer to the full set of chunks.
Why call it "inversion"?
The term comes from this inverted storage pattern: instead of keeping data inline with the row, we keep a reference in the row and store the actual data elsewhere. To retrieve the full large object, PostgreSQL has to "reverse" the process—using the OID to look up and assemble all the scattered data chunks. This is the opposite of the direct, inline storage model, hence the name "inversion".
Looking at your code snippet
The constants you shared are internal flags that control access modes for inversion large objects:
INV_WRITE 0x00020000: Flags that a large object is being opened in write modeINV_READ 0x00040000: Flags that a large object is being opened in read-only mode
These are used by PostgreSQL’s low-level large object APIs (like lo_open). Most application developers won’t interact with these hex constants directly—instead, they’ll use the corresponding macro names or higher-level functions to work with LOBs.
内容的提问来源于stack exchange,提问作者slow_mohammud

