lightdb 支持从父查询中返回子查询表中的 rowid

背景

在如下的 sql 中,

select rowid from (select 1 from t);

lightdb 24.1 以前会直接报错,说找不到 rowid 列。为了兼容 Oracle, 在 24.1 中,我们选择将告知子查询除了返回子查询应有的列之外,还需返回 rowid 列。

样例

以下样例 sql 说明了 lightdb 24.1 中支持的 rowid 的功能:

-- rowid is passed down to table t1
select rowid from (select 1 from t1);
select rowid, a from (select a from t1);
-- rowid is passed down to table t1
select a.rowid from (select 1 from t1) a;
--= error, `a` could not be referenced from `public` schema as `a` is not a regular table
select public.a.rowid from (select 1 from t1) a;

--
-- multi-level subqueries
--
select rowid from (select 1 from (select 1 from t1));
select rowid from (select 1 from (select 1 from (select 1 from (select 1 from (select 1 from (t1))))));

-- lateral join
select t2.rowid from t2 cross join lateral (select t1.a from t1 where t1.rowid = t2.rowid) a;

-- rowid should not pass down to subquery
select t1.rowid from (select t1.a from t1, t2), t1;

posted on 2024-04-11 16:26  winter-loo  阅读(1)  评论(0编辑  收藏  举报

导航