X-Original-To: pgsql-bugs-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id BB270D1D146; Tue, 19 Aug 2003 21:43:15 -0300 (ADT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 29920-06; Tue, 19 Aug 2003 21:43:08 -0300 (ADT) Received: from pcslink.com (pcslink.com [208.145.64.10]) by svr1.postgresql.org (Postfix) with ESMTP id 1F93ED1BA97; Tue, 19 Aug 2003 21:43:04 -0300 (ADT) Received: (from ryan@localhost) by pcslink.com (8.9.3/8.9.2) id RAA53251; Tue, 19 Aug 2003 17:43:07 -0700 (MST) (envelope-from ryan) Date: Tue, 19 Aug 2003 14:43:07 -1000 From: Ryan Mooney To: pgsql-interfaces@postgresql.org Cc: pgsql-bugs@postgresql.org Subject: Re: [INTERFACES] ECPG Connect user :variable problem Message-ID: <20030820004307.GB10232@pcslink.com> References: <20030819221656.GA10232@pcslink.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="PNTmBPCT7hxwcZjr" Content-Disposition: inline In-Reply-To: <20030819221656.GA10232@pcslink.com> User-Agent: Mutt/1.3.25i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200308/165 X-Sequence-Number: 6537 --PNTmBPCT7hxwcZjr Content-Type: text/plain; charset=us-ascii Content-Disposition: inline All, It appears that there is an extra space around a " ?" replaceable string in the preprocessor that should have read "?". Attached (and inline) is a patch to /src/interfaces/ecpg/preproc/prepoc.y that fixes the problem. Also interestingly none of the test files for the ecpg processor exercise the "USER :user USING :password" functionality (at least that I could see - although I'm sortof blind so I might be missing something :) *** preproc.y Tue Aug 19 17:06:44 2003 --- preproc.y.old Tue Aug 19 17:06:35 2003 *************** *** 4174,4180 **** { if ($1[0] == '\"') $$ = $1; ! else if (strcmp($1, "?") == 0) /* variable */ { enum ECPGttype type = argsinsert->variable->type->type; --- 4174,4180 ---- { if ($1[0] == '\"') $$ = $1; ! else if (strcmp($1, " ?") == 0) /* variable */ { enum ECPGttype type = argsinsert->variable->type->type; > > Hello, > > I'm having a major problem using ecpg with 7.4beta1. The problem is that > if I try to pass in the username or password as :variables to the EXEC SQL > CONNECT code they are essentially ignored (replaced by " ?"). > > I've tried it on both redhat 7.2 IA64 and Redhat 9.0 IA32 (different enough > that I don't think its the platform). I also tried it with postgres 7.3.2 > which seemed to do the "right thing" and put the variables into the ECPGconnect > call. > > Any thoughts? > > --------------------------------------------------------------- > int pg_connect(void) > { > > EXEC SQL BEGIN DECLARE SECTION; > char *target = "dbname"; > char *connection_name = "myconnection"; > char *uname = "myuser"; > char *password = "mypassword"; > EXEC SQL END DECLARE SECTION; > > EXEC SQL CONNECT TO :target as :connection_name user :uname using :password; > > } > > --------------------------------------------------------------- > > int pg_connect(void) > { > > /* exec sql begin declare section */ > > > > > > #line 5 "connect.pgc" > char * target = "dbname" ; > > #line 6 "connect.pgc" > char * connection_name = "myconnection" ; > > #line 7 "connect.pgc" > char * uname = "myuser" ; > > #line 8 "connect.pgc" > char * password = "mypassword" ; > /* exec sql end declare section */ > #line 9 "connect.pgc" > > > { ECPGconnect(__LINE__, 0, target , " ?" , " ?" , connection_name, 0); } > #line 11 "connect.pgc" > > > } > > > -- > >-=-=-=-=-=-=-<>-=-=-=-=-=-<>-=-=-=-=-=-<>-=-=-=-=-=-<>-=-=-=-=-=-=-< > Ryan Mooney ryan@pcslink.com > <-=-=-=-=-=-=-><-=-=-=-=-=-><-=-=-=-=-=-><-=-=-=-=-=-><-=-=-=-=-=-=-> > > ---------------------------(end of broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/docs/faqs/FAQ.html -- >-=-=-=-=-=-=-<>-=-=-=-=-=-<>-=-=-=-=-=-<>-=-=-=-=-=-<>-=-=-=-=-=-=-< Ryan Mooney ryan@pcslink.com <-=-=-=-=-=-=-><-=-=-=-=-=-><-=-=-=-=-=-><-=-=-=-=-=-><-=-=-=-=-=-=-> --PNTmBPCT7hxwcZjr Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="preproc.y.diffs" *** preproc.y Tue Aug 19 17:06:44 2003 --- preproc.y.old Tue Aug 19 17:06:35 2003 *************** *** 4174,4180 **** { if ($1[0] == '\"') $$ = $1; ! else if (strcmp($1, "?") == 0) /* variable */ { enum ECPGttype type = argsinsert->variable->type->type; --- 4174,4180 ---- { if ($1[0] == '\"') $$ = $1; ! else if (strcmp($1, " ?") == 0) /* variable */ { enum ECPGttype type = argsinsert->variable->type->type; --PNTmBPCT7hxwcZjr--