CROSS JOIN 可以是 "implicitly LATERAL" 吗?

Can a CROSS JOIN be "implicitly LATERAL"?

假设以下数据库相当简单:

CREATE TABLE test_table(
  name TEXT,
  data JSONB
);
INSERT INTO test_table VALUES ('name1', '{"a": 1, "b": 2}'), ('name2', '{"c": 3, "d": 4, "e": 5}');

所以我们有以下 table:

# SELECT * FROM test_table ;
 name  |           data
-------+--------------------------
 name1 | {"a": 1, "b": 2}
 name2 | {"c": 3, "d": 4, "e": 5}
(2 rows)

现在我看到了这样的查询:

# SELECT * FROM test_table CROSS JOIN JSONB_EACH(test_table.data);

return结果如下:

 name  |           data           | key | value
-------+--------------------------+-----+-------
 name1 | {"a": 1, "b": 2}         | a   | 1
 name1 | {"a": 1, "b": 2}         | b   | 2
 name2 | {"c": 3, "d": 4, "e": 5} | c   | 3
 name2 | {"c": 3, "d": 4, "e": 5} | d   | 4
 name2 | {"c": 3, "d": 4, "e": 5} | e   | 5
(5 rows)

我的问题是我不明白这里发生了什么。一方面 手,这看起来像一个 LATERAL 连接,因为右侧 JOIN指的是左边那个,结果完美 合乎逻辑的。另一方面,手册是这样说的:

(Without LATERAL, each sub-SELECT is evaluated independently and so cannot cross-reference any other FROM item.)

还有这个:

The column source table(s) must be INNER or LEFT joined to the LATERAL item […]

(参见here),当然CROSS JOIN不return n×m 行(如 this page 所说)。

我的问题是:上面的查询结果与 手动的?如果不是,那是否意味着 JSONB_EACH 以某种方式被处理 特别? (我会觉得很惊讶。)

If not, does that mean that JSONB_EACH is somehow treated specially?

是的,因为它是一个 table 函数(又名 "set returning function")

Quote from the manual

Table functions appearing in FROM can also be preceded by the key word LATERAL, but for functions the key word is optional; the function's arguments can contain references to columns provided by preceding FROM items in any case.

(强调我的)