Ignore:
Timestamp:
08/12/18 15:48:05 (6 years ago)
Author:
tbretz
Message:
Added the --index option.
File:
1 edited

Legend:

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

    r19154 r19155  
    7171        ("conditional",    po_switch(),               "Conditional insert. Only insert if no entry exists yet with the constants defined by --const")
    7272        ("delete",         po_switch(),               "Delete all entries first which fit all constant columns defined by --const")
     73        ("index",          po_switch(),               "If a table is created, all const columns are used as a single index")
    7374        ;
    7475
     
    205206        "(note that this happend after the table drop/create but before the delete/insert.\n"
    206207        "\n"
     208        "To ensure efficient access for a conditonal execution, it makes sense to have "
     209        "an index created for those columns. This can be done during table creation "
     210        "with the --index option.\n"
     211        "\n"
    207212        "If a query failed, the query is printed to stderr together with the error message. "
    208213        "For the main INSERT query, this is only true if the verbosity level is at least 2 "
     
    319324    if (string(msg).substr(0,24)=="no dictionary for class ")
    320325        return;
     326    if (string(msg).substr(0, 5)=="unknown branch ")
     327        return;
    321328
    322329    DefaultErrorHandler(level, abort, location, msg);
     
    353360    const bool conditional       = conf.Get<bool>("conditional");
    354361    const bool run_delete        = conf.Get<bool>("delete");
     362    const bool index             = conf.Get<bool>("index");
    355363
    356364    const string engine          = conf.Get<string>("engine");
     
    435443
    436444    string where;
     445    vector<string> vindex;
    437446    for (auto it=fixed.cbegin(); it!=fixed.cend(); it++)
    438447    {
     
    473482        vec.emplace_back(name, val);
    474483        where += " AND `"+name+"`="+val;
     484        vindex.emplace_back(name);
    475485    }
    476486
     
    615625    if (!primary.empty())
    616626        query += ",\n   PRIMARY KEY USING BTREE (`"+boost::algorithm::join(primary, "`, `")+"`)";
     627
     628    if (!vindex.empty() && index)
     629        query += ",\n   INDEX USING BTREE (`"+boost::algorithm::join(vindex, "`, `")+"`)";
    617630
    618631    query +=
Note: See TracChangeset for help on using the changeset viewer.