Received: from aaz.links.ru (aaz.links.ru [193.125.152.37]) by postgresql.org (Postfix) with ESMTP id 5C82B47511A for ; Sat, 20 Apr 2002 19:33:05 -0400 (EDT) Received: (from babolo@localhost) by aaz.links.ru (8.9.3/8.9.3) id DAA24386; Sun, 21 Apr 2002 03:33:06 +0400 (MSD) Message-Id: <200204202333.DAA24386@aaz.links.ru> Subject: Re: [INTERFACES] sqlbang In-Reply-To: <200204180349.g3I3nBv04245@candle.pha.pa.us> from "Bruce Momjian" at "Apr 17, 2 11:49:11 pm" To: pgman@candle.pha.pa.us (Bruce Momjian) Date: Sun, 21 Apr 2002 03:33:06 +0400 (MSD) Cc: pgsql-hackers@postgreSQL.org From: "."@babolo.ru MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Archive-Number: 200204/1125 X-Sequence-Number: 21789 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. > > I propose to include this feature. > > Sorry for bad English. -- @BABOLO http://links.ru/