/ Block filter testing for IN operator on Column/Array operands. */ Here we call Find that returns true if the value is in the array */ with X equal to the index of the found value in the array, or */ false if the value is not in the array with Inf and Sup being the */ indexes of the array values that are immediately below and over */ the not found value. This enables to restrict th
| 834 | /* true or other. */ |
| 835 | /***********************************************************************/ |
| 836 | int ARRAY::BlockTest(PGLOBAL, int opc, int opm, |
| 837 | void *minp, void *maxp, bool s) |
| 838 | { |
| 839 | bool bin, bax, pin, pax, veq, all = (opm == 2); |
| 840 | |
| 841 | if (Ndif == 0) // Array is empty |
| 842 | // Return true for ALL because it means that there are no item that |
| 843 | // does not verify the condition, which is true indeed. |
| 844 | // Return false for ANY because true means that there is at least |
| 845 | // one item that verifies the condition, which is false. |
| 846 | return (all) ? 2 : -2; |
| 847 | else if (opc == OP_EQ && all && Ndif > 1) |
| 848 | return -2; |
| 849 | else if (opc == OP_NE && !all && Ndif > 1) |
| 850 | return 2; |
| 851 | // else if (Ndif == 1) |
| 852 | // all = false; |
| 853 | |
| 854 | // veq is true when all values in the block are equal |
| 855 | switch (Type) { |
| 856 | case TYPE_STRING: veq = (Vblp->IsCi()) |
| 857 | ? !stricmp((char*)minp, (char*)maxp) |
| 858 | : !strcmp((char*)minp, (char*)maxp); break; |
| 859 | case TYPE_SHORT: veq = *(short*)minp == *(short*)maxp; break; |
| 860 | case TYPE_INT: veq = *(int*)minp == *(int*)maxp; break; |
| 861 | case TYPE_DOUBLE: veq = *(double*)minp == *(double*)maxp; break; |
| 862 | default: veq = false; // Error ? |
| 863 | } // endswitch type |
| 864 | |
| 865 | if (!s) |
| 866 | Bot = -1; |
| 867 | |
| 868 | Top = Ndif; // Reset Top at top of list |
| 869 | Value->SetBinValue(maxp); |
| 870 | Top = (bax = Find(Value)) ? X + 1 : Sup; |
| 871 | |
| 872 | if (bax) { |
| 873 | if (opc == OP_EQ) |
| 874 | return (veq) ? 1 : 0; |
| 875 | else if (opc == OP_NE) |
| 876 | return (veq) ? -1 : 0; |
| 877 | |
| 878 | if (X == 0) switch (opc) { |
| 879 | // Max value is equal to min list value |
| 880 | case OP_LE: return 1; break; |
| 881 | case OP_LT: return (veq) ? -1 : 0; break; |
| 882 | case OP_GE: return (veq) ? 1 : 0; break; |
| 883 | case OP_GT: return -1; break; |
| 884 | } // endswitch opc |
| 885 | |
| 886 | pax = (opc == OP_GE) ? (X < Ndif - 1) : true; |
| 887 | } else if (Inf == Bot) { |
| 888 | // Max value is smaller than min list value |
| 889 | return (opc == OP_LT || opc == OP_LE || opc == OP_NE) ? 1 : -1; |
| 890 | } else |
| 891 | pax = (Sup < Ndif); // True if max value is inside the list value |
| 892 | |
| 893 | if (!veq) { |
no test coverage detected