pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alexander Lakhin <exclusion@gmail.com>
To: Alexander Korotkov <aekorotkov@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #17847: Unaligned memory access in ltree_gist
Date: Mon, 20 Mar 2023 10:00:00 +0300
Message-ID: <365d1917-f5b7-ff20-2d0b-8d501cee5434@gmail.com> (raw)
In-Reply-To: <CAPpHfds=s6CmMzB1pO2UX9QnUvz6nOWofdnK84NXPQdVp0VWEw@mail.gmail.com>
References: <17847-171232970bea406b@postgresql.org>
	<3966266.1678995315@sss.pgh.pa.us>
	<CAPpHfds=s6CmMzB1pO2UX9QnUvz6nOWofdnK84NXPQdVp0VWEw@mail.gmail.com>

Hi,
19.03.2023 20:08, Alexander Korotkov wrote:
> On Thu, Mar 16, 2023 at 10:35 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> What I'm inclined to do about this is add a restriction that the siglen
>> value be a multiple of MAXALIGN.  It doesn't look like the reloption
>> mechanism has a way to specify that declaratively, but we could probably
>> get close enough by just making LTREE_GET_SIGLEN throw an error if it's
>> wrong.  That's not ideal because you could probably get through making
>> an empty index without hitting the error, but I don't offhand see a
>> way to make it better.
> Sorry for missing this.
>
> Please, note that there are infrastructure of reltoption validators.
> I think this is the most appropriate place to check for alignment of
> siglen.  That works even for empty indexes.  See the attached patch.

Thanks for the fix! It works for me.

Maybe it's worth to reflect this restriction in the documentation too?
      <literal>gist_ltree_ops</literal> GiST opclass approximates a set of
      path labels as a bitmap signature.  Its optional integer parameter
      <literal>siglen</literal> determines the
      signature length in bytes.  The default signature length is 8 bytes.
      Valid values of signature length are between 1 and 2024 bytes.

How about "The length must be a multiple of <type>int</type> alignment between 4 and 2024."?
(There is a wording "<type>int</type> alignment (4 bytes on most machines)" in catalogs.sgml.)

Also maybe change the error message a little:
s/siglen value must be integer-alignment/siglen value must be integer-aligned/
or "int-aligned"? (this spelling can be found in src/)

(There is also a detail message, that probably should be corrected too:
DETAIL:  Valid values are between "1" and "2024".
->
DETAIL:  Valid values are int-aligned positive integers less than 2024.
?)

Best regards,
Alexander





view thread (20+ messages)  latest in thread

Message-ID: <365d1917-f5b7-ff20-2d0b-8d501cee5434@gmail.com>
Permalink:  ../365d1917-f5b7-ff20-2d0b-8d501cee5434@gmail.com/
Also on:    postgresql.org/message-id/365d1917-f5b7-ff20-2d0b-8d501cee5434@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: exclusion@gmail.com, aekorotkov@gmail.com, tgl@sss.pgh.pa.us, pgsql-bugs@lists.postgresql.org
  Subject: Re: BUG #17847: Unaligned memory access in ltree_gist
  In-Reply-To: <365d1917-f5b7-ff20-2d0b-8d501cee5434@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox