Skip to content

[#10] [NARS] [estess] Implement $query(glvn,-1) aka reverse $query; fixes #10

Narayanan Iyer requested to merge nars1:reverse_query into master

…; Fix $query(gvn) to avoid infinite loops with null subscripts & GT.M Null Collation

Release Note

$query(glvn,-1) returns the previous subscripted local or global variable node name, independent of level, which follows the node specified by its argument in M collating sequence and has a data value. That is, if $query(glvn1) returns glvn2, then $query(glvn2,-1) should return glvn1. (#10 (closed))

$query(gvn) works correctly in case the global corresponding to gvn has nodes with null subscripts and the database has Standard Null Collation set to FALSE (i.e. GT.M Null Collation is in effect). Previously, this would result in infinite loops. (#10 (closed))

Messages & Recovery Manual

A QUERY2 error is issued when $query(gvn,dir) is invoked with dir not evaluating to a -1 or 1 (the only permissible values).

Test

  • New automated r100/reversequery subtest to exercise $query(gvn,-1) and $query(lvn,-1).
  • Manually tested $query(gvn,-1) across GTCM GNP server. Will add automated test later when multi-host testing is possible.
  • E_ALL run many times to ensure no regressions.

README

$QUERY, which was until now a 1-operand function, becomes a 2-operand function due to the addition of the direction parameter. This meant a lot of changes in the compiler (particularly f_query.c). Added complications were the need to handle side-effects as well as the naked indicator with the additional direction parameter. A lot of this implementation was based on $ORDER which also allowed for an optional 2nd direction parameter.

New opcodes were added to ttt.txt and ttt.c was therefore regenerated.

Since new opcodes were added, the object file format was bumped in objlabel.h.

While implementing $query(gvn,-1), it was not clear what purpose there was to a block of code in gvcst_query.c and so that was removed.

TREF(last_gvquery_key) remembers the node returned from the last $query(gvn) operation if that node had a null subscript as the last subscript. The next time a $query(gvn) is done, this TREF is used to check if it is the same as the input key and if so the null subscript is not handled specially i.e. it does not imply the first subscript in case of $query(gvn,1) or last subscript in case of $query(gvn,-1). This avoids infinite $query loops. This was modeled on TREF(last_fnquery*) which already existed for lvn.

$query(gvn,-1) also works across from a GT.CM GNP client. Since the GT.CM GNP server now supports a new feature, its protocol level was bumped up in gtcm_release_name.c.

In addition there were a few miscellaneous fixes

  • msg.m (used to regenerate merrors_ctl.c from merrors.msg) had to be fixed to handle just one year in copyright.txt
  • configure.gtc and gtminstall.sh were enhanced to stop processing in case of errors (known benign error scenarios were handled by temporarily suspending set -e and using a subshell + exit 0 return from subshell).

Merge request reports