Re: BUG #12819: CREATE TYPE fails within CREATE SCHEMA

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: postgresql(dot)org(at)ciotog(dot)net
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #12819: CREATE TYPE fails within CREATE SCHEMA
Date: 2015-03-02 17:53:55
Message-ID: 6455.1425318835@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

postgresql(dot)org(at)ciotog(dot)net writes:
> When creating objects within a CREATE SCHEMA definition, "CREATE TYPE" fails
> with 'ERROR: syntax error at or near "TYPE"'.

That's not supported; per the manual, we only allow these things within a
run-on CREATE SCHEMA:

Currently, only CREATE TABLE, CREATE VIEW, CREATE INDEX, CREATE
SEQUENCE, CREATE TRIGGER and GRANT are accepted as clauses within
CREATE SCHEMA.

That's basically driven by what was required in SQL92. It's unlikely
that we're going to worry about extending that set much, because the
lack of separating semicolons means that we risk syntax ambiguities
anytime we add more options. We could only resolve such problems by
making more keywords fully reserved, which is a disadvantage that greatly
outweighs any value anyone might see in this syntax for CREATE SCHEMA.

My advice: use a simple CREATE SCHEMA and separate commands for the
contained objects. You can wrap the whole thing in a transaction
if you're concerned about making it atomic.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message John R Pierce 2015-03-02 18:03:14 Re: BUG #12819: CREATE TYPE fails within CREATE SCHEMA
Previous Message postgresql.org 2015-03-02 16:55:54 BUG #12819: CREATE TYPE fails within CREATE SCHEMA