gitlab.com/CoiaPrant/sqlite3@v1.19.1/testdata/tcl/vtabrhs1.test (about)

     1  # 2022-01-20
     2  #
     3  # The author disclaims copyright to this source code.  In place of
     4  # a legal notice, here is a blessing:
     5  #
     6  #    May you do good and not evil.
     7  #    May you find forgiveness for yourself and forgive others.
     8  #    May you share freely, never taking more than you give.
     9  #
    10  #***********************************************************************
    11  # 
    12  # This file implements tests for sqlite3_vtab_rhs_value() interface.
    13  #
    14  
    15  set testdir [file dirname $argv0]
    16  source $testdir/tester.tcl
    17  set testprefix vtabrhs1
    18  
    19  ifcapable !vtab {
    20    finish_test
    21    return
    22  }
    23  load_static_extension db qpvtab
    24  
    25  # EVIDENCE-OF: R-60223-49197 When the sqlite3_vtab_rhs_value(P,J,V)
    26  # interface is invoked from within the xBestIndex method of a virtual
    27  # table implementation, with P being a copy of the sqlite3_index_info
    28  # object pointer passed into xBestIndex and J being a 0-based index into
    29  # P->aConstraint[], then this routine attempts to set *V to the value
    30  # of the right-hand operand of that constraint if the right-hand operand
    31  # is known.
    32  #
    33  do_execsql_test 1.1 {
    34    SELECT rhs FROM qpvtab
    35     WHERE cn='a'
    36       AND a=12345
    37  } {12345}
    38  do_execsql_test 1.2 {
    39    SELECT rhs FROM qpvtab
    40     WHERE cn='a'
    41       AND a<>4.5
    42  } {4.5}
    43  do_execsql_test 1.3 {
    44    SELECT rhs FROM qpvtab
    45     WHERE cn='a'
    46       AND 'quokka' < a
    47  } {'quokka'}
    48  do_execsql_test 1.4 {
    49    SELECT rhs FROM qpvtab
    50     WHERE cn='a'
    51       AND a IS NULL
    52  } {{}}
    53  do_execsql_test 1.5 {
    54    SELECT rhs FROM qpvtab
    55     WHERE cn='a'
    56       AND a GLOB x'0123'
    57  } {x'0123'}
    58  
    59  # EVIDENCE-OF: R-37799-62852 If the right-hand operand is not known,
    60  # then *V is set to a NULL pointer.
    61  #
    62  do_execsql_test 2.1 {
    63    SELECT typeof(rhs) FROM qpvtab WHERE cn='a' AND a=format('abc');
    64  } {null}
    65  do_execsql_test 2.2 {
    66    SELECT typeof(rhs) FROM qpvtab WHERE cn='a' AND a=?2
    67  } {null}
    68  
    69  # EVIDENCE-OF: R-14553-25174 When xBestIndex returns, the sqlite3_value
    70  # object returned by sqlite3_vtab_rhs_value() is automatically
    71  # deallocated.
    72  #
    73  # Where this not the case, the following "finish_test" statement would
    74  # report a memory leak.
    75  #
    76  finish_test