From: | jian he <jian(dot)universality(at)gmail(dot)com> |
---|---|
To: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | attndims, typndims still not enforced, but make the value within a sane threshold |
Date: | 2024-09-18 13:06:00 |
Message-ID: | CACJufxH0RxsxUQnAT2AVG08JFpA3C60L91_cEMM8JQd8P=12ow@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
hi.
while looking at tablecmd.c, BuildDescForRelation
attdim = list_length(entry->typeName->arrayBounds);
if (attdim > PG_INT16_MAX)
ereport(ERROR,
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("too many array dimensions"))
makes me related to array_in refactor previously we did.
at first, i thought it should be "if (attdim > MAXDIM)"
pg_attribute attndims description in [1]
attndims int2
Number of dimensions, if the column is an array type; otherwise 0.
(Presently, the number of dimensions of an array is not enforced, so
any nonzero value effectively means “it's an array”.)
pg_type typndims description in [2]
typndims int4
typndims is the number of array dimensions for a domain over an array
(that is, typbasetype is an array type). Zero for types other than
domains over array types.
since array_in is the only source of the real array data.
MAXDIM (6) ensure the max dimension is 6.
Can we error out at the stage "create table", "create domain"
time if the attndims or typndims is larger than MAXDIM (6) ?
for example, error out the following queries immediately
create table t112(a int[][] [][] [][] [][][]);
create domain d_text_arr text [1][][][][][][][];
in the doc, we can still say "the number of dimensions of an array is
not enforced",
but attndims, typndims value would be within a sane threshold.
We can change typndims from int4 to int2,
so array type's dimension is consistent with domain type's dimension.
but it seems with the change, pg_type occupies the same amount of
storage as int4.
[1] https://www.postgresql.org/docs/current/catalog-pg-attribute.html
[2] https://www.postgresql.org/docs/current/catalog-pg-type.html
From | Date | Subject | |
---|---|---|---|
Next Message | Fujii Masao | 2024-09-18 13:27:29 | Re: Inconsistency in reporting checkpointer stats |
Previous Message | Andrew Dunstan | 2024-09-18 12:47:21 | Re: [PATCH] WIP: replace method for jsonpath |