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 6510253C8E for ; Fri, 8 Apr 2005 20:22:35 +0100 (BST) 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 18808-03 for ; Fri, 8 Apr 2005 19:22:32 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.195]) by svr1.postgresql.org (Postfix) with ESMTP id 0F9F553CC9 for ; Fri, 8 Apr 2005 20:22:31 +0100 (BST) Received: by wproxy.gmail.com with SMTP id 69so1141890wri for ; Fri, 08 Apr 2005 12:22:33 -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:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=i1SQ68461Nz5rrP4lRwbYvj9TUxWBPZmO7h/IXFVGv7q/oz8vKe8bmIMUKW/Tyfzw7l0yJKbd4BwGZwfuwMTwd3asp/SMuUnpFxXD2DFyIBY5YQXnH3ju0AS3WJYt4O5glvx6BGJSvo7r/pj34sKsKuWkqljbumBaVV+ErLb1j4= Received: by 10.54.2.44 with SMTP id 44mr228859wrb; Fri, 08 Apr 2005 12:22:32 -0700 (PDT) Received: by 10.54.45.39 with HTTP; Fri, 8 Apr 2005 12:22:32 -0700 (PDT) Message-ID: Date: Fri, 8 Apr 2005 15:22:32 -0400 From: Vlad Reply-To: Vlad To: Tom Lane Subject: Re: [Dbdpg-general] benchmarking old Pg and DBD::Pg Cc: Brandon Metcalf , dbdpg-general@gborg.postgresql.org, pgsql-interfaces@postgresql.org In-Reply-To: <16221.1112987509@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit References: <16221.1112987509@sss.pgh.pa.us> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.27 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200504/35 X-Sequence-Number: 5451 Tom, Thanks for suggestion - I'm gonna try this patch: --- dbdimp.c.bak Wed Apr 6 16:40:20 2005 +++ dbdimp.c Fri Apr 8 15:21:29 2005 @@ -1415,7 +1415,7 @@ } else if (NULL == currph->bind_type) { /* "sticky" data type */ /* This is the default type, but we will honor defaultval if we can */ - currph->bind_type = pg_type_data(VARCHAROID); + currph->bind_type = pg_type_data(UNKNOWNOID); if (!currph->bind_type) croak("Default type is bad!!!!???"); } On Apr 8, 2005 3:11 PM, Tom Lane wrote: > Vlad writes: > > Ideallly a programmer doesn't need to care to specify column type when > > putting a code like this (assuming C is of an "int" type ): > > > my $sth = $dbh->prepare_cached( "select A from B where C=?"); > > $sth->execute( 123 ); > > ... > > > and DBD::Pg would guess (don't ask me how) the column types and pass > > it to postgresql so the query executed in most efficient way. > > DBD::Pg shouldn't need to do any such thing --- the backend can do it a > whole lot better than DBD::Pg could. What should be happening here is > that if DBD::Pg hasn't been told a specific type for the parameter, it > should pass the parameter type to the backend as "UNKNOWN" (yes, there > is such a type ID) and let the backend try to infer the type. > > There are cases where there's not enough information to infer the type, > and then the programmer has to provide it, either by writing a cast in > the query text or by passing the info to bind_param. It sounds like > bind_param could do with some work too ... but 80% of this issue would > go away if UNKNOWN were being used correctly. > > regards, tom lane > -- Vlad