pg.ddx.io  pgsql-testers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Possible 9.0 bug
8+ messages / 3 participants
[nested] [flat]

* Possible 9.0 bug
@ 2010-05-07 12:25 Paul Anderson <paul.a@pnlassociates.com>
  2010-05-07 17:21 ` Re: Possible 9.0 bug Josh Berkus <josh@agliodbs.com>
  0 siblings, 1 reply; 8+ messages in thread

From: Paul Anderson @ 2010-05-07 12:25 UTC (permalink / raw)
  To: pgsql-testers; +Cc: Paul B. Anderson <paul.a@pnlassociates.com>

I have a small test case (shown below) that is not working under 
9.0beta1 but works fine under 8.1.  I have other code that is virtually 
identical to this that does not encounter the error.

When I connect using empty string user id and password (and specifying 
ident in pg_hba) I get the following:

================
 >testconnect

Database connection failed: connection failed:-402:could not connect to 
database "mchs" on line 53

Could not connect to database: connection failed:-402:could not connect 
to database "mchs" on line 53

=================

When I put in non-empty user id and password, it is OK:

 >testconnect

Connected to database OK

Disconnected from database

=================

This is my test case:

=================

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define  USERNAME           ""
#define  PASSWORD           ""

#include <sqlca.h>

int db_connect(char *);
void db_disconnect();

int main(int argc, char *argv[])
{
   char message[81];

   if (db_connect(message) != 0) {
     printf("Could not connect to database: %s\n", message);
   } else {
     printf("Connected to database OK\n");
     db_disconnect();
   }

   return 0;
}

int db_connect(char *message)
{
   int  result = 0;

   EXEC SQL BEGIN DECLARE SECTION;
      VARCHAR username[128];
      VARCHAR password[32];
   EXEC SQL END DECLARE SECTION;

   strcpy(username.arr,USERNAME);
   username.len = strlen(username.arr);

   strcpy(password.arr,PASSWORD);
   password.len = strlen(password.arr);

   EXEC SQL CONNECT TO mchs USER :username IDENTIFIED BY :password;
   if (sqlca.sqlcode == 0) {
     result = 0;
   } else {
     result = 1;
     sprintf(message,"connection failed:%d:%s\n",
             sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
     printf("\nDatabase connection failed: %s\n", message);
   }
   return result;
}

void db_disconnect()
{
   EXEC SQL ROLLBACK;

   EXEC SQL CONNECT RESET;

   printf("\nDisconnected from database\n");
}




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

* Re: Possible 9.0 bug
  2010-05-07 12:25 Possible 9.0 bug Paul Anderson <paul.a@pnlassociates.com>
@ 2010-05-07 17:21 ` Josh Berkus <josh@agliodbs.com>
  0 siblings, 0 replies; 8+ messages in thread

From: Josh Berkus @ 2010-05-07 17:21 UTC (permalink / raw)
  To: pgsql-testers

On 05/07/2010 05:25 AM, Paul Anderson wrote:
> I have a small test case (shown below) that is not working under
> 9.0beta1 but works fine under 8.1. I have other code that is virtually
> identical to this that does not encounter the error.

Can you try this on 8.4?

-- 
                                   -- Josh Berkus
                                      PostgreSQL Experts Inc.
                                      http://www.pgexperts.com



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

* Re: Possible 9.0 bug
@ 2010-05-07 19:41 Michael Meskes <meskes@postgresql.org>
  2010-05-07 19:43 ` Re: Possible 9.0 bug Paul Anderson <paul.a@pnlassociates.com>
  2010-05-07 19:46 ` Re: Possible 9.0 bug Paul Anderson <paul.a@pnlassociates.com>
  2010-05-07 19:59 ` Re: Possible 9.0 bug Paul Anderson <paul.a@pnlassociates.com>
  0 siblings, 3 replies; 8+ messages in thread

From: Michael Meskes @ 2010-05-07 19:41 UTC (permalink / raw)
  To: Paul B. Anderson <paul.a@pnlassociates.com>; +Cc: pgsql-testers

Hi Paul,

actually this bug was introduced in 8.4 when ecpg moved to the new libpq
connect function. Thanks for spotting it. The code in CVS is fixed for both,
8.4 and 9.0.

Michael
-- 
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org
ICQ 179140304, AIM/Yahoo/Skype michaelmeskes, Jabber meskes@jabber.org
VfL Borussia! Força Barça! Go SF 49ers! Use Debian GNU/Linux, PostgreSQL



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

* Re: Possible 9.0 bug
  2010-05-07 19:41 Re: Possible 9.0 bug Michael Meskes <meskes@postgresql.org>
@ 2010-05-07 19:43 ` Paul Anderson <paul.a@pnlassociates.com>
  2 siblings, 0 replies; 8+ messages in thread

From: Paul Anderson @ 2010-05-07 19:43 UTC (permalink / raw)
  To: Michael Meskes <meskes@postgresql.org>; +Cc: pgsql-testers

Thanks!

Paul


On 5/7/10 3:41 PM, Michael Meskes wrote:
> Hi Paul,
>
> actually this bug was introduced in 8.4 when ecpg moved to the new libpq
> connect function. Thanks for spotting it. The code in CVS is fixed for both,
> 8.4 and 9.0.
>
> Michael
>    



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

* Re: Possible 9.0 bug
  2010-05-07 19:41 Re: Possible 9.0 bug Michael Meskes <meskes@postgresql.org>
@ 2010-05-07 19:46 ` Paul Anderson <paul.a@pnlassociates.com>
  2010-05-07 20:20   ` Re: Possible 9.0 bug Michael Meskes <meskes@postgresql.org>
  2 siblings, 1 reply; 8+ messages in thread

From: Paul Anderson @ 2010-05-07 19:46 UTC (permalink / raw)
  To: Michael Meskes <meskes@postgresql.org>; +Cc: pgsql-testers

I tried it on 8.4.1 and it did not fail.  Is that consistent?

On 5/7/10 3:41 PM, Michael Meskes wrote:
> Hi Paul,
>
> actually this bug was introduced in 8.4 when ecpg moved to the new libpq
> connect function. Thanks for spotting it. The code in CVS is fixed for both,
> 8.4 and 9.0.
>
> Michael
>    



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

* Re: Possible 9.0 bug
  2010-05-07 19:41 Re: Possible 9.0 bug Michael Meskes <meskes@postgresql.org>
  2010-05-07 19:46 ` Re: Possible 9.0 bug Paul Anderson <paul.a@pnlassociates.com>
@ 2010-05-07 20:20   ` Michael Meskes <meskes@postgresql.org>
  0 siblings, 0 replies; 8+ messages in thread

From: Michael Meskes @ 2010-05-07 20:20 UTC (permalink / raw)
  To: Paul Anderson <paul.a@pnlassociates.com>; +Cc: Michael Meskes <meskes@postgresql.org>; pgsql-testers

On Fri, May 07, 2010 at 03:46:14PM -0400, Paul Anderson wrote:
> I tried it on 8.4.1 and it did not fail.  Is that consistent?

Well the bug might get hidden by some other stuff but it definitely was there.
The problem was that the code only checked for user/password == NULL to find
empty parameters which of course doesn't catch "". 

Michael
-- 
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org
ICQ 179140304, AIM/Yahoo/Skype michaelmeskes, Jabber meskes@jabber.org
VfL Borussia! Força Barça! Go SF 49ers! Use Debian GNU/Linux, PostgreSQL



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

* Re: Possible 9.0 bug
  2010-05-07 19:41 Re: Possible 9.0 bug Michael Meskes <meskes@postgresql.org>
@ 2010-05-07 19:59 ` Paul Anderson <paul.a@pnlassociates.com>
  2010-05-07 20:22   ` Re: Possible 9.0 bug Michael Meskes <meskes@postgresql.org>
  2 siblings, 1 reply; 8+ messages in thread

From: Paul Anderson @ 2010-05-07 19:59 UTC (permalink / raw)
  To: Michael Meskes <meskes@postgresql.org>; +Cc: pgsql-testers

While the test case I sent earlier runs under 8.4.1, a different program 
with almost identical code fails using 8.4.1.

The problem I reported earlier only occurred in some cases.  I have a 
number of programs with near identical connection code and only some of 
them failed.

Paul

On 5/7/10 3:41 PM, Michael Meskes wrote:
> Hi Paul,
>
> actually this bug was introduced in 8.4 when ecpg moved to the new libpq
> connect function. Thanks for spotting it. The code in CVS is fixed for both,
> 8.4 and 9.0.
>
> Michael
>    



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

* Re: Possible 9.0 bug
  2010-05-07 19:41 Re: Possible 9.0 bug Michael Meskes <meskes@postgresql.org>
  2010-05-07 19:59 ` Re: Possible 9.0 bug Paul Anderson <paul.a@pnlassociates.com>
@ 2010-05-07 20:22   ` Michael Meskes <meskes@postgresql.org>
  0 siblings, 0 replies; 8+ messages in thread

From: Michael Meskes @ 2010-05-07 20:22 UTC (permalink / raw)
  To: Paul Anderson <paul.a@pnlassociates.com>; +Cc: Michael Meskes <meskes@postgresql.org>; pgsql-testers

On Fri, May 07, 2010 at 03:59:17PM -0400, Paul Anderson wrote:
> The problem I reported earlier only occurred in some cases.  I have
> a number of programs with near identical connection code and only
> some of them failed.

If you want you can try if there is another problem being discovered by your
test cases. The patch is here:

http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/interfaces/ecpg/ecpglib/connect.c.diff?r1=1.54;r2...

It's just a short one, but it fixed your test case for me.

Michael
-- 
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org
ICQ 179140304, AIM/Yahoo/Skype michaelmeskes, Jabber meskes@jabber.org
VfL Borussia! Força Barça! Go SF 49ers! Use Debian GNU/Linux, PostgreSQL



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


end of thread, other threads:[~2010-05-07 20:22 UTC | newest]

Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2010-05-07 12:25 Possible 9.0 bug Paul Anderson <paul.a@pnlassociates.com>
2010-05-07 17:21 ` Josh Berkus <josh@agliodbs.com>
2010-05-07 19:41 Re: Possible 9.0 bug Michael Meskes <meskes@postgresql.org>
2010-05-07 19:43 ` Paul Anderson <paul.a@pnlassociates.com>
2010-05-07 19:46 ` Paul Anderson <paul.a@pnlassociates.com>
2010-05-07 20:20   ` Michael Meskes <meskes@postgresql.org>
2010-05-07 19:59 ` Paul Anderson <paul.a@pnlassociates.com>
2010-05-07 20:22   ` 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