0 Replies Latest reply on Jul 19, 2019 6:02 PM by 3762889

    Bug in berkeleydb SQL implementation of custom PRAGMAs

    3762889

      I have found a bug in the implementation of the custom PRAGMAs in the berkeleydb SQLite code.

       

      Specifically, db-18.1.32/lang/sql/adapter/db_pragma.c in the code that configures the output column name for returning the value of a pragma.

       

      As an example, the implementation of the "multiversion" PRAGMA, line 644:

       

      sqlite3VdbeSetColName(v, 0, COLNAME_NAME, zLeft, SQLITE_STATIC)

       

      The use of SQLITE_STATIC implies that the pointer to the column name will be guaranteed valid by the caller. This isn't the case, however, and as a result there is corruption in the column name.

       

      To avoid this, I've managed to patch the code locally changing SQLITE_STATIC to SQLITE_TRANSIENT -- this tells sqlite to make a copy of the string. With this patch, the column name is set correctly and communicated correctly to the code issuing the query.

       

      I hope you can patch this in a subsequent version.