Example #1
0
        // Run the parser and code generator recursively in order to generate code for the SQL statement given onto the end of the pParse context
        // currently under construction.  When the parser is run recursively this way, the final OP_Halt is not appended and other initialization
        // and finalization steps are omitted because those are handling by the outermost parser.
        //
        // Not everything is nestable.  This facility is designed to permit INSERT, UPDATE, and DELETE operations against SQLITE_MASTER.  Use
        // care if you decide to try to use this routine for some other purposes.
        internal static void sqlite3NestedParse(Parse pParse, string zFormat, params object[] ap)
        {
            var db = pParse.db;

            if (pParse.nErr != 0)
            {
                return;
            }
            Debug.Assert(pParse.nested < 10);  // Nesting should only be of limited depth
            lock (lock_va_list)
            {
                va_start(ap, zFormat);
                var zSql = sqlite3VMPrintf(db, zFormat, ap);
                va_end(ref ap);
            }
            lock (_nestingLock)
            {
                pParse.nested++;
                pParse.SaveMembers();
                pParse.ResetMembers();
                string zErrMsg = string.Empty;
                sqlite3RunParser(pParse, zSql, ref zErrMsg);
                sqlite3DbFree(db, ref zErrMsg);
                sqlite3DbFree(db, ref zSql);
                pParse.RestoreMembers();
                pParse.nested--;
            }
        }
Example #2
0
 // Run the parser and code generator recursively in order to generate code for the SQL statement given onto the end of the pParse context
 // currently under construction.  When the parser is run recursively this way, the final OP_Halt is not appended and other initialization
 // and finalization steps are omitted because those are handling by the outermost parser.
 //
 // Not everything is nestable.  This facility is designed to permit INSERT, UPDATE, and DELETE operations against SQLITE_MASTER.  Use
 // care if you decide to try to use this routine for some other purposes.
 internal static void sqlite3NestedParse(Parse pParse, string zFormat, params object[] ap)
 {
     var db = pParse.db;
     if (pParse.nErr != 0)
         return;
     Debug.Assert(pParse.nested < 10);  // Nesting should only be of limited depth
     lock (lock_va_list)
     {
         va_start(ap, zFormat);
         var zSql = sqlite3VMPrintf(db, zFormat, ap);
         va_end(ref ap);
     }
     lock (_nestingLock)
     {
         pParse.nested++;
         pParse.SaveMembers();
         pParse.ResetMembers();
         string zErrMsg = string.Empty;
         sqlite3RunParser(pParse, zSql, ref zErrMsg);
         sqlite3DbFree(db, ref zErrMsg);
         sqlite3DbFree(db, ref zSql);
         pParse.RestoreMembers();
         pParse.nested--;
     }
 }