Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 2E6559FBB61 for ; Tue, 22 May 2007 16:24:18 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 32008-03 for ; Tue, 22 May 2007 16:24:11 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from lists.commandprompt.com (host-254.commandprompt.net [207.173.203.254]) by postgresql.org (Postfix) with ESMTP id F0FEC9FBB35 for ; Tue, 22 May 2007 16:24:10 -0300 (ADT) Received: from perhan.alvh.no-ip.org (201-221-217-243.bk12-dsl.surnet.cl [201.221.217.243]) (authenticated bits=0) by lists.commandprompt.com (8.13.7/8.13.6) with ESMTP id l4MJOAdF021514; Tue, 22 May 2007 12:24:11 -0700 Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id A952D32A14; Tue, 22 May 2007 15:24:06 -0400 (CLT) Date: Tue, 22 May 2007 15:24:06 -0400 From: Alvaro Herrera To: Jeff Lynn Cc: pgsql-interfaces@postgresql.org Subject: Re: How do you convert PostgreSQL internal binary field to C datatypes Message-ID: <20070522192406.GG11032@alvh.no-ip.org> References: <465337D6.6080103@rogers.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <465337D6.6080103@rogers.com> User-Agent: Mutt/1.5.13 (2006-08-11) X-Virus-Scanned: ClamAV version 0.88.5, clamav-milter version 0.88.5 on projects.commandprompt.com X-Virus-Status: Clean X-Greylist: Sender succeded SMTP AUTH authentication, not delayed by milter-greylist-1.6 (lists.commandprompt.com [192.168.2.159]); Tue, 22 May 2007 12:24:12 -0700 (PDT) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200705/45 X-Sequence-Number: 6552 Jeff Lynn wrote: > Does someone out there has some example(s) of converting the > PostgreSQL's internal (network byte order) representation of float4, > flost8, date, datetime and timestamp into Win32 float, double, CTime or > any Win32 date/time construct under Intel x86 h/w architecture? > > Andrew McNamara in previous post suggested that there are answers in the > server source codes. But for a beginner like me, even though I have > extensive coding experience in C, C++ and Java, such undertaking for a > significant product like PostgreSQL is a bit overwhelming for now. > > I really do want to explore the usage of PostgreSQL further! So any > help will be greatly appreciated. The code to handle these datatypes lies mostly here: http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/utils/adt/ For example, in float.c look for float4send which directs you to pq_sendfloat4 which you can find in http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/libpq/pqformat.c -- Alvaro Herrera http://www.CommandPrompt.com/ The PostgreSQL Company - Command Prompt, Inc.