From 7875662f09bc9d1146f5e88195eaec7e64210241 Mon Sep 17 00:00:00 2001 From: Hyunjee Kim Date: Fri, 10 Apr 2020 14:15:41 +0900 Subject: [PATCH] Imported Upstream version 0.1.1 Change-Id: Ifc5e364439ff87671d39a8f676422606f64aaef2 Signed-off-by: Hyunjee Kim --- PKG-INFO | 2 +- pysqlite3.egg-info/PKG-INFO | 2 +- setup.cfg | 1 - setup.py | 2 +- src/connection.c | 19 ++++++------- src/cursor.c | 53 +++++++++---------------------------- src/module.c | 10 ++++--- src/statement.c | 20 +++++++------- 8 files changed, 42 insertions(+), 67 deletions(-) diff --git a/PKG-INFO b/PKG-INFO index 21bcc2c..5ecd1aa 100644 --- a/PKG-INFO +++ b/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: pysqlite3 -Version: 0.1.0 +Version: 0.1.1 Summary: DB-API 2.0 interface for Sqlite 3.x Home-page: https://github.com/rigglemania/pysqlcipher3 Author: Charles Leifer diff --git a/pysqlite3.egg-info/PKG-INFO b/pysqlite3.egg-info/PKG-INFO index 21bcc2c..5ecd1aa 100644 --- a/pysqlite3.egg-info/PKG-INFO +++ b/pysqlite3.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: pysqlite3 -Version: 0.1.0 +Version: 0.1.1 Summary: DB-API 2.0 interface for Sqlite 3.x Home-page: https://github.com/rigglemania/pysqlcipher3 Author: Charles Leifer diff --git a/setup.cfg b/setup.cfg index f170bdf..8443209 100644 --- a/setup.cfg +++ b/setup.cfg @@ -6,5 +6,4 @@ library_dirs = /usr/lib [egg_info] tag_build = tag_date = 0 -tag_svn_revision = 0 diff --git a/setup.py b/setup.py index d3eaf4c..0ef9ef7 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ from setuptools import Extension # If you need to change anything, it should be enough to change setup.cfg. PACKAGE_NAME = 'pysqlite3' -VERSION = '0.1.0' +VERSION = '0.1.1' # define sqlite sources sources = [os.path.join('src', source) diff --git a/src/connection.c b/src/connection.c index 1c6aa54..4ce58d9 100644 --- a/src/connection.c +++ b/src/connection.c @@ -71,7 +71,7 @@ int pysqlite_connection_init(pysqlite_Connection* self, PyObject* args, PyObject { static char *kwlist[] = { "database", "timeout", "detect_types", "isolation_level", - "check_same_thread", "factory", "cached_statements", "uri", + "check_same_thread", "factory", "cached_statements", "uri", "flags", NULL }; @@ -81,14 +81,16 @@ int pysqlite_connection_init(pysqlite_Connection* self, PyObject* args, PyObject PyObject* factory = NULL; int check_same_thread = 1; int cached_statements = 100; + int flags = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE; int uri = 0; double timeout = 5.0; int rc; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|diOiOip", kwlist, + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|diOiOipi", kwlist, &database, &timeout, &detect_types, &isolation_level, &check_same_thread, - &factory, &cached_statements, &uri)) + &factory, &cached_statements, &uri, + &flags)) { return -1; } @@ -110,15 +112,14 @@ int pysqlite_connection_init(pysqlite_Connection* self, PyObject* args, PyObject #ifdef SQLITE_OPEN_URI Py_BEGIN_ALLOW_THREADS rc = sqlite3_open_v2(database, &self->db, - SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | - (uri ? SQLITE_OPEN_URI : 0), NULL); + flags | (uri ? SQLITE_OPEN_URI : 0), NULL); #else if (uri) { PyErr_SetString(pysqlite_NotSupportedError, "URIs not supported"); return -1; } Py_BEGIN_ALLOW_THREADS - rc = sqlite3_open(database, &self->db); + rc = sqlite3_open_v2(database, &self->db, flags, NULL); #endif Py_END_ALLOW_THREADS @@ -375,7 +376,7 @@ PyObject* _pysqlite_connection_begin(pysqlite_Connection* self) sqlite3_stmt* statement; Py_BEGIN_ALLOW_THREADS - rc = sqlite3_prepare(self->db, self->begin_statement, -1, &statement, &tail); + rc = sqlite3_prepare_v2(self->db, self->begin_statement, -1, &statement, &tail); Py_END_ALLOW_THREADS if (rc != SQLITE_OK) { @@ -418,7 +419,7 @@ PyObject* pysqlite_connection_commit(pysqlite_Connection* self, PyObject* args) if (!sqlite3_get_autocommit(self->db)) { Py_BEGIN_ALLOW_THREADS - rc = sqlite3_prepare(self->db, "COMMIT", -1, &statement, &tail); + rc = sqlite3_prepare_v2(self->db, "COMMIT", -1, &statement, &tail); Py_END_ALLOW_THREADS if (rc != SQLITE_OK) { _pysqlite_seterror(self->db, NULL); @@ -462,7 +463,7 @@ PyObject* pysqlite_connection_rollback(pysqlite_Connection* self, PyObject* args pysqlite_do_all_statements(self, ACTION_RESET, 1); Py_BEGIN_ALLOW_THREADS - rc = sqlite3_prepare(self->db, "ROLLBACK", -1, &statement, &tail); + rc = sqlite3_prepare_v2(self->db, "ROLLBACK", -1, &statement, &tail); Py_END_ALLOW_THREADS if (rc != SQLITE_OK) { _pysqlite_seterror(self->db, NULL); diff --git a/src/cursor.c b/src/cursor.c index 8237340..1d7b63c 100644 --- a/src/cursor.c +++ b/src/cursor.c @@ -535,45 +535,18 @@ PyObject* _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* goto error; } - /* Keep trying the SQL statement until the schema stops changing. */ - while (1) { - /* Actually execute the SQL statement. */ - rc = pysqlite_step(self->statement->st, self->connection); + rc = pysqlite_step(self->statement->st, self->connection); + if (rc != SQLITE_DONE && rc != SQLITE_ROW) { if (PyErr_Occurred()) { - (void)pysqlite_statement_reset(self->statement); - goto error; - } - if (rc == SQLITE_DONE || rc == SQLITE_ROW) { - /* If it worked, let's get out of the loop */ - break; - } - /* Something went wrong. Re-set the statement and try again. */ - rc = pysqlite_statement_reset(self->statement); - if (rc == SQLITE_SCHEMA) { - /* If this was a result of the schema changing, let's try - again. */ - rc = pysqlite_statement_recompile(self->statement, parameters); - if (rc == SQLITE_OK) { - continue; + if (_enable_callback_tracebacks) { + PyErr_Print(); } else { - /* If the database gave us an error, promote it to Python. */ - (void)pysqlite_statement_reset(self->statement); - _pysqlite_seterror(self->connection->db, NULL); - goto error; - } - } else { - if (PyErr_Occurred()) { - /* there was an error that occurred in a user-defined callback */ - if (_enable_callback_tracebacks) { - PyErr_Print(); - } else { - PyErr_Clear(); - } + PyErr_Clear(); } - (void)pysqlite_statement_reset(self->statement); - _pysqlite_seterror(self->connection->db, NULL); - goto error; } + (void)pysqlite_statement_reset(self->statement); + _pysqlite_seterror(self->connection->db, NULL); + goto error; } if (pysqlite_build_row_cast_map(self) != 0) { @@ -705,11 +678,11 @@ PyObject* pysqlite_cursor_executescript(pysqlite_Cursor* self, PyObject* args) while (1) { Py_BEGIN_ALLOW_THREADS - rc = sqlite3_prepare(self->connection->db, - script_cstr, - -1, - &statement, - &script_cstr); + rc = sqlite3_prepare_v2(self->connection->db, + script_cstr, + -1, + &statement, + &script_cstr); Py_END_ALLOW_THREADS if (rc != SQLITE_OK) { _pysqlite_seterror(self->connection->db, NULL); diff --git a/src/module.c b/src/module.c index fb4c432..ed3367e 100644 --- a/src/module.c +++ b/src/module.c @@ -52,7 +52,7 @@ static PyObject* module_connect(PyObject* self, PyObject* args, PyObject* static char *kwlist[] = { "database", "timeout", "detect_types", "isolation_level", - "check_same_thread", "factory", "cached_statements", "uri", + "check_same_thread", "factory", "cached_statements", "uri", "flags", NULL }; char* database; @@ -61,15 +61,17 @@ static PyObject* module_connect(PyObject* self, PyObject* args, PyObject* PyObject* factory = NULL; int check_same_thread = 1; int cached_statements; + int flags = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE; int uri = 0; double timeout = 5.0; PyObject* result; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|diOiOip", kwlist, + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|diOiOipi", kwlist, &database, &timeout, &detect_types, &isolation_level, &check_same_thread, - &factory, &cached_statements, &uri)) + &factory, &cached_statements, &uri, + &flags)) { return NULL; } @@ -85,7 +87,7 @@ static PyObject* module_connect(PyObject* self, PyObject* args, PyObject* PyDoc_STRVAR(module_connect_doc, "connect(database[, timeout, detect_types, isolation_level,\n\ - check_same_thread, factory, cached_statements, uri])\n\ + check_same_thread, factory, cached_statements, uri, flags])\n\ \n\ Opens a connection to the SQLite database file *database*. You can use\n\ \":memory:\" to open a database connection to a database that resides in\n\ diff --git a/src/statement.c b/src/statement.c index 087375b..0f9c2f9 100644 --- a/src/statement.c +++ b/src/statement.c @@ -93,11 +93,11 @@ int pysqlite_statement_create(pysqlite_Statement* self, pysqlite_Connection* con } Py_BEGIN_ALLOW_THREADS - rc = sqlite3_prepare(connection->db, - sql_cstr, - -1, - &self->st, - &tail); + rc = sqlite3_prepare_v2(connection->db, + sql_cstr, + -1, + &self->st, + &tail); Py_END_ALLOW_THREADS self->db = connection->db; @@ -334,11 +334,11 @@ int pysqlite_statement_recompile(pysqlite_Statement* self, PyObject* params) } Py_BEGIN_ALLOW_THREADS - rc = sqlite3_prepare(self->db, - sql_cstr, - -1, - &new_st, - &tail); + rc = sqlite3_prepare_v2(self->db, + sql_cstr, + -1, + &new_st, + &tail); Py_END_ALLOW_THREADS if (rc == SQLITE_OK) { -- 2.34.1