Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
d0b1a5f
add: processUuid and processId
yutaro-sakamoto Jul 8, 2025
bd158b4
add: create a new table `file_lock`
yutaro-sakamoto Jul 8, 2025
08f0641
refactor: suppress PMD warnings
yutaro-sakamoto Jul 8, 2025
2bd145c
fix: sql statement creating a new table `file_lock`
yutaro-sakamoto Jul 8, 2025
6ad7bc4
wip: wip
yutaro-sakamoto Jul 8, 2025
7d432b0
fix: a PMD warning
yutaro-sakamoto Jul 10, 2025
5b04f85
fix: a SpotBug warning
yutaro-sakamoto Jul 10, 2025
34bef78
refactor: remove printStackTrace()
yutaro-sakamoto Jul 10, 2025
5d17946
fix: check formats of indexed files to open
yutaro-sakamoto Jul 10, 2025
e24918f
test: remove unnecessary checks
yutaro-sakamoto Jul 10, 2025
1e298b1
fix: change constants to avoid overlaps
yutaro-sakamoto Jul 10, 2025
09dd15c
fix: add a file existing check
yutaro-sakamoto Jul 10, 2025
81a4e2d
test: fix the test of opening an invalid indexed file
yutaro-sakamoto Jul 10, 2025
0876e50
test: fix load.at not to call default error handlers
yutaro-sakamoto Jul 10, 2025
f7983ca
chore: end a transaction
yutaro-sakamoto Jul 10, 2025
9946fd4
refactor: CobolIndexedFile.java
yutaro-sakamoto Jul 10, 2025
c6e92e0
test: prevent infinite loops
yutaro-sakamoto Jul 11, 2025
6528998
Merge branch 'fix-indexed-file' into lock-indexed-file
yutaro-sakamoto Jul 11, 2025
71bb7ae
refactor: CobolIndexedFile.java
yutaro-sakamoto Jul 11, 2025
b44799e
wip: wip
yutaro-sakamoto Jul 11, 2025
71c0f1f
fix: improve open_ in CobolIndexedFile.java
yutaro-sakamoto Jul 14, 2025
4336adc
change: set transaction settings
yutaro-sakamoto Jul 14, 2025
c878db0
feat: implement file locks of indexed files
yutaro-sakamoto Jul 14, 2025
de982ca
fix: change the condition of creating file_lock
yutaro-sakamoto Jul 15, 2025
379532f
change: set the transaction isolation to SERIALIZABLE
yutaro-sakamoto Jul 15, 2025
4eca7f6
test: add tests of file locking of indexed files
yutaro-sakamoto Jul 17, 2025
303d281
change: the schema of the record key table
yutaro-sakamoto Jul 17, 2025
c2ad6de
fix: an INSERT statement
yutaro-sakamoto Jul 23, 2025
9570f56
fix: an insert statement for primary record tables
yutaro-sakamoto Jul 23, 2025
36678bb
feat: add a new option `-default_select_lock_mode`
yutaro-sakamoto Jul 23, 2025
a17c13b
channge: insert information when calling read_()
yutaro-sakamoto Jul 23, 2025
4c55f9e
fix: the method read_
yutaro-sakamoto Jul 24, 2025
bec1926
Implement file locking of indexed files (#678)
yutaro-sakamoto Jul 25, 2025
b56953d
Merge remote-tracking branch 'org/indexed-lock' into lock-indexed-fil…
yutaro-sakamoto Jul 25, 2025
192405d
refactor: CobolIndexedFile.java
yutaro-sakamoto Jul 25, 2025
d067c94
add: lock a record when READ NEXT is executed
yutaro-sakamoto Jul 25, 2025
1d83256
add: unlock records when closing indexed files
yutaro-sakamoto Jul 25, 2025
c3ab180
fix: the process of unlocking a file lock
yutaro-sakamoto Jul 25, 2025
a8a1cdf
fix: controling transactions when rewriting records
yutaro-sakamoto Jul 28, 2025
fac9874
fix: commit timing when writing records
yutaro-sakamoto Jul 28, 2025
a85f119
fix: commits and rollbacks in WRITE, REWRITE and DELETE
yutaro-sakamoto Jul 28, 2025
8aaf985
change: -default_lock_mode to -lock-mode-automatic
yutaro-sakamoto Jul 29, 2025
d3304b4
refactor: code for commiting data
yutaro-sakamoto Jul 29, 2025
99acfa1
add: unlock the previous record after writing
yutaro-sakamoto Jul 29, 2025
f847da4
add: unlock previous records after rewriting
yutaro-sakamoto Jul 29, 2025
4c44e52
add: impelment record lockings of DELETE
yutaro-sakamoto Jul 29, 2025
1b3eb4c
fix: constant numbers
yutaro-sakamoto Jul 30, 2025
f70d4e5
chore: remove duplicated code
yutaro-sakamoto Jul 30, 2025
043a284
fix: close ResultSet not to lock database implicitly
yutaro-sakamoto Jul 31, 2025
8f8fd8d
fix: close ResultSet in CobolIndexedFile.java
yutaro-sakamoto Jul 31, 2025
28eb5fb
add: NewIndexedCursor.java
yutaro-sakamoto Aug 1, 2025
eb3dac9
wip: read forward
yutaro-sakamoto Aug 1, 2025
f0d5b2a
wip: read prev
yutaro-sakamoto Aug 1, 2025
c82f261
fix: fetchRecord
yutaro-sakamoto Aug 1, 2025
22a55b7
fix: READ NEXT/PREVIOUS
yutaro-sakamoto Aug 2, 2025
5ff8912
fix: READ
yutaro-sakamoto Aug 2, 2025
c048ad4
fix: fetchRecord
yutaro-sakamoto Aug 2, 2025
416ea2f
fix: fetchRecord
yutaro-sakamoto Aug 2, 2025
f8b9453
fix: START
yutaro-sakamoto Aug 2, 2025
dc73ad5
fix: START ~ KEY IS GREATER THAN
yutaro-sakamoto Aug 2, 2025
7fa9482
fix: START ~ KEY IS <=
yutaro-sakamoto Aug 2, 2025
ff90b21
fix: START and READ NEXT RECORD
yutaro-sakamoto Aug 2, 2025
e614b97
refactor: resolve PMD warnings
yutaro-sakamoto Aug 2, 2025
dc56fde
chore: migrate NewIndexedCursor to IndexedCursor
yutaro-sakamoto Aug 4, 2025
3ff4e7d
fix: allow READ WITH LOCK/WITH NO LOCK if LOCK MODE IS AUTOMATIC
yutaro-sakamoto Aug 4, 2025
5ddb983
fix: call commit() in the end of READ and READ NEXT/PREV
yutaro-sakamoto Aug 6, 2025
ddd4ea0
fix: initialize previousLockedReclordKey in close_()
yutaro-sakamoto Aug 6, 2025
97799e7
test: add some tests for record locking
yutaro-sakamoto Aug 6, 2025
c2faca9
fix: unlock Previous records at the end of READ
yutaro-sakamoto Aug 6, 2025
1a4712a
test: accelerate file locking tests
yutaro-sakamoto Aug 7, 2025
1396d83
test: wip
yutaro-sakamoto Aug 7, 2025
bfba9a6
test: add tests for `READ WITH LOCK`
yutaro-sakamoto Aug 7, 2025
c70e32e
test: check the final state of an indexed file
yutaro-sakamoto Aug 7, 2025
fde00f1
fix: do not read data when the file status is not 00
yutaro-sakamoto Aug 7, 2025
1dc4529
test: move common java code for record lock tests
yutaro-sakamoto Aug 14, 2025
b63208a
test: add tests for different records
yutaro-sakamoto Aug 14, 2025
1c88fbb
test: add tests for input mode
yutaro-sakamoto Aug 14, 2025
d3dc106
test: add tests for the same process
yutaro-sakamoto Aug 15, 2025
e29c725
fix: commit at the end of start_
yutaro-sakamoto Aug 15, 2025
c263afe
test: guarantee that OPEN,START,WRITE,REWRITE cannot lock indexed fil…
yutaro-sakamoto Aug 15, 2025
16980fe
test: fix tests for OPEN,START,WRITE and REWRITE
yutaro-sakamoto Aug 18, 2025
1fb08f4
fix: processes of unlocking records
yutaro-sakamoto Aug 18, 2025
80da303
tests: add tests for unlocking records
yutaro-sakamoto Aug 18, 2025
c3ee9fa
tests: add tests of OPEN INPUT
yutaro-sakamoto Aug 18, 2025
9156f85
test: add tests for LOCK MODE
yutaro-sakamoto Aug 18, 2025
bfa1992
test: add tests of -lock-mode-automatic
yutaro-sakamoto Aug 18, 2025
c6db8e0
tests: move tests for indexed files lock to tests/indexed-lock
yutaro-sakamoto Aug 19, 2025
0f9ef94
ci: run tests `indexed-lock`
yutaro-sakamoto Aug 19, 2025
a495974
chore: fix typo
yutaro-sakamoto Aug 19, 2025
5abd49f
fix: the syntax error of an sql statement in IndexedCursor.java
yutaro-sakamoto Aug 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
- name: Run other tests
working-directory: tests
run: |
tests=("command-line-options" "data-rep" "i18n_sjis" "jp-compat" "run" "syntax" "cobj-idx" "misc")
tests=("command-line-options" "data-rep" "i18n_sjis" "jp-compat" "run" "syntax" "cobj-idx" "indexed-lock" "misc")
for test in "${tests[@]}"; do
./"$test" || true
done
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ jobs:
- "syntax"
- "cobj-idx"
- "misc"
- "indexed-lock"
os: ["ubuntu:24.04", "almalinux:9", "amazonlinux:2023"]
uses: ./.github/workflows/test-other.yml
with:
Expand All @@ -74,6 +75,7 @@ jobs:
- "run"
- "syntax"
- "cobj-idx"
- "indexed-lock"
#- "misc"
os: ["ubuntu:24.04", "almalinux:9", "amazonlinux:2023"]
uses: ./.github/workflows/test-other.yml
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ jobs:
- "run"
- "syntax"
- "cobj-idx"
- "indexed-lock"
- "misc"
os: ["ubuntu:24.04"]
uses: ./.github/workflows/test-other.yml
Expand All @@ -79,6 +80,7 @@ jobs:
- "run"
- "syntax"
- "cobj-idx"
- "indexed-lock"
#- "misc"
os: ["ubuntu:24.04"]
uses: ./.github/workflows/test-other.yml
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ tests/jp-compat
tests/cobj-idx
tests/misc
tests/run
tests/indexed-lock
tests/*.log
tests/syntax
tests/cobol85/*/*.class
Expand Down
11 changes: 11 additions & 0 deletions cobj/cobj.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,14 @@ int cb_flag_main = 0;

int cb_default_byte_specified = 0;
unsigned char cb_default_byte = 0;

int cb_default_select_lock_mode = COB_LOCK_MANUAL;

#define OPTION_ID_DEFAULT_BYTE (1024)
#define OPTION_ID_SINGLE_JAR (1025)
#define OPTION_ID_JAR (1026)
#define OPTION_ID_INFO_JSON (1027)
#define OPTION_ID_LOCK_MODE_AUTOMATIC (1028)

int external_flg = 0;
int errorcount = 0;
Expand Down Expand Up @@ -311,6 +315,7 @@ static const struct option long_options[] = {
{"reference_check", no_argument, NULL, 'K'},
{"constant", optional_argument, NULL, '3'},
{"fdefaultbyte", required_argument, NULL, OPTION_ID_DEFAULT_BYTE},
{"lock-mode-automatic", no_argument, NULL, OPTION_ID_LOCK_MODE_AUTOMATIC},
#undef CB_FLAG
#define CB_FLAG(var, name, doc) \
{"f" name, no_argument, &var, 1}, {"fno-" name, no_argument, &var, 0},
Expand Down Expand Up @@ -901,6 +906,8 @@ static void cobc_print_usage(void) {
"representing a character"));
puts(_(" * octodecimal 00..0377 "
"representing a character"));
puts(_(" -lock-mode-automatic Set the default lock mode of "
"select clauses to AUTOMATIC"));
puts(_(" -info-json-dir=<dir> Specify the directory path of "
"JSON files that hold information of COBOL programs"));
puts(_(" -java-package(=<package name>) Specify the package name of the "
Expand Down Expand Up @@ -1156,6 +1163,10 @@ static int process_command_line(const int argc, char *argv[]) {
fflush(stderr);
break;

case OPTION_ID_LOCK_MODE_AUTOMATIC:
cb_default_select_lock_mode = COB_LOCK_AUTOMATIC;
break;

case '3': /* --constant */
if (optarg) {
cb_constant_list_add(optarg);
Expand Down
1 change: 1 addition & 0 deletions cobj/cobj.h
Original file line number Diff line number Diff line change
Expand Up @@ -383,4 +383,5 @@ extern int cb_verify(const enum cb_support tag, const char *feature);
extern int cb_flag_info_json;
extern char *cb_info_json_dir;

extern int cb_default_select_lock_mode;
#endif /* CB_COBC_H */
2,938 changes: 1,489 additions & 1,449 deletions cobj/parser.c

Large diffs are not rendered by default.

8 changes: 3 additions & 5 deletions cobj/parser.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* A Bison parser, made by GNU Bison 3.8.2. */
/* A Bison parser, made by GNU Bison 3.7.4. */

/* Bison interface for Yacc-like parsers in C

Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation,
Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2020 Free Software Foundation,
Inc.

This program is free software: you can redistribute it and/or modify
Expand All @@ -16,7 +16,7 @@
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
along with this program. If not, see <http://www.gnu.org/licenses/>. */

/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
Expand Down Expand Up @@ -515,8 +515,6 @@ typedef int YYSTYPE;

extern YYSTYPE yylval;


int yyparse (void);


#endif /* !YY_YY_PARSER_H_INCLUDED */
4 changes: 1 addition & 3 deletions cobj/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -5382,9 +5382,7 @@ read_statement:
CB_FILE(cb_ref ($3))->organization != COB_ORG_INDEXED)) {
current_statement->handler_id = COB_EC_I_O_PERMANENT_ERROR;
}
if ($7 && (CB_FILE(cb_ref ($3))->lock_mode & COB_LOCK_AUTOMATIC)) {
cb_error (_("LOCK clause invalid with file LOCK AUTOMATIC"));
} else if ($8 &&
if ($8 &&
(CB_FILE(cb_ref ($3))->organization != COB_ORG_RELATIVE &&
CB_FILE(cb_ref ($3))->organization != COB_ORG_INDEXED)) {
cb_error (_("KEY clause invalid with this file type"));
Expand Down
1 change: 1 addition & 0 deletions cobj/tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -1725,6 +1725,7 @@ struct cb_file *build_file(cb_tree name) {
p->access_mode = COB_ACCESS_SEQUENTIAL;
p->handler = CB_LABEL(cb_standard_error_handler);
p->handler_prog = current_program;
p->lock_mode = cb_default_select_lock_mode;
if (external_flg == 1) {
p->external_assign = 1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,10 +346,10 @@ public class CobolFile {
protected static final int COB_LOCK_MANUAL = 2;

/** TODO: 準備中 */
protected static final int COB_LOCK_AUTOMATIC = 3;
protected static final int COB_LOCK_AUTOMATIC = 4;

/** TODO: 準備中 */
protected static final int COB_LOCK_MULTIPLE = 1;
protected static final int COB_LOCK_MULTIPLE = 8;

/** TODO: 準備中 */
protected static final int COB_LOCK_MASK = 0x7;
Expand Down Expand Up @@ -1436,17 +1436,6 @@ public void read(AbstractCobolField key, AbstractCobolField fnstatus, int readOp
readOpts &= ~COB_READ_LOCK;
}

if (this.organization == COB_ORG_INDEXED /* && bdb_env != null */) {
if (this.open_mode != COB_OPEN_I_O || (this.lock_mode & COB_LOCK_EXCLUSIVE) != 0) {
readOpts &= ~COB_READ_LOCK;
} else if ((this.lock_mode & COB_LOCK_AUTOMATIC) != 0
&& (readOpts & COB_READ_NO_LOCK) == 0) {
readOpts |= COB_READ_LOCK;
}
} else {
readOpts &= ~COB_READ_LOCK;
}

int ret;
if (key != null) {
ret = this.read_(key, readOpts);
Expand Down
Loading
Loading