Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 3EA3E633532 for ; Fri, 9 Jul 2010 05:21:27 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 27975-07-4 for ; Fri, 9 Jul 2010 08:21:18 +0000 (UTC) Received: from news.hub.org (news.hub.org [200.46.204.72]) by mail.postgresql.org (Postfix) with ESMTP id 261C9633466 for ; Fri, 9 Jul 2010 05:21:19 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.14.4/8.14.4) with ESMTP id o698LEV3057813 for ; Fri, 9 Jul 2010 05:21:14 -0300 (ADT) (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.14.4/8.14.4/Submit) id o697rItp082220 for pgsql-sql@postgresql.org; Fri, 9 Jul 2010 04:53:18 -0300 (ADT) (envelope-from news) From: "Davor J." X-Newsgroups: pgsql.sql Subject: Re: Well-formed SQL check in postgres? Date: Fri, 9 Jul 2010 09:52:10 +0200 Organization: Hub.Org Networking Services Lines: 23 Message-ID: References: X-Complaints-To: usenet@news.hub.org X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5931 To: pgsql-sql@postgresql.org X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.79 tagged_above=-5 required=5 tests=BAYES_50=0.8, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201007/54 X-Sequence-Number: 34367 Two rrror codes are interesting for this: 42000 SYNTAX ERROR OR ACCESS RULE VIOLATION 42601 SYNTAX ERROR "Davor J." wrote in message news:hu8ang$1isi$1@news.hub.org... > Has anyone a suggestion on how to check whether a SQL SELECT query in > postgres is well-formed (like wff). The query should not be executed (!), > only checked for well-formedness. > > What I was thinking off is appending EXPLAIN to the query. EXPLAIN doesn't > execute it, but just runs it through the planner. Then I can read whether > there was any error or not. > > Is there a better way or is this the way to go? > > Thanks, > Davor >