Re: BUG #6052: ADD COLUMN - ERROR: tables can have at most 1600 columns

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Juris Kaminskis <juris(dot)kaminskis(at)gmail(dot)com>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #6052: ADD COLUMN - ERROR: tables can have at most 1600 columns
Date: 2023-09-19 19:57:33
Message-ID: 05023ab8-0629-36fe-6423-447c116d70b9@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


On 2023-09-18 Mo 10:16, Juris Kaminskis wrote:
> Hello,
>
> I would like to refresh this problem again. The use case: local
> automated testing of database migrations. If those migrations ALTER
> TABLES by adding and dropping columns, at some point the only valid
> way out of 1600 columns error is to reload database. If this is not a
> big problem would be nice to solve.
>
> Juris
>
> pirmd., 2023. g. 18. sept., plkst. 17:11 — lietotājs dinesh
> (<dinesh(at)milkorwater(dot)com>) rakstīja:
>
>
> The following bug has been logged online:
>
> Bug reference:      6052
> Logged by:          dinesh
> Email address: dinesh(at)milkorwater(dot)com
> PostgreSQL version: 8.4.7
> Operating system:   WIndows 7 pro 64 bit
> Description:        ADD COLUMN - ERROR: tables can have at most
> 1600 columns
> Details:
>
> I have a table which is used during data uploads, a so-called
> staging table.
> This table has a fixed number of columns that [must] match the
> input CSV
> file. This CSV file is uploaded using COPY command. Following the
> COPY, a
> new column (meant for indexing) is constructed on this table using
> some
> application logic; and dropped after that data upload cycle is over.
>

This is simply untrue. The number of table columns does not have to
match the CSV. It can have more columns, all you have to do is name the
columns you are inserting into explicitly:

COPY mytable (col1, col2, ...) FROM srcloc CSV;

That's always been the case.

If you need to be selective about which fields you insert from the CSV
there is also the file_textarray_fdw extension.

cheers

andrew

--
Andrew Dunstan
EDB:https://www.enterprisedb.com

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Thomas Munro 2023-09-19 22:51:12 Re: BUG #17928: Standby fails to decode WAL on termination of primary
Previous Message Tom Lane 2023-09-19 16:12:11 Re: a plpgsql bug