The number of the column. Ordinary columns are numbered from 1
- up. System columns, such as oid,
+ up. System columns, such as ctid,
have (arbitrary) negative numbers.
ctid will change if it is
updated or moved by VACUUM FULL. Therefore
ctid is useless as a long-term row
- identifier. The OID, or even better a user-defined serial
- number, should be used to identify logical rows.
+ identifier. A primary key should be used to identify logical rows.
CREATE TABLE, nor is it possible to add columns to
partitions after-the-fact using ALTER TABLE. Tables may be
added as a partition with ALTER TABLE ... ATTACH PARTITION
- only if their columns exactly match the parent, including any
- oid column.
+ only if their columns exactly match the parent.
The view columns contains information about all
table columns (or view columns) in the database. System columns
- (oid, etc.) are not included. Only those columns are
+ (ctid, etc.) are not included. Only those columns are
shown that the current user has access to (by way of being the
owner or having some privilege).
that the NEW row seen by the condition is the current value,
as possibly modified by earlier triggers. Also, a BEFORE
trigger's WHEN condition is not allowed to examine the
- system columns of the NEW row (such as oid),
+ system columns of the NEW row (such as ctid),
because those won't have been set yet.
INSERT oid count
- The count is the
- number of rows inserted or updated. If
- class="parameter">count is exactly one, and the
- target table has OIDs, then
- class="parameter">oid is the
OID
- assigned to the inserted row. The single row must have been
- inserted rather than updated. Otherwise
- class="parameter">oid is zero.
+ The count is the number of
+ rows inserted or updated. oid is always 0 (it
+ used to be the
OID assigned to the inserted row if
+ rows was exactly one and the target table was
+ declared WITH OIDS and 0 otherwise, but creating a table
+ WITH OIDS is not supported anymore).
command. This variable is only guaranteed to be valid until
after the result of the next
SQL command has
been displayed.
+
PostgreSQL servers since version 12 do not
+ support OID system columns anymore, thus LASTOID will always be 0
+ following INSERT when targeting such servers.
If
colname refers to a system column (e.g.,
- oid) then the appropriate negative column number will
+ ctid) then the appropriate negative column number will
be returned. The caller should be careful to test the return value
for exact equality to SPI_ERROR_NOATTRIBUTE to
detect an error; testing the result for less than or equal to 0 is