Re: [sqlite] How to compile sqlite with gcov support?

2020-02-18 Thread Xingwei Lin
When I deleted the --enable-debug flag, the .gcno file can be generated.

Not sure why the --enable-debug flag will influence gcov compilation.

On Tue, Feb 18, 2020 at 3:16 PM Xingwei Lin  wrote:

> Hi,
>
> I decompressed the sqlite-autoconf-3310100.tar.gz and compiled it with the
> following commands:
>
> ```
> cd sqlite-autoconf-3310100
> CFLAGS="-g -ftest-coverage -fprofile-arcs" ./configure --enable-fts3
> --enable-debug --enable-session
> make -j$(nproc)
> ```
>
> But when I completed the building process, I didn't find the .gcno file.
> And when I execute sqlite3, it also didn't occur the  .gcda files.
>
> --
> Best regards,
> Xingwei Lin
>


-- 
Best regards,
Xingwei Lin
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] How to compile sqlite with gcov support?

2020-02-17 Thread Xingwei Lin
Hi,

I decompressed the sqlite-autoconf-3310100.tar.gz and compiled it with the
following commands:

```
cd sqlite-autoconf-3310100
CFLAGS="-g -ftest-coverage -fprofile-arcs" ./configure --enable-fts3
--enable-debug --enable-session
make -j$(nproc)
```

But when I completed the building process, I didn't find the .gcno file.
And when I execute sqlite3, it also didn't occur the  .gcda files.

-- 
Best regards,
Xingwei Lin
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] how to disable dot commands?

2020-01-12 Thread Xingwei Lin
I like this answer!! I think I think it's the easiest way.

On Mon, Jan 13, 2020 at 10:22 AM Keith Medcalf  wrote:

>
> On Sunday, 12 January, 2020 18:44, Xingwei Lin 
> wrote:
>
> >Is there any way can we disable the dot commands feature in sqlite?
>
> SQLite does not process dot commands, they are commands to the shell.c
> SQLite Application program.
>
> The current shell.c application currently does not have a way to omit the
> meta commands.
>
> However, if you build your own you can simply search shell.c (or
> shell.c.in) for the function do_meta_command function definition and have
> it execute a "return 0;" at the top of the function after the variable
> declarations rather that process the meta command.  This will not remove
> the code that handles the meta commands but merely bypass the processing of
> them.
>
> That is make it look thusly by inserting the return 0; line:
>
> /*
> ** If an input line begins with "." then invoke this routine to
> ** process that line.
> **
> ** Return 1 on error, 2 to exit, and 0 otherwise.
> */
> static int do_meta_command(char *zLine, ShellState *p){
>   int h = 1;
>   int nArg = 0;
>   int n, c;
>   int rc = 0;
>   char *azArg[52];
>
>   return 0;
>
> #ifndef SQLITE_OMIT_VIRTUALTABLE
>   if( p->expert.pExpert ){
> expertFinish(p, 1, 0);
>   }
> #endif
>
> --
> The fact that there's a Highway to Hell but only a Stairway to Heaven says
> a lot about anticipated traffic volume.
>
>
>
>
> _______
> sqlite-users mailing list
> sqlite-users@mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>


-- 
Best regards,
Xingwei Lin
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] how to disable dot commands?

2020-01-12 Thread Xingwei Lin
Hi,

Is there any way can we disable the dot commands feature in sqlite?

-- 
Best regards,
Xingwei Lin
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] how to pass -Dxxx compile option

2020-01-09 Thread Xingwei Lin
Thanks all the nice guys' reply!!

On Thu, Jan 9, 2020 at 10:59 PM Gary R. Schmidt  wrote:

> On 09/01/2020 17:47, Xingwei Lin wrote:
> > Hi,
> >
> > How can I pass -Dxxx compile option when I build sqlite? Such as, -
> > DSQLITE_ENABLE_INTERNAL_FUNCTIONS.
> >
> ./configure --help will tell you that CFLAGS is how you do that, so:
>
>  ./configure CFLAGS=-Dwhatever
>
> If you have many options:
>
>  ./configure CFLAGS="-Dwhatever -Dthis -Dthat -mwhoops"
>
> Cheers,
> GaryB-)
> ___
> sqlite-users mailing list
> sqlite-users@mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>


-- 
Best regards,
Xingwei Lin
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] how to pass -Dxxx compile option

2020-01-09 Thread Xingwei Lin
Thanks for reply.

I always use ./configure && make to compile sqlite.

./configure can add some compile options, but I don't know how to add -Dxxx
option in this compilation process.

On Thu, Jan 9, 2020 at 5:29 PM Simon Slavin  wrote:

> On 9 Jan 2020, at 6:47am, Xingwei Lin  wrote:
>
> > How can I pass -Dxxx compile option when I build sqlite? Such as, -
> > DSQLITE_ENABLE_INTERNAL_FUNCTIONS.
>
> Depends on which compiler you're using.  See examples for gcc on this page:
>
> <https://www.sqlite.org/howtocompile.html>
> ___
> sqlite-users mailing list
> sqlite-users@mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>


-- 
Best regards,
Xingwei Lin
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] how to pass -Dxxx compile option

2020-01-08 Thread Xingwei Lin
Hi,

How can I pass -Dxxx compile option when I build sqlite? Such as, -
DSQLITE_ENABLE_INTERNAL_FUNCTIONS.

-- 
Best regards,
Xingwei Lin
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] divide-by-zero bug in whereLoopAddBtreeIndex function

2019-08-15 Thread Xingwei Lin
Hi, Richard:

Sorry for that, the poc is attached here.

On Thu, Aug 15, 2019 at 9:08 PM Richard Hipp  wrote:

> The mailing list strips attachments as an anti-spam measure.  Please
> send the POC directly d...@sqlite.org.
>
> On 8/15/19, Xingwei Lin  wrote:
> > Attach is the poc sql file.
> > I used the following command:
>
>
> --
> D. Richard Hipp
> d...@sqlite.org
>


-- 
Best regards,
Xingwei Lin
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] divide-by-zero bug in whereLoopAddBtreeIndex function

2019-08-15 Thread Xingwei Lin
Hi, all

I found a divide-by-zero bug in *whereLoopAddBtreeIndex* function in
version 3.29.0.

The GDB debug traces are:

> #0  0x561757f1e842 in whereLoopAddBtreeIndex (pBuilder=0x7ffea0f422a0,
> pSrc=0x56175954b070, pProbe=0x561759565e78, nInMul=0) at sqlite3.c:143263
> #1  0x561757f1faeb in whereLoopAddBtree (pBuilder=0x7ffea0f422a0,
> mPrereq=0) at sqlite3.c:143653
> #2  0x561757f212ed in whereLoopAddAll (pBuilder=0x7ffea0f422a0) at
> sqlite3.c:144172
> #3  0x561757f24297 in sqlite3WhereBegin (pParse=0x7ffea0f43210,
> pTabList=0x56175954b068, pWhere=0x561759557548, pOrderBy=0x0,
> pResultSet=0x561759550018, wctrlFlags=0, iAuxArg=320) at sqlite3.c:145367
> #4  0x561757f03e99 in sqlite3Select (pParse=0x7ffea0f43210,
> p=0x561759554b18, pDest=0x7ffea0f426d0) at sqlite3.c:131229
> #5  0x561757f2d731 in yy_reduce (yypParser=0x7ffea0f42810,
> yyruleno=80, yyLookahead=1, yyLookaheadToken=..., pParse=0x7ffea0f43210) at
> sqlite3.c:152165
> #6  0x561757f32464 in sqlite3Parser (yyp=0x7ffea0f42810, yymajor=1,
> yyminor=...) at sqlite3.c:153461
> #7  0x561757f33a69 in sqlite3RunParser (pParse=0x7ffea0f43210,
> zSql=0x56175953abcf "", pzErrMsg=0x7ffea0f431e8) at sqlite3.c:154597
> #8  0x561757ef535b in sqlite3Prepare (db=0x56175953ae48,
> zSql=0x56175953ab90 "EXPLAIN QUERY PLAN\nSELECT 0 FROM t001\nWHERE t001.a
> IN(SELECT 0)", nBytes=-1, prepFlags=128, pReprepare=0x0,
> ppStmt=0x7ffea0f434c8, pzTail=0x7ffea0f434d0) at sqlite3.c:124831
> #9  0x561757ef5718 in sqlite3LockAndPrepare (db=0x56175953ae48,
> zSql=0x56175953ab90 "EXPLAIN QUERY PLAN\nSELECT 0 FROM t001\nWHERE t001.a
> IN(SELECT 0)", nBytes=-1, prepFlags=128, pOld=0x0, ppStmt=0x7ffea0f434c8,
> pzTail=0x7ffea0f434d0) at sqlite3.c:124924
> #10 0x561757ef5a90 in sqlite3_prepare_v2 (db=0x56175953ae48,
> zSql=0x56175953ab90 "EXPLAIN QUERY PLAN\nSELECT 0 FROM t001\nWHERE t001.a
> IN(SELECT 0)", nBytes=-1, ppStmt=0x7ffea0f434c8, pzTail=0x7ffea0f434d0) at
> sqlite3.c:125008
> #11 0x561757e2ea66 in shell_exec (pArg=0x7ffea0f45250,
> zSql=0x56175953ab90 "EXPLAIN QUERY PLAN\nSELECT 0 FROM t001\nWHERE t001.a
> IN(SELECT 0)", pzErrMsg=0x7ffea0f43538) at shell.c:11585
> #12 0x561757e40361 in runOneSqlLine (p=0x7ffea0f45250,
> zSql=0x56175953a8d0 "CREATE TABLE t1(a,b);INSERT INTO t1 VALUES(0,0);INSERT
> INTO t1 VALUES(0,0);INSERT INTO t1 SELECT 0,0;INSERT INTO t1
> SELECT+0,0;CREATE TABLE t0(c,d);INSERT INTO t0 SELECT 0,0;PRAGMA a;SELECT
> 0;SELECT(0"..., in=0x56175950b6e0, startline=1) at shell.c:18110
> #13 0x561757e4095a in process_input (p=0x7ffea0f45250) at shell.c:18224
> #14 0x561757e3c4ae in do_meta_command (zLine=0x56175952d300 ".read",
> p=0x7ffea0f45250) at shell.c:16799
> #15 0x561757e4066a in process_input (p=0x7ffea0f45250) at shell.c:18177
> #16 0x561757e42445 in main (argc=1, argv=0x7ffea0f46848) at
> shell.c:18963


The bug occurs in "*rCostIdx = pNew->nOut + 1 +
(15*pProbe->szIdxRow)/pSrc->pTab->szTabRow;*" statement, where szTabRow
variable is zero.

Attach is the poc sql file.
I used the following command:

> ./sqlite3
> sqlite> .read crash.sql


-- 
Best regards,
Xingwei Lin
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] sqlite3Init null pointer bug

2019-01-04 Thread Xingwei Lin
Hi,

I found a null pointer access problem in *sqlite3Init *function in version
3.26.0.

The poc is simple:

> .open .

.selftest


The GDB debug traces are:

> #0  0x55d76316ae12 in sqlite3Init (db=0x55d76509de18,
> pzErrMsg=0x7fffa3d64ac0) at sqlite3.c:123082

#1  0x55d7631a22d7 in sqlite3_table_column_metadata (db=0x55d76509de18,
> zDbName=0x55d7631fa22e "main", zTableName=0x55d763200574 "selftest",
> zColumnName=0x0, pzDataType=0x0, pzCollSeq=0x0, pNotNull=0x0,
> pPrimaryKey=0x0, pAutoinc=0x0) at sqlite3.c:156312

#2  0x55d7630e73f3 in do_meta_command (zLine=0x55d765090970
> ".selftest", p=0x7fffa3d68090) at shell.c:14816

#3  0x55d7630ea430 in process_input (p=0x7fffa3d68090,
> in=0x55d76506f6d0) at shell.c:15712

#4  0x55d7630e669c in do_meta_command (zLine=0x55d7650909f0 ".read",
> p=0x7fffa3d68090) at shell.c:14369

#5  0x55d7630ea430 in process_input (p=0x7fffa3d68090, in=0x0) at
> shell.c:15712

#6  0x55d7630ec173 in main (argc=1, argv=0x7fffa3d69668) at
> shell.c:16479


When we invoke "*.open .*", sqlite3 will fail to open "." database.
However, sqlite3 will still create db("struct sqlite3") object without full
initialization and not destroy it in "*shell.c:11306*".

Then when we invoke "*.selftest"*, when the routine go to *sqlite3Init*
function, it will call "*ENC(db) = SCHEMA_ENC(db)*;",
which is a macro: "*#define SCHEMA_ENC(db) ((db)->aDb[0].pSchema->enc)*".

"SCHEMA_ENC(db)" will access "pSchema" field, which has not been
initialized yet for the failure create "." database.

Attach is the poc sql file.
I used the following command:

./sqlite3

sqlite >.read crash.sql


-- 
Best regards,
Xingwei Lin
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users