Identity Constraints
PostgreSQL does not support identity columns; however, the database provides auto-incrementing of column values using pseudo datatypes SERIAL and BIGSERIAL. These types actually create columns of type INTEGER and BIGINT respectively, and auto increment by internally creating a sequence and then setting a DEFAULT clause on the column that takes the next value from the sequence.
To use this functionality with the DB Access Module for PostgreSQL, associate an
RWDBIdentityConstraint object with a column and set the column’s datatype to either
RWDBValue::Long or
RWDBValue::LongLong. For a valid
RWDBIdentityConstraint object attached to a column of type
RWDBValue::Long, the module creates a column of type
SERIAL. Similarly, a column with a valid constraint object and a type of
RWDBValue::LongLong results in a column of type
BIGSERIAL.
All other
RWDBValue type columns, when associated with a valid
RWDBIdentityConstraint object, produce a
not supported error, aborting SQL generation.
The DB Access Module for PostgreSQL ignores all identity constraint attributes since they are not supported by the
SERIAL and
BIGSERIAL datatypes. Consequently, while fetching a table schema, the columns created as the types
SERIAL and
BIGSERIAL are not fetched with a valid
RWDBIdentityConstraint object; rather, they will have a
DEFAULT clause containing a reference to the internal sequence.