pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: sundar@mudupalli.com
Subject: BUG #18962: Type Conversion incorrect when performing UNION of queries.
Date: Thu, 19 Jun 2025 12:21:15 +0000
Message-ID: <18962-71e1ca655df5139f@postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      18962
Logged by:          Sundar Mudupalli
Email address:      sundar@mudupalli.com
PostgreSQL version: 17.5
Operating system:   Ubuntu I believe (using a Cloud SQL instance in GC
Description:        

Take the following table definitions:
```
create table public.test_table_1 as
SELECT
   'AA'::character(2) AS text_type
UNION ALL
SELECT
   'BB'::character(2) AS text_type
UNION ALL
SELECT
   'CC'::TEXT AS text_type
;
create table public.test_table_2 (
        char_fixed character,
        char_fixed_len character(5),
        char_var character varying(5),
        text_column text );
```
Based on the [type conversion rules for
Union](https://www.postgresql.org/docs/current/typeconv-union-case.html),
the column `text_type` in `test_table_1` should resolve to the postgres data
type `TEXT`. However running the following query produces the following:
```
select table_name, column_name, data_type, character_maximum_length from
information_schema.columns where table_name like 'test_table_%' order by
table_name;
  table_name  |  column_name   |     data_type     |
character_maximum_length
--------------+----------------+-------------------+--------------------------
 test_table_1 | text_type      | character         |
 test_table_2 | char_fixed     | character         |
1
 test_table_2 | char_fixed_len | character         |
5
 test_table_2 | char_var       | character varying |
5
 test_table_2 | text_column    | text              |
(5 rows)
```
The data type for text says `character` (fixed length character string) of
undetermined length, when it should really be of type `text` as the column
`text_column` in `test_table_2`.



view thread (4+ messages)  latest in thread

Message-ID: <18962-71e1ca655df5139f@postgresql.org>
Permalink:  ../18962-71e1ca655df5139f@postgresql.org/
Also on:    postgresql.org/message-id/18962-71e1ca655df5139f@postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, sundar@mudupalli.com
  Subject: Re: BUG #18962: Type Conversion incorrect when performing UNION of queries.
  In-Reply-To: <18962-71e1ca655df5139f@postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox