SQLite Forum

An assertion failure in function sqlite3TableColumnAffinity()
Login

An assertion failure in function sqlite3TableColumnAffinity()

(1.1) By Wang Ke (krking) on 2021-11-07 03:38:24 edited from 1.0 [link]

Hello developers,

We found an assertion failure in SQLite version 3.37.0 2021-11-06 20:25:29 **with --enable-debug**.

The test case is as follows:

```
CREATE TABLE t0(a);
SELECT a FROM t0 LEFT JOIN (SELECT a AS b FROM t0) AS t1 WHERE (a,1)=(SELECT 2,2 UNION SELECT total(b),max(b) OVER(ORDER BY b) ORDER BY 2 DESC) AND b=4 ORDER BY b DESC;
```

which causes:

> sqlite3.c: char sqlite3TableColumnAffinity(const Table *, int): Assertion `iCol\<pTab->nCol' failed.

in line:

>  assert( iCol\<pTab->nCol );

Bisecting shows the issue may be related to [check-in 0d11d777c8](https://sqlite.org/src/info/0d11d777c8).

**For other readers, this is not necessarily a problem in release builds.**

The version with no debug enabled gives:

> Error: in prepare, 2 columns assigned 1 values (1)

Hope the problem will be handled properly :)

(2) By Wang Ke (krking) on 2021-11-08 01:09:38 in reply to 1.1

It seems that the problem has been fixed [on trunk](https://sqlite.org/src/info/0f9fc6b6073365d5).

Thanks for the fix!