Implement Sqlite3 Module#4260
Merged
Merged
Conversation
0a7f6fe to
8bebe38
Compare
Contributor
Author
|
@youknowone Can you help with that compilation fail with android? |
Member
|
that looks like a toolchain problem. rather than fighting with it, how about just disabling sqlite3 for android? |
youknowone
approved these changes
Jan 5, 2023
Member
youknowone
left a comment
There was a problem hiding this comment.
Great! You made a huge work!
Comment on lines
+846
to
+856
| let guard = self.db.lock(); | ||
| if guard.is_some() { | ||
| Ok(PyMutexGuard::map(guard, |x| unsafe { | ||
| x.as_mut().unwrap_unchecked() | ||
| })) | ||
| } else { | ||
| Err(new_programming_error( | ||
| vm, | ||
| "Cannot operate on a closed database.".to_owned(), | ||
| )) | ||
| } |
Member
There was a problem hiding this comment.
Suggested change
| let guard = self.db.lock(); | |
| if guard.is_some() { | |
| Ok(PyMutexGuard::map(guard, |x| unsafe { | |
| x.as_mut().unwrap_unchecked() | |
| })) | |
| } else { | |
| Err(new_programming_error( | |
| vm, | |
| "Cannot operate on a closed database.".to_owned(), | |
| )) | |
| } | |
| let Some(guard) = self.db.lock() else { | |
| return Err(new_programming_error( | |
| vm, | |
| "Cannot operate on a closed database.".to_owned(), | |
| )); | |
| }; | |
| Ok(PyMutexGuard::map(guard, |x| unsafe { | |
| x.as_mut().unwrap_unchecked() | |
| })) |
Contributor
Author
There was a problem hiding this comment.
This is not going to work as the variable guard is MutexGuard<Option<_>>
Comment on lines
+1097
to
+1099
| unsafe { | ||
| sqlite3_create_collation_v2(db.db, name.as_ptr(), SQLITE_UTF8, null_mut(), None, None); | ||
| return Ok(()); | ||
| } |
Member
There was a problem hiding this comment.
Suggested change
| unsafe { | |
| sqlite3_create_collation_v2(db.db, name.as_ptr(), SQLITE_UTF8, null_mut(), None, None); | |
| return Ok(()); | |
| } | |
| unsafe { | |
| sqlite3_create_collation_v2(db.db, name.as_ptr(), SQLITE_UTF8, null_mut(), None, None); | |
| } | |
| return Ok(()); |
later code's unsafe blocks don't contain return Ok(()) but this one does.
Comment on lines
+1365
to
+1375
| let guard = self.inner.lock(); | ||
| if guard.is_some() { | ||
| Ok(PyMutexGuard::map(guard, |x| unsafe { | ||
| x.as_mut().unwrap_unchecked() | ||
| })) | ||
| } else { | ||
| Err(new_programming_error( | ||
| vm, | ||
| "Cannot operate on a closed cursor.".to_owned(), | ||
| )) | ||
| } |
Member
There was a problem hiding this comment.
Suggested change
| let guard = self.inner.lock(); | |
| if guard.is_some() { | |
| Ok(PyMutexGuard::map(guard, |x| unsafe { | |
| x.as_mut().unwrap_unchecked() | |
| })) | |
| } else { | |
| Err(new_programming_error( | |
| vm, | |
| "Cannot operate on a closed cursor.".to_owned(), | |
| )) | |
| } | |
| let Some(guard) = self.inner.lock() else { | |
| return Err(new_programming_error( | |
| vm, | |
| "Cannot operate on a closed cursor.".to_owned(), | |
| )); | |
| }; | |
| Ok(PyMutexGuard::map(guard, |x| unsafe { | |
| x.as_mut().unwrap_unchecked() | |
| })) |
| } | ||
|
|
||
| fn inner(&self, vm: &VirtualMachine) -> PyResult<PyMappedMutexGuard<BlobInner>> { | ||
| let guard = self.inner.lock(); |
Contributor
There was a problem hiding this comment.
Can you do let-else on a MutexGuard?
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #3983