Skip to content

Commit 839adcd

Browse files
committed
Fix abort error when run with driver script when foreign keys are
enabled https://perconadev.atlassian.net/browse/PSTRESS-152 Problem ======= The parent table pointer of the foreign key table object became invalid after the first trial and was not updated properly for the subsequent trials causing SIGSEGV errors. Solution ======== The parent table name is also stored in the dll file for each step and the parent table pointer for tables with foreign keys is set properly when metadata is loaded from the dll files.
1 parent ec40d4e commit 839adcd

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/random_test.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,8 +1020,11 @@ template <typename Writer> void Table::Serialize(Writer &writer) const {
10201020
}
10211021
} else if (type == FK) {
10221022
auto fk_table = static_cast<const FK_table *>(this);
1023+
std::string parent = fk_table->parent->name_;
10231024
std::string on_update = fk_table->enumToString(fk_table->on_update);
10241025
std::string on_delete = fk_table->enumToString(fk_table->on_delete);
1026+
writer.String("parent");
1027+
writer.String(parent.c_str(), static_cast<SizeType>(parent.length()));
10251028
writer.String("on_update");
10261029
writer.String(on_update.c_str(), static_cast<SizeType>(on_update.length()));
10271030
writer.String("on_delete");
@@ -3360,7 +3363,15 @@ static std::string load_metadata_from_file() {
33603363
} else if (table_type == "FK") {
33613364
std::string on_update = tab["on_update"].GetString();
33623365
std::string on_delete = tab["on_delete"].GetString();
3366+
std::string parent_name = tab["parent"].GetString();
3367+
33633368
table = new FK_table(name, on_update, on_delete);
3369+
for (auto &tbl : *all_tables) {
3370+
if (tbl->name_ == parent_name) {
3371+
static_cast<FK_table *>(table)->parent = tbl;
3372+
break;
3373+
}
3374+
}
33643375
} else
33653376
throw std::runtime_error("Unhandle Table type " + table_type);
33663377

0 commit comments

Comments
 (0)