pg.ddx.io  pgsql-testers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Paul Anderson <paul.a@pnlassociates.com>
To: pgsql-testers@postgresql.org
Cc: Paul B. Anderson <paul.a@pnlassociates.com>
Subject: Possible 9.0 bug
Date: Fri, 07 May 2010 08:25:11 -0400
Message-ID: <4BE406A7.6000101@pnlassociates.com> (raw)

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");
}




view thread (8+ messages)  latest in thread

Message-ID: <4BE406A7.6000101@pnlassociates.com>
Permalink:  ../4BE406A7.6000101@pnlassociates.com/
Also on:    postgresql.org/message-id/4BE406A7.6000101@pnlassociates.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-testers@postgresql.org
  Cc: paul.a@pnlassociates.com
  Subject: Re: Possible 9.0 bug
  In-Reply-To: <4BE406A7.6000101@pnlassociates.com>
  References: <4BE406A7.6000101@pnlassociates.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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