OmniSciDB  6686921089
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Parser::DDLStmt Class Referenceabstract

#include <ParserNode.h>

+ Inheritance diagram for Parser::DDLStmt:
+ Collaboration diagram for Parser::DDLStmt:

Public Member Functions

virtual void execute (const Catalog_Namespace::SessionInfo &session)=0
 
void setColumnDescriptor (ColumnDescriptor &cd, const ColumnDef *coldef)
 
- Public Member Functions inherited from Parser::Node
virtual ~Node ()
 

Detailed Description

Definition at line 758 of file ParserNode.h.

Member Function Documentation

void Parser::DDLStmt::setColumnDescriptor ( ColumnDescriptor cd,
const ColumnDef coldef 
)

Definition at line 4234 of file ParserNode.cpp.

References Parser::ColumnDef::get_column_constraint(), Parser::ColumnDef::get_column_name(), Parser::ColumnDef::get_column_type(), Parser::ColumnDef::get_compression(), Parser::ColumnConstraintDef::get_defaultval(), ddl_utils::SqlType::get_is_array(), Parser::ColumnConstraintDef::get_notnull(), Parser::StringLiteral::get_stringval(), and ddl_utils::set_column_descriptor().

Referenced by Parser::AddColumnStmt::execute().

4234  {
4235  bool not_null;
4236  const ColumnConstraintDef* cc = coldef->get_column_constraint();
4237  if (cc == nullptr) {
4238  not_null = false;
4239  } else {
4240  not_null = cc->get_notnull();
4241  }
4242  std::string default_value;
4243  const std::string* default_value_ptr = nullptr;
4244  if (cc) {
4245  if (auto def_val_literal = cc->get_defaultval()) {
4246  auto defaultsp = dynamic_cast<const StringLiteral*>(def_val_literal);
4247  default_value =
4248  defaultsp ? *defaultsp->get_stringval() : def_val_literal->to_string();
4249  // The preprocessing below is needed because:
4250  // a) TypedImportBuffer expects arrays in the {...} format
4251  // b) TypedImportBuffer expects string literals inside arrays w/o any quotes
4252  if (coldef->get_column_type()->get_is_array()) {
4253  std::regex array_re(R"(^ARRAY\s*\[(.*)\]$)", std::regex_constants::icase);
4254  default_value = std::regex_replace(default_value, array_re, "{$1}");
4255  boost::erase_all(default_value, "\'");
4256  }
4257  default_value_ptr = &default_value;
4258  }
4259  }
4260  ddl_utils::set_column_descriptor(*coldef->get_column_name(),
4261  cd,
4262  coldef->get_column_type(),
4263  not_null,
4264  coldef->get_compression(),
4265  default_value_ptr);
4266 }
void set_column_descriptor(const std::string &column_name, ColumnDescriptor &cd, SqlType *column_type, const bool not_null, const Encoding *encoding, const std::string *default_value)
Definition: DdlUtils.cpp:645

+ Here is the call graph for this function:

+ Here is the caller graph for this function:


The documentation for this class was generated from the following files: