| 356 | |
| 357 | |
| 358 | bool PgWriter::CheckTableExists(std::string const& name) |
| 359 | { |
| 360 | std::ostringstream oss; |
| 361 | oss << "SELECT count(*) FROM pg_tables WHERE tablename ILIKE '" << |
| 362 | name << "'"; |
| 363 | |
| 364 | log()->get(LogLevel::Debug) << "checking for table '" << name << |
| 365 | "' existence ... " << std::endl; |
| 366 | |
| 367 | std::string count_str = pg_query_once(m_session, oss.str()); |
| 368 | if (count_str.empty()) |
| 369 | throwError("Unable to check for the existence of 'pg_table'."); |
| 370 | int count = atoi(count_str.c_str()); |
| 371 | |
| 372 | if (count == 1) |
| 373 | return true; |
| 374 | else if (count > 1) |
| 375 | log()->get(LogLevel::Debug) << "found more than 1 table named '" << |
| 376 | name << "'" << std::endl; |
| 377 | return false; |
| 378 | } |
| 379 | |
| 380 | void PgWriter::CreateTable(std::string const& schema_name, |
| 381 | std::string const& table_name, std::string const& column_name, |
nothing calls this directly
no test coverage detected