# 2025 October 13
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
#
# This test is focused on really large position lists. Those that require
# 4 or 5 byte position-list size varints. Because of the amount of memory
# required, these tests only run on 64-bit platforms.
#

source [file join [file dirname [info script]] fts5_common.tcl]
set testprefix fts5corruptbig

# If SQLITE_ENABLE_FTS5 is not defined, omit this file.
ifcapable !fts5 {
  finish_test
  return
}

if { $tcl_platform(wordSize)<8 } {
  finish_test
  return
}

if { $SQLITE_MAX_LENGTH!=0x7FFFFFFF } {
  finish_test
  return
}

do_execsql_test 1.0 { 
  CREATE VIRTUAL TABLE t1 USING fts5(x);
}

do_execsql_test 1.1 { 
  UPDATE t1_data SET block = zeroblob(2147483640) WHERE id=10;
}

do_execsql_test 1.2 { 
  SELECT id, length(block) FROM t1_data
} {1 0 10 2147483640}

do_catchsql_test 1.3 {
  SELECT * FROM t1('abc')
} {1 {out of memory}}

finish_test

