XREFDATA^%YDBAIM continues cross referencing after first value of lowest level subscript if xsub has range (:) syntax with empty range-end

Final Release Note

XREFDATA^%YDBAIM continues cross referencing after first value of lowest level subscript if xsub has range (:) syntax with empty range-end.

Previously, when cross referencing the lowest level subscript, if a range is specified without an end, e.g., 2:, the logic for processes scanning nodes in ascending order would have terminated the loop if the actual subscript collated after the empty string. This would cause it to terminate after the first value. The logic for higher level subscripts was correct The bug was intermittent, because sometimes the process scanning nodes in the reverse direction would cross reference those nodes. But sometimes, the process scanning in ascending order would conclude that that it was done with its cross referencing, and terminate the process scanning in the descending order. In this latter case, there would be missing cross references. [#72 (closed)]

Description

This is a longstanding issue in YDBAIM that I noticed while trying to write test cases for YottaDB/DBMS/YDBOcto#959 (closed). Below is a simple test case that demonstrates the issue.

$ cat test.m
 write "# Setting 5 nodes ^x(1) to ^x(5) all to same value [abcd|efgh]",!
 kill ^x
 for i=1:1:5 set ^x(i)="abcd|efgh"
 for opt="2:4","2:" do
 . write !,"# Trying $$XREFDATA^%YDBAIM with subs(1)=",opt,!
 . DO UNXREFDATA^%YDBAIM
 . set subs(1)=opt
 . set xref=$$XREFDATA^%YDBAIM("^x",.subs,"|",1)
 . write "# Doing ZWRITE of xref global to see how many rows got cross referenced",!
 . write "# Expecting to see 3 rows of output",!
 . zwrite @xref@(1,"abcd",*)
 quit

And below is the output of the above M program.

$ yottadb -run test
# Setting 5 nodes ^x(1) to ^x(5) all to same value [abcd|efgh]

# Trying $$XREFDATA^%YDBAIM with subs(1)=2:4
# Doing ZWRITE of xref global to see how many rows got cross referenced
# Expecting to see 3 rows of output
^%ydbAIMDhpgwKj2LWAjID42l3ZvGE3(1,"abcd",2)=""
^%ydbAIMDhpgwKj2LWAjID42l3ZvGE3(1,"abcd",3)=""
^%ydbAIMDhpgwKj2LWAjID42l3ZvGE3(1,"abcd",4)=""

# Trying $$XREFDATA^%YDBAIM with subs(1)=2:
# Doing ZWRITE of xref global to see how many rows got cross referenced
# Expecting to see 3 rows of output
^%ydbAIMD6ymUDxBsvlFG8siwwpQz10(1,"abcd",2)=""

Notice that when subs(1) was set to 2:4, I see 3 rows of cross referenced output as expected. But when subs(1) was set to 2:, I only see 1 row of output whereas I expect 3 rows even in that case.

Initial Release Note

Edited by K.S. Bhaskar