Open vivekgalatage opened 7 years ago
This turned out to be a problem in the printCreateStatementInfo
function in src/util/sqlhelper.cpp
. The value of stmt->fileName
was null so it errored out.
This modified version adds a null check and a loop to print the column names and types. It's really ugly but I hastily put this together just to try and get this working:
void printCreateStatementInfo(const CreateStatement* stmt, uintmax_t numIndent) {
inprint("CreateStatment", numIndent);
inprint(stmt->tableName, numIndent + 1);
if (stmt->filePath) {
inprint(stmt->filePath, numIndent + 1);
}
inprint("Columns", numIndent + 1);
for (hsql::ColumnDefinition* column : *stmt->columns) {
std::string typeStr{};
switch (column->type) {
case hsql::ColumnDefinition::DataType::INT:
typeStr = "INT";
break;
case hsql::ColumnDefinition::DataType::DOUBLE:
typeStr = "DOUBLE";
break;
case hsql::ColumnDefinition::DataType::TEXT:
typeStr = "INT";
break;
default:
typeStr = "UNKNOWN";
}
std::cout << indent(numIndent + 2).c_str() << column->name << " " << typeStr << std::endl;
}
}
Results:
./example "CREATE TABLE Persons (PersonID int);"
Parsed successfully!
Number of statements: 1
CreateStatment
Persons
Columns
PersonID INT
This issue is fixed. The cited example passes with in the current origin/master
.
The nullptr check is present in sqlhelper.cpp (300)
void printCreateStatementInfo(const CreateStatement* stmt, uintmax_t numIndent) {
inprint("CreateStatement", numIndent);
inprint(stmt->tableName, numIndent + 1);
if (stmt->filePath) inprint(stmt->filePath, numIndent + 1);
}
I think this can be closed now
Thanks for pointing this out. Yes, the nullptr ckeck is fixed. I will add the proposed column definitions and then close this issue.
I built the code on Mac and tried executing the
example
with below statementAnd this results in a SEGFAULT. So I tried to debug and got the following stack