$PIECE() in a database trigger returns correct results when invoked from SimpleAPI
Final Release Note
$PIECE() in trigger logic invoked by ydb_set_s()
/ydb_set_st()
/ydb_incr_s()
/ydb_incr_st()
works correctly. Previously, such a $PIECE() invocation could return incorrect results. This was observed in the development / test environment and was never reported by a user. [#576 (closed)]
Description
This is an issue that was noticed Octo (see YottaDB/DBMS/YDBOcto!583 (comment 333919051) for details on the failed pipeline jobs). Octo uses the SimpleAPI to do database updates and has triggers installed for those updates. A $PIECE invocation inside the M trigger code returned incorrect results. Below are the details of that particular failure.
The M code that was invoked was the following.
SET newValue=$PIECE($ZTVALUE,$ZTDELIM,$ZTUPDATE)
And below is the value of the involved variables at the time of the above $PIECE invocation.
$ZTVALUE="LOTSOFCOLS|2200|16388|0|16385|0|16386|0|0|0|0|16389|1|0|p|r|3|0|0|1|0|0|0|0|0|1|d|0|571|1||||803051"
$ZTDELIM="|"
$ZTUPDATE=1
We therefore expect newValue
to be set to LOTSOFCOLS
. But instead it is set to LOTSOF
(this in turn results in an incorrect update to the ^%ydboctoxref global and in turn results in an incorrect output of a pg catalog query and the TC013 subtest validation routine catches this and fails the test).
This failure is seen only in Release builds. Never in Debug builds. Even with Release builds, this failure happens only rarely and only on some servers so it is most likely an uninitialized variable issue in the YDB code base.
Draft Release Note
ydb_set_s()/ydb_set_st()/ydb_incr_s()/ydb_incr_st() work correctly in case they update a global variable node and that update invokes a database trigger that in turn does $PIECE operations. Previously, such a $PIECE invocation could return incorrect results resulting in application integrity issues.