Re: ecpg rejects input parameters

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Andrew Pennebaker <andrew(dot)pennebaker(at)gmail(dot)com>
Cc: PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: ecpg rejects input parameters
Date: 2015-04-08 20:53:32
Message-ID: 5525954C.6040906@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 04/08/2015 01:38 PM, Andrew Pennebaker wrote:
> Could you be more specific?
>
> I can't find a relevant section to address my specific problem: ecpg
> complaining when I try to check the syntax of my .sql files that use
> input parameters.

I think this has more to do with pgsanity:

https://github.com/markdrago/pgsanity

"So the approach that PgSanity takes is to take a file that has a list
of bare SQL in it, make that file look like a C file with embedded SQL,
run it through ecpg and let ecpg report on the syntax errors of the SQL."

A quick look through:

https://github.com/markdrago/pgsanity/blob/master/pgsanity/sqlprep.py

which is where the passed in SQL string is processed into ecpg format
does not show that it deals with variables. So you might to take this up
with the pgsanity author.

>
> On Wed, Apr 8, 2015 at 9:34 AM, Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com
> <mailto:adrian(dot)klaver(at)aklaver(dot)com>> wrote:
>
> On 04/08/2015 07:22 AM, Andrew Pennebaker wrote:
>
> PostgreSQL uses a :colon syntax for parameterizing SQL commands with
> command line variables.
>
> create-database.sql:
>
> CREATE DATABASE :db;
>
> Usage:
>
> $ psql -f create-database.sql -v db=test
>
> However, pgsanity/ecpg rejects these.
>
> $ pgsanity create-database.sql
> line 1: ERROR: syntax error at or near ":db"
>
> Is there a flag I can give to ecpg to ignore input parameters?
>
> Is there a patch we could make to ecpg to accept input parameters?
>
> Is there another way to write my input parameters to work around
> this error?
>
>
> If I am following correctly:
>
> http://www.postgresql.org/__docs/9.4/interactive/ecpg-__variables.html
> <http://www.postgresql.org/docs/9.4/interactive/ecpg-variables.html>
>
>
> --
> Cheers,
>
> Andrew Pennebaker
> www.yellosoft.us <http://www.yellosoft.us> <http://www.yellosoft.us>
>
>
>
> --
> Adrian Klaver
> adrian(dot)klaver(at)aklaver(dot)com <mailto:adrian(dot)klaver(at)aklaver(dot)com>
>
>
>
>
> --
> Cheers,
>
> Andrew Pennebaker
> www.yellosoft.us <http://www.yellosoft.us>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Nykolyn, Andy (AS) 2015-04-08 21:11:45 Error Creating DBlink Extension in 9.4.1
Previous Message Tom Lane 2015-04-08 20:53:02 Re: ecpg rejects input parameters