From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Bruce Momjian <bruce(at)momjian(dot)us> |
Cc: | Michael Paquier <michael(at)paquier(dot)xyz>, jian he <jian(dot)universality(at)gmail(dot)com>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Kirill Reshke <reshkekirill(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: attndims, typndims still not enforced, but make the value within a sane threshold |
Date: | 2025-01-19 23:47:14 |
Message-ID: | 2881901.1737330434@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Bruce Momjian <bruce(at)momjian(dot)us> writes:
> Using the queries in that URL, I see:
> CREATE TABLE test (data integer, data_array integer[5][5]);
> CREATE TABLE test2 (LIKE test);
> CREATE TABLE test3 AS SELECT * FROM test;
> SELECT relname, attndims
> FROM pg_class JOIN pg_attribute ON (pg_attribute.attrelid = pg_class.oid)
> WHERE attname = 'data_array';
> relname | attndims
> ---------+----------
> test | 2
> --> test2 | 0
> --> test3 | 0
Yeah, that's not great. We don't have the ability to extract a
number-of-dimensions from a result column of a SELECT, but we could
at least take care to make attndims be 1 not 0 for an array type.
And CREATE TABLE LIKE can easily do better. See attached draft.
(We could simplify it a little bit if we decide to store only 1 or 0
in all cases.)
> Interestingly, if I dump and restore with:
> $ createdb test2; pg_dump test | sql test2
> and run the query again I get:
> relname | attndims
> ---------+----------
> test | 1
> test2 | 1
> test3 | 1
I looked at getting a better result here and decided that it didn't
look very promising. pg_dump uses format_type() to build the type
name to put in CREATE TABLE, and that doesn't have access to attndims.
regards, tom lane
Attachment | Content-Type | Size |
---|---|---|
v1-preserve-attndims-better.patch | text/x-diff | 6.4 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Tatsuo Ishii | 2025-01-19 23:55:17 | Re: Add RESPECT/IGNORE NULLS and FROM FIRST/LAST options |
Previous Message | Tom Lane | 2025-01-19 21:29:14 | Re: stored short varlena in array |