-
Notifications
You must be signed in to change notification settings - Fork 173
fix(c/driver/sqlite): support PRIMARY KEY constraint in GetObjects #777
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
TODO: Use the new helper from #769 |
|
Hmm, the new helper is a little too rigid for SQLite's purposes |
ed79dd5 to
5ba7dc7
Compare
|
Just needs a small bend to work! |
a07af36 to
60391c5
Compare
|
Hmm, I just realized, why is this all in utils.c in the first place? Seems like it should go in adbc_validation_util.cc... |
|
I think the ASAN problem is with the destructor - I think can push up a fix soon |
|
I think should be resolved by #785 |
c/driver/common/utils.c
Outdated
| struct AdbcGetObjectsConstraint* constraint = table->table_constraints[i]; | ||
| struct ArrowStringView name = constraint->constraint_name; | ||
| if (!strncmp(name.data, constraint_name, name.size_bytes)) { | ||
| if (!constraint_name || !strncmp(name.data, constraint_name, name.size_bytes)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm is this function receiving a nullptr? Seems a bit strange to call a GetByName function, pass it a NULL pointer for the name and expect a result back
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Current implementation does allow for UB if constraint_name is NULL so makes sense to return early if that happens, though I think that should be on function entry and also just return NULL there instead of grabbing the first constraint?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair.
SQLite doesn't name its constraints so I wanted some way to just get any constraint.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah OK. In that case maybe you want to do something like this instead?
struct AdbcGetObjectsTable* table =
AdbcGetObjectsDataGetTableByName(*get_objects_data, quirks()->catalog().c_str(),
quirks()->db_schema().c_str(), "adbc_pkey_test");
if (table->n_table_constraints > 0) {
struct AdbcGetObjectsConstraint *constraint = table->table_constraints[0];
...
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternately could add a AdbcGetObjectsDataGetConstraintByPosition function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, nice. I'll update it tomorrow morning
60391c5 to
94cc45a
Compare
Fixes #666.