Skip to content

Commit

Permalink
Fix incorrect system target list detection for AO update
Browse files Browse the repository at this point in the history
AO table can still provide some system colums, including ctid, table_oid,
gp_segment_id and foreign table_oid.
  • Loading branch information
foreyes authored and my-ship-it committed Nov 1, 2024
1 parent f573ee1 commit 9b9dd58
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
9 changes: 7 additions & 2 deletions src/backend/gpopt/translate/CTranslatorDXLToPlStmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
extern "C" {
#include "postgres.h"

#include "access/sysattr.h"
#include "catalog/gp_distribution_policy.h"
#include "catalog/pg_collation.h"
#include "cdb/cdbutil.h"
Expand Down Expand Up @@ -5851,10 +5852,14 @@ CTranslatorDXLToPlStmt::CheckSafeTargetListForAOTables(List *target_list)
ForEach(lc, target_list)
{
TargetEntry *te = (TargetEntry *) lfirst(lc);
if (te->resorigcol < 0)
if (te->resorigcol < 0 &&
te->resorigcol != SelfItemPointerAttributeNumber &&
te->resorigcol != TableOidAttributeNumber &&
te->resorigcol != GpSegmentIdAttributeNumber &&
te->resorigcol != GpForeignServerAttributeNumber)
{
GPOS_RAISE(gpdxl::ExmaDXL, gpdxl::ExmiQuery2DXLUnsupportedFeature,
GPOS_WSZ_LIT("System column in target list found for AO table"));
GPOS_WSZ_LIT("Invalid system target list found for AO table"));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ DELETE 1
ao | ExclusiveLock | relation | master
(1 row)
2: SELECT * FROM locktest_segments WHERE coalesce = 'ao';
coalesce | mode | locktype | node
----------+---------------+----------+-----------
ao | ExclusiveLock | relation | 1 segment
coalesce | mode | locktype | node
----------+---------------+----------+------------
ao | ExclusiveLock | relation | n segments
(1 row)
-- The case here should delete a tuple at the same seg with(2).
-- Under jump hash, (2) and (3) are on the same seg(seg0).
Expand Down
6 changes: 3 additions & 3 deletions src/test/regress/expected/ao_locks_optimizer.out
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ SELECT * FROM locktest_master where coalesce = 'ao_locks_table' or

SELECT * FROM locktest_segments where coalesce = 'ao_locks_table' or
coalesce like 'aovisimap%' or coalesce like 'aoseg%';
coalesce | mode | locktype | node
-----------------+------------------+----------+-----------
ao_locks_table | ExclusiveLock | relation | 1 segment
coalesce | mode | locktype | node
-----------------+------------------+----------+------------
ao_locks_table | ExclusiveLock | relation | n segments
aovisimap table | RowExclusiveLock | relation | 1 segment
aovisimap index | RowExclusiveLock | relation | 1 segment
(3 rows)
Expand Down

0 comments on commit 9b9dd58

Please sign in to comment.