]> git.sur5r.net Git - bacula/bacula/commitdiff
Clean up a bit. Randomize the name of the table.
authorDirk H Bartley <dbartley@schupan.com>
Fri, 27 Jul 2007 01:22:03 +0000 (01:22 +0000)
committerDirk H Bartley <dbartley@schupan.com>
Fri, 27 Jul 2007 01:22:03 +0000 (01:22 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@5247 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/qt-console/restore/restoretree.cpp

index 8ca2f467f4dcc4c3df565aa001f36a5f3c6b9436..4cbaa016947fe33b4abe2f3637a7b32c146e780b 100644 (file)
@@ -1390,26 +1390,18 @@ void restoreTree::testButtonPushed()
       /* did not succeed in getting an iterator to work as expected on versionFilesMulti so use doneKeys */
       if (doneKeys.value(fversion, 0) == 0) {
          if (tempTable == "") {
-            tempTable = "restoretest" + QString("%1").arg(fversion);
-            //if (mainWin->m_sqlDebug)
+            QSettings settings("www.bacula.org", "bat");
+            settings.beginGroup("Restore");
+            int counter = settings.value("Counter", 1).toInt();
+            settings.setValue("Counter", counter+1);
+            settings.endGroup();
+            tempTable = "restore_" + QString("%1").arg(qrand()) + "_" + QString("%1").arg(counter);
             QString sqlcmd = "CREATE TEMPORARY TABLE " + tempTable + " (JobId INTEGER, FileIndex INTEGER)";
+            if (mainWin->m_sqlDebug)
+               Pmsg1(000, "Query cmd : %s ;\n", sqlcmd.toUtf8().data());
             QStringList results;
-            Pmsg1(000, "Query cmd : %s ;\n", sqlcmd.toUtf8().data());
-            if (m_console->sql_cmd(sqlcmd, results)) {
-               QStringList fieldlist;
-               int row = 0;
-               foreach (QString resultline, results) {
-                  int column = 0;
-                  fieldlist = resultline.split("\t");
-                  foreach (QString field, fieldlist) {
-                     if (column == 0) {
-                        Pmsg1(000, "Returned from CREATE TABLE command %s\n", field.toUtf8().data());
-                     }
-                     column++;
-                  }
-                  row++;
-               }
-            }
+            if (!m_console->sql_cmd(sqlcmd, results))
+               Pmsg1(000, "CREATE TABLE FAILED!!!! %s\n", sqlcmd.toUtf8().data());
          }
 
          if (mainWin->m_rtRestore2Debug) Pmsg1(000, "Version->%i\n", fversion);
@@ -1418,27 +1410,12 @@ void restoreTree::testButtonPushed()
          foreach(QString ffullPath, fullPathList) {
             int fileIndex = fileIndexHash.value(ffullPath);
             if (mainWin->m_rtRestore2Debug) Pmsg2(000, "  file->%s id %i\n", ffullPath.toUtf8().data(), fileIndex);
-            //cmd += " file=\"" + ffullPath + "\"";
             QString sqlcmd = "INSERT INTO " + tempTable + " (JobId, FileIndex) VALUES (" + QString("%1").arg(fversion) + ", " + QString("%1").arg(fileIndex) + ")";
+            if (mainWin->m_sqlDebug)
+               Pmsg1(000, "Query cmd : %s ;\n", sqlcmd.toUtf8().data());
             QStringList results;
-//            Pmsg1(000, "Query cmd : %s ;\n", sqlcmd.toUtf8().data());
-            /* use printf for the moment to make pasting into psql easier. */
-            printf("%s ;\n", sqlcmd.toUtf8().data());
-            if (m_console->sql_cmd(sqlcmd, results)) {
-               QStringList fieldlist;
-               int row = 0;
-               foreach (QString resultline, results) {
-                  int column = 0;
-                  fieldlist = resultline.split("\t");
-                  foreach (QString field, fieldlist) {
-                     if (column == 0) {
-                        Pmsg1(000, "Returned from INSERT INTO command %s\n", field.toUtf8().data());
-                     }
-                     column++;
-                  }
-                  row++;
-               }
-            }
+            if (!m_console->sql_cmd(sqlcmd, results))
+               Pmsg1(000, "INSERT INTO FAILED!!!! %s\n", sqlcmd.toUtf8().data());
          } /* foreach fullPathList */
          doneKeys.insert(fversion,1);
          jobList.append(fversion);