Skip site navigation (1) Skip section navigation (2)

Re: [INTERFACES] sqlbang

From: "(dot)"(at)babolo(dot)ru
To: pgman(at)candle(dot)pha(dot)pa(dot)us (Bruce Momjian)
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [INTERFACES] sqlbang
Date: 2002-04-20 23:33:06
Message-ID: 200204202333.DAA24386@aaz.links.ru (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-interfaces
Nobody interested?

I prepare my ISP Management System (ispms)
to publish and want reduce number of patches
needed to install it.

SQLbangs widely ised in it:
0cicuta~(1)>grep -r '^#\!/usr/local/bin/psql' /usr/local/libexec/ispms | wc -l
      61
The most reason for patch are paremeters,
because without parameters 

#!/usr/local/bin/psql -flags

can be substituted for:

#!/bin/sh
/usr/local/bin/psql -flags << "EOF"

but for substitute shell's ${1}, ${2} so on
for real parameters "EOF" in above example
MUST be without quotes.
So all SQL text will be preprocessored
by shell. Things are worst - some
of SQLbangs prepare simple shell's
programs with some shell
variables and quotes in it which must
be escaped to be not expanded
when SQL executes.

Yes, I have m4 build system to do such
escaping:
0cicuta~(2)>find w/ispms -name \*.m4 | wc -l
      71
for WWW interface mostly, but without
SQLbangs escape level will be 1 level more,
shell has some errors (or features, I dont
know) with high level escaping and
I do not want depend on this errors
(or features) in base ispms system
(WWW interface has low rights)

Bruce Momjian writes:
> Can someone comment on this feature?
> 
> ---------------------------------------------------------------------------
> 
> "."@babolo.ru wrote:
> > Sorry I don't know if this is right list.
> > 
> > I use scripts of such a kind (I say "SQLbang")
> > 
> > #!/usr/local/bin/psql -qQ
> > \a \t \pset fieldsep ' '
> > 
> > \set router '\'' :1 '\''
> > 
> > SELECT ispdb_sfbsdr_allow(network(inet),niface)
> >  FROM ispdb_sfbsdr_riaddr, nets
> >  WHERE nrouter = :router 
> >    AND int_type = index_int_type('int')
> >    AND network(inet) <<= network(net)
> >    AND nets.control
> > 
> > Parameters after sqlbang's name goes to :1, :2 so on.
<patch skiped>
> > I propose to include this feature.
> > Sorry for bad English.

-- 
@BABOLO      http://links.ru/

In response to

Responses

pgsql-hackers by date

Next:From: Francisco Jr.Date: 2002-04-21 00:11:15
Subject: Implement a .NET Data Provider
Previous:From: Tom LaneDate: 2002-04-20 17:25:00
Subject: Re: Improved scanner performance

pgsql-interfaces by date

Next:From: Peter EisentrautDate: 2002-04-21 04:53:28
Subject: Re: [INTERFACES] sqlbang
Previous:From: lexx_hDate: 2002-04-19 13:32:07
Subject: getting value of just inserted rows

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group