|
|
LogicalIndex | index |
| | The indexed column of the constraint. Only used for single-column constraints, invalid otherwise.
|
|
vector< string > | columns |
| | The names of the columns on which this constraint is defined. Only set if the index field is not set.
|
|
bool | is_primary_key |
| | Whether this is a PRIMARY KEY constraint, or a UNIQUE constraint.
|
|
ConstraintType | type |
|
|
static constexpr const ConstraintType | TYPE = ConstraintType::UNIQUE |
◆ UniqueConstraint() [1/4]
| duckdb::UniqueConstraint::UniqueConstraint |
( |
const LogicalIndex | index, |
|
|
const bool | is_primary_key ) |
336062}
LogicalIndex index
The indexed column of the constraint. Only used for single-column constraints, invalid otherwise.
Definition duckdb.cpp:9204
bool is_primary_key
Whether this is a PRIMARY KEY constraint, or a UNIQUE constraint.
Definition duckdb.cpp:9208
◆ UniqueConstraint() [2/4]
| duckdb::UniqueConstraint::UniqueConstraint |
( |
const LogicalIndex | index, |
|
|
string | column_name, |
|
|
const bool | is_primary_key ) |
336065 columns.push_back(std::move(column_name_p));
336066}
vector< string > columns
The names of the columns on which this constraint is defined. Only set if the index field is not set.
Definition duckdb.cpp:9206
◆ UniqueConstraint() [3/4]
| duckdb::UniqueConstraint::UniqueConstraint |
( |
vector< string > | columns, |
|
|
const bool | is_primary_key ) |
336071}
static constexpr const idx_t INVALID_INDEX
The value used to signify an invalid index entry.
Definition duckdb.hpp:1117
◆ UniqueConstraint() [4/4]
| duckdb::UniqueConstraint::UniqueConstraint |
( |
| ) |
|
|
private |
◆ ToString()
| string duckdb::UniqueConstraint::ToString |
( |
| ) |
const |
|
overridevirtual |
Implements duckdb::Constraint.
336073 {
336076 if (i > 0) {
336077 base += ", ";
336078 }
336080 }
336081 return base + ")";
336082}
static string WriteOptionallyQuoted(const string &text, char quote='"', bool allow_caps = true, KeywordCategory category = KeywordCategory::KEYWORD_NONE)
Writes a string that is optionally quoted + escaped so it can be used as an identifier.
Definition duckdb.cpp:338034
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237
◆ Copy()
| unique_ptr< Constraint > duckdb::UniqueConstraint::Copy |
( |
| ) |
const |
|
overridevirtual |
Implements duckdb::Constraint.
336084 {
336087 }
336088
336090 return std::move(result);
336091}
bool HasIndex() const
Returns true, if the constraint is defined on a single column.
Definition duckdb.cpp:336097
◆ Serialize()
| void duckdb::UniqueConstraint::Serialize |
( |
Serializer & | serializer | ) |
const |
|
overridevirtual |
Reimplemented from duckdb::Constraint.
415617 {
415618 Constraint::Serialize(serializer);
415619 serializer.WritePropertyWithDefault<
bool>(200,
"is_primary_key",
is_primary_key);
415620 serializer.WriteProperty<LogicalIndex>(201,
"index",
index);
415621 serializer.WritePropertyWithDefault<vector<string>>(202,
"columns",
columns);
415622}
◆ Deserialize()
415624 {
415625 auto result = duckdb::unique_ptr<UniqueConstraint>(new UniqueConstraint());
415626 deserializer.ReadPropertyWithDefault<bool>(200, "is_primary_key", result->is_primary_key);
415627 deserializer.ReadProperty<LogicalIndex>(201, "index", result->index);
415628 deserializer.ReadPropertyWithDefault<vector<string>>(202, "columns", result->columns);
415629 return std::move(result);
415630}
◆ IsPrimaryKey()
| bool duckdb::UniqueConstraint::IsPrimaryKey |
( |
| ) |
const |
Returns true, if the constraint is a PRIMARY KEY constraint.
◆ HasIndex()
| bool duckdb::UniqueConstraint::HasIndex |
( |
| ) |
const |
Returns true, if the constraint is defined on a single column.
◆ GetIndex()
Returns the column index on which the constraint is defined.
336101 {
336103 throw InternalException("UniqueConstraint::GetIndex called on a unique constraint without an index");
336104 }
336106}
◆ SetIndex()
| void duckdb::UniqueConstraint::SetIndex |
( |
const LogicalIndex | new_index | ) |
|
Sets the column index of the constraint.
336108 {
336110 index = new_index;
336111}
◆ GetColumnNames()
| const vector< string > & duckdb::UniqueConstraint::GetColumnNames |
( |
| ) |
const |
Returns a constant reference to the column names on which the constraint is defined.
◆ GetColumnNamesMutable()
| vector< string > & duckdb::UniqueConstraint::GetColumnNamesMutable |
( |
| ) |
|
Returns a mutable reference to the column names on which the constraint is defined.
◆ GetLogicalIndexes()
Returns the column indexes on which the constraint is defined.
336123 {
336126 }
336127
336128 vector<LogicalIndex> indexes;
336130 D_ASSERT(column_list.ColumnExists(col_name));
336131 auto &col = column_list.GetColumn(col_name);
336132 D_ASSERT(!col.Generated());
336133 indexes.push_back(col.Logical());
336134 }
336135 return indexes;
336136}
LogicalIndex GetIndex() const
Returns the column index on which the constraint is defined.
Definition duckdb.cpp:336101
const vector< string > & GetColumnNames() const
Returns a constant reference to the column names on which the constraint is defined.
Definition duckdb.cpp:336113
◆ GetName()
| string duckdb::UniqueConstraint::GetName |
( |
const string & | table_name | ) |
const |
Get the name of the constraint.
336138 {
336139 auto type =
IsPrimaryKey() ? IndexConstraintType::PRIMARY : IndexConstraintType::UNIQUE;
336140 auto type_name = EnumUtil::ToString(type);
336141
336142 string name;
336144 name += "_" + column_name;
336145 }
336146 return type_name + "_" + table_name + name;
336147}
bool IsPrimaryKey() const
Returns true, if the constraint is a PRIMARY KEY constraint.
Definition duckdb.cpp:336093
The documentation for this class was generated from the following file: