DataRow message for Integer(int4) returns result as text?

From: Tyler Brock <tyler(dot)brock(at)gmail(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: DataRow message for Integer(int4) returns result as text?
Date: 2022-04-20 23:39:15
Message-ID: CACr_h8QSz4k9KckE7MTspYnHbkLLKmM0WyvfNpWzVF50SZMoPw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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).

It makes sense that at the time the RowDescription is written out that it
can’t possibly know how many bytes the textual representation of each int
will take so it just uses the length of the underlying type.

Is this accurate?

-Tyler

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David G. Johnston 2022-04-20 23:40:44 doc: New cumulative stats subsystem obsoletes comment in maintenance.sgml
Previous Message Robert Haas 2022-04-20 23:03:25 Re: preserving db/ts/relfilenode OIDs across pg_upgrade (was Re: storing an explicit nonce)