Fwd: Question about the enum type
От | Tim Hart |
---|---|
Тема | Fwd: Question about the enum type |
Дата | |
Msg-id | cbb13ccf7b006af6b585a5b0f78b3b89@mac.com обсуждение исходный текст |
Список | pgsql-general |
I answered my own question. Should have waited another 5 minutes before composing the e-mail. This page: http://www.postgresql.org/docs/8.3/interactive/sql-keywords-appendix.html States that 'POSITION' is non-reserved, but cannot be a function or type. Slightly confusing as stated - I appreciate that postgres tried to accommodate me. Very mildly annoyed that there wasn't some kind of notice regarding how it helpfully 're-named' my type. I'm not an experienced administrator though - if this is well-understood behavior, than consider me educated. ;) Tim Begin forwarded message: <excerpt><bold><color><param>0000,0000,0000</param>From: </color></bold>Tim Hart <<tjhart@mac.com> <bold><color><param>0000,0000,0000</param>Date: </color></bold>February 17, 2008 8:24:44 PM CST <bold><color><param>0000,0000,0000</param>To: </color></bold>pgsql-general@postgresql.org <bold><color><param>0000,0000,0000</param>Subject: </color>Question about the enum type </bold> I was playing around with the enum type today. I was toying around with a schema to model information about baseball, and decided to create an enum named position: tjhart=# create type position as enum('pitcher', 'catcher', 'first base', 'second base', 'third base', 'short stop', 'left field', 'center field', 'right field', 'designated hitter', 'pinch hitter'); CREATE TYPE At first, I thought I had done something wrong: tjhart=# select 'pitcher'::position; ERROR: syntax error at or near "position" LINE 1: select 'pitcher'::position; It took a bit of fumbling and reading - and closer inspection of the following before I determined what happened: tjhart=# \dT+ public.*; List of data types Schema | Name | Internal name | Size | Description --------+------------+---------------+------+------------- public | "position" | position | 4 | (1 row) tjhart=# select 'right field'::"position"; position ------------- right field (1 row) tjhart=# The example 'mood' enum in the documentation isn't quoted when it's created. I noticed that 'position' is a function, but I can create types with the same name as other functions (abs), and the name isn't quoted. I also tried creating an enum type with a reserved word: tjhart=# create type select as enum('foo'); ERROR: syntax error at or near "select" LINE 1: create type select as enum('foo'); ^ I'm just toying around, so this isn't high priority. I'll probably change the name of the enum to fielding_position for clarity's sake anyway. But for my own education - what's so unique about the name 'position'? Tim Hart </excerpt> I answered my own question. Should have waited another 5 minutes before composing the e-mail. This page: http://www.postgresql.org/docs/8.3/interactive/sql-keywords- appendix.html States that 'POSITION' is non-reserved, but cannot be a function or type. Slightly confusing as stated - I appreciate that postgres tried to accommodate me. Very mildly annoyed that there wasn't some kind of notice regarding how it helpfully 're-named' my type. I'm not an experienced administrator though - if this is well-understood behavior, than consider me educated. ;) Tim Begin forwarded message: > From: Tim Hart <tjhart@mac.com> > Date: February 17, 2008 8:24:44 PM CST > To: pgsql-general@postgresql.org > Subject: Question about the enum type > > I was playing around with the enum type today. I was toying around > with a schema to model information about baseball, and decided to > create an enum named position: > > tjhart=# create type position as enum('pitcher', 'catcher', 'first > base', 'second base', 'third base', 'short stop', 'left field', > 'center field', 'right field', 'designated hitter', 'pinch hitter'); > CREATE TYPE > > At first, I thought I had done something wrong: > > tjhart=# select 'pitcher'::position; > ERROR: syntax error at or near "position" > LINE 1: select 'pitcher'::position; > > It took a bit of fumbling and reading - and closer inspection of the > following before I determined what happened: > > tjhart=# \dT+ public.*; > List of data types > Schema | Name | Internal name | Size | Description > --------+------------+---------------+------+------------- > public | "position" | position | 4 | > (1 row) > > tjhart=# select 'right field'::"position"; > position > ------------- > right field > (1 row) > > tjhart=# > > The example 'mood' enum in the documentation isn't quoted when it's > created. > > I noticed that 'position' is a function, but I can create types with > the same name as other functions (abs), and the name isn't quoted. I > also tried creating an enum type with a reserved word: > > tjhart=# create type select as enum('foo'); > ERROR: syntax error at or near "select" > LINE 1: create type select as enum('foo'); > ^ > > I'm just toying around, so this isn't high priority. I'll probably > change the name of the enum to fielding_position for clarity's sake > anyway. But for my own education - what's so unique about the name > 'position'? > > Tim Hart >
В списке pgsql-general по дате отправления: