MCPcopy Create free account
hub / github.com/PDAL/PDAL / CheckTableExists

Method CheckTableExists

plugins/pgpointcloud/io/PgWriter.cpp:358–378  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

356
357
358bool 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
380void PgWriter::CreateTable(std::string const& schema_name,
381 std::string const& table_name, std::string const& column_name,

Callers

nothing calls this directly

Calls 5

pg_query_onceFunction · 0.85
strMethod · 0.80
logFunction · 0.50
getMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected