Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
gh-133390: Support SQL keyword completion for sqlite3 CLI#133393
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes from1 commit
1b96be35e50871c1941cb47daca5c54c2f68fff491a766805da55014ca587e0311b4f370f46e99d03730bfcff38805d997276b4a709eeac8fc57d71c508069231b9e7121b06990a86cf5170733b40982a226ea9f4eebbd93f9b2c10410fa2bd0b9ce35a17e73dd16b3f3ea951a493ad334cfc78477b48b68bb4f34c3b1224f1221e38651318d4f659ccd98a5d681425ffd0f026188a6d370dd8b16b1674ea108ba13b527efafd1bb140818cfd6c89e588fb6a5623f1688c8d59b3a2b88File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -32,6 +32,7 @@ | ||
| #include "microprotocols.h" | ||
| #include "row.h" | ||
| #include "blob.h" | ||
| #include "util.h" | ||
| #if SQLITE_VERSION_NUMBER < 3015002 | ||
| #error "SQLite 3.15.2 or higher required" | ||
| @@ -405,51 +406,39 @@ pysqlite_error_name(int rc) | ||
| } | ||
| static int | ||
| add_keyword_tuple(PyObject *module) | ||
| { | ||
| int count = sqlite3_keyword_count(); | ||
erlend-aasland marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| PyObject *keywords = PyTuple_New(count); | ||
| if (keywords == NULL) { | ||
| goto error; | ||
| } | ||
| for (int i = 0; i < count; i++) { | ||
| const char *keyword; | ||
| int size; | ||
| int result = sqlite3_keyword_name(i, &keyword, &size); | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. For the record: | ||
| if (result != SQLITE_OK) { | ||
| pysqlite_state *state = pysqlite_get_state(module); | ||
| set_error_from_code(state, result); | ||
| goto error; | ||
| } | ||
| PyObject *kwd = PyUnicode_FromStringAndSize(keyword, size); | ||
| if (!kwd) { | ||
| goto error; | ||
| } | ||
| if (PyTuple_SetItem(keywords, i, kwd) < 0) { | ||
serhiy-storchaka marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| Py_DECREF(kwd); | ||
| goto error; | ||
| } | ||
| } | ||
| if (PyModule_Add(module, "SQLITE_KEYWORDS", keywords) < 0) { | ||
serhiy-storchaka marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| goto error; | ||
| } | ||
| return 0; | ||
| error: | ||
| Py_XDECREF(keywords); | ||
| return -1; | ||
| } | ||
| static int | ||
| @@ -750,8 +739,8 @@ module_exec(PyObject *module) | ||
| goto error; | ||
| } | ||
| /* Setthe keyword tuple */ | ||
erlend-aasland marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| if (add_keyword_tuple(module) < 0) { | ||
| goto error; | ||
| } | ||