OmniSciDB  21ac014ffc
 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 732 of file ParserNode.h.

Member Function Documentation

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

Definition at line 4065 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().

4065  {
4066  bool not_null;
4067  const ColumnConstraintDef* cc = coldef->get_column_constraint();
4068  if (cc == nullptr) {
4069  not_null = false;
4070  } else {
4071  not_null = cc->get_notnull();
4072  }
4073  std::string default_value;
4074  const std::string* default_value_ptr = nullptr;
4075  if (cc) {
4076  if (auto def_val_literal = cc->get_defaultval()) {
4077  auto defaultsp = dynamic_cast<const StringLiteral*>(def_val_literal);
4078  default_value =
4079  defaultsp ? *defaultsp->get_stringval() : def_val_literal->to_string();
4080  // The preprocessing below is needed because:
4081  // a) TypedImportBuffer expects arrays in the {...} format
4082  // b) TypedImportBuffer expects string literals inside arrays w/o any quotes
4083  if (coldef->get_column_type()->get_is_array()) {
4084  std::regex array_re(R"(^ARRAY\s*\[(.*)\]$)", std::regex_constants::icase);
4085  default_value = std::regex_replace(default_value, array_re, "{$1}");
4086  boost::erase_all(default_value, "\'");
4087  }
4088  // NULL for default value means no default value
4089  if (!boost::iequals(default_value, "NULL")) {
4090  default_value_ptr = &default_value;
4091  }
4092  }
4093  }
4094  ddl_utils::set_column_descriptor(*coldef->get_column_name(),
4095  cd,
4096  coldef->get_column_type(),
4097  not_null,
4098  coldef->get_compression(),
4099  default_value_ptr);
4100 }
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:509

+ 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: