Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 026591DACBC1 for ; Wed, 4 Jan 2012 10:49:21 -0400 (AST) Received: from gwmta.wicourts.gov ([165.219.244.99] helo=gw.wicourts.gov) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RiS9X-0003qn-Ix for pgsql-bugs@postgresql.org; Wed, 04 Jan 2012 14:49:21 +0000 Received: from Courts-MTA by gw.wicourts.gov with Novell_GroupWise; Wed, 04 Jan 2012 08:49:06 -0600 Message-Id: <4F0412790200002500044333@gw.wicourts.gov> X-Mailer: Novell GroupWise Internet Agent 8.0.1 Date: Wed, 04 Jan 2012 08:48:57 -0600 From: "Kevin Grittner" To: , Subject: Re: BUG #6376: Cannot prepare a "CREATE TABLE" statement, error message is unhelpful References: In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Pg-Spam-Score: -6.1 (------) X-Archive-Number: 201201/18 X-Sequence-Number: 32085 wrote: > postgres=# prepare foo as create table bar (c integer); > ERROR: syntax error at or near "create" > LINE 1: prepare foo as create table bar (c integer); > ^ > > This error message does not in any way indicate that one cannot > prepare a create table statement. > > It appears that PostgreSQL does not support this operation, but I > cannot find any documentation that indicates why, or indeed if > this is intentional. http://www.postgresql.org/docs/9.1/interactive/sql-prepare.html The synopsis is: PREPARE name [ ( data_type [, ...] ) ] AS statement and the Parameters section says: statement Any SELECT, INSERT, UPDATE, DELETE, or VALUES statement. Thus, to put anything except a valid SELECT, INSERT, UPDATE, DELETE, or VALUES statement at that position is a syntax error. What would you expect to happen in general when you put some statement in the middle of another statement where it is not supported? For example, if you put a CREATE TABLE statement in the FROM clause of a SELECT statement, what would you expect? -Kevin