Skip to content

Commit 0873375

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 e492ba1 commit 0873375

File tree

5 files changed

+10
-19
lines changed

5 files changed

+10
-19
lines changed

src/backend/gpopt/translate/CTranslatorDXLToPlStmt.cpp

+1-8
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

+6
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

+1-4
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

+1-4
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/sql/gdd/concurrent_update.sql

+1-3
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,7 @@ insert into test values (1, 1, 1), (1, 2, 1);
240240
1: update t_splitupdate_raise_error set a = a + 1;
241241

242242
2: begin;
243-
-- TODO: turn off orca, we should fix this until ORCA
244-
-- can generate lockrows plannode.
245-
2: set optimizer = off;
243+
-- ORCA will fallback
246244
2&: select * from t_splitupdate_raise_error for update;
247245

248246
1: end;

0 commit comments

Comments
 (0)