예제 #1
0
inline void dialect_ms_sql::sql_intersect(command* cmd, const table_def& tbl, const std::string& col, const std::vector<boost::box>& boxes, std::string& sql, std::vector<column_def>& keys)
{
  using namespace std;

  if (!tbl.rtree(col) || boxes.size() < 2) return;

  auto idx(find_if(begin(tbl.indexes), end(tbl.indexes), [&](const index_def& i){ return index_type::Primary == i.type; }));
  if (idx == end(tbl.indexes)) throw runtime_error("unique columns error");
  keys = brig::detail::get_columns(tbl.columns, idx->columns);
  
  const string sql_prefix("(SELECT " + sql_select_list(this, cmd, keys) + " FROM " + dialect::sql_identifier(tbl.id) + " " + sql_hint(tbl, col) + " WHERE (");
  const string sql_suffix("))");
  
  for (auto box(begin(boxes)); box != end(boxes); ++box)
  {
    if (box != begin(boxes)) sql += " UNION ";
    sql += sql_prefix + sql_intersect(tbl, col, *box) + sql_suffix;
  }
}
예제 #2
0
파일: dialect_db2.hpp 프로젝트: respu/brig
inline std::string dialect_db2::sql_create_spatial_index(const table_def& tbl, const std::string& col)
{
  return "CREATE INDEX " + sql_identifier(tbl.rtree(col)->id.name) + " ON " + sql_identifier(tbl.id.name) + " (" + sql_identifier(col) + ") EXTEND USING DB2GSE.SPATIAL_INDEX (1, 0, 0)";
}
예제 #3
0
inline std::string dialect_postgres::sql_create_spatial_index(const table_def& tbl, const std::string& col)
{
  return "CREATE INDEX " + sql_identifier(tbl.rtree(col)->id.name) + " ON " + sql_identifier(tbl.id.name) + " USING GIST(" + sql_identifier(col) + ")";
}