Skip to content

Commit a1471ef

Browse files
committed
Remove numbered headings from nested subfunction documentation
The numbered headings (1., 2., 3.) in section titles were redundant and inconsistent with the overall documentation style. This change replaces them with clean hierarchical headings while preserving all technical content.
1 parent be7b2eb commit a1471ef

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

CN/modules/ROOT/pages/master/6.3.7.adoc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,29 @@
1212

1313
== 实现说明
1414

15-
=== 一、嵌套子函数语法识别
15+
=== 嵌套子函数语法识别
1616

17-
==== 1. 识别嵌套写法
17+
==== 识别嵌套写法
1818

1919
当 `DECLARE` 块里出现 `function ... is/as begin ... end` 结构时,`pl_gram.y` 会调用 `plisql_build_subproc_function()`(对应创建普通函数,这一阶段相当于在 `pg_proc` 中更新 catalog 中的注册信息):
2020

2121
. 在 `PLiSQL_function` 的 `subprocfuncs[]` 数组中创建 `PLiSQL_subproc_function` 结构,记录名称、参数、返回类型、属性等,获得一个下标 `fno` 作为该子函数的标识。
2222
. 调用 `plisql_check_subprocfunc_properties()` 校验声明与定义的合法组合。
2323

24-
==== 2. 数据项保存
24+
==== 数据项保存
2525

2626
保存到父函数的 `datum` 表:编译期的 `PLiSQL_function->datums` 描述子函数里的变量、记录字段,`PLiSQL_execstate->datums` 保存着执行过程中的变量。
2727

28-
==== 3. 保存多态函数模板
28+
==== 保存多态函数模板
2929

3030
如果子函数里使用了多态参数,在语法阶段保存到 `subprocfunc->src`,同时将 `has_poly_argument` 设成 `true`,执行时按不同实参类型重新编译。
3131

32-
=== 二、父函数重新编译
32+
=== 父函数重新编译
3333

3434
. 父函数的 `PLiSQL_function` 结构多了一个 `subprocfuncs` 数组,里面每个元素就是刚才创建的 `PLiSQL_subproc_function`。
3535
. 子函数结构体 `PLiSQL_subproc_function` 有一个哈希表指针 `HTAB *poly_tab`,默认为空。当子函数里使用了多态函数时,`has_poly_argument` 为 `true`,则会在初次编译时初始化 `poly_tab`。`poly_tab` 的 key 是 `PLiSQL_func_hashkey`,记录着子函数的 `fno`、输入参数类型等; value 是编译好的 `PLiSQL_function *`(`plisql` 函数的执行上下文)。
3636

37-
=== 三、调用时解析
37+
=== 调用时解析
3838

3939
. 编译过程中,`pg` 解析器会生成一个 `ParseState` 结构,`plisql_subprocfunc_ref()` 会通过 `ParseState->p_subprocfunc_hook()` 找到父函数的 `PLiSQL_function`,调用 `plisql_ns_lookup()` 找到所有同名子函数的 `fno`,根据参数个数、类型找到最合适的多态函数。
4040
. `FuncExpr` 结构构造时会对子函数进行标记,方便后期执行阶段识别:`function_from = FUNC_FROM_SUBPROCFUNC`,`parent_func` 指向父级 `PLiSQL_function`,`funcid = fno`。

CN/modules/ROOT/pages/master/7.19.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55

66
= 兼容Oracle 嵌套子函数
77

8-
== 1.目的
8+
== 目的
99

1010
- 在 IvorySQL 中使用 Oracle 风格嵌套子函数。
1111

12-
== 2.功能说明
12+
== 功能说明
1313

1414
- 支持在匿名块、函数或过程内部声明与调用子函数/子过程,作用域限定在父块内。
1515
- 子函数可读取及更新父级变量,也可定义自身局部变量;父级无法直接访问子函数内部状态。
1616
- 支持重载解析机制,按参数个数、类型或命名区分同名子程序。
1717

18-
== 3.测试用例
18+
== 测试用例
1919

2020
[source,sql]
2121
----

EN/modules/ROOT/pages/master/6.3.7.adoc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,29 @@
1212

1313
== Implementation Notes
1414

15-
=== 1. Syntax Recognition for Nested Subfunctions
15+
=== Syntax Recognition for Nested Subfunctions
1616

17-
==== 1. Detecting Nested Definitions
17+
==== Detecting Nested Definitions
1818

1919
When a `DECLARE` block contains a `function ... is/as begin ... end` construct, `pl_gram.y` calls `plisql_build_subproc_function()` (similar to creating a regular function and updating the entry in `pg_proc`):
2020

2121
. Create a `PLiSQL_subproc_function` entry in the parent `PLiSQL_function`'s `subprocfuncs[]` array to store the name, arguments, return type, and other attributes, and record the index `fno` as the identifier of this subfunction.
2222
. Call `plisql_check_subprocfunc_properties()` to validate the combination of declaration and definition attributes.
2323

24-
==== 2. Storing Datum Entries
24+
==== Storing Datum Entries
2525

2626
Nested subfunctions share the parent's datum table. During compilation, `PLiSQL_function->datums` describes variables and record fields inside the subfunction, while `PLiSQL_execstate->datums` keeps the runtime values.
2727

28-
==== 3. Preserving Polymorphic Templates
28+
==== Preserving Polymorphic Templates
2929

3030
If the subfunction uses polymorphic parameters, the parser stores its source code in `subprocfunc->src` and sets `has_poly_argument` to `true` so that the executor can recompile it for each distinct argument type.
3131

32-
=== 2. Recompiling the Parent Program
32+
=== Recompiling the Parent Program
3333

3434
. The parent `PLiSQL_function` gains a `subprocfuncs` array, each element being the `PLiSQL_subproc_function` created earlier.
3535
. Each `PLiSQL_subproc_function` has a `HTAB *poly_tab` pointer that is initialized on the first compilation when `has_poly_argument` is `true`. The hash key is `PLiSQL_func_hashkey`, which records the subfunction's `fno` and input argument types; the value is the compiled `PLiSQL_function *` execution context.
3636

37-
=== 3. Name Resolution During Invocation
37+
=== Name Resolution During Invocation
3838

3939
. PostgreSQL builds a `ParseState` structure during compilation. `plisql_subprocfunc_ref()` locates the parent `PLiSQL_function` through `ParseState->p_subprocfunc_hook()` and calls `plisql_ns_lookup()` to gather all `fno` values for subfunctions sharing the same name, then selects the best match based on argument count and types.
4040
. When `FuncExpr` nodes are created, the subfunction call is tagged for later execution: `function_from = FUNC_FROM_SUBPROCFUNC`, `parent_func` points to the parent `PLiSQL_function`, and `funcid = fno`.

EN/modules/ROOT/pages/master/7.19.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55

66
= Oracle-Compatible Nested Subfunctions
77

8-
== 1. Objective
8+
== Objective
99

1010
- Using Oracle-style nested subfunctions in IvorySQL.
1111

12-
== 2. Feature Description
12+
== Feature Description
1313

1414
- Allows declaring and invoking subfunctions or subprocedures inside anonymous blocks, functions, or procedures, with scope limited to the parent block.
1515
- Nested subfunctions can read and update variables defined in the parent scope while introducing their own local variables; the parent scope cannot directly access the subfunction's internal state.
1616
- Supports overloading resolution that distinguishes homonymous subfunctions by argument count, data type, or named parameters.
1717

18-
== 3. Test Cases
18+
== Test Cases
1919

2020
[source,sql]
2121
----

0 commit comments

Comments
 (0)