[Bug] ORCA generates wrong plan for select-for-update statement.
- Dominant language
- C
- Stars
- 1.4k
- Forks
- 247
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 39
Description
### Apache Cloudberry version
_No response_
### What happened
when set optimizer to on, plan for select-for-update statement is not correct because LockRows is lacked.
```
postgres=# set optimizer to on;
SET
postgres=# explain select * from test for update;
QUERY PLAN
------------------------------------------------------------------------------
Gather Motion 2:1 (slice1; segments: 2) (cost=0.00..431.00 rows=1 width=4)
-> Seq Scan on test (cost=0.00..431.00 rows=1 width=4)
Optimizer: GPORCA
(3 rows)
postgres=# set optimizer to off;
SET
postgres=# explain select * from test for update;
QUERY PLAN
------------------------------------------------------------------------------------
Gather Motion 2:1 (slice1; segments: 2) (cost=0.00..2457.50 rows=96300 width=10)
-> LockRows (cost=0.00..1013.00 rows=48150 width=10)
-> Seq Scan on test (cost=0.00..531.50 rows=48150 width=10)
Optimizer: Postgres query optimizer
(4 rows)
```
### What you think should happen instead
_No response_
### How to reproduce
set optimizer to on;
explain select * from test for update;
### Operating System
centos
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes, I am willing to submit a PR!
### Code of Conduct
- [x] I agree to follow this project's [Code of Conduct](https://github.com/apache/cloudberry/blob/main/CODE_OF_CONDUCT.md).
Contributor guide
Assessment
This issue has not been assessed yet.