Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h1>Reason for segfault</h1> <p>The <a href="https://www.sqlite.org/c3ref/column_blob.html" rel="nofollow">sqlite3 documentation for <code>sqlite3_column_text</code></a> says:</p> <blockquote> <p>If any of these routines are called [...] after <code>sqlite3_step()</code> has returned something other than <code>SQLITE_ROW</code>, the results are undefined."</p> </blockquote> <p>You aren't checking the return value of <code>sqlite3_step</code>, so it seems your query is returning some sort of error, and then <code>sqlite3_column_text</code> is returning an invalid pointer.</p> <h1>Debugging the SQL error</h1> <p>According to <a href="https://www.sqlite.org/c3ref/prepare.html" rel="nofollow">the documentation for <code>prepare</code></a>:</p> <blockquote> <p>The <code>sqlite3_prepare_v2()</code> and <code>sqlite3_prepare16_v2()</code> interfaces are recommended for all new programs. The two older interfaces [including <code>sqlite3_prepare</code>, which you call] are retained for backwards compatibility, but their use is discouraged.</p> <p>[...]</p> <p>When an error occurs, sqlite3_step() will return one of the detailed error codes or extended error codes. The legacy behavior was that sqlite3_step() would only return a generic SQLITE_ERROR result code and the application would have to make a second call to sqlite3_reset() in order to find the underlying cause of the problem. With the "v2" prepare interfaces, the underlying reason for the error is returned immediately.</p> </blockquote> <p>So if you switch to the newer interface, it should give a more informative message, rather than the generic <code>SQLITE_ERROR</code>.</p> <p>You could also try using the <code>sqlite3</code> command-line program, which will directly tell you what the error is. Example session:</p> <pre><code>user@host:/path$ sqlite3 test.sqlite sqlite&gt; create table example ( id numeric primary key ); sqlite&gt; select bogus from example; Error: no such column: bogus </code></pre> <hr> <p>Incidentally, for standard C++ use <code>#include &lt;cstring&gt;</code> for <code>#include &lt;string.h&gt;</code> and <code>bool CanClose()</code> for <code>bool CanClose(void)</code>.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload