Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support collating sequence for indexed file keys of alphanumeric class #177

Open
wants to merge 6 commits into
base: gcos4gnucobol-3.x
Choose a base branch
from

Conversation

nberth
Copy link
Contributor

@nberth nberth commented Sep 12, 2024

  • Warn when a collating sequence is ignored for keys of indexed files
  • Use file collating sequence for any key of alphanumeric class

Before this change, only keys that were alphanumeric elementary items or numeric display were supported.

@nberth nberth force-pushed the indexed-key-colseq-for-alphanum-groups branch from 2acff2b to b33b98e Compare September 12, 2024 09:50
@nberth nberth force-pushed the indexed-key-colseq-for-alphanum-groups branch 2 times, most recently from 108a61b to 57b4fbc Compare September 12, 2024 10:11
Copy link
Collaborator

@GitMensch GitMensch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor changes requested, especially to the test cases and likely to a missing warning

cobc/tree.c Outdated Show resolved Hide resolved
cobc/tree.c Outdated
@@ -4721,6 +4721,15 @@ validate_indexed_key_field (struct cb_file *f, struct cb_field *records,
}
k = CB_FIELD_PTR (key_ref);

/* check collating sequence is not ignored */
if (f->collating_sequence != NULL &&
cbak == NULL && /* only if no alternate key is given (bit of hack for now) */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not checking the alternative keys in a loop as well? Aren't the collations used for those?
What about split keys?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finding a way to avoid emitting "too much" warnings for the file-level collating sequence seems a little tedious here.
Split keys appear to always be handled as alphanumerics (as per the code).

tests/testsuite.src/syn_file.at Outdated Show resolved Hide resolved
tests/testsuite.src/run_file.at Outdated Show resolved Hide resolved
tests/testsuite.src/run_file.at Outdated Show resolved Hide resolved
@nberth nberth force-pushed the indexed-key-colseq-for-alphanum-groups branch from 57b4fbc to 9be8442 Compare September 23, 2024 09:04
@GitMensch

This comment was marked as outdated.

@nberth nberth force-pushed the indexed-key-colseq-for-alphanum-groups branch 5 times, most recently from 8fcdfc1 to 511d25e Compare September 24, 2024 09:37
Before this change, only keys that were alphanumeric elementary items
or numeric display were supported.
@nberth nberth force-pushed the indexed-key-colseq-for-alphanum-groups branch from 511d25e to 56e6811 Compare September 24, 2024 09:59
@ddeclerck
Copy link
Contributor

Looks like this could be merged ; is anything missing here @GitMensch ?

Copy link
Collaborator

@GitMensch GitMensch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering: don't we need a --without-db and --with-vbisam setup in the workflow to verify the tests work as expected in those environments?

tests/testsuite.src/run_file.at Outdated Show resolved Hide resolved
# This is, so far, only supported by the BDB backend
AT_CHECK([test "$COB_HAS_ISAM" = "db"], [0], [], [],
# Previous test "failed" --> other ISAM, skip the test
[AT_CHECK([true])],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be XFAIL?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get an "UNEXPECTED PASS" when if I add an AT_XFAIL_IF([true]) here and when I configure --with-db.
I'm guessing AT_XFAIL_IF may not be a regular autotest macro that just does in-place shell-script expansion.

We could just turn the non-db case into a somewhat "artificial" expected failure with:

AT_XFAIL_IF([test "$COB_HAS_ISAM" != "db"])
AT_CHECK([test "$COB_HAS_ISAM" = "db"], [0], [], [],
# Previous test "failed" --> other ISAM, fail the test
[AT_CHECK([false])],

… but that may be a bit strange to do it like this.

Side note: the version of VBISAM I found here for testing this required to #define vbisam_off_t off_t in vbisam.h to compile properly.

cobc/tree.c Outdated
Comment on lines 4795 to 4796
_("COLLATING SEQUENCE is ignored for non-alphanumeric"
" key '%s'"), k->name);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should use a cb_tree pos and set it depending on which colseq is used - if it is from the key - use that as pos, if it is from the file use k as pos.
Maybe the name of the collation should be included in this diagnostic as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done and improved with a KEY or FILE prefix to better show what kind of key is ignored.

Comment on lines 727 to 732
[prog.cob:33: warning: handling of FILE COLLATING SEQUENCE is unfinished; implementation is likely to be changed
prog.cob:33: warning: handling of KEY COLLATING SEQUENCE is unfinished; implementation is likely to be changed
prog.cob:39: warning: handling of FILE COLLATING SEQUENCE is unfinished; implementation is likely to be changed
prog.cob:39: warning: handling of KEY COLLATING SEQUENCE is unfinished; implementation is likely to be changed
prog.cob:46: warning: handling of FILE COLLATING SEQUENCE is unfinished; implementation is likely to be changed
prog.cob:46: warning: handling of KEY COLLATING SEQUENCE is unfinished; implementation is likely to be changed
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we have two diagnostics on the same line?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was parser-related; I've included a fix.

@ddeclerck
Copy link
Contributor

Wondering: don't we need a --without-db and --with-vbisam setup in the workflow to verify the tests work as expected in those environments?

Last time I checked VBISAM with 3.x (was a while ago), there were testsuite failures.

@GitMensch
Copy link
Collaborator

Last time I checked VBISAM with 3.x (was a while ago), there were testsuite failures.

That would be unrelated to a --without-db --without-curses --without-xml2 --without-json build :-)

But even with a set of failures (even the NEWS file says that depending on the version of vbisam used there will be some unexpected passes and failures and will do so until we have a V-ISAM version released) this gets "only" down to working it out - we tinker the MSYS2 and MSVC builds for some testsuite expectations in GitHub CI as well - and this does help to catch any new issues that arise (and may also show some positive side effects we otherwise don't catch).
Note: I'm not planning to adjust any test expectations specific for VBISAM in GnuCOBOL 3.3 but the "no isam" and "not bdb" ones should definitely work.

@GitMensch
Copy link
Collaborator

GitMensch commented Sep 27, 2024

I'm taking on the "minimal build" and send a PR for that (this should pass here in any case) --> #184 and would let the vbisam part optional to you.

@ddeclerck
Copy link
Contributor

Last time I checked VBISAM with 3.x (was a while ago), there were testsuite failures.

That would be unrelated to a --without-db --without-curses --without-xml2 --without-json build :-)

Sure, but you mentionned --with-vbisam :-)

@nberth nberth force-pushed the indexed-key-colseq-for-alphanum-groups branch from 2a365a5 to 0be00c2 Compare September 27, 2024 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants