Thread: GiST operator class for bool
It could be useful to use bool in exclusion constraints, but it's currently not nicely supported. The attached patch adds support for bool to the btree_gist extension, so we can do this. I am adding this to the commitfest 2021-07.
Attachment
Hi! > 8 июня 2021 г., в 13:48, Emre Hasegeli <emre@hasegeli.com> написал(а): > > It could be useful to use bool in exclusion constraints, but it's > currently not nicely supported. The attached patch adds support for > bool to the btree_gist extension, so we can do this. > > I am adding this to the commitfest 2021-07. > <0001-btree_gist-Support-bool.patch> It definitely makes sense to include bool into list of supported types. But patch that you propose does not support sorting build added in PG14. Or we can add this functionality later in https://commitfest.postgresql.org/31/2824/ ... Thanks! Best regards, Andrey Borodin.
> But patch that you propose does not support sorting build added in PG14. It looks like the change to btree_gist is not committed yet. I'll rebase my patch once it's committed. It was a long thread. I couldn't read all of it. Though, the last patches felt to me like a part of what's already been committed. Shouldn't they also be committed to version 14?
> 8 июня 2021 г., в 19:53, Emre Hasegeli <emre@hasegeli.com> написал(а): > >> But patch that you propose does not support sorting build added in PG14. > > It looks like the change to btree_gist is not committed yet. I'll > rebase my patch once it's committed. Changes to GiST are committed. There will be no need to rebase anyway :) > > It was a long thread. I couldn't read all of it. Though, the last > patches felt to me like a part of what's already been committed. > Shouldn't they also be committed to version 14? Well, yeah, it could would be cool to have gist build and gist_btree support it together, but there was many parts and wecould did not finish it before feature freeze. Best regards, Andrey Borodin.
Hi, I looked at this patch today - it's pretty simple and in pretty good shape, I can't think of anything that'd need fixing. Perhaps the test might also do EXPLAIN like for other types, to verify the new index is actually used. But that's minor enough to handle during commit. I've marked this as RFC and will get it committed in a day or two. -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company
On 11/3/21 16:18, Tomas Vondra wrote: > Hi, > > I looked at this patch today - it's pretty simple and in pretty good > shape, I can't think of anything that'd need fixing. Perhaps the test > might also do EXPLAIN like for other types, to verify the new index is > actually used. But that's minor enough to handle during commit. > > > I've marked this as RFC and will get it committed in a day or two. > Pushed, after adding some simple EXPLAIN to the regression test. Thanks for the patch! regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company
Tomas Vondra <tomas.vondra@enterprisedb.com> writes: > Pushed, after adding some simple EXPLAIN to the regression test. skink is reporting that this has some valgrind issues [1]. I suspect sloppy conversion between bool and Datum, but didn't go looking. ==1805451== VALGRINDERROR-BEGIN ==1805451== Uninitialised byte(s) found during client check request ==1805451== at 0x59EFEA: PageAddItemExtended (bufpage.c:346) ==1805451== by 0x2100B9: gistfillbuffer (gistutil.c:46) ==1805451== by 0x2050F9: gistplacetopage (gist.c:562) ==1805451== by 0x20546B: gistinserttuples (gist.c:1277) ==1805451== by 0x205BB5: gistinserttuple (gist.c:1230) ==1805451== by 0x206067: gistdoinsert (gist.c:885) ==1805451== by 0x2084FB: gistBuildCallback (gistbuild.c:829) ==1805451== by 0x23B572: heapam_index_build_range_scan (heapam_handler.c:1694) ==1805451== by 0x208E7D: table_index_build_scan (tableam.h:1756) ==1805451== by 0x208E7D: gistbuild (gistbuild.c:309) ==1805451== by 0x2D10C8: index_build (index.c:2983) ==1805451== by 0x2D2A7D: index_create (index.c:1232) ==1805451== by 0x383E67: DefineIndex (indexcmds.c:1128) ==1805451== Address 0x10cab1e4 is 12 bytes inside a block of size 16 client-defined ==1805451== at 0x712AC5: palloc0 (mcxt.c:1118) ==1805451== by 0x1E0A07: index_form_tuple (indextuple.c:146) ==1805451== by 0x210BA8: gistFormTuple (gistutil.c:582) ==1805451== by 0x2084C2: gistBuildCallback (gistbuild.c:813) ==1805451== by 0x23B572: heapam_index_build_range_scan (heapam_handler.c:1694) ==1805451== by 0x208E7D: table_index_build_scan (tableam.h:1756) ==1805451== by 0x208E7D: gistbuild (gistbuild.c:309) ==1805451== by 0x2D10C8: index_build (index.c:2983) ==1805451== by 0x2D2A7D: index_create (index.c:1232) ==1805451== by 0x383E67: DefineIndex (indexcmds.c:1128) ==1805451== by 0x5AED2E: ProcessUtilitySlow (utility.c:1535) ==1805451== by 0x5AE262: standard_ProcessUtility (utility.c:1066) ==1805451== by 0x5AE33A: ProcessUtility (utility.c:527) ==1805451== ==1805451== VALGRINDERROR-END regards, tom lane [1] https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=skink&dt=2021-11-06%2023%3A56%3A57
Hi, On 11/7/21 17:44, Tom Lane wrote: > Tomas Vondra <tomas.vondra@enterprisedb.com> writes: >> Pushed, after adding some simple EXPLAIN to the regression test. > > skink is reporting that this has some valgrind issues [1]. > I suspect sloppy conversion between bool and Datum, but > didn't go looking. > It's actually a bit worse than that :-( The opclass is somewhat confused about the type it should use for storage. The gbtree_ninfo struct says it's using gbtreekey4, the SQL script claims the params are gbtreekey8, and it should actually use gbtreekey2. Sorry for not noticing that. The attached patch fixes the valgrind error for me. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company
Attachment
On 11/7/21 20:53, Tomas Vondra wrote: > Hi, > > On 11/7/21 17:44, Tom Lane wrote: >> Tomas Vondra <tomas.vondra@enterprisedb.com> writes: >>> Pushed, after adding some simple EXPLAIN to the regression test. >> >> skink is reporting that this has some valgrind issues [1]. >> I suspect sloppy conversion between bool and Datum, but >> didn't go looking. >> > > It's actually a bit worse than that :-( The opclass is somewhat confused > about the type it should use for storage. The gbtree_ninfo struct says > it's using gbtreekey4, the SQL script claims the params are gbtreekey8, > and it should actually use gbtreekey2. Sorry for not noticing that. > > The attached patch fixes the valgrind error for me. > I've pushed the fix, hopefully that'll make skink happy. What surprised me a bit is that the opclass used gbtreekey4 storage, the equality support proc was defined as using gbtreekey8 FUNCTION 7 gbt_bool_same (gbtreekey8, gbtreekey8, internal), yet the gistvalidate() did not report this. Turns out this is because ok = check_amproc_signature(procform->amproc, INTERNALOID, false, 3, 3, opckeytype, opckeytype, INTERNALOID); i.e. with exact=false, so these type differences are ignored. Changing it to true reports the issue (and no other issues in check-world). But maybe there are reasons to keep using false? regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company
Attachment
Hello, I don't see any changes in the documentation.[1] Should bool appear in the looong list of supported operator classes? [1] https://www.postgresql.org/docs/devel/btree-gist.html -- Pavel Luzanov Postgres Professional: https://postgrespro.com The Russian Postgres Company
On 12/6/21 22:35, Pavel Luzanov wrote: > Hello, > > I don't see any changes in the documentation.[1] > > Should bool appear in the looong list of supported operator classes? > You're right, I forgot to update the list of data types in the docs. Fixed, thanks for the report. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company