RE: [HACKERS] Enum type emulation: problem with opaque type in PL/pgSQL functions - Mailing list pgsql-general

From Christopher Kings-Lynne
Subject RE: [HACKERS] Enum type emulation: problem with opaque type in PL/pgSQL functions
Date
Msg-id NEBBIOAJBMEENKACLNPCEEIPCCAA.chriskl@familyhealth.com.au
Whole thread Raw
In response to Enum type emulation: problem with opaque type in PL/pgSQL functions  (Max Fonin <fonin@ziet.zhitomir.ua>)
List pgsql-general
> I don't care how but I need to emulate ENUM type, just to convert
> MySQL dumps to PostgreSQL. E.g. ENUM values
> stored in MySQL dump should be restorable in Postgres without any
> conversion.

In MySQL, ENUM is like this:

create table blah (
    sex ENUM ('M', 'F')
);

This can be emulated in Postgres like this:

create table blah (
    sex CHAR(1) CHECK (sex IN ('M', 'F'))
);

The _real_ trick is implementing MySQL sets in Postgres...

Chris


pgsql-general by date:

Previous
From:
Date:
Subject: Re: my C pgm
Next
From: "Willis, Ian (Ento, Canberra)"
Date:
Subject: RE: Running several postmaster using same database in p arallel