MCPcopy Create free account
hub / github.com/duckdb/duckdb / RunTableDumpQuery

Method RunTableDumpQuery

tools/shell/shell.cpp:873–897  ·  view source on GitHub ↗

** 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

Source from the content-addressed store, hash-verified

871** won't consume the semicolon terminator.
872*/
873void 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
899bool ShellState::ColumnTypeIsInteger(const char *type) {
900 if (!type) {

Callers 1

DumpTableFunction · 0.80

Calls 4

c_strMethod · 0.80
QueryMethod · 0.45
HasErrorMethod · 0.45
GetErrorMethod · 0.45

Tested by

no test coverage detected