pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
ECPG Connect user :variable problem
4+ messages / 2 participants
[nested] [flat]

* ECPG Connect user :variable problem
@ 2003-08-19 22:17  Ryan Mooney <ryan@pcslink.com>
  0 siblings, 2 replies; 4+ messages in thread

From: Ryan Mooney @ 2003-08-19 22:17 UTC (permalink / raw)
  To: pgsql-interfaces


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?

------------------------------<snip "connect.pgc">---------------------------------
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;

}

------------------------------<snip "connect.c">---------------------------------

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 
<-=-=-=-=-=-=-><-=-=-=-=-=-><-=-=-=-=-=-><-=-=-=-=-=-><-=-=-=-=-=-=-> 



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: [INTERFACES] ECPG Connect user :variable problem
@ 2003-08-20 00:43  Ryan Mooney <ryan@pcslink.com>
  parent: Ryan Mooney <ryan@pcslink.com>
  1 sibling, 0 replies; 4+ messages in thread

From: Ryan Mooney @ 2003-08-20 00:43 UTC (permalink / raw)
  To: pgsql-interfaces; +Cc: pgsql-bugs@postgresql.org


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?
> 
> ------------------------------<snip "connect.pgc">---------------------------------
> 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;
> 
> }
> 
> ------------------------------<snip "connect.c">---------------------------------
> 
> 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 
<-=-=-=-=-=-=-><-=-=-=-=-=-><-=-=-=-=-=-><-=-=-=-=-=-><-=-=-=-=-=-=-> 
*** 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;
  

Attachments:

  [text/plain] preproc.y.diffs (472B, ../../20030820004307.GB10232@pcslink.com/2-preproc.y.diffs)
  download | inline:
*** 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;
  

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: [INTERFACES] ECPG Connect user :variable problem
@ 2003-08-20 18:05  Ryan Mooney <ryan@pcslink.com>
  parent: Ryan Mooney <ryan@pcslink.com>
  1 sibling, 1 reply; 4+ messages in thread

From: Ryan Mooney @ 2003-08-20 18:05 UTC (permalink / raw)
  To: pgsql-interfaces; +Cc: pgsql-bugs@postgresql.org


Sorry about that last patch, I hit the wrong one (my bison is
way out of date, so I'm hacking the resulting .c file for test
and backporting to the .y file, not that thats an excuse :)

Anyway here is a patch to 7.4b1 that seems to apply to the snap
from yesterday as well.

This allows you to

  EXEC SQL CONNECT TO :target as :connection_name user :uname using :password;

and have the uname and password C variables get passed correctly to the 
ECPGconnect fucntion after epgc processing.

On Tue, Aug 19, 2003 at 12:17:08PM -1000, Ryan Mooney wrote:
> 
> 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?
> 
> ------------------------------<snip "connect.pgc">---------------------------------
> 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;
> 
> }
> 
> ------------------------------<snip "connect.c">---------------------------------
> 
> 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 
<-=-=-=-=-=-=-><-=-=-=-=-=-><-=-=-=-=-=-><-=-=-=-=-=-><-=-=-=-=-=-=-> 



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: ECPG Connect user :variable problem
@ 2003-08-26 16:09  Michael Meskes <meskes@postgresql.org>
  parent: Ryan Mooney <ryan@pcslink.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Michael Meskes @ 2003-08-26 16:09 UTC (permalink / raw)
  To: Ryan Mooney <ryan@pcslink.com>; +Cc: pgsql-interfaces; pgsql-bugs@postgresql.org

On Wed, Aug 20, 2003 at 08:05:28AM -1000, Ryan Mooney wrote:
> Anyway here is a patch to 7.4b1 that seems to apply to the snap
> from yesterday as well.

Well there seems to be an attachement missing, but I think I know what
you meant and just fixed this. Also I added one test case. :-)

Thanks.

Michael
-- 
Michael Meskes
Email: Michael at Fam-Meskes dot De
ICQ: 179140304, AIM/Yahoo: michaelmeskes, Jabber: meskes@jabber.org
Go SF 49ers! Go Rhein Fire! Use Debian GNU/Linux! Use PostgreSQL!



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2003-08-26 16:09 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-08-19 22:17 ECPG Connect user :variable problem Ryan Mooney <ryan@pcslink.com>
2003-08-20 00:43 ` Ryan Mooney <ryan@pcslink.com>
2003-08-20 18:05 ` Ryan Mooney <ryan@pcslink.com>
2003-08-26 16:09   ` Michael Meskes <meskes@postgresql.org>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox