Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id B42299FA46D for ; Thu, 28 Sep 2006 09:22:57 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 23484-09 for ; Thu, 28 Sep 2006 12:22:52 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from web58304.mail.re3.yahoo.com (web58304.mail.re3.yahoo.com [68.142.236.157]) by postgresql.org (Postfix) with SMTP id 363FC9FB309 for ; Thu, 28 Sep 2006 09:22:52 -0300 (ADT) Received: (qmail 21393 invoked by uid 60001); 28 Sep 2006 12:16:11 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=kBxbuBD9hlYBaG2Z7RAWLU9QUmvJxGXtiTSogee1RyNJY4lUCadupkwJnflMiuAb3wyiA6grDuLskpWGw20FfXT+QOAZ6vV5a9GyM3K8fzqlk1aCHrUffTjKU6tAWg6eweO0fSa7IhzABqg5LZWmodPNSpepifuewyI6sO32uwA= ; Message-ID: <20060928121611.21391.qmail@web58304.mail.re3.yahoo.com> Received: from [88.247.172.183] by web58304.mail.re3.yahoo.com via HTTP; Thu, 28 Sep 2006 05:16:10 PDT Date: Thu, 28 Sep 2006 05:16:10 -0700 (PDT) From: erkan kolemen Subject: PGExec returns error without any comment To: pgsql-interfaces@postgresql.org MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-518361595-1159445770=:20670" Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=3.356 tagged_above=0 required=5 tests=DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST, DNS_FROM_RFC_WHOIS, HTML_MESSAGE X-Spam-Level: *** X-Archive-Number: 200609/31 X-Sequence-Number: 6276 --0-518361595-1159445770=:20670 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Hi, Following code fails at PQExec. I am using PQerrorMessage() function to print error message but no output. Error code is 2. What could be the problem with select query? I tried with "drop table" it worked. [root@hq src]# ./1 PQExec failed(2): 1.c #include #include #include #include #include #include int main() { char *conninfo; PGconn *conn; PGresult *res; /* Prepare connection info */ conninfo = (char *) malloc(64); if (conninfo == NULL) { fprintf(stderr, "malloc error: %s\n", strerror(errno)); return -1; } memset(conninfo, 0, 64); strncpy(conninfo, "dbname=llist user=yyy password=xxx", 63); /* Make a connection to the database */ conn = PQconnectdb(conninfo); /* Check to see that the backend connection was successfully made */ if (PQstatus(conn) != CONNECTION_OK) { fprintf(stderr, "Connection to database failed: %s", PQerrorMessage(conn)); return -1; } res = PQexec(conn, "select * from lists;"); if (PQresultStatus(res) != PGRES_COMMAND_OK) { fprintf(stderr, "PQExec failed(%d): %s\n", PQresultStatus(res), PQerrorMessage(conn)); PQclear(res); return -1; } PQclear(res); PQfinish(conn); return 0; } --------------------------------- Do you Yahoo!? Get on board. You're invited to try the new Yahoo! Mail. --0-518361595-1159445770=:20670 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Hi,

Following code fails at PQExec. I am using PQerrorMessage() function to print error message but no output. Error code is 2. What could be the problem with select query? I tried with "drop table" it worked.

[root@hq src]# ./1
PQExec failed(2):

1.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/time.h>
#include <libpq-fe.h>

int main()
{
        char *conninfo;
        PGconn     *conn;
        PGresult   *res;

        /* Prepare connection info */
        conninfo = (char *) malloc(64);
        if (conninfo == NULL) {
                fprintf(stderr, "malloc error: %s\n", strerror(errno));
                return -1;
        }

        memset(conninfo, 0, 64);
        strncpy(conninfo, "dbname=llist user=yyy password=xxx", 63);

        /* Make a connection to the database */
        conn = PQconnectdb(conninfo);

        /* Check to see that the backend connection was successfully made */
        if (PQstatus(conn) != CONNECTION_OK)
        {
                fprintf(stderr, "Connection to database failed: %s", PQerrorMessage(conn));
                return -1;
        }

        res = PQexec(conn, "select * from lists;");
        if (PQresultStatus(res) != PGRES_COMMAND_OK)
        {
                fprintf(stderr, "PQExec failed(%d): %s\n", PQresultStatus(res), PQerrorMessage(conn));
                PQclear(res);
                return -1;
        }

        PQclear(res);

        PQfinish(conn);

        return 0;
}


Do you Yahoo!?
Get on board. You're invited to try the new Yahoo! Mail. --0-518361595-1159445770=:20670--