zero char is returned as space

From: Konstantin Izmailov <pgfizm(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: zero char is returned as space
Date: 2022-04-06 04:58:17
Message-ID: CAAw-Mse09yrTd=XKWY=k1ru_HvpQwBHa7PkubkbS3wJndFxxgw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,
could you help me understand if this is an intended behaviour, or I'm
incorrectly querying a "char" field? I have simple table with column
declared as:
c_tinyint char NOT NULL

The column contains tiny integers in range 0-10. When I query the column
from my app using libpq values 1-10 are returned correctly as 0x1-0x10. But
value of zero is returned as 0x20 (expected 0x0).
The pgAdmin displays result of the query
SELECT c_tinyint, ascii(c_tinyint) FROM tbl
as shown below:
| c_tinyint | ascii |
| character(1) | integer |
| | 0 |
| | 1 |
| | 2 |
| | 3 |
| | 4 |

Thank you
K

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeff Davis 2022-04-06 05:02:43 Re: pg_walinspect - a new extension to get raw WAL data and WAL stats
Previous Message Amit Kapila 2022-04-06 04:33:52 Re: Logical replication row filtering and TOAST