From: | John Naylor <john(dot)naylor(at)enterprisedb(dot)com> |
---|---|
To: | Robert Haas <robertmhaas(at)gmail(dot)com> |
Cc: | Andres Freund <andres(at)anarazel(dot)de>, Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Julien Rouhaud <rjuju123(at)gmail(dot)com>, Денис Романенко <deromanenko(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: NAMEDATALEN increase because of non-latin languages |
Date: | 2022-07-18 02:46:44 |
Message-ID: | CAFBsxsEcWQeqi1oHMQx-cz+zvUc2yEOTrp-uLqPD6bAKGHZGEA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Thu, Jun 23, 2022 at 9:27 PM Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
>
> I'm not sure whether your idea of creating translator functions is a
> good one or not, but it doesn't seem too crazy. It'd be like a special
> purpose tuple deformer.
>
> deform_pg_class_tuple(&pg_class_struct, pg_class_tuple);
>
> The code in there could be automatically generated statements that
> maybe look like this:
>
> memcpy(&struct.relnamespace, tuple + Aoffset_pg_class_relnamespace,
> sizeof(Oid));
I've made a small step in this direction.
0001 is just boilerplate, same as v1
0002 teaches Catalog.pm to export both C attr name and SQL attr name, so we
can use "sizeof".
0003 generates static inline functions that work the same as the current
GETSTRUCT macro, i.e. just cast to the right pointer and return it.
0004 generates a function for pg_cast that memcpys to a passed struct, for
demonstration.
Here's the full deforming function generated for pg_cast. In English, the
current offset is the previous offset plus the previous type length, plus
any alignment padding suitable for the current type (there is none here, so
the alignment aspect is not tested). I'm hoping something like this will be
sufficient for what's in the current structs, but of course will need
additional work when expanding those to include pointers to varlen
attributes. I've not yet inspected the emitted assembly language, but
regression tests pass.
static inline void
Deform_pg_cast_tuple(Form_pg_cast pg_cast_struct, char * pg_cast_tuple)
{
#define Aoff_pg_cast_oid 0
memcpy(&pg_cast_struct->oid, pg_cast_tuple + Aoff_pg_cast_oid, sizeof(Oid));
#define Aoff_pg_cast_castsource att_align_nominal(Aoff_pg_cast_oid +
sizeof(Oid), 'i')
memcpy(&pg_cast_struct->castsource, pg_cast_tuple +
Aoff_pg_cast_castsource, sizeof(Oid));
#define Aoff_pg_cast_casttarget att_align_nominal(Aoff_pg_cast_castsource +
sizeof(Oid), 'i')
memcpy(&pg_cast_struct->casttarget, pg_cast_tuple +
Aoff_pg_cast_casttarget, sizeof(Oid));
#define Aoff_pg_cast_castfunc att_align_nominal(Aoff_pg_cast_casttarget +
sizeof(Oid), 'i')
memcpy(&pg_cast_struct->castfunc, pg_cast_tuple + Aoff_pg_cast_castfunc,
sizeof(Oid));
#define Aoff_pg_cast_castcontext att_align_nominal(Aoff_pg_cast_castfunc +
sizeof(Oid), 'c')
memcpy(&pg_cast_struct->castcontext, pg_cast_tuple +
Aoff_pg_cast_castcontext, sizeof(char));
#define Aoff_pg_cast_castmethod att_align_nominal(Aoff_pg_cast_castcontext
+ sizeof(char), 'c')
memcpy(&pg_cast_struct->castmethod, pg_cast_tuple +
Aoff_pg_cast_castmethod, sizeof(char));
}
Here's an example of the changes done in the call sites. For the rest of
the catalogs, perhaps many of them can be done mechanically. I still
anticipate a lot of manual work. Note that GETSTRUCT_MEMCPY is just
temporary scaffolding to distinguish from just returning a pointer, and is
not proposed for commit.
- Form_pg_cast castForm = GETSTRUCT(pg_cast, tuple);
+ FormData_pg_cast castForm;
CoercionContext castcontext;
+ GETSTRUCT_MEMCPY(pg_cast, &castForm, tuple);
+
/* convert char value for castcontext to CoercionContext
enum */
- switch (castForm->castcontext)
+ switch (castForm.castcontext)
--
John Naylor
EDB: http://www.enterprisedb.com
Attachment | Content-Type | Size |
---|---|---|
v2-0004-Generate-pg_cast-function-to-deform-tuples-into-s.patch | text/x-patch | 8.6 KB |
v2-0003-Generate-stubs-for-catalog-tuple-deforming-functi.patch | text/x-patch | 51.1 KB |
v2-0002-Distinguish-C-name-and-C-type-from-SQL-name-and-S.patch | text/x-patch | 6.1 KB |
v2-0001-Transform-GETSTRUCT-macro-to-pass-the-catalog-nam.patch | text/x-patch | 391.7 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Andres Freund | 2022-07-18 02:58:41 | Re: NAMEDATALEN increase because of non-latin languages |
Previous Message | Tom Lane | 2022-07-18 02:34:42 | Re: pgsql: Default to hidden visibility for extension libraries where possi |