Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/backend/cdb/motion/tupser.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,11 @@ SerializeTuple(TupleTableSlot *slot, SerTupInfo *pSerInfo, struct directTranspor
{
Form_pg_attribute attr = TupleDescAttr(slot->tts_tupleDescriptor, i);

if (!attr->attisdropped && attr->attlen == -1 && !slot->tts_isnull[i])
/*
* Cannot access slot->tts_isnull before invoking slot_getallattrs.
* See Github Issue 16906.
*/
if (!attr->attisdropped && attr->attlen == -1)
{
hasExternalAttr = true;
break;
Expand Down
16 changes: 16 additions & 0 deletions src/test/regress/expected/toast.out
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,19 @@ SELECT encode(substring(a from 521*26+1 for 26), 'escape') FROM toast_chunk_test
abcdefghijklmnopqrstuvwxyz
(1 row)

-- Test for Github Issue 16906
create table t_16906(a int, b text) distributed by(a);
-- Insert two rows and make sure they are in the same segment (same dist key)
-- the 1st row's column b must be NULL;
-- the 2nd row's column b must be a long string even after toast compression
-- for details please refer to the issue page.
insert into t_16906 values(1, null);
insert into t_16906 values(1, randomtext(10240));
-- Don't want actually fetch all data just need to test
-- it does not hit assert fail or error. Using explain
-- analyze might introduce a new ansfile for ORCA so here
-- I decide to use \o.
\o /tmp/t_16906.tmp
select * from t_16906;
\o
drop table t_16906;
20 changes: 20 additions & 0 deletions src/test/regress/sql/toast.sql
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,23 @@ SELECT * FROM toast_chunk_test WHERE a <> repeat('abcdefghijklmnopqrstuvwxyz', 1

-- Random access into the toast table should work equally well.
SELECT encode(substring(a from 521*26+1 for 26), 'escape') FROM toast_chunk_test;

-- Test for Github Issue 16906
create table t_16906(a int, b text) distributed by(a);

-- Insert two rows and make sure they are in the same segment (same dist key)
-- the 1st row's column b must be NULL;
-- the 2nd row's column b must be a long string even after toast compression
-- for details please refer to the issue page.
insert into t_16906 values(1, null);
insert into t_16906 values(1, randomtext(10240));

-- Don't want actually fetch all data just need to test
-- it does not hit assert fail or error. Using explain
-- analyze might introduce a new ansfile for ORCA so here
-- I decide to use \o.
\o /tmp/t_16906.tmp
select * from t_16906;
\o

drop table t_16906;