Changeset 19142 for trunk/FACT++
- Timestamp:
- 08/05/18 20:02:10 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/rootifysql.cc
r19139 r19142 22 22 void SetupConfiguration(Configuration &conf) 23 23 { 24 po::options_description control(" Rootify SQL");24 po::options_description control("Database options"); 25 25 control.add_options() 26 26 ("uri,u", var<string>()->required(), "Database link as in\n\tuser:password@server[:port]/database[?compress=0|1].") … … 28 28 ("file", var<string>("rootify.sql"), "An ASCII file with the MySQL query (overwrites --query)") 29 29 ("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")36 30 ("display,d", po_switch(), "Displays contents on the screen (most usefull in combination with mysql statements as SHOW or EXPLAIN)") 37 31 ("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)")40 32 ("delimiter", var<string>(""), "The delimiter used if contents are displayed with --display (default=\\t)") 41 33 ("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") … … 48 40 ; 49 41 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 50 54 po::positional_options_description p; 51 55 p.add("file", 1); // The 1st positional options (n=1) … … 53 57 54 58 conf.AddOptions(control); 59 conf.AddOptions(root); 55 60 conf.SetArgumentPositions(p); 56 61 } … … 75 80 "This can be useful to create an ascii file or to show results as 'SHOW DATABASES' " 76 81 "or 'EXPLAIN table'. To redirect the contents into an ascii file, the option -v0 " 77 "is useful. To suppre ddwriting to an output file --null can be used.\n"82 "is useful. To suppress writing to an output file --null can be used.\n" 78 83 "\n" 79 84 "The default is to read the query from a file called rootify.sql. Except if a different " … … 91 96 "You can use environment definitions for substitutions in your SQL query. " 92 97 "For example --env.TEST=5 would replace $TEST or ${TEST} in your query by 5." 93 "If you specif iy one environmentvariable more than once, a list is created. "98 "If you specify one environment variable more than once, a list is created. " 94 99 "For example --env.TEST=1 --env.TEST=2 --env.TEST=3 would substitute " 95 100 "$TEST or ${TEST} by '1, 2, 3'. This is useful for the SQL `IN` keyword. " … … 101 106 "/*comment*/ or introduced with # (shell script style) or -- (SQL style).\n" 102 107 "\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" 104 109 "\n" 105 110 "Usage: rootifysql [rootify.sql [rootify.root]] [-u URI] [-q query|-f file] [-i] [-o out] [-f] [-cN] [-t tree] [-vN]\n" … … 380 385 cerr << "\nSHOW WARNINGS\n\n"; 381 386 cerr << "SQL query failed:\n" << e.what() << endl; 382 return 6;387 return 1; 383 388 } 384 389 } … … 420 425 cerr << "\nSHOW PROFILE ALL\n\n"; 421 426 cerr << "SQL query failed:\n" << e.what() << '\n' <<endl; 422 return 11;427 return 2; 423 428 } 424 429 } … … 438 443 cerr << "\nSHOW STATUS LIKE 'Bytes_%'\n\n"; 439 444 cerr << "SQL query failed:\n" << e.what() << endl; 440 return 6;445 return 3; 441 446 } 442 447 } … … 503 508 { 504 509 cerr << "Could not open query in '" << file << "': " << strerror(errno) << endl; 505 return 1;510 return 4; 506 511 } 507 512 getline(fin, query, (char)fin.eof()); … … 511 516 { 512 517 cerr << "No query specified." << endl; 513 return 2;518 return 5; 514 519 } 515 520 … … 530 535 { 531 536 cerr << "Could not open environment in '" << fname << "' for ${" << ident << "}: " << strerror(errno) << endl; 532 return 3;537 return 6; 533 538 } 534 539 … … 569 574 { 570 575 cerr << "File '" << path << "' is not writable." << endl; 571 return 3;576 return 7; 572 577 } 573 578 … … 575 580 { 576 581 cerr << "File '" << path << "' already exists." << endl; 577 return 4;582 return 8; 578 583 } 579 584 } … … 603 608 { 604 609 const auto &res1 = connection.query("SHOW STATUS LIKE 'Compression'").store(); 605 cout << "Compression of datab se connection is " << string(res1[0][1]) << endl;610 cout << "Compression of database connection is " << string(res1[0][1]) << endl; 606 611 607 612 const auto &res2 = connection.query("SHOW STATUS LIKE 'Ssl_cipher'").store(); … … 612 617 cerr << "\nSHOW STATUS LIKE 'Compression'\n\n"; 613 618 cerr << "SQL query failed:\n" << e.what() << endl; 614 return 6;619 return 9; 615 620 } 616 621 } … … 625 630 cerr << "\nSET profiling=1\n\n"; 626 631 cerr << "SQL query failed:\n" << e.what() << endl; 627 return 6;632 return 10; 628 633 } 629 634 … … 645 650 cerr << '\n' << varset << "\n\n"; 646 651 cerr << "SQL query failed:\n" << e.what() << endl; 647 return 7;652 return 11; 648 653 } 649 654 … … 730 735 cerr << '\n' << query << "\n\n"; 731 736 cerr << "SQL query failed:\n" << e.what() << endl; 732 return 8;737 return 12; 733 738 } 734 739 … … 757 762 TFile tfile(path, update?"UPDATE":(force?"RECREATE":"CREATE"), "Rootify SQL", compression); 758 763 if (tfile.IsZombie()) 759 return 9;764 return 13; 760 765 761 766 // ------------------------------------------------------------------------- … … 767 772 cerr << "Empty set returned... nothing to write." << endl; 768 773 finish(connection, verbose, profiling, print_connection); 769 return 1 0;774 return 14; 770 775 } 771 776
Note:
See TracChangeset
for help on using the changeset viewer.