| 14 | static std::string at("@"); |
| 15 | |
| 16 | int runsql(cdb2_hndl_tp *h, std::string &sql) |
| 17 | { |
| 18 | int rc = cdb2_run_statement(h, sql.c_str()); |
| 19 | if (rc != 0) { |
| 20 | fprintf(stderr, "cdb2_run_statement failed: %d %s\n", rc, |
| 21 | cdb2_errstr(h)); |
| 22 | return rc; |
| 23 | } |
| 24 | |
| 25 | rc = cdb2_next_record(h); |
| 26 | while (rc == CDB2_OK) { |
| 27 | int n = cdb2_numcolumns(h); |
| 28 | int i; |
| 29 | const char *c = ""; |
| 30 | for (i = 0; i < n; ++i) { |
| 31 | if(cdb2_column_type(h, i) == CDB2_CSTRING) { |
| 32 | char * v = (char *)cdb2_column_value(h, i); |
| 33 | printf("%s%s", c, v); |
| 34 | c = ", "; |
| 35 | } |
| 36 | } |
| 37 | if(*c) printf("\n"); |
| 38 | rc = cdb2_next_record(h); |
| 39 | } |
| 40 | |
| 41 | if (rc == CDB2_OK_DONE) |
| 42 | rc = 0; |
| 43 | else |
| 44 | fprintf(stderr, "cdb2_next_record failed: %d %s\n", rc, cdb2_errstr(h)); |
| 45 | return rc; |
| 46 | } |
| 47 | |
| 48 | |
| 49 | int runtag(cdb2_hndl_tp *h, std::string &sql, std::vector<int> &types) |
no test coverage detected