Files
TheRock/rocm-systems/projects/rocprofiler-systems/external/sqlite/test/capi3b.test
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

146 lines
3.3 KiB
Plaintext

# 2004 September 2
#
# 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 file implements regression tests for SQLite library. The
# focus of this script testing the callback-free C/C++ API and in
# particular the behavior of sqlite3_step() when trying to commit
# with lock contention.
#
# $Id: capi3b.test,v 1.4 2007/08/10 19:46:14 drh Exp $
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# These tests depend on the pager holding changes in cache
# until it is time to commit. But that won't happen if the
# soft-heap-limit is set too low. So disable the soft heap limit
# for the duration of this test.
#
sqlite3_soft_heap_limit 0
set DB [sqlite3_connection_pointer db]
sqlite3 db2 test.db
set DB2 [sqlite3_connection_pointer db2]
# Create some data in the database
#
do_test capi3b-1.1 {
execsql {
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(1);
INSERT INTO t1 VALUES(2);
SELECT * FROM t1
}
} {1 2}
# Make sure the second database connection can see the data
#
do_test capi3b-1.2 {
execsql {
SELECT * FROM t1
} db2
} {1 2}
# First database connection acquires a shared lock
#
do_test capi3b-1.3 {
execsql {
BEGIN;
SELECT * FROM t1;
}
} {1 2}
# Second database connection tries to write. The sqlite3_step()
# function returns SQLITE_BUSY because it cannot commit.
#
do_test capi3b-1.4 {
set VM [sqlite3_prepare $DB2 {INSERT INTO t1 VALUES(3)} -1 TAIL]
sqlite3_step $VM
} SQLITE_BUSY
# The sqlite3_step call can be repeated multiple times.
#
do_test capi3b-1.5.1 {
sqlite3_step $VM
} SQLITE_BUSY
do_test capi3b-1.5.2 {
sqlite3_step $VM
} SQLITE_BUSY
# The first connection closes its transaction. This allows the second
# connections sqlite3_step to succeed.
#
do_test capi3b-1.6 {
execsql COMMIT
sqlite3_step $VM
} SQLITE_DONE
do_test capi3b-1.7 {
sqlite3_finalize $VM
} SQLITE_OK
do_test capi3b-1.8 {
execsql {SELECT * FROM t1} db2
} {1 2 3}
do_test capi3b-1.9 {
execsql {SELECT * FROM t1}
} {1 2 3}
# Start doing a SELECT with one connection. This gets a SHARED lock.
# Then do an INSERT with the other connection. The INSERT should
# not be able to complete until the SELECT finishes.
#
do_test capi3b-2.1 {
set VM1 [sqlite3_prepare $DB {SELECT * FROM t1} -1 TAIL]
sqlite3_step $VM1
} SQLITE_ROW
do_test capi3b-2.2 {
sqlite3_column_text $VM1 0
} 1
do_test capi3b-2.3 {
set VM2 [sqlite3_prepare $DB2 {INSERT INTO t1 VALUES(4)} -1 TAIL]
sqlite3_step $VM2
} SQLITE_BUSY
do_test capi3b-2.4 {
sqlite3_step $VM1
} SQLITE_ROW
do_test capi3b-2.5 {
sqlite3_column_text $VM1 0
} 2
do_test capi3b-2.6 {
sqlite3_step $VM2
} SQLITE_BUSY
do_test capi3b-2.7 {
sqlite3_step $VM1
} SQLITE_ROW
do_test capi3b-2.8 {
sqlite3_column_text $VM1 0
} 3
do_test capi3b-2.9 {
sqlite3_step $VM2
} SQLITE_BUSY
do_test capi3b-2.10 {
sqlite3_step $VM1
} SQLITE_DONE
do_test capi3b-2.11 {
sqlite3_step $VM2
} SQLITE_DONE
do_test capi3b-2.12 {
sqlite3_finalize $VM1
sqlite3_finalize $VM2
execsql {SELECT * FROM t1}
} {1 2 3 4}
catch {db2 close}
sqlite3_soft_heap_limit $cmdlinearg(soft-heap-limit)
finish_test