| 109 | |
| 110 | |
| 111 | void PgWriter::writeInit() |
| 112 | { |
| 113 | if (m_schema_is_initialized) |
| 114 | return; |
| 115 | |
| 116 | // Start up the database connection |
| 117 | pg_begin(m_session); |
| 118 | |
| 119 | // Pre-SQL can be *either* a SQL file to execute, *or* a SQL statement |
| 120 | // to execute. We find out which one here. |
| 121 | if (m_pre_sql.size()) |
| 122 | { |
| 123 | std::string sql = FileUtils::readFileIntoString(m_pre_sql); |
| 124 | if (!sql.size()) |
| 125 | { |
| 126 | // if there was no file to read because the data in pre_sql was |
| 127 | // actually the sql code the user wanted to run instead of the |
| 128 | // filename to open, we'll use that instead. |
| 129 | sql = m_pre_sql; |
| 130 | } |
| 131 | pg_execute(m_session, sql); |
| 132 | } |
| 133 | |
| 134 | bool bHaveTable = CheckTableExists(m_table_name); |
| 135 | |
| 136 | // Apply the over-write preference if it is set |
| 137 | if (m_overwrite && bHaveTable) |
| 138 | { |
| 139 | DeleteTable(m_schema_name, m_table_name); |
| 140 | bHaveTable = false; |
| 141 | } |
| 142 | |
| 143 | // Read or create a PCID for our new table |
| 144 | m_pcid = SetupSchema(m_srid); |
| 145 | |
| 146 | // Create the table! |
| 147 | if (! bHaveTable) |
| 148 | { |
| 149 | CreateTable(m_schema_name, m_table_name, m_column_name, m_pcid); |
| 150 | } |
| 151 | |
| 152 | m_schema_is_initialized = true; |
| 153 | } |
| 154 | |
| 155 | void PgWriter::write(const PointViewPtr view) |
| 156 | { |
nothing calls this directly
no test coverage detected