add_constraint Action
Implement the add_constraint DoAction to support ALTER TABLE ADD CONSTRAINT statements for check and unique constraints.
The add_constraint action adds a constraint (such as CHECK, UNIQUE, or FOREIGN KEY) to an existing table. This action is invoked when executing an ALTER TABLE ... ADD CONSTRAINT SQL statement.
SQL Example
ALTER TABLE example.main.employees ADD CONSTRAINT salary_positive CHECK (salary > 0);
ALTER TABLE example.main.employees ADD CONSTRAINT unique_email UNIQUE (email);Input Parameters
The action receives a single msgpack-serialized parameter:
// The base class for all alter parameters.
struct AirportAlterBase
{
//! Catalog name to alter
std::string catalog;
//! Schema name to alter
std::string schema;
//! Entry name to alter
std::string name;
bool ignore_not_found;
};
struct AirportAlterTableAddConstraintParameters : AirportAlterBase
{
std::string constraint;
MSGPACK_DEFINE_MAP(catalog, schema, name, constraint);
};Return Value
The action must return a single FlightInfo structure representing the modified table with the constraint applied. The app_metadata field must be populated appropriately to identify the flight as a table.