Received: from localhost (unknown [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 41AA32E3C1E for ; Thu, 20 Dec 2007 01:49:31 -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 82140-05-2 for ; Thu, 20 Dec 2007 01:49:22 -0400 (AST) Received: from fk-out-0910.google.com (fk-out-0910.google.com [209.85.128.187]) by postgresql.org (Postfix) with ESMTP id 2C4862E3763 for ; Thu, 20 Dec 2007 01:29:14 -0400 (AST) Received: by fk-out-0910.google.com with SMTP id b27so3327356fka.3 for ; Wed, 19 Dec 2007 21:29:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:reply-to:to:subject:mime-version:content-type; bh=4ymITN3rtRJWIBvjFIx/uUApmypTEfRud9xr9VmiZ/Q=; b=Ei6i1qfP8pwaQjlDdBx8VBsPWpEu19H1liri+DvkDyzPwD3wHqy44OAz++fwhrqzIAr177L8tix4JynrQe09Bl8Jsy9g8K1Y23H8MV0JhctCAbEf8N8kNW74da0BE0TUXksGmvZLoUjyTOq6nUozrWLg3Ul1jDj5LCpRAn3j2us= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:reply-to:to:subject:mime-version:content-type; b=TIROrvKtwRqLkoa9bSNQkQ7Gy7LGvLkFiG+lUh+2V9EICW/HJSh1mjd7yuAdecIDySqMFNyalxYOZZ5r0fLrr5mUmEd+bcuhMKOmKGZJeVBh5Ch3QznPwSBbm2x4MUWaBO55FhGbxWJP4+Ecp45rIFvqM7dgVVpUiJ/tEJnVXn8= Received: by 10.86.4.2 with SMTP id 2mr9703368fgd.77.1198128553047; Wed, 19 Dec 2007 21:29:13 -0800 (PST) Received: by 10.86.58.10 with HTTP; Wed, 19 Dec 2007 21:29:13 -0800 (PST) Message-ID: <59d6a8dc0712192129s485fb71wcb7c6323fac85258@mail.gmail.com> Date: Wed, 19 Dec 2007 21:29:13 -0800 From: "Iuri Sampaio" Reply-To: iuri.sampaio@computer.org To: pgsql-sql@postgresql.org Subject: sql query - create replace function MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_16455_6120471.1198128553054" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200712/104 X-Sequence-Number: 29796 ------=_Part_16455_6120471.1198128553054 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 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: # from your shell prompt enter: $ psql # From the psql prompt enter the follow plpgsql code to create the bitfromint4 function: $ create or replace function bitfromint4 (integer) returns bit varying as ' begin return $1::bit(32); end;' language 'plpgsql' immutable strict; #Exit psql: $ \q 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;" but i see when the script runs "pgsql dbname" the bash script looses control of the process, and there's no way back, from pgql shell prompt when it gets in, to continue the script iuri ------=_Part_16455_6120471.1198128553054 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline
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:
 
# from your shell prompt enter:
$ psql <dbname>
 
# From the psql prompt enter the follow plpgsql code to create the bitfromint4 function:

$ create or replace function bitfromint4 (integer) returns bit varying as ' begin return $1::bit(32); end;' language 'plpgsql' immutable strict;

#Exit psql:

$ \q 
 
 
 
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;"
 
but i see when the script runs "pgsql dbname" the bash script looses control of the process, and there's no way back, from pgql shell prompt when it gets in, to continue the script
 
iuri
------=_Part_16455_6120471.1198128553054--