Re: DataRow message for Integer(int4) returns result as text? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: DataRow message for Integer(int4) returns result as text?
Date
Msg-id 3078175.1650510559@sss.pgh.pa.us
Whole thread Raw
In response to DataRow message for Integer(int4) returns result as text?  (Tyler Brock <tyler.brock@gmail.com>)
List pgsql-hackers
Tyler Brock <tyler.brock@gmail.com> writes:
> I think this makes sense but I wanted to get confirmation:
> I created a table with a column having the type int4 (integer). When I
> insert a row with a number into that column and get it back out I've
> observed a discrepancy:

> The DataRow message has the field encoded as an ASCII ‘7’ with a column
> length of 1 despite the RowDescription having a column length 4. I assume
> that this is because it’s a simple query (Q) and therefore the format code
> for all columns is 0 (for text format).

If you mean the "data type size" (typlen) field of RowDescription, that
is arguably completely irrelevant; it's there for historical reasons,
I think.  The contents of a DataRow field will either be a textual
conversion of the value or the on-the-wire binary representation defined
by the type's typsend routine.  In either case, the actual length of
the value as it appears in DataRow is given right there in the DataRow
message.  And in either case, the typlen value doesn't necessarily have
anything to do with the length of the DataRow representation.  typlen
does happen to match up with the length that'd appear in DataRow for
simple integral types sent in binary format ... but for other cases,
not so much.

            regards, tom lane



pgsql-hackers by date:

Previous
From: "wangw.fnst@fujitsu.com"
Date:
Subject: RE: Data is copied twice when specifying both child and parent table in publication
Next
From: vignesh C
Date:
Subject: Re: Skipping schema changes in publication