Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
add_library_unity(duckdb_parsed_data | ||
OBJECT | ||
alter_table_info.cpp) | ||
set(ALL_OBJECT_FILES | ||
${ALL_OBJECT_FILES} $<TARGET_OBJECTS:duckdb_parsed_data> | ||
PARENT_SCOPE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#include "duckdb/parser/parsed_data/alter_table_info.hpp" | ||
#include "duckdb/common/serializer.hpp" | ||
|
||
using namespace duckdb; | ||
using namespace std; | ||
|
||
void AlterInfo::Serialize(Serializer &serializer) { | ||
serializer.Write<AlterType>(type); | ||
} | ||
|
||
unique_ptr<AlterInfo> AlterInfo::Deserialize(Deserializer &source) { | ||
auto type = source.Read<AlterType>(); | ||
switch(type) { | ||
case AlterType::ALTER_TABLE: | ||
return AlterTableInfo::Deserialize(source); | ||
default: | ||
throw SerializationException("Unknown alter type for deserialization!"); | ||
} | ||
} | ||
|
||
void AlterTableInfo::Serialize(Serializer &serializer) { | ||
AlterInfo::Serialize(serializer); | ||
serializer.Write<AlterTableType>(alter_table_type); | ||
serializer.WriteString(schema); | ||
serializer.WriteString(table); | ||
} | ||
|
||
unique_ptr<AlterInfo> AlterTableInfo::Deserialize(Deserializer &source) { | ||
auto type = source.Read<AlterTableType>(); | ||
auto schema = source.Read<string>(); | ||
auto table = source.Read<string>(); | ||
unique_ptr<AlterTableInfo> info; | ||
switch(type) { | ||
case AlterTableType::RENAME_COLUMN: | ||
return RenameColumnInfo::Deserialize(source, schema, table); | ||
default: | ||
throw SerializationException("Unknown alter table type for deserialization!"); | ||
} | ||
} | ||
|
||
void RenameColumnInfo::Serialize(Serializer &serializer) { | ||
AlterTableInfo::Serialize(serializer); | ||
serializer.WriteString(name); | ||
serializer.WriteString(new_name); | ||
} | ||
|
||
unique_ptr<AlterInfo> RenameColumnInfo::Deserialize(Deserializer &source, string schema, string table) { | ||
auto name = source.Read<string>(); | ||
auto new_name = source.Read<string>(); | ||
return make_unique<RenameColumnInfo>(schema, table, name, new_name); | ||
} |