Changeset 19142 for trunk


Ignore:
Timestamp:
08/05/18 20:02:10 (6 years ago)
Author:
tbretz
Message:
Adapted the return numbers, fixed a few typos, sorted the resources.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/rootifysql.cc

    r19139 r19142  
    2222void SetupConfiguration(Configuration &conf)
    2323{
    24     po::options_description control("Rootify SQL");
     24    po::options_description control("Database options");
    2525    control.add_options()
    2626        ("uri,u",         var<string>()->required(),   "Database link as in\n\tuser:password@server[:port]/database[?compress=0|1].")
     
    2828        ("file",          var<string>("rootify.sql"),  "An ASCII file with the MySQL query (overwrites --query)")
    2929        ("ignore-null,i", po_switch(),                 "Do not skip rows containing any NULL field")
    30         ("out,o",         var<string>("rootify.root"), "Output root file name")
    31         ("force,f",       po_switch(),                 "Force overwriting an existing root file ('RECREATE')")
    32         ("update",        po_switch(),                 "Update an existing root file with the new tree ('UPDATE')")
    33         ("compression,c", var<uint16_t>(1),            "zlib compression level for the root file")
    34         ("tree,t",        var<string>("Result"),       "Name of the root tree")
    35         ("ignore",        vars<string>(),              "Ignore the given columns")
    3630        ("display,d",     po_switch(),                 "Displays contents on the screen (most usefull in combination with mysql statements as SHOW or EXPLAIN)")
    3731        ("write,w",       var<string>(""),             "Write output to an ascii file")
    38         ("null,n",        po_switch(),                 "Redirect the output file to /dev/null (mainly for debugging purposes, e.g. performance studies)")
    39         ("no-fill",       po_switch(),                 "Do not fill events into the root file (mainly for debugging purposes, e.g. performance studies)")
    4032        ("delimiter",     var<string>(""),             "The delimiter used if contents are displayed with --display (default=\\t)")
    4133        ("explain",       po_switch(),                 "Requests an EXPLAIN from the server (shows the server optimized query)\nsee also https://dev.mysql.com/doc/refman/explain-output.html")
     
    4840        ;
    4941
     42    po::options_description root("Root file options");
     43    root.add_options()
     44        ("out,o",         var<string>("rootify.root"), "Output root file name")
     45        ("force,f",       po_switch(),                 "Force overwriting an existing root file ('RECREATE')")
     46        ("update",        po_switch(),                 "Update an existing root file with the new tree ('UPDATE')")
     47        ("compression,c", var<uint16_t>(1),            "zlib compression level for the root file")
     48        ("tree,t",        var<string>("Result"),       "Name of the root tree")
     49        ("ignore",        vars<string>(),              "Ignore the given columns")
     50        ("null,n",        po_switch(),                 "Redirect the output file to /dev/null (mainly for debugging purposes, e.g. performance studies)")
     51        ("no-fill",       po_switch(),                 "Do not fill events into the root file (mainly for debugging purposes, e.g. performance studies)")
     52        ;
     53
    5054    po::positional_options_description p;
    5155    p.add("file", 1); // The 1st positional options (n=1)
     
    5357
    5458    conf.AddOptions(control);
     59    conf.AddOptions(root);
    5560    conf.SetArgumentPositions(p);
    5661}
     
    7580        "This can be useful to create an ascii file or to show results as 'SHOW DATABASES' "
    7681        "or 'EXPLAIN table'. To redirect the contents into an ascii file, the option -v0 "
    77         "is useful. To suppredd writing to an output file --null can be used.\n"
     82        "is useful. To suppress writing to an output file --null can be used.\n"
    7883        "\n"
    7984        "The default is to read the query from a file called rootify.sql. Except if a different "
     
    9196        "You can use environment definitions for substitutions in your SQL query. "
    9297        "For example --env.TEST=5 would replace $TEST or ${TEST} in your query by 5."
    93         "If you specifiy one environmentvariable more than once, a list is created. "
     98        "If you specify one environment variable more than once, a list is created. "
    9499        "For example --env.TEST=1 --env.TEST=2 --env.TEST=3 would substitute "
    95100        "$TEST or ${TEST} by '1, 2, 3'. This is useful for the SQL `IN` keyword. "
     
    101106        "/*comment*/ or introduced with # (shell script style) or -- (SQL style).\n"
    102107        "\n"
    103         "In case of succes, 0 is returned, a value>0 otherwise.\n"
     108        "In case of success, 0 is returned, a value>0 otherwise.\n"
    104109        "\n"
    105110        "Usage: rootifysql [rootify.sql [rootify.root]] [-u URI] [-q query|-f file] [-i] [-o out] [-f] [-cN] [-t tree] [-vN]\n"
     
    380385            cerr << "\nSHOW WARNINGS\n\n";
    381386            cerr << "SQL query failed:\n" << e.what() << endl;
    382             return 6;
     387            return 1;
    383388        }
    384389    }
     
    420425            cerr << "\nSHOW PROFILE ALL\n\n";
    421426            cerr << "SQL query failed:\n" << e.what() << '\n' <<endl;
    422             return 11;
     427            return 2;
    423428        }
    424429    }
     
    438443            cerr << "\nSHOW STATUS LIKE 'Bytes_%'\n\n";
    439444            cerr << "SQL query failed:\n" << e.what() << endl;
    440             return 6;
     445            return 3;
    441446        }
    442447    }
     
    503508        {
    504509            cerr << "Could not open query in '" << file << "': " << strerror(errno) << endl;
    505             return 1;
     510            return 4;
    506511        }
    507512        getline(fin, query, (char)fin.eof());
     
    511516    {
    512517        cerr << "No query specified." << endl;
    513         return 2;
     518        return 5;
    514519    }
    515520
     
    530535        {
    531536            cerr << "Could not open environment in '" << fname << "' for ${" << ident << "}: " << strerror(errno) << endl;
    532             return 3;
     537            return 6;
    533538        }
    534539
     
    569574        {
    570575            cerr << "File '" << path << "' is not writable." << endl;
    571             return 3;
     576            return 7;
    572577        }
    573578
     
    575580        {
    576581            cerr << "File '" << path << "' already exists." << endl;
    577             return 4;
     582            return 8;
    578583        }
    579584    }
     
    603608        {
    604609            const auto &res1 = connection.query("SHOW STATUS LIKE 'Compression'").store();
    605             cout << "Compression of databse connection is " << string(res1[0][1]) << endl;
     610            cout << "Compression of database connection is " << string(res1[0][1]) << endl;
    606611
    607612            const auto &res2 = connection.query("SHOW STATUS LIKE 'Ssl_cipher'").store();
     
    612617            cerr << "\nSHOW STATUS LIKE 'Compression'\n\n";
    613618            cerr << "SQL query failed:\n" << e.what() << endl;
    614             return 6;
     619            return 9;
    615620        }
    616621    }
     
    625630        cerr << "\nSET profiling=1\n\n";
    626631        cerr << "SQL query failed:\n" << e.what() << endl;
    627         return 6;
     632        return 10;
    628633    }
    629634
     
    645650            cerr << '\n' << varset << "\n\n";
    646651            cerr << "SQL query failed:\n" << e.what() << endl;
    647             return 7;
     652            return 11;
    648653        }
    649654
     
    730735            cerr << '\n' << query << "\n\n";
    731736            cerr << "SQL query failed:\n" << e.what() << endl;
    732             return 8;
     737            return 12;
    733738        }
    734739
     
    757762    TFile tfile(path, update?"UPDATE":(force?"RECREATE":"CREATE"), "Rootify SQL", compression);
    758763    if (tfile.IsZombie())
    759         return 9;
     764        return 13;
    760765
    761766    // -------------------------------------------------------------------------
     
    767772        cerr << "Empty set returned... nothing to write." << endl;
    768773        finish(connection, verbose, profiling, print_connection);
    769         return 10;
     774        return 14;
    770775    }
    771776
Note: See TracChangeset for help on using the changeset viewer.