Exemplo n.º 1
0
 /// <summary>
 /// GetResultSet is the core resultset processing method.  It gets called by NextResult
 /// and will loop until it finds a select resultset at which point it will return the
 /// number of columns in that result.  It will _not_ return for non-select resultsets instead
 /// just updating the internal lastInsertId and affectedRows variables.
 /// </summary>
 /// <returns>-1 if no more results exist, >= 0 for select results</returns>
 private long GetResultSet()
 {
     while (true)
     {
         ulong affectedRowsTemp = 0;
         long  fieldCount       = driver.ReadResult(ref affectedRowsTemp, ref lastInsertId);
         if (fieldCount > 0)
         {
             return(fieldCount);
         }
         else if (fieldCount == 0)
         {
             command.lastInsertedId = lastInsertId;
             if (affectedRows == -1)
             {
                 affectedRows = (long)affectedRowsTemp;
             }
             else
             {
                 affectedRows += (long)affectedRowsTemp;
             }
         }
         else if (fieldCount == -1)
         {
             if (!statement.ExecuteNext())
             {
                 break;
             }
         }
     }
     return(-1);
 }
Exemplo n.º 2
0
        public bool ReadNextResult(bool isFirst)
        {
            long rows = 0;

            while ((driver.ServerStatus & (ServerStatusFlags.MoreResults | ServerStatusFlags.AnotherQuery)) != 0 ||
                   isFirst)
            {
                fieldCount = (ulong)driver.ReadResult(ref rows, ref lastInsertId);
                if (rows != -1)
                {
                    if (affectedRows == -1)
                    {
                        affectedRows = 0;
                    }
                    affectedRows += rows;
                }
                if (isFirst)
                {
                    isFirst = false;
                }

                if (IsResultSet)
                {
                    readSchema = false;
                    readRows   = false;
                    return(true);
                }
            }

            // if our batch resulted in warnings, then report them now
            if (driver.HasWarnings)
            {
                driver.ReportWarnings();
            }

            return(false);
        }