I am adding PostgreSQL support to some software that I've been
developing and I've hit a few snags.
I've found that MySQL's "ENUM" can be emulated with PostgreSQL's
"CHECK". Unfortunately it appears that I cannot use both the DEFAULT
modifier and the check modifier at the same time.
This line:
address_type VARCHAR(30) DEFAULT 'unknown' NOT NULL CHECK(address_type
IN ("unknown", "forged", "proxy", "temporary", "permanent"))
gives the error:
psql:IRDB_POSTGRES:69: ERROR: Attribute 'unknown' not found
If I write the definition without DEFAULT it works fine, if I write it
without the CHECK statement it works fine too..
(I've also split up the column definition and the check definition, i.e.
address_type VARCHAR(30) DEFAULT 'unknown' NOT NULL,
CHECK(address_type IN ("unknown", "forged", "proxy", "temporary", "permanent"))
)
Is the SQL wrong? Is it just not possible to do this? Or is this a
possible bug?
Any help is appreciated!
--
Matthew Wirges
Developer::CERIAS Incident Response Database
https://cirdb.cerias.purdue.edu/
wirges@cerias.purdue.edu