Re: DataRow Null values Frontend/Backend Protocol TCP/IP - Mailing list pgsql-general

From Craig Ringer
Subject Re: DataRow Null values Frontend/Backend Protocol TCP/IP
Date
Msg-id 4AEEA856.7000809@postnewspapers.com.au
Whole thread Raw
In response to Re: DataRow Null values Frontend/Backend Protocol TCP/IP  (Raimon Fernandez <coder@montx.com>)
Responses Re: DataRow Null values Frontend/Backend Protocol TCP/IP  (Raimon Fernandez <coder@montx.com>)
List pgsql-general
On 2/11/2009 5:21 PM, Raimon Fernandez wrote:
> Here I'm again ...
>
>
> I'm parsing the DataRow(B), and I'm having problems with NULL values.
>
> In the docs I can read they have a -1 value, an no bytes follow them for
> the value.
>
> But I'm getting a 1020 value instead of -1

You're using RealBasic or something, right?

If so, you're probably doing something funky with signed/unsigned
integer handling and the representation of integers.

-1 is 0xffffffff as a _signed_ 32 bit integer, same in little-endian or
big-endian form. The same hex value as an unsigned integer is 4294967295 .

Simple example in C++:

#include <iostream>
#include <iomanip>
int main() {
        std::cout << std::dec << (signed int)(-1) << ' ' <<
                     std::hex << (signed int)(-1) << std::endl;
        std::cout << std::dec << (unsigned int)(-1) << ' ' <<
                     std::hex << (unsigned int)(-1) << std::endl;
}

produces:

-1 ffffffff
4294967295 ffffffff


I don't know where you're getting the 1020, but 4294967295 is MAXUINT32
and suggests you're treating the data as an unsigned rather than a
signed 32 bit integer.

--
Craig Ringer

pgsql-general by date:

Previous
From: Craig Ringer
Date:
Subject: Re: Cancelling Requests Frontend/Backend Protocol TCP/IP
Next
From: "Bernard Grosperrin"
Date:
Subject: Re: Error on compile for Windows