Received: from localhost (unknown [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 1FB202E2FB9 for ; Thu, 20 Dec 2007 04:31:34 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 78445-01-3 for ; Thu, 20 Dec 2007 04:31:31 -0400 (AST) Received: from pih-relay06.plus.net (pih-relay06.plus.net [212.159.14.133]) by postgresql.org (Postfix) with ESMTP id 279BD2E2EAC for ; Thu, 20 Dec 2007 04:31:31 -0400 (AST) Received: from [84.51.143.99] (helo=server3.office.archonet.com) by pih-relay06.plus.net with esmtp (Exim) id 1J5GoT-0001cS-LS; Thu, 20 Dec 2007 08:31:29 +0000 Received: from [192.168.1.36] (dell36.office.archonet.com [192.168.1.36]) by server3.office.archonet.com (Postfix) with ESMTP id 5B535274057; Thu, 20 Dec 2007 08:31:29 +0000 (GMT) Message-ID: <476A2861.2060905@archonet.com> Date: Thu, 20 Dec 2007 08:31:29 +0000 From: Richard Huxton User-Agent: Thunderbird 2.0.0.9 (X11/20071031) MIME-Version: 1.0 To: iuri.sampaio@computer.org CC: pgsql-sql@postgresql.org Subject: Re: sql query - create replace function References: <59d6a8dc0712192129s485fb71wcb7c6323fac85258@mail.gmail.com> In-Reply-To: <59d6a8dc0712192129s485fb71wcb7c6323fac85258@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200712/105 X-Sequence-Number: 29797 Iuri Sampaio wrote: > Hi all, > > I created a script to install postgresql. One of the steps is to run a sql > query. > > the problem is that i need to run the query as postgres user, plus it needs > to be at psql shell prompt command line, i.e: Why does it need to be at the psql prompt? > I expected something like > su - postgres -c "pgsql dbname && create or replace function bitfromint4 > (integer) returns bit varying as ' begin return $1::bit(32); end;' language > 'plpgsql' immutable str\ > ict;" What's wrong with this? -- Richard Huxton Archonet Ltd