1//===----------------------------------------------------------------------===//
2// DuckDB
3//
4// duckdb/parser/parsed_data/alter_info.hpp
5//
6//
7//===----------------------------------------------------------------------===//
8
9#pragma once
10
11#include "duckdb/common/enums/catalog_type.hpp"
12#include "duckdb/parser/column_definition.hpp"
13#include "duckdb/parser/parsed_data/parse_info.hpp"
14#include "duckdb/common/enums/on_entry_not_found.hpp"
15
16namespace duckdb {
17
18enum class AlterType : uint8_t {
19 INVALID = 0,
20 ALTER_TABLE = 1,
21 ALTER_VIEW = 2,
22 ALTER_SEQUENCE = 3,
23 CHANGE_OWNERSHIP = 4,
24 ALTER_SCALAR_FUNCTION = 5,
25 ALTER_TABLE_FUNCTION = 6
26};
27
28struct AlterEntryData {
29 AlterEntryData() {
30 }
31 AlterEntryData(string catalog_p, string schema_p, string name_p, OnEntryNotFound if_not_found)
32 : catalog(std::move(catalog_p)), schema(std::move(schema_p)), name(std::move(name_p)),
33 if_not_found(if_not_found) {
34 }
35
36 string catalog;
37 string schema;
38 string name;
39 OnEntryNotFound if_not_found;
40};
41
42struct AlterInfo : public ParseInfo {
43 AlterInfo(AlterType type, string catalog, string schema, string name, OnEntryNotFound if_not_found);
44 virtual ~AlterInfo() override;
45
46 AlterType type;
47 //! if exists
48 OnEntryNotFound if_not_found;
49 //! Catalog name to alter
50 string catalog;
51 //! Schema name to alter
52 string schema;
53 //! Entry name to alter
54 string name;
55 //! Allow altering internal entries
56 bool allow_internal;
57
58public:
59 virtual CatalogType GetCatalogType() const = 0;
60 virtual unique_ptr<AlterInfo> Copy() const = 0;
61 void Serialize(Serializer &serializer) const;
62 virtual void Serialize(FieldWriter &writer) const = 0;
63 static unique_ptr<AlterInfo> Deserialize(Deserializer &source);
64 virtual string GetColumnName() const {
65 return "";
66 };
67
68 AlterEntryData GetAlterEntryData() const;
69};
70
71} // namespace duckdb
72