** Execute a query statement that will generate SQL output. Print ** the result columns, comma-separated, on a line and then add a ** semicolon terminator to the end of that line. ** ** If the number of columns is 1 and that column contains text "--" ** then write the semicolon on a separate line. That way, if a ** "--" comment occurs at the end of the statement, the comment ** won't consume the
| 871 | ** won't consume the semicolon terminator. |
| 872 | */ |
| 873 | void ShellState::RunTableDumpQuery(const string &zSelect) { |
| 874 | auto &con = *conn; |
| 875 | auto result = con.Query(zSelect); |
| 876 | if (result->HasError()) { |
| 877 | PrintF("/**** ERROR: %s *****/\n", result->GetError().c_str()); |
| 878 | AddError(); |
| 879 | return; |
| 880 | } |
| 881 | for (auto &row : *result) { |
| 882 | auto zStr = row.GetValue<string>(0); |
| 883 | Print(zStr); |
| 884 | auto z = zStr.c_str(); |
| 885 | if (!z) { |
| 886 | z = ""; |
| 887 | } |
| 888 | while (z[0] && (z[0] != '-' || z[1] != '-')) { |
| 889 | z++; |
| 890 | } |
| 891 | if (z[0]) { |
| 892 | PrintF("\n;\n"); |
| 893 | } else { |
| 894 | PrintF(";\n"); |
| 895 | } |
| 896 | } |
| 897 | } |
| 898 | |
| 899 | bool ShellState::ColumnTypeIsInteger(const char *type) { |
| 900 | if (!type) { |