Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Tym0K-000712-ED for pgsql-docs@arkaria.postgresql.org; Fri, 25 Jan 2013 16:19:48 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1Tym0J-0001mg-T6 for pgsql-docs@arkaria.postgresql.org; Fri, 25 Jan 2013 16:19:47 +0000 Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Tym0G-0001k8-FO for pgsql-docs@postgresql.org; Fri, 25 Jan 2013 16:19:44 +0000 Received: from momjian.us ([72.94.173.45]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Tym0E-0003hz-Tf for pgsql-docs@postgresql.org; Fri, 25 Jan 2013 16:19:43 +0000 Received: from bruce by momjian.us with local (Exim 4.72) (envelope-from ) id 1Tym0E-0003vf-GK; Fri, 25 Jan 2013 11:19:42 -0500 Date: Fri, 25 Jan 2013 11:19:42 -0500 From: Bruce Momjian To: Alan B Cc: pgsql-docs@postgresql.org Subject: Re: Add clarification example to EXEC SQL CONNECT with password Message-ID: <20130125161942.GA6848@momjian.us> References: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="LZvS9be/3tNcYl/X" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-docs Precedence: bulk Sender: pgsql-docs-owner@postgresql.org --LZvS9be/3tNcYl/X Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Sep 20, 2012 at 06:17:15PM +0200, Alan B wrote: > Hi list, > Hope this is the right place to suggest that change in the docs, otherwise is > there a ticket management system for this stuff somewhere? > > Paying attention to the documentation at http://www.postgresql.org/docs/8.4/ > static/ecpg-connect.html and subsequent versions of the page (I am using 8.4), > there is the option to specify "user-name" in various ways. However this may be > confused as a single parameter to the connect string while it is a combination > of 1 or 2 parameters that cannot go into a single string. > > To avoid confusion I suggest providing a complete example in "Here are some > examples of CONNECT statements:" as follows: > > > EXEC SQL CONNECT TO mydb@sql.mydomain.com; > > EXEC SQL CONNECT TO unix:postgresql://sql.mydomain.com/mydb AS myconnection USER john; > > EXEC SQL BEGIN DECLARE SECTION; > const char *target = "mydb@sql.mydomain.com"; > const char *user = "john"; > const char *passwd = "secret"; > EXEC SQL END DECLARE SECTION; > ... > > EXEC SQL CONNECT TO :target USER :user USING :passwd; > or > EXEC SQL CONNECT TO :target USER :user/:passwd; > > To make the distinction of parameters and string variables evident. I had a look at this just now, and you are right that it is very confusing. I couldn't even figure out how to explain it in text, and agree that your example is the best solution. Attached patch applied to git head and 9.2. Thanks. -- Bruce Momjian http://momjian.us EnterpriseDB http://enterprisedb.com + It's impossible for everything to be true. + --LZvS9be/3tNcYl/X Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="ecpg.diff" diff --git a/doc/src/sgml/ecpg.sgml b/doc/src/sgml/ecpg.sgml new file mode 100644 index 63aaf89..bf01857 *** a/doc/src/sgml/ecpg.sgml --- b/doc/src/sgml/ecpg.sgml *************** EXEC SQL CONNECT TO unix:postgresql://sq *** 194,202 **** EXEC SQL BEGIN DECLARE SECTION; const char *target = "mydb@sql.mydomain.com"; const char *user = "john"; EXEC SQL END DECLARE SECTION; ... ! EXEC SQL CONNECT TO :target USER :user; The last form makes use of the variant referred to above as character variable reference. You will see in later sections how C --- 194,205 ---- EXEC SQL BEGIN DECLARE SECTION; const char *target = "mydb@sql.mydomain.com"; const char *user = "john"; + const char *passwd = "secret"; EXEC SQL END DECLARE SECTION; ... ! EXEC SQL CONNECT TO :target USER :user USING :passwd; ! ! EXEC SQL CONNECT TO :target USER :user/:passwd; The last form makes use of the variant referred to above as character variable reference. You will see in later sections how C --LZvS9be/3tNcYl/X Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-docs --LZvS9be/3tNcYl/X--