X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 32B1FD6FC7 for ; Wed, 24 Aug 2005 12:30:46 -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 64803-09 for ; Wed, 24 Aug 2005 15:30:41 +0000 (GMT) Received: from mx-3.zoominternet.net (mx-3.zoominternet.net [24.154.1.22]) by svr1.postgresql.org (Postfix) with ESMTP id 73DA4D6F3F for ; Wed, 24 Aug 2005 12:30:40 -0300 (ADT) Received: from mua-3.zoominternet.net (mua-3.zoominternet.net [24.154.1.46]) by mx-3.zoominternet.net (8.12.11/8.12.11) with ESMTP id j7OFUWU4016153; Wed, 24 Aug 2005 11:30:32 -0400 Received: from [192.168.0.188] (acs-24-144-211-60.zoominternet.net [24.144.211.60]) by mua-3.zoominternet.net (Postfix) with ESMTP id D1D897F40A; Wed, 24 Aug 2005 11:30:18 -0400 (EDT) Subject: Re: DBD::Pg and "invalid frontend message type 10" From: Scott Cain To: Tom Lane Cc: Michael Fuhr , pgsql-interfaces@postgresql.org In-Reply-To: <26062.1124896206@sss.pgh.pa.us> References: <1124889034.2940.132.camel@localhost.localdomain> <20050824133453.GA50029@winnie.fuhr.org> <26062.1124896206@sss.pgh.pa.us> Content-Type: text/plain Date: Wed, 24 Aug 2005 11:30:30 -0400 Message-Id: <1124897430.2940.143.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.2.3 (2.2.3-2.fc4) Content-Transfer-Encoding: 7bit X-CanItPRO-Stream: outgoing X-Scanned-By: CanIt (www . roaringpenguin . com) on 24.154.1.22 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 required=5 tests=[none] X-Spam-Level: X-Archive-Number: 200508/45 X-Sequence-Number: 5716 On Wed, 2005-08-24 at 11:10 -0400, Tom Lane wrote: > Since 10 is the ascii code for line-feed, I wonder if this could > indicate an unwanted newline format conversion someplace. In particular > I'm imagining something like this: > > * frontend thinks it's sending 'Q' message type, message length, > and a query string that ends with \n: > Q 0 0 0 42 SELECT ... \n > * some evil code changes this to > Q 0 0 0 42 SELECT ... \r \n > * backend receives and executes > Q 0 0 0 42 SELECT ... \r > which is perfectly OK > * next time backend tries to read a message, it gets the \n > which leads to the reported complaint > > I've glossed over some details but in general it seems like something > like this could be happening, if you are using the V3 protocol which > relies on message length words. > Wow, Tom, I have no idea what that means! I haven't heard back from my user whom I asked to turn on query logging so that we can see what the server is seeing, but I suspect that the offending code may be in this sub that is doing a COPY FROM STDIN: sub copy_from_stdin { my $dbh = shift; my $table = shift; my $fields = shift; my $file = shift; my $sequence = shift; my $nextval = shift; warn "Loading data into $table table ...\n"; my $query = "COPY $table $fields FROM STDIN;"; #warn "\t".$query; my $sth = $dbh->prepare($query); $sth->execute(); open FILE, $file; while () { $dbh->func($_, 'putline'); } $dbh->func('endcopy'); # no docs on this func--got from google close FILE; $sth->finish; #update the sequence so that later inserts will work $dbh->do("SELECT setval('public.$sequence', $nextval) FROM $table"); } Does that help at all? Thanks, Scott -- ------------------------------------------------------------------------ Scott Cain, Ph. D. cain@cshl.edu GMOD Coordinator (http://www.gmod.org/) 216-392-3087 Cold Spring Harbor Laboratory