Skip to content

Commit d08f70c

Browse files
yutaro-sakamotoCopilotmo-shimada
authored
doc: add documentation of locking for indexed files (#700)
* doc: add documentation of locking for indexed files * doc: fix documents * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> * Update doc/specification-locking-indexed-file_JP.md Co-authored-by: Copilot <[email protected]> * Update locking specification * Update locking specification --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: Momoka Shimada <[email protected]>
1 parent 5f0c42c commit d08f70c

File tree

4 files changed

+91
-0
lines changed

4 files changed

+91
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ java [PROGRAM-ID]
171171
* [The API reference of the runtime library `libcobj.jar`](https://opensourcecobol.github.io/opensourcecobol4j/javadoc/libcobj/index.html)
172172
* [opensource COBOL 4J: Java変換解説](./doc/converted_Java_file_JP.md)
173173
* [configuration-params-JP](./doc/configuration-params-JP.md)
174+
* [The specification of locking for INDEXED files in opensource COBOL 4J](./doc/specification-locking-indexed-file.md)
174175

175176
## Development Progress
176177

README_JP.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ java [PROGRAM-ID]
160160
* [ランタイムライブラリ`libcobj.jar`のAPIリファレンス](https://opensourcecobol.github.io/opensourcecobol4j/javadoc/libcobj/index.html)
161161
* [opensource COBOL 4J: Java変換解説](./doc/converted_Java_file_JP.md)
162162
* [configuration-params-JP](./doc/configuration-params-JP.md)
163+
* [INDEXEDファイルのロックの仕様](./doc/specification-locking-indexed-file_JP.md)
163164

164165
## 実装状況
165166
実装済み機能:
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# INDEXED File Locking Specification
2+
3+
## LOCK MODE in the SELECT Statement
4+
5+
- The SELECT statement's LOCK MODE can only specify AUTOMATIC or MANUAL.
6+
- When omitted, the default value for LOCK MODE is MANUAL
7+
- When `-lock-mode-automatic` is specified at compile time, the default value for omitted LOCK MODE becomes AUTOMATIC.
8+
9+
## Record Locking Behavior
10+
11+
- When a file is opened with OPEN I-O and a READ statement without WITH NO LOCK or WITH LOCK is executed:
12+
- If the SELECT statement's LOCK MODE is MANUAL, the record is not locked
13+
- If the SELECT statement's LOCK MODE is AUTOMATIC, the record is locked
14+
- When a file is opened with OPEN I-O and a READ statement with WITH LOCK is executed, the record is locked
15+
- When a file is opened with OPEN I-O and a READ statement with WITH NO LOCK is executed, the record is not locked
16+
- When processing fails due to record locking, the file status becomes 51
17+
18+
## File Locking Behavior
19+
20+
- When a file is opened with OPEN OUTPUT, a file lock is applied to the file
21+
- When processing fails due to file locking, the file status becomes 61
22+
23+
## Migrating Legacy INDEXED Files to the New Version
24+
25+
Legacy INDEXED files cannot be used directly with the new version of opensource COBOL 4J.
26+
To convert INDEXED files created with legacy versions to be compatible with the new version, please use the following command:
27+
28+
```sh
29+
cobj-idx migrate <<INDEXED_FILE>>
30+
```
31+
32+
This command converts the specified INDEXED file to be compatible with the new version.
33+
34+
## Unlocking INDEXED Files
35+
36+
The following command can release all file locks and record locks on an INDEXED file:
37+
38+
```sh
39+
cobj-idx unlock <<INDEXED_FILE>>
40+
```
41+
42+
## Behavior When Opening Legacy INDEXED Files
43+
44+
When attempting to open legacy INDEXED files, the file status becomes 92.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
2+
# INDEXEDファイルのロック仕様
3+
4+
## SELECT句のLOCK MODE
5+
6+
- SELECT句のLOCK MODEにはAUTOMATICかMANUALのみ指定可能である。
7+
- 省略した場合のLOCK MODEのデフォルト値はMANUAL
8+
- コンパイル時に`-lock-mode-automatic`を指定した場合、LOCK MODEを省略した場合のデフォルト値はAUTOMATICになる。
9+
10+
## レコードロックの動作
11+
12+
- OPEN I-Oでファイルを開き、WITH NO LOCKもWITH LOCKも指定されないREAD文を実行したとき
13+
- SELECT句のLOCK MODEがMANUALの場合、当該レコードをロックしない
14+
- SELECT句のLOCK MODEがAUTOMATICの場合、当該レコードをロックする
15+
- OPEN I-Oでファイルを開き、WITH LOCK指定のあるREAD文を実行したとき、当該レコードをロックする
16+
- OPEN I-Oでファイルを開き、WITH NO LOCK指定のあるREAD文を実行したとき、当該レコードをロックしない
17+
- レコードロックにより処理が失敗した場合、ファイルステータスが51となる
18+
19+
## ファイルロックの動作
20+
21+
- OPEN OUTPUTで開いたときに、当該ファイルにファイルロックがかかる
22+
- ファイルロックにより処理が失敗した場合、ファイルステータスは61となる
23+
24+
## 古いバージョンのINDEXEDファイルを新バージョンに対応させる。
25+
26+
古いバージョンのINDEXEDファイルは、直接最新バージョンのopensource COBOL 4Jでは使用できません。
27+
古いバージョンで作成したINDEXEDファイルを新バージョンに対応したものに変換するには、以下のコマンドを実行してください。
28+
29+
```sh
30+
cobj-idx migrate <<INDEXEDファイル>>
31+
```
32+
33+
これにより、指定したINDEXEDファイルが新バージョンに対応したものに変換される。
34+
35+
## INDEXEDファイルのロックを解除する
36+
37+
下記のコマンドで、INDEXEDファイルにかかったファイルロックとすべてのレコードロックを解除できる。
38+
39+
```sh
40+
cobj-idx unlock <<INDEXEDファイル>>
41+
```
42+
43+
## 古いバージョンのINDEXEDファイルを開いたときの動作
44+
45+
古いバージョンのINDEXEDファイルを開こうとした場合、ファイルステータスが92となる。

0 commit comments

Comments
 (0)