Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1swJua-00370q-82 for pgsql-hackers@arkaria.postgresql.org; Thu, 03 Oct 2024 11:22:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1swJuZ-00DoSN-GS for pgsql-hackers@arkaria.postgresql.org; Thu, 03 Oct 2024 11:22:23 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1swJuZ-00DoSF-5A for pgsql-hackers@lists.postgresql.org; Thu, 03 Oct 2024 11:22:23 +0000 Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1swJuQ-002L9f-Se for pgsql-hackers@postgresql.org; Thu, 03 Oct 2024 11:22:22 +0000 Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-5389917ef34so941389e87.2 for ; Thu, 03 Oct 2024 04:22:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727954534; x=1728559334; darn=postgresql.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=wMrHsKl23Clp5/AyHI2UtPBv8H/7kGA9H/d3Heui12Q=; b=I8uIWtNZckycGu96AG9FYcUhRh+lLHAmjlbZXTcEofluqusp6ZtRYgJrkOG50rNHx9 bb2JrE76pp3hWVeK9Pc255ihN5V9XPuFDPAxkDEdwyp8Dl6eTHqZLunRivN/fF1XlOrg N03YtH9wH8+d1gH0Vq8WI9dMFWJFIEFQ9NOEN5d+UZptwg6qZSgc4KcGfQUc328ibnei F3cpAoQl6XRLtprWLUAhkKC7WcSa2rkuelJXRNXbyWzGy07ytdRdhvqE7Ogp4StSud9h e/zlIFe0gvsNGNVbEzR+6R3cMBP4XZld5fhDAY9V/HVrgFpeKcsHeyPvC5iCLWauhqyS 9xlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727954534; x=1728559334; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=wMrHsKl23Clp5/AyHI2UtPBv8H/7kGA9H/d3Heui12Q=; b=JVejl7fP5Bu+VMyn9IXxPazQtWg7A+5lNjoWCl7+Jhcfi0MKosbkuObSqAFKpJxHX3 4ew0Q+yNwlPT4msk3u7ZJZegCJwcW6ql02TNdeyGW2Jy2HEzjed4SLpbz7xi/b3GNP4s OVUuIOrvNTHYQ9YOmzXnPdQK3YqWUj4gRFNHrozdiHze7pC4DflH+aMvvipyX1OObjYh 00RFdoEcnFYJhVS3Dj1ostYDIm/hYM2GWFZJYwC+7l42RmQABI/cwYknSYPdp5ZwS5oD mhfp2JQL01bnbvn5HRWx3zfimObIEDyjxOPUylXDfJ2oYOurmpkCCt/yF8CQm2OnnVSs Z73Q== X-Gm-Message-State: AOJu0Yx+hPMMq5JsA5MTlnEtvf1zpDHwTGLty0/tJhL86kAj8kjVaEzI OXeLOxqelvZA13FiWqiJwW9pFw8C4183S3JK3OHVcrTahEBwc1FUYWVAtvijqwJyE0/KaoDf2ub JftE5cweoC90+WTA0xb5LwHoU+rg5DjlG X-Google-Smtp-Source: AGHT+IFkTFOz0rwyfMZmyO3JdU3/xYpqaWw6O0m5KhSXiY6fQa7+wu/nigl6H0MBK8YraDf2j5S64xEsA36snzzzLj0= X-Received: by 2002:a05:6512:6d6:b0:539:8bde:eb90 with SMTP id 2adb3069b0e04-539a0682745mr3785310e87.32.1727954533994; Thu, 03 Oct 2024 04:22:13 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: =?UTF-8?B?Vmluw61jaXVzIEFicmFow6Nv?= Date: Thu, 3 Oct 2024 12:21:37 +0100 Message-ID: Subject: Re: Possibilities on code change to implement pseudodatatypes To: pgsql-hackers@postgresql.org Content-Type: multipart/alternative; boundary="0000000000002fdd78062390c416" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000002fdd78062390c416 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Sep 30, 2024 at 10:19=E2=80=AFAM Vin=C3=ADcius Abrah=C3=A3o wrote: > On Mon, Sep 30, 2024 at 9:01=E2=80=AFAM Vin=C3=ADcius Abrah=C3=A3o > wrote: > >> Greetings >> >> I understand the complexity of implementing a pseudo data type when >> passing it over parameters, or using it when creating an object. >> vide: git grep pseudo | egrep -v -e "po|out|sgml|sql" | more >> >> My initial problem was saving history (for backup to be used during >> troubleshoot analysis) of plan changing and so on.. of the pg_statistic >> table/object. >> >> I was surprised - in a good way - to observe so much effort when handlin= g >> it for that specific purpose. I started to wonder if/when I want to crea= te >> an object of other *pseudatatypes *or pass it through a function >> parameter that the same level of effort during code implementation would= be >> the same. >> >> I understand this would be much more a code architecture discretion >> rather than a punctual question. >> >> I have posted in pgsql-admin a question which is "simple problem" when >> creating a table using anyarray and indeed the problem is simple - the >> solution might not be. >> >> What folks, more experienced in this subject, would recommend as a >> starting point to achieve that objective? >> >> Kind regards, >> >> Bazana Schmidt, Vin=C3=ADcius >> >> PS.: apologize in advance for the HTML email. >> > > Complementing - > > Under this optics below: > > [vinnix@vesuvio postgres]$ git grep CheckAttributeType > src/backend/catalog/heap.c: * flags controls which datatypes ar= e > allowed, cf CheckAttributeType. > src/backend/catalog/heap.c: > CheckAttributeType(NameStr(TupleDescAttr(tupdesc, i)->attname), > src/backend/catalog/heap.c: * CheckAttributeType > src/backend/catalog/heap.c:CheckAttributeType(const char *attname, > src/backend/catalog/heap.c: CheckAttributeType(attname, > getBaseType(atttypid), attcollation, > src/backend/catalog/heap.c: > CheckAttributeType(NameStr(attr->attname), > src/backend/catalog/heap.c: CheckAttributeType(attname, > get_range_subtype(atttypid), > src/backend/catalog/heap.c: CheckAttributeType(attname, > att_typelem, attcollation, > src/backend/catalog/index.c: > CheckAttributeType(NameStr(to->attname), > src/backend/commands/tablecmds.c: > CheckAttributeType(NameStr(attribute->attname), attribute->atttypid, > attribute->attcollation, > src/backend/commands/tablecmds.c: CheckAttributeType(colName, > targettype, targetcollid, > src/backend/commands/tablecmds.c: > CheckAttributeType(partattname, > src/include/catalog/heap.h:/* flag bits for > CheckAttributeType/CheckAttributeNamesTypes */ > src/include/catalog/heap.h:extern void CheckAttributeType(const char > *attname, > > and this line: > > https://github.com/postgres/postgres/blob/master/src/backend/catalog/heap= .c#L562 > > if (att_typtype =3D=3D TYPTYPE_PSEUDO) > { > /* > * We disallow pseudo-type columns, with the exception of ANYARRAY," > <<=3D=3D > > > What WE are missing? WHY? How could we make this state true for creating > table commands? > I will try to find time to keep researching about it - if you folks have > any insights please let me know. > I see now how to workaround it based on the parameter below. However, it's expected this will never work for a regular user/role. postgres=3D# set allow_system_table_mods to on; SET Time: 5.190 ms postgres=3D# create table a(a anyarray) ; CREATE TABLE Time: 132.959 ms This is verified at heap_create_with_catalog(...) function. Cheers, -- vinnix aka: Vin=C3=ADcius Abrah=C3=A3o Bazana Schmidt twitter.com/vischmidt linkedin.com/in/vischmidt --0000000000002fdd78062390c416 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Mon, Sep 30, 2024 at 10:19=E2=80=AFAM = Vin=C3=ADcius Abrah=C3=A3o <vinn= ix.bsd@gmail.com> wrote:
On= Mon, Sep 30, 2024 at 9:01=E2=80=AFAM Vin=C3=ADcius Abrah=C3=A3o <vinnix.bsd@gmail.com> wrote:

[vinnix@vesuvio postgres]$ git grep CheckAttributeType=
src/backend/catalog/heap.c: * =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 flags = controls which datatypes are allowed, cf CheckAttributeType.
src/backend= /catalog/heap.c: =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 CheckAttributeTy= pe(NameStr(TupleDescAttr(tupdesc, i)->attname),
src/backend/catalog/h= eap.c: * =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 CheckAttributeType
src/backe= nd/catalog/heap.c:CheckAttributeType(const char *attname,
src/backend/ca= talog/heap.c: =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 CheckAttributeType(= attname, getBaseType(atttypid), attcollation,
src/backend/catalog/heap.c= : =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Che= ckAttributeType(NameStr(attr->attname),
src/backend/catalog/heap.c: = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 CheckAttributeType(attname, get_r= ange_subtype(atttypid),
src/backend/catalog/heap.c: =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 CheckAttributeType(attname, att_typelem, attcollation= ,
src/backend/catalog/index.c: =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0CheckAttributeType(NameStr(to->attname),
= src/backend/commands/tablecmds.c: =C2=A0 =C2=A0 =C2=A0 CheckAttributeType(N= ameStr(attribute->attname), attribute->atttypid, attribute->attcol= lation,
src/backend/commands/tablecmds.c: =C2=A0 =C2=A0 =C2=A0 CheckAttr= ibuteType(colName, targettype, targetcollid,
src/backend/commands/tablec= mds.c: =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 CheckAttributeType(partattname,
src/include/catalog/heap.h:/*= flag bits for CheckAttributeType/CheckAttributeNamesTypes */
src/includ= e/catalog/heap.h:extern void CheckAttributeType(const char *attname,
=

=C2=A0
=C2=A0 if (att_t= yptype =3D=3D TYPTYPE_PSEUDO)
=C2=A0 {=
=C2=A0 /*
=C2=A0 * = We disallow pseudo-type columns, with the exception of ANYARRAY,"=C2= =A0 <<=3D=3D


Wh= at WE are missing? WHY? How could we make this state true for creati= ng table commands?
I will try to find time to keep researching ab= out it - if you folks have any insights please let me know.
=

I see now how to workaround it based on the parameter below. Howev= er, it's expected this will never work for a regular user/role.

<= span style=3D"font-family:monospace">postgres=3D# set allow_system_table_mo= ds to on;
SET
Time: 5.190 ms
postgres=3D# create table a(a anyarra= y) ;
CREATE TABLE
Time: 132.959 ms

This is verified at heap_create_with_catalog(...) function.


Che= ers,

--
vinnix
aka: Vin=C3=ADcius Abr= ah=C3=A3o Bazana Schmidt
twitter.com/vischmidt
=
--0000000000002fdd78062390c416--