Test unusable constraints

This commit is contained in:
Colin Dellow 2018-03-10 13:38:34 -05:00
parent 96fcafcd2f
commit d28ae86d15
2 changed files with 15 additions and 7 deletions

View File

@ -279,14 +279,15 @@ static int parquetEof(sqlite3_vtab_cursor *cur){
void debugConstraints(sqlite3_index_info *pIdxInfo, ParquetTable *table, int argc, sqlite3_value** argv) { void debugConstraints(sqlite3_index_info *pIdxInfo, ParquetTable *table, int argc, sqlite3_value** argv) {
printf("debugConstraints, argc=%d\n", argc); printf("debugConstraints, argc=%d\n", argc);
int j = 0;
for(int i = 0; i < pIdxInfo->nConstraint; i++) { for(int i = 0; i < pIdxInfo->nConstraint; i++) {
std::string valueStr = "?"; std::string valueStr = "?";
if(argv != NULL) { if(argv != NULL && pIdxInfo->aConstraint[i].usable) {
int type = sqlite3_value_type(argv[i]); int type = sqlite3_value_type(argv[j]);
switch(type) { switch(type) {
case SQLITE_INTEGER: case SQLITE_INTEGER:
{ {
sqlite3_int64 rv = sqlite3_value_int64(argv[i]); sqlite3_int64 rv = sqlite3_value_int64(argv[j]);
std::ostringstream ss; std::ostringstream ss;
ss << rv; ss << rv;
valueStr = ss.str(); valueStr = ss.str();
@ -294,7 +295,7 @@ void debugConstraints(sqlite3_index_info *pIdxInfo, ParquetTable *table, int arg
} }
case SQLITE_FLOAT: case SQLITE_FLOAT:
{ {
double rv = sqlite3_value_double(argv[i]); double rv = sqlite3_value_double(argv[j]);
std::ostringstream ss; std::ostringstream ss;
ss << rv; ss << rv;
valueStr = ss.str(); valueStr = ss.str();
@ -302,7 +303,7 @@ void debugConstraints(sqlite3_index_info *pIdxInfo, ParquetTable *table, int arg
} }
case SQLITE_TEXT: case SQLITE_TEXT:
{ {
const unsigned char* rv = sqlite3_value_text(argv[i]); const unsigned char* rv = sqlite3_value_text(argv[j]);
std::ostringstream ss; std::ostringstream ss;
ss << "'" << rv << "'"; ss << "'" << rv << "'";
valueStr = ss.str(); valueStr = ss.str();
@ -310,7 +311,7 @@ void debugConstraints(sqlite3_index_info *pIdxInfo, ParquetTable *table, int arg
} }
case SQLITE_BLOB: case SQLITE_BLOB:
{ {
int sizeBytes = sqlite3_value_bytes(argv[i]); int sizeBytes = sqlite3_value_bytes(argv[j]);
std::ostringstream ss; std::ostringstream ss;
ss << "'..." << sizeBytes << "-byte blob...'"; ss << "'..." << sizeBytes << "-byte blob...'";
valueStr = ss.str(); valueStr = ss.str();
@ -322,6 +323,7 @@ void debugConstraints(sqlite3_index_info *pIdxInfo, ParquetTable *table, int arg
break; break;
} }
} }
j++;
} }
printf(" constraint %d: col %s %s %s, usable %d\n", printf(" constraint %d: col %s %s %s, usable %d\n",
i, i,
@ -372,8 +374,12 @@ static int parquetBestIndex(
} else { } else {
pIdxInfo->estimatedCost = 1; pIdxInfo->estimatedCost = 1;
pIdxInfo->idxNum = 1; pIdxInfo->idxNum = 1;
int j = 0;
for(int i = 0; i < pIdxInfo->nConstraint; i++) { for(int i = 0; i < pIdxInfo->nConstraint; i++) {
pIdxInfo->aConstraintUsage[i].argvIndex = i + 1; if(pIdxInfo->aConstraint[i].usable) {
j++;
pIdxInfo->aConstraintUsage[i].argvIndex = j;
}
} }
// TODO: consider setting this when querying by rowid? Unclear if that's implied. // TODO: consider setting this when querying by rowid? Unclear if that's implied.

View File

@ -0,0 +1,2 @@
select nn1.int8_1 from no_nulls1 nn1 join no_nulls2 nn2 using (int8_1) where nn1.int8_1 = 0;
0