debugging 带有SQLITE_DEBUG的sqlite编译选项

tcomlyy6  于 2022-11-14  发布在  SQLite
关注(0)|答案(1)|浏览(211)

Recently I'm working with SQLite and want to enable debugging during compiling.
I use the latest version of SQLite, which is 3.39.0
However, no matter how I tried, I couldn't enable it. I will list the options that I have tried:
I download the source code of SQLite, then I tried the following method

  1. modify the Makefile
mkdir bld
cd bld
../configure

them I manually modify the Makefile , add the following statement:

TCC += -DSQLITE_DEBUG=2
TCC += -DSQLITE_ENABLE_EXPLAIN_COMMENTS

I also deleted this:

TCC += -DNDEBUG

them I run:

make

but got nothing.

  1. using CFLAGS='-DSQLITE_DEBUG' I use this statement during the configure command:
../configure CFLAGS='-DSQLITE_DEBUG'

then:

make clean
make

but invalid

  1. using export CFLAGS='-DSQLITE_DEBUG'
export CFLAGS='-DSQLITE_DEBUG'
../configure
make clean
make

still got nothing.
Notice that I use 2 ways to check if I enable the SQLITE_DEBUG

  1. running the following code:
for(int i = 0; i< 100; i++){
        if(sqlite3_compileoption_get(i) != NULL){
            printf(sqlite3_compileoption_get(i));
            printf("\n");
        }
    }

output:

ATOMIC_INTRINSICS=1
COMPILER=gcc-8.4.0
DEFAULT_AUTOVACUUM
DEFAULT_CACHE_SIZE=-2000
DEFAULT_FILE_FORMAT=4
DEFAULT_JOURNAL_SIZE_LIMIT=-1
DEFAULT_MMAP_SIZE=0
DEFAULT_PAGE_SIZE=4096
DEFAULT_PCACHE_INITSZ=20
DEFAULT_RECURSIVE_TRIGGERS
DEFAULT_SECTOR_SIZE=4096
DEFAULT_SYNCHRONOUS=2
DEFAULT_WAL_AUTOCHECKPOINT=1000
DEFAULT_WAL_SYNCHRONOUS=2
DEFAULT_WORKER_THREADS=0
MALLOC_SOFT_LIMIT=1024
MAX_ATTACHED=10
MAX_COLUMN=2000
MAX_COMPOUND_SELECT=500
MAX_DEFAULT_PAGE_SIZE=8192
MAX_EXPR_DEPTH=1000
MAX_FUNCTION_ARG=127
MAX_LENGTH=1000000000
MAX_LIKE_PATTERN_LENGTH=50000
MAX_MMAP_SIZE=0x7fff0000
MAX_PAGE_COUNT=1073741823
MAX_PAGE_SIZE=65536
MAX_SQL_LENGTH=1000000000
MAX_TRIGGER_DEPTH=1000
MAX_VARIABLE_NUMBER=32766
MAX_VDBE_OP=250000000
MAX_WORKER_THREADS=8
MUTEX_PTHREADS
SYSTEM_MALLOC
TEMP_STORE=1
THREADSAFE=1

I couldn't see the definition of SQLITE_DEBUG

  1. manually run SQL script
CREATE TABLE testtb(name varchar(10), age int);
insert into testtb values ("zhang",10);
select * from testtb;
select sum(age) from testtb;
drop table testtb;
EXPLAIN CREATE TABLE testtb(name varchar(10), age int);

No additional information.

von4xj4u

von4xj4u1#

我是sqlite3的新手,我读了official documentation,试着在Ubuntu的gcc-11.2上用-DSQLITE_DEBUG编译,然后就成功了。
就像这样:

gcc shell.c sqlite3.c -lpthread -ldl -lm -DSQLITE_DEBUG -o sqlite3

result pic
您不需要修改Makefile,并且应该在编译后显示错误消息。

相关问题