diff options
author | Robert Haas <rhaas@postgresql.org> | 2021-03-25 19:55:32 -0400 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2021-03-25 19:55:32 -0400 |
commit | 5db1fd7823a1a12e2bdad98abc8e102fd71ffbda (patch) | |
tree | eb2f2a7db5a5351357d04c863c1374c568431415 /src/backend/access/common/indextuple.c | |
parent | 71f4c8c6f74ba021e55d35b1128d22fb8c6e1629 (diff) | |
download | postgresql-5db1fd7823a1a12e2bdad98abc8e102fd71ffbda.tar.gz postgresql-5db1fd7823a1a12e2bdad98abc8e102fd71ffbda.zip |
Fix interaction of TOAST compression with expression indexes.
Before, trying to compress a value for insertion into an expression
index would crash.
Dilip Kumar, with some editing by me. Report by Jaime Casanova.
Discussion: http://postgr.es/m/CAJKUy5gcs0zGOp6JXU2mMVdthYhuQpFk=S3V8DOKT=LZC1L36Q@mail.gmail.com
Diffstat (limited to 'src/backend/access/common/indextuple.c')
-rw-r--r-- | src/backend/access/common/indextuple.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/backend/access/common/indextuple.c b/src/backend/access/common/indextuple.c index 1f6b7b77d4e..ae932691af8 100644 --- a/src/backend/access/common/indextuple.c +++ b/src/backend/access/common/indextuple.c @@ -103,8 +103,19 @@ index_form_tuple(TupleDesc tupleDescriptor, (att->attstorage == TYPSTORAGE_EXTENDED || att->attstorage == TYPSTORAGE_MAIN)) { - Datum cvalue = toast_compress_datum(untoasted_values[i], - att->attcompression); + Datum cvalue; + char compression = att->attcompression; + + /* + * If the compression method is not valid, use the default. We + * don't expect this to happen for regular index columns, which + * inherit the setting from the corresponding table column, but + * we do expect it to happen whenever an expression is indexed. + */ + if (!CompressionMethodIsValid(compression)) + compression = GetDefaultToastCompression(); + + cvalue = toast_compress_datum(untoasted_values[i], compression); if (DatumGetPointer(cvalue) != NULL) { |