Changeset 19191


Ignore:
Timestamp:
08/28/18 20:21:02 (6 years ago)
Author:
tbretz
Message:
Added possibility to create a unique index.
Location:
trunk/FACT++/src
Files:
2 edited

Legend:

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

    r19186 r19191  
    198198        "with the --index option.\n"
    199199        "\n"
     200        "To create the index as a UNIQUE INDEX, you can use the --unique option which "
     201        "implies --index.\n"
     202        "\n"
    200203        "If a query failed, the query is printed to stderr together with the error message. "
    201204        "For the main INSERT query, this is only true if the verbosity level is at least 2 "
     
    325328    const bool run_delete        = conf.Get<bool>("delete");
    326329    const bool index             = conf.Get<bool>("index");
     330    const bool unique            = conf.Get<bool>("unique");
    327331
    328332    const string engine          = conf.Get<string>("engine");
     
    592596        query += ",\n   PRIMARY KEY USING BTREE (`"+boost::algorithm::join(primary, "`, `")+"`)";
    593597
    594     if (!vindex.empty() && index)
    595         query += ",\n   INDEX USING BTREE (`"+boost::algorithm::join(vindex, "`, `")+"`)";
     598    if (!vindex.empty() && (index || unique))
     599        query += ",\n   "+string(unique?"UNIQUE ":"")+"INDEX USING BTREE (`"+boost::algorithm::join(vindex, "`, `")+"`)";
    596600
    597601    query +=
  • trunk/FACT++/src/root2sql.cc

    r19187 r19191  
    6565        ("conditional",    po_switch(),               "Conditional insert. Only insert if no entry exists yet with the constants defined by --const")
    6666        ("delete",         po_switch(),               "Delete all entries first which fit all constant columns defined by --const")
    67         ("index",          po_switch(),               "If a table is created, all const columns are used as a single index")
     67        ("index",          po_switch(),               "If a table is created, all const columns are used as a single index (INDEX)")
     68        ("unique",         po_switch(),               "If a table is created, all const columns are used as a unqiue index (UNIQUE)")
    6869        ;
    6970
     
    205206        "with the --index option.\n"
    206207        "\n"
     208        "To create the index as a UNIQUE INDEX, you can use the --unique option which "
     209        "implies --index.\n"
     210        "\n"
    207211        "If a query failed, the query is printed to stderr together with the error message. "
    208212        "For the main INSERT query, this is only true if the verbosity level is at least 2 "
     
    356360    const bool run_delete        = conf.Get<bool>("delete");
    357361    const bool index             = conf.Get<bool>("index");
     362    const bool unique            = conf.Get<bool>("unique");
    358363
    359364    const string engine          = conf.Get<string>("engine");
     
    629634        query += ",\n   PRIMARY KEY USING BTREE (`"+boost::algorithm::join(primary, "`, `")+"`)";
    630635
    631     if (!vindex.empty() && index)
    632         query += ",\n   INDEX USING BTREE (`"+boost::algorithm::join(vindex, "`, `")+"`)";
     636    if (!vindex.empty() && (index || unique))
     637        query += ",\n   "+string(unique?"UNIQUE ":"")+"INDEX USING BTREE (`"+boost::algorithm::join(vindex, "`, `")+"`)";
    633638
    634639    query +=
Note: See TracChangeset for help on using the changeset viewer.