pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #17130: Error while executing request
6+ messages / 5 participants
[nested] [flat]

* BUG #17130: Error while executing request
@ 2021-08-03 07:20 PG Bug reporting form <noreply@postgresql.org>
  2021-08-03 08:47 ` Re: BUG #17130: Error while executing request Erik Rijkers <er@xs4all.nl>
  0 siblings, 1 reply; 6+ messages in thread

From: PG Bug reporting form @ 2021-08-03 07:20 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; +Cc: viktor@alenkov.name

The following bug has been logged on the website:

Bug reference:      17130
Logged by:          Viktor Alenkov
Email address:      viktor@alenkov.name
PostgreSQL version: 13.3
Operating system:   Docker
Description:        

query: 
  CREATE SCHEMA "my_schema"
    CREATE TABLE "my_ids" AS SELECT "a"."n" AS "id" FROM GENERATE_SERIES(1,
99) AS "a"("n");

I get the error `syntax error at or near "AS"`



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: BUG #17130: Error while executing request
  2021-08-03 07:20 BUG #17130: Error while executing request PG Bug reporting form <noreply@postgresql.org>
@ 2021-08-03 08:47 ` Erik Rijkers <er@xs4all.nl>
  2021-08-03 13:13   ` Re: BUG #17130: Error while executing request Guillaume Lelarge <guillaume@lelarge.info>
  0 siblings, 1 reply; 6+ messages in thread

From: Erik Rijkers @ 2021-08-03 08:47 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org

On 8/3/21 9:20 AM, PG Bug reporting form wrote:
> CREATE SCHEMA "my_schema"
>      CREATE TABLE "my_ids" AS SELECT "a"."n" AS "id" FROM GENERATE_SERIES(1,
> 99) AS "a"("n");

Understandable: you forgot the semicolon after the create schema statement.







^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: BUG #17130: Error while executing request
  2021-08-03 07:20 BUG #17130: Error while executing request PG Bug reporting form <noreply@postgresql.org>
  2021-08-03 08:47 ` Re: BUG #17130: Error while executing request Erik Rijkers <er@xs4all.nl>
@ 2021-08-03 13:13   ` Guillaume Lelarge <guillaume@lelarge.info>
  2021-08-03 13:18     ` Re: BUG #17130: Error while executing request David G. Johnston <david.g.johnston@gmail.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Guillaume Lelarge @ 2021-08-03 13:13 UTC (permalink / raw)
  To: Erik Rijkers <er@xs4all.nl>; +Cc: PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>

Le mar. 3 août 2021 à 10:48, Erik Rijkers <er@xs4all.nl> a écrit :

> On 8/3/21 9:20 AM, PG Bug reporting form wrote:
> > CREATE SCHEMA "my_schema"
> >      CREATE TABLE "my_ids" AS SELECT "a"."n" AS "id" FROM
> GENERATE_SERIES(1,
> > 99) AS "a"("n");
>
> Understandable: you forgot the semicolon after the create schema statement.
>
>
Actually, the syntax should be valid. You can add a DDL right after CREATE
SCHEMA without a semicolon in between (see the examples on
https://www.postgresql.org/docs/13/sql-createschema.html). But I fail to
explain why it doesn't work here. A workaround would be to add the
semicolon as you said, but it should work without.


-- 
Guillaume.

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: BUG #17130: Error while executing request
  2021-08-03 07:20 BUG #17130: Error while executing request PG Bug reporting form <noreply@postgresql.org>
  2021-08-03 08:47 ` Re: BUG #17130: Error while executing request Erik Rijkers <er@xs4all.nl>
  2021-08-03 13:13   ` Re: BUG #17130: Error while executing request Guillaume Lelarge <guillaume@lelarge.info>
@ 2021-08-03 13:18     ` David G. Johnston <david.g.johnston@gmail.com>
  2021-08-03 13:26       ` Re: BUG #17130: Error while executing request Guillaume Lelarge <guillaume@lelarge.info>
  2021-08-03 13:52       ` Re: BUG #17130: Error while executing request Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 2 replies; 6+ messages in thread

From: David G. Johnston @ 2021-08-03 13:18 UTC (permalink / raw)
  To: Guillaume Lelarge <guillaume@lelarge.info>; +Cc: Erik Rijkers <er@xs4all.nl>; PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>

On Tue, Aug 3, 2021 at 6:13 AM Guillaume Lelarge <guillaume@lelarge.info>
wrote:

> Le mar. 3 août 2021 à 10:48, Erik Rijkers <er@xs4all.nl> a écrit :
>
>> On 8/3/21 9:20 AM, PG Bug reporting form wrote:
>> > CREATE SCHEMA "my_schema"
>> >      CREATE TABLE "my_ids" AS SELECT "a"."n" AS "id" FROM
>> GENERATE_SERIES(1,
>> > 99) AS "a"("n");
>>
>> Understandable: you forgot the semicolon after the create schema
>> statement.
>>
>>
> Actually, the syntax should be valid. You can add a DDL right after CREATE
> SCHEMA without a semicolon in between (see the examples on
> https://www.postgresql.org/docs/13/sql-createschema.html). But I fail to
> explain why it doesn't work here. A workaround would be to add the
> semicolon as you said, but it should work without.
>
>
CREATE TABLE and CREATE TABLE AS are two very different commands and only
the former is documented to work.

David J.

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: BUG #17130: Error while executing request
  2021-08-03 07:20 BUG #17130: Error while executing request PG Bug reporting form <noreply@postgresql.org>
  2021-08-03 08:47 ` Re: BUG #17130: Error while executing request Erik Rijkers <er@xs4all.nl>
  2021-08-03 13:13   ` Re: BUG #17130: Error while executing request Guillaume Lelarge <guillaume@lelarge.info>
  2021-08-03 13:18     ` Re: BUG #17130: Error while executing request David G. Johnston <david.g.johnston@gmail.com>
@ 2021-08-03 13:26       ` Guillaume Lelarge <guillaume@lelarge.info>
  1 sibling, 0 replies; 6+ messages in thread

From: Guillaume Lelarge @ 2021-08-03 13:26 UTC (permalink / raw)
  To: David G. Johnston <david.g.johnston@gmail.com>; +Cc: Erik Rijkers <er@xs4all.nl>; PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>

Le mar. 3 août 2021 à 15:18, David G. Johnston <david.g.johnston@gmail.com>
a écrit :

> On Tue, Aug 3, 2021 at 6:13 AM Guillaume Lelarge <guillaume@lelarge.info>
> wrote:
>
>> Le mar. 3 août 2021 à 10:48, Erik Rijkers <er@xs4all.nl> a écrit :
>>
>>> On 8/3/21 9:20 AM, PG Bug reporting form wrote:
>>> > CREATE SCHEMA "my_schema"
>>> >      CREATE TABLE "my_ids" AS SELECT "a"."n" AS "id" FROM
>>> GENERATE_SERIES(1,
>>> > 99) AS "a"("n");
>>>
>>> Understandable: you forgot the semicolon after the create schema
>>> statement.
>>>
>>>
>> Actually, the syntax should be valid. You can add a DDL right after
>> CREATE SCHEMA without a semicolon in between (see the examples on
>> https://www.postgresql.org/docs/13/sql-createschema.html). But I fail to
>> explain why it doesn't work here. A workaround would be to add the
>> semicolon as you said, but it should work without.
>>
>>
> CREATE TABLE and CREATE TABLE AS are two very different commands and only
> the former is documented to work.
>
>
Oh, you're right. The schema_element only accepts CREATE TABLE, CREATE
VIEW, CREATE INDEX, CREATE SEQUENCE, CREATE TRIGGER and GRANT. There's no
CREATE TABLE AS on this list. My bad.


-- 
Guillaume.

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: BUG #17130: Error while executing request
  2021-08-03 07:20 BUG #17130: Error while executing request PG Bug reporting form <noreply@postgresql.org>
  2021-08-03 08:47 ` Re: BUG #17130: Error while executing request Erik Rijkers <er@xs4all.nl>
  2021-08-03 13:13   ` Re: BUG #17130: Error while executing request Guillaume Lelarge <guillaume@lelarge.info>
  2021-08-03 13:18     ` Re: BUG #17130: Error while executing request David G. Johnston <david.g.johnston@gmail.com>
@ 2021-08-03 13:52       ` Tom Lane <tgl@sss.pgh.pa.us>
  1 sibling, 0 replies; 6+ messages in thread

From: Tom Lane @ 2021-08-03 13:52 UTC (permalink / raw)
  To: David G. Johnston <david.g.johnston@gmail.com>; +Cc: Guillaume Lelarge <guillaume@lelarge.info>; Erik Rijkers <er@xs4all.nl>; PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>

"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Tue, Aug 3, 2021 at 6:13 AM Guillaume Lelarge <guillaume@lelarge.info>
> wrote:
>> Actually, the syntax should be valid. You can add a DDL right after CREATE
>> SCHEMA without a semicolon in between (see the examples on
>> https://www.postgresql.org/docs/13/sql-createschema.html). But I fail to
>> explain why it doesn't work here. A workaround would be to add the
>> semicolon as you said, but it should work without.

> CREATE TABLE and CREATE TABLE AS are two very different commands and only
> the former is documented to work.

Right.  CREATE SCHEMA allows additional DDL to create objects within
the schema right away, but it only does DDL not DML, so you can't
additionally populate the table as part of the command.

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2021-08-03 13:52 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-08-03 07:20 BUG #17130: Error while executing request PG Bug reporting form <noreply@postgresql.org>
2021-08-03 08:47 ` Erik Rijkers <er@xs4all.nl>
2021-08-03 13:13   ` Guillaume Lelarge <guillaume@lelarge.info>
2021-08-03 13:18     ` David G. Johnston <david.g.johnston@gmail.com>
2021-08-03 13:26       ` Guillaume Lelarge <guillaume@lelarge.info>
2021-08-03 13:52       ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox