|
From: Shridhar D. <gho...@gh...> - 2010-01-13 14:16:03
|
Hello All,
Given recent discussions and my needs for enum support, I experimented a bit
and found that postgresql enums works perfectly as text. Essentially they are
predefined values of text.
PFA a test program to demonstrate that. Here is the sql session and the
program run. The select was run after the program was run in another terminal.
----------------------
test=# create type enum1 as enum('enumval1','enumval2');
CREATE TYPE
test=# create table enumtable(name varchar(20), state enum1);
CREATE TABLE
test=# select * from enumtable;
name | state
-----------+----------
stringval | enumval1
(1 row)
----------------------
----------------------
shridhar@bheem /mnt1/shridhar/development/test/soci$ bjam &&
bin/gcc-4.4.2/release/enum
...found 31 targets...
...updating 2 targets...
gcc.compile.c++ bin/gcc-4.4.2/release/enum.o
gcc.link bin/gcc-4.4.2/release/enum
...updated 2 targets...
enum1:'enumval1' enum2:'enumval1'
Error:ERROR: invalid input value for enum enum1: "nosuchval"
----------------------
This was run on 64 bit archlinux, with postgresql 8.4.2
--
Shridhar
|