Skip to content

Commit 542dc9d

Browse files
committed
ORCA: fallback the locking clause
If the current GDD is closed and there is a `forupdate` statement, ORCA and planner does not need to generate a `LockRows` operator, expect the table is foreign table. However, if the current GDD is enabled, ORCA will generate a plan without the `LockRows` operator, which is a wrong plan. Supporting locking clauses in ORCA is a very difficult thing. Because ORCA does not fill `root->glob->paramExecTypes` in every operator, even if ORCA generates the `LockRows` operator, it may not working in the executor. For details, please refer to the EPQ(evalPlanQual) mechanism. Also I don't think ORCA should consider supporting locking clause. ORCA is an optimizer that is more biased towards OLAP scenarios. Support the EPQ mechanism will make ORCA more complex and more difficult to expand.
1 parent 1cbab9b commit 542dc9d

File tree

5 files changed

+10
-19
lines changed

5 files changed

+10
-19
lines changed

contrib/pax_storage/src/test/isolation2/sql/gdd/concurrent_update.sql

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,7 @@ DROP TABLE t_concurrent_update;
177177
1: update t_splitupdate_raise_error set a = a + 1;
178178

179179
2: begin;
180-
-- TODO: turn off orca, we should fix this until ORCA
181-
-- can generate lockrows plannode.
182-
2: set optimizer = off;
180+
-- ORCA will fallback
183181
2&: select * from t_splitupdate_raise_error for update;
184182

185183
1: end;

src/backend/gpopt/translate/CTranslatorDXLToPlStmt.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4723,14 +4723,7 @@ CTranslatorDXLToPlStmt::TranslateDXLDml(
47234723
isSplit = true; // AO tables are always use split updates
47244724
}
47254725

4726-
if (md_rel->IsPartitioned())
4727-
{
4728-
dml->forceTupleRouting = true;
4729-
}
4730-
else
4731-
{
4732-
dml->forceTupleRouting = false;
4733-
}
4726+
dml->forceTupleRouting = md_rel->IsPartitioned();
47344727

47354728
if (IMDRelation::EreldistrMasterOnly != md_rel->GetRelDistribution())
47364729
{

src/backend/gpopt/translate/CTranslatorQueryToDXL.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,12 @@ CTranslatorQueryToDXL::TranslateSelectQueryToDXL()
627627
}
628628
}
629629

630+
// Locking clause is not supported.
631+
if (m_query->canOptSelectLockingClause) {
632+
GPOS_RAISE(gpdxl::ExmaDXL, gpdxl::ExmiQuery2DXLUnsupportedFeature,
633+
GPOS_WSZ_LIT("Locking clause"));
634+
}
635+
630636
// RETURNING is not supported yet.
631637
if (m_query->returningList)
632638
{

src/test/isolation2/expected/gdd/concurrent_update.out

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -402,10 +402,7 @@ UPDATE 1
402402

403403
2: begin;
404404
BEGIN
405-
-- TODO: turn off orca, we should fix this until ORCA
406-
-- can generate lockrows plannode.
407-
2: set optimizer = off;
408-
SET
405+
-- ORCA will fallback
409406
2&: select * from t_splitupdate_raise_error for update; <waiting ...>
410407

411408
1: end;

src/test/isolation2/expected/gdd/concurrent_update_optimizer.out

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -402,10 +402,7 @@ UPDATE 1
402402

403403
2: begin;
404404
BEGIN
405-
-- TODO: turn off orca, we should fix this until ORCA
406-
-- can generate lockrows plannode.
407-
2: set optimizer = off;
408-
SET
405+
-- ORCA will fallback
409406
2&: select * from t_splitupdate_raise_error for update; <waiting ...>
410407

411408
1: end;

0 commit comments

Comments
 (0)