SQLite

Check-in [bc516ff5]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix the xBestIndex method of the pragma virtual table so that it correctly gives a higher cost to plans where the schema hidden parameter is unconstrained. Fix for the problem reported by forum post 85b6a8b6705fb77a.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: bc516ff5202ee6e9834266bf755fe26e30ac557dcc7975ca7a06dfe33874fcd2
User & Date: drh 2024-03-24 21:10:45
Context
2024-03-25
00:38
Improvements to the vtablog.c extension, for better logging of virtual table interactions. (check-in: e253bb36 user: drh tags: trunk)
2024-03-24
21:18
Fix the xBestIndex method of the pragma virtual table so that it correctly gives a higher cost to plans where the schema hidden parameter is unconstrained. (check-in: ec791413 user: drh tags: branch-3.45)
21:15
Fix the xBestIndex method of the pragma virtual table so that it correctly gives a higher cost to plans where the schema hidden parameter is unconstrained. (check-in: d68fb8b5 user: drh tags: branch-3.44)
21:10
Fix the xBestIndex method of the pragma virtual table so that it correctly gives a higher cost to plans where the schema hidden parameter is unconstrained. Fix for the problem reported by forum post 85b6a8b6705fb77a. (check-in: bc516ff5 user: drh tags: trunk)
20:26
Improved "wheretrace" debugging output for calls to xBestIndex. No changes to release code. (check-in: 33966bb0 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/pragma.c.
2881
2882
2883
2884
2885
2886
2887
2888




2889
2890
2891
2892
2893
2894
2895
    pIdxInfo->estimatedCost = (double)2147483647;
    pIdxInfo->estimatedRows = 2147483647;
    return SQLITE_OK;
  }
  j = seen[0]-1;
  pIdxInfo->aConstraintUsage[j].argvIndex = 1;
  pIdxInfo->aConstraintUsage[j].omit = 1;
  if( seen[1]==0 ) return SQLITE_OK;




  pIdxInfo->estimatedCost = (double)20;
  pIdxInfo->estimatedRows = 20;
  j = seen[1]-1;
  pIdxInfo->aConstraintUsage[j].argvIndex = 2;
  pIdxInfo->aConstraintUsage[j].omit = 1;
  return SQLITE_OK;
}







|
>
>
>
>







2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
    pIdxInfo->estimatedCost = (double)2147483647;
    pIdxInfo->estimatedRows = 2147483647;
    return SQLITE_OK;
  }
  j = seen[0]-1;
  pIdxInfo->aConstraintUsage[j].argvIndex = 1;
  pIdxInfo->aConstraintUsage[j].omit = 1;
  if( seen[1]==0 ){
    pIdxInfo->estimatedCost = (double)1000;
    pIdxInfo->estimatedRows = 1000;
    return SQLITE_OK;
  }
  pIdxInfo->estimatedCost = (double)20;
  pIdxInfo->estimatedRows = 20;
  j = seen[1]-1;
  pIdxInfo->aConstraintUsage[j].argvIndex = 2;
  pIdxInfo->aConstraintUsage[j].omit = 1;
  return SQLITE_OK;
}
Changes to test/pragma4.test.
260
261
262
263
264
265
266












267
268
     , c DEFAULT +4.0 /* another comment */
  );
  PRAGMA table_info = t4;
} {
  0 a {} 0 'abc' 0 1 b {} 0 -1 0 2 c {} 0 +4.0 0
}














finish_test







>
>
>
>
>
>
>
>
>
>
>
>


260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
     , c DEFAULT +4.0 /* another comment */
  );
  PRAGMA table_info = t4;
} {
  0 a {} 0 'abc' 0 1 b {} 0 -1 0 2 c {} 0 +4.0 0
}

# 2024-03-24 https://sqlite.org/forum/forumpost/85b6a8b6705fb77a
#
reset_db
do_execsql_test 6.0 {
  CREATE TABLE t1(a INT PRIMARY KEY, b INT);
  CREATE TABLE t2(c INT PRIMARY KEY, d INT REFERENCES t1);
  SELECT t.name, f."table", f."from", i.name, i.pk
    FROM pragma_table_list() AS t
         JOIN pragma_foreign_key_list(t.name, t.schema) AS f
         JOIN pragma_table_info(f."table", t.schema) AS i
   WHERE i.pk;
} {t2 t1 d a 1}

finish_test