X-Original-To: pgsql-odbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id F2F9753808 for ; Wed, 30 Mar 2005 17:02:47 +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 39380-07 for ; Wed, 30 Mar 2005 16:02:47 +0000 (GMT) Received: from fep01-app.kolumbus.fi (fep01-0.kolumbus.fi [193.229.0.41]) by svr1.postgresql.org (Postfix) with ESMTP id 5FB34537F9 for ; Wed, 30 Mar 2005 17:02:45 +0100 (BST) Received: from [192.168.1.103] (really [80.186.80.234]) by fep01-app.kolumbus.fi with ESMTP id <20050330160244.YMCX20421.fep01-app.kolumbus.fi@[192.168.1.103]> for ; Wed, 30 Mar 2005 19:02:44 +0300 Message-ID: <424ACDA1.8070703@kolumbus.fi> Date: Wed, 30 Mar 2005 19:02:41 +0300 From: Marko Ristola User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5) Gecko/20050105 Debian/1.7.5-1 X-Accept-Language: en MIME-Version: 1.0 To: PostgreSQL ODBC mailing list Subject: Rewrite about convert.h and convert.c Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.315 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200503/118 X-Sequence-Number: 5136 Hello. I like about Java filters: 1. Create a filter object. Prepare it as much as you can. 2. Filter the data thrue the object filter. 3. Destroy the filter object. Objects are inefficient to create and destroy very many times. With a filter object, you can create and prepare the filter once, and then use that filter for the whole data stream. So the idea for a fast data conversion for SQL SELECTs is this: 1. SQLPrepare() => create a filter object. => Find out about column types as much as you can. => (Alternatively find out the information from the first query result row.) 2. SQLBindCol() calls. => write into the filter object the needed column binding information and resolv the needed conversion function, for example cvtInt4toWChar() 3. SQLExecute() call => Use the filter object in stmt->select_filter for each result row. 4. Return into SQLBindCol() phase. So here is what needs to be made: Create files query_convert.h and query_convert.c. Create files converters.h and converters.c for cvtInt4toWChar() style functions. converters.h has also one huge function, that can do bool->char->int4 two-phase conversions. It calls for example both cvtBooltoChar() and cvtChartoInt4() functions. query_convert.h contains the following function definitions: QC_new() QC_destroy(qc) QC_SetBackendType(qc,colIdx,type) QC_GetBackendType(qc,colIdx) QC_SetBindType(qc,colIdx,type) QC_GetBindType(qc,colIdx) QC_ConvertItem(qc,colIdx,source,dest) QC_ConvertRow(qc,source,dest) QC_ConvertRowSet(qc,srcRowset,destRowset) So, for each row, the filter needs to call the cvtXXX function to do the conversion. It won't need to be resolved every time. Functions are also simple, but there are many functions. If the converter functions (backend->Int4 are local for SQL selects, and can not be reused for inserts or updates, they need not be in common C file, in the conversions.c/h. What do you think about this? In my opinion this would be easier to understand than the current implementation. You could also put the data via many filters: you could possibly implement a distinct charset filter on the client side also. Marko Ristola