Skip site navigation (1) Skip section navigation (2)

Re: "Named" column default expression

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Thomas Kellerer <spam_eater(at)gmx(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: "Named" column default expression
Date: 2011-10-28 14:21:50
Message-ID: 22585.1319811710@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-general
Thomas Kellerer <spam_eater(at)gmx(dot)net> writes:
>>> I just noticed that Postgres allows the following syntax:
>>> create table foo
>>> (
>>> id integer constraint id_default_value default 42
>>> );

> I'm wondering why this doesn't throw an error then.

It's an implementation artifact --- our grammar regards everything after
a column's type name as a list of column constraints.  So "DEFAULT foo"
has to be considered as one variant of column constraint.  We could
probably tweak the grammar enough so it didn't allow "CONSTRAINT name"
to be prefixed to that one case, but there seems little point in adding
complexity for that.  The most it would accomplish is to break
applications that are expecting this particular deviation from spec to
work.

			regards, tom lane

In response to

Responses

pgsql-general by date

Next:From: Adrian KlaverDate: 2011-10-28 14:27:50
Subject: Re: PostgreSQL Naming Rules
Previous:From: Albe LaurenzDate: 2011-10-28 14:08:04
Subject: Re: PostgreSQL Naming Rules

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group