-
Ole John Aske authored
When retrieving a SPJ result, which should be returned in sorted order as available from an ordered index, we need to merge results retrieved from the fragments. If the sorted index is specified over multiple columns, and the query only select and/or 'order by' on a leading subset of these columns, the index may still be used to provide sorted result order for this subset. The fragment sort-merge used the compare_ndbrecord() function to compare two records from different fragments. However, this function assumed that all columns from the sorted index was retrieved and present in the 'result_records'. For any non-present column it effectively compared non defined data, potentially causing the reported require to fail in the compare methods. This patch introduce the usage of the bitmask 'result_mask' which hold information about which columns being defined in the 'result_record'. compare_ndbrecord() is enhanced such that it returns when it has compared all the 'valid' columns from the ordered index preent in the 'result_record'. Note that compare_ndbrecord() is also used when reading sorted result from a non-pushed table access, using a sorted NdbIndexScanOperation. However, for this use case the NdbIndexScanOperation will add any non specified index column to the specified set of columns to retrieve - effectively retrieving more columns then first specified. Ww could probably have eliminated this by using the specified 'result_mask' in this case as well. However, that would have changed the behaviour of a already public interface (As opposed to the NdbQuery interface) so we leave that for another bug report. Patch also remove declaration of compare_ndbrecord() from the public API header file storage/ndb/include/ndbapi/NdbIndexScanOperation.hpp. Declaration is already available in the 'friend' declarion NdbReceiver.hpp. Reviewed by: Frazer Clement <frazer.clement@oracle.com> (cherry picked from commit 49b3eaea2bf1901cbe7c774fd9553c4a22dc061d)
Ole John Aske authoredWhen retrieving a SPJ result, which should be returned in sorted order as available from an ordered index, we need to merge results retrieved from the fragments. If the sorted index is specified over multiple columns, and the query only select and/or 'order by' on a leading subset of these columns, the index may still be used to provide sorted result order for this subset. The fragment sort-merge used the compare_ndbrecord() function to compare two records from different fragments. However, this function assumed that all columns from the sorted index was retrieved and present in the 'result_records'. For any non-present column it effectively compared non defined data, potentially causing the reported require to fail in the compare methods. This patch introduce the usage of the bitmask 'result_mask' which hold information about which columns being defined in the 'result_record'. compare_ndbrecord() is enhanced such that it returns when it has compared all the 'valid' columns from the ordered index preent in the 'result_record'. Note that compare_ndbrecord() is also used when reading sorted result from a non-pushed table access, using a sorted NdbIndexScanOperation. However, for this use case the NdbIndexScanOperation will add any non specified index column to the specified set of columns to retrieve - effectively retrieving more columns then first specified. Ww could probably have eliminated this by using the specified 'result_mask' in this case as well. However, that would have changed the behaviour of a already public interface (As opposed to the NdbQuery interface) so we leave that for another bug report. Patch also remove declaration of compare_ndbrecord() from the public API header file storage/ndb/include/ndbapi/NdbIndexScanOperation.hpp. Declaration is already available in the 'friend' declarion NdbReceiver.hpp. Reviewed by: Frazer Clement <frazer.clement@oracle.com> (cherry picked from commit 49b3eaea2bf1901cbe7c774fd9553c4a22dc061d)
Loading