SQLite

Check-in [1c0b0345]
Login

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

Overview
Comment:Avoid slowdown when exprNodeIsConstant() is called on deeply nested SQL functions.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 1c0b0345451853846076467831884f951c92ec79476be40ce7f7b766fd2d8fc1
User & Date: dan 2024-04-24 11:40:47
Context
2024-04-24
11:51
Add comments linking the assert() added in [cef4d9e3ba586735] to the places where the precondition that the assert() tests are actually required. (check-in: 6f0e7e19 user: drh tags: trunk)
11:40
Avoid slowdown when exprNodeIsConstant() is called on deeply nested SQL functions. (check-in: 1c0b0345 user: dan tags: trunk)
11:21
Ensure that temporary SrcItem objects created by trigger processing have either SrcItem.zName or SrcItem.pSelect defined. Every SrcItem should have one or the other. (check-in: cef4d9e3 user: drh tags: trunk)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/expr.c.

2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
   || pDef->xFinalize!=0
   || (pDef->funcFlags & (SQLITE_FUNC_CONSTANT|SQLITE_FUNC_SLOCHNG))==0
   || ExprHasProperty(pExpr, EP_WinFunc)
  ){
    pWalker->eCode = 0;
    return WRC_Abort;
  }
  return WRC_Continue;
}


/*
** These routines are Walker callbacks used to check expressions to
** see if they are "constant" for some definition of constant.  The
** Walker.eCode value determines the type of "constant" we are looking







|







2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
   || pDef->xFinalize!=0
   || (pDef->funcFlags & (SQLITE_FUNC_CONSTANT|SQLITE_FUNC_SLOCHNG))==0
   || ExprHasProperty(pExpr, EP_WinFunc)
  ){
    pWalker->eCode = 0;
    return WRC_Abort;
  }
  return WRC_Prune;
}


/*
** These routines are Walker callbacks used to check expressions to
** see if they are "constant" for some definition of constant.  The
** Walker.eCode value determines the type of "constant" we are looking

Changes to test/func2.test.

503
504
505
506
507
508
509























510
511
  set blob [execsql "SELECT SUBSTR(x'1234', 2, -1)"]
  bin_to_hex [lindex $blob 0]
} "12"
do_test func2-3.9.2 {
  set blob [execsql "SELECT SUBSTR(x'1234', 2, -2)"]
  bin_to_hex [lindex $blob 0]
} "12"
























finish_test







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


503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
  set blob [execsql "SELECT SUBSTR(x'1234', 2, -1)"]
  bin_to_hex [lindex $blob 0]
} "12"
do_test func2-3.9.2 {
  set blob [execsql "SELECT SUBSTR(x'1234', 2, -2)"]
  bin_to_hex [lindex $blob 0]
} "12"

#-------------------------------------------------------------------------
# At one point this was extremely slow to compile.
#
do_test func2-3.10 {
  set tm [time {
    execsql {
      SELECT '' IN (zerobloB(zerobloB(zerobloB(zerobloB(zerobloB(
      zerobloB(zerobloB(zerobloB(zerobloB(zerobloB(zerobloB(zerobloB(
      zerobloB(zerobloB(zerobloB(zerobloB(zerobloB(zerobloB(zerobloB(
      zerobloB(zerobloB(zerobloB(zerobloB(zerobloB(zerobloB(zerobloB(
      zerobloB(zerobloB(zerobloB(zerobloB(zerobloB(zerobloB(zerobloB(
      zerobloB(zerobloB(zerobloB(zerobloB(zerobloB(zerobloB(zerobloB(
      zerobloB(zerobloB(zerobloB(zerobloB(zerobloB(zerobloB(zerobloB(
      zerobloB(zerobloB(zerobloB(zerobloB(zerobloB(zerobloB(zerobloB(
      zerobloB(zerobloB(zerobloB(zerobloB(zerobloB(zerobloB(zerobloB(1)
      )))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
  }
  }]

  set tm [lindex $tm 0]
  expr $tm<2000000
} {1}

finish_test