]> git.sur5r.net Git - bacula/bacula/commitdiff
Not all databases allow you to refer to field in an "AS field" clause.
authorDan Langille <dan@langille.org>
Sat, 17 Jul 2004 15:49:39 +0000 (15:49 +0000)
committerDan Langille <dan@langille.org>
Sat, 17 Jul 2004 15:49:39 +0000 (15:49 +0000)
So use count(*) instead of the field name in selects.

Use DISTINCT intead of GROUP BY, because that's what we really want
because this won't work on non-MySQL.

git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1478 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/tools/dbcheck.c

index c4af96203fe07a1fac33c4be0b6d548695b980e3..54114787fe2061a330a7daea49890ca30c21795a 100644 (file)
@@ -515,8 +515,8 @@ static void eliminate_duplicate_filenames()
    printf("Checking for duplicate Filename entries.\n");
    
    /* Make list of duplicated names */
-   query = "SELECT Name,count(Name) as Count FROM Filename GROUP BY Name "
-           "HAVING Count > 1";
+   query = "SELECT Name, count(Name) as Count FROM Filename GROUP BY  Name "
+           "HAVING count(Name) > 1";
 
    if (!make_name_list(query, &name_list)) {
       exit(1);
@@ -569,8 +569,8 @@ static void eliminate_duplicate_paths()
    
    /* Make list of duplicated names */
 
-   query = "SELECT Path,count(Path) as Count FROM Path "
-           "GROUP BY Path HAVING Count > 1";
+   query = "SELECT Path, count(Path) as Count FROM Path "
+           "GROUP BY Path HAVING count(Path) > 1";
 
    if (!make_name_list(query, &name_list)) {
       exit(1);
@@ -680,9 +680,9 @@ static void eliminate_orphaned_path_records()
    const char *query;
 
    printf("Checking for orphaned Path entries. This may take some time!\n");
-   query = "SELECT Path.PathId,File.PathId FROM Path "
+   query = "SELECT DISTINCT Path.PathId,File.PathId FROM Path "
            "LEFT OUTER JOIN File ON (Path.PathId=File.PathId) "
-           "GROUP BY Path.PathId HAVING File.PathId IS NULL";
+           "HAVING File.PathId IS NULL";
    if (verbose > 1) {
       printf("%s\n", query);
    }