1//===----------------------------------------------------------------------===//
2// DuckDB
3//
4// duckdb/parser/constraints/unique_constraint.hpp
5//
6//
7//===----------------------------------------------------------------------===//
8
9#pragma once
10
11#include "duckdb/parser/constraint.hpp"
12#include "duckdb/common/vector.hpp"
13
14namespace duckdb {
15
16class UniqueConstraint : public Constraint {
17public:
18 static constexpr const ConstraintType TYPE = ConstraintType::UNIQUE;
19
20public:
21 DUCKDB_API UniqueConstraint(LogicalIndex index, bool is_primary_key);
22 DUCKDB_API UniqueConstraint(vector<string> columns, bool is_primary_key);
23
24 //! The index of the column for which this constraint holds. Only used when the constraint relates to a single
25 //! column, equal to DConstants::INVALID_INDEX if not used
26 LogicalIndex index;
27 //! The set of columns for which this constraint holds by name. Only used when the index field is not used.
28 vector<string> columns;
29 //! Whether or not this is a PRIMARY KEY constraint, or a UNIQUE constraint.
30 bool is_primary_key;
31
32public:
33 DUCKDB_API string ToString() const override;
34
35 DUCKDB_API unique_ptr<Constraint> Copy() const override;
36
37 //! Serialize to a stand-alone binary blob
38 DUCKDB_API void Serialize(FieldWriter &writer) const override;
39 //! Deserializes a ParsedConstraint
40 DUCKDB_API static unique_ptr<Constraint> Deserialize(FieldReader &source);
41};
42
43} // namespace duckdb
44