From: | Aurimas Černius <aurisc4(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: connecting using libpq breaks printf |
Date: | 2009-02-18 15:01:14 |
Message-ID: | 499C22BA.4010004@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi,
> This is my first attempt at using libpq, and I'm running across a strange
> problem. Here is my bare-bones program:
>
> #include<stdio.h>
> #include "libpq-fe.h"
>
> int main(int argc, char **argv) {
> PGconn *conn;
> fprintf(stderr, "connecting\n");
> conn = PQconnectdb("dbname=postgres");
> PQfinish(conn);
> return 0;
> }
>
> I expected this program to print "connecting", but in fact I get no output
> whatsoever. If I comment out the PQconnectdb and PQfinish lines, I see
> "connecting" as expected. What could be going on here?
Did you use *exactly* the same command line to compile both versions?
What is that command line(s)?
> A few notes:
> - I'm running PostgreSQL 8.3.6 on Windows XP. I used the one-click installer
> to install.
> - I'm compiling the program with MinGW. I get no compiler warnings or errors.
> - I can connect to the database just fine using both pgAdmin and the
> command-line client. The database is running on localhost.
> - I've tried adding code to see if PQstatus(conn) == CONNECTION_OK, but this
> hasn't been useful. Since fprintf() isn't working, I can't display a message
> showing the result of the comparison.
> - I've tried various combinations of connection options in case there was an
> issue with the hostname, database name, username, or password. I always get
> the same result: no output.
> - I've tried printing to stdout and to a file, but neither helped.
>
> Thanks for any help you can provide.
> Joey
>
--
Aurimas
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2009-02-18 15:35:27 | Re: Query palns and tug-of-war with enable_sort |
Previous Message | Lennin Caro | 2009-02-18 14:53:32 | Re: connecting using libpq breaks printf |