X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E04F15286C for ; Fri, 20 May 2005 10:20:42 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 66027-05 for ; Fri, 20 May 2005 13:20:40 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.196]) by svr1.postgresql.org (Postfix) with ESMTP id D16BA52837 for ; Fri, 20 May 2005 10:20:36 -0300 (ADT) Received: by wproxy.gmail.com with SMTP id 68so1221777wra for ; Fri, 20 May 2005 06:20:58 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=BM0GSiBS37fCFL5Hit09jovFpKlWzbC/KIYijpL0cUwrBvZKHqzd/1ukmNiJUbt2bpSjzbSJBVjn5HOVbNe0o9p2lVEnHzhMbM/skLLMQuvWgHmTrRyMG0z/Ul80of+gzTimO7fBCyKWNBgB5r2rLx228V5oVtjIr2DIkiRkVQM= Received: by 10.54.61.12 with SMTP id j12mr1129289wra; Fri, 20 May 2005 06:20:58 -0700 (PDT) Received: by 10.54.3.70 with HTTP; Fri, 20 May 2005 06:20:58 -0700 (PDT) Message-ID: <2b5c484b05052006206c301de@mail.gmail.com> Date: Fri, 20 May 2005 14:20:58 +0100 From: Gustavo Lopes Reply-To: Gustavo Lopes To: pgsql-interfaces@postgresql.org Subject: Re: libpq on windows In-Reply-To: <20704.202.47.227.25.1116570741.squirrel@202.47.227.25> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <2b5c484b05051906526f8bb577@mail.gmail.com> <20704.202.47.227.25.1116570741.squirrel@202.47.227.25> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.273 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200505/50 X-Sequence-Number: 5553 No, I'd say the notice processor/receiver is not the problem since I've been able to implement a notice receiver that would display the received notices without any complications. The problem seems to arise only when a message contains a HINT attached (I don't even know whether messages of type NOTICE can cointain a hint field, but anyway that doesn't seem relevant to this issue). Gustavio Lopes On 20/05/05, jtv@xs4all.nl wrote: > Gustavo Lopes wrote: >=20 > > The problem seems to occurr only when the server sends a hint or the > > dll generates one. This can happen when the connection to the server > > cannot be established because the server is not running, a nonexistant > > postgres function exist is called, when one attempts to drop an index > > upon which a constraint depends, etc. (the program doesn't go beyond > > PQconnectdb, PQexec or PQexecparam). Since my debugging skills are > > very poor I cannot give any accurate description on what is causing > > the exception. > > The problem can be very easily reproduced by creating a C program > > which calls PQconnectdb with a host parameter that points to a machine > > that is not running postgres. > > Running the same program under linux (although I used older versions > > of the interface and the server) does not cause any problems. >=20 > It could be the notice processor that crashes. A "notice processor" is a > callback that you can register with libpq that handles error messages. > The default is to print them to the console, but I'm not sure you can > always do that in a Windows program. Or since you're apparently using > different compilers for libpq and the application, maybe the default > notice processor gets linked to a different standard library than it > expects and fails because of that. >=20 > Notice processors are documented here: >=20 > http://www.postgresql.org/docs/8.0/interactive/libpq-notice-processing.ht= ml >=20 > To find out if this is what's wrong, try creating an empty function (with > C-style calling convention, not a regular C++ function) and setting that > as the notice processor: >=20 > extern "C" { /* (this line only needed in C++) */ > void emptynoticeprocessor(void *, const char *) > { > } > } /* (this line only needed in C++) */ >=20 > Now in your code, just after you opened your connection (call it "c"): >=20 > PQsetNoticeProcessor(c,emptynoticeprocessor,NULL); >=20 > Of course that will mean that error messages are not displayed, so if thi= s > solves your crashing problem then your next step is to implement somethin= g > here that displays the given message! >=20 > Jeroen >=20 >