From: Peter Eisentraut Date: Tue, 10 Aug 2010 20:41:28 +0000 (+0000) Subject: is a floating element, so it's use is inappropriate when the X-Git-Tag: REL9_0_RC1~59 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e0e08d3c80cb0db98cd1710f35fd52b6274ef88e;p=postgresql is a floating element, so it's use is inappropriate when the surrounding text refers to the example inline. --- diff --git a/doc/src/sgml/datatype.sgml b/doc/src/sgml/datatype.sgml index b91c25ad72..8251b3b4be 100644 --- a/doc/src/sgml/datatype.sgml +++ b/doc/src/sgml/datatype.sgml @@ -1,4 +1,4 @@ - + Data Types @@ -2869,10 +2869,6 @@ CREATE TYPE mood AS ENUM ('sad', 'ok', 'happy'); Once created, the enum type can be used in table and function definitions much like any other type: - - - - Basic Enum Usage CREATE TYPE mood AS ENUM ('sad', 'ok', 'happy'); CREATE TABLE person ( @@ -2886,7 +2882,7 @@ SELECT * FROM person WHERE current_mood = 'happy'; Moe | happy (1 row) - + @@ -2897,10 +2893,7 @@ SELECT * FROM person WHERE current_mood = 'happy'; order in which the values were listed when the type was created. All standard comparison operators and related aggregate functions are supported for enums. For example: - - - - Enum Ordering + INSERT INTO person VALUES ('Larry', 'sad'); INSERT INTO person VALUES ('Curly', 'ok'); @@ -2926,7 +2919,7 @@ WHERE current_mood = (SELECT MIN(current_mood) FROM person); Larry (1 row) - + @@ -2934,11 +2927,8 @@ WHERE current_mood = (SELECT MIN(current_mood) FROM person); Each enumerated data type is separate and cannot - be compared with other enumerated types. - + be compared with other enumerated types. See this example: - - Lack of Casting CREATE TYPE happiness AS ENUM ('happy', 'very happy', 'ecstatic'); CREATE TABLE holidays ( @@ -2954,15 +2944,12 @@ SELECT person.name, holidays.num_weeks FROM person, holidays WHERE person.current_mood = holidays.happiness; ERROR: operator does not exist: mood = happiness - + If you really need to do something like that, you can either write a custom operator or add explicit casts to your query: - - - Comparing Different Enums by Casting to Text SELECT person.name, holidays.num_weeks FROM person, holidays WHERE person.current_mood::text = holidays.happiness::text; @@ -2972,7 +2959,7 @@ SELECT person.name, holidays.num_weeks FROM person, holidays (1 row) - +