From 6b990988f1afeedaf1bc15b01e2d41211fb10fbb Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Mon, 21 Jun 2010 11:06:31 +0000 Subject: [PATCH] MFB: Implemented FR #51295 (SQLite3::busyTimeout not existing). (Mark) --- NEWS | 1 + ext/sqlite3/sqlite3.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/NEWS b/NEWS index 03b0479cef..bb52a3d888 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,7 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? 2010, PHP 5.3.3 RC2 +- Implemented FR #51295 (SQLite3::busyTimeout not existing). (Mark) - Fixed the mail.log ini setting when no filename was given. (Johannes) - Fixed bug #52115 (mysqli_result::fetch_all returns null, not an empty array). (Andrey) diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c index 10bd32024b..f5d321dbf9 100644 --- a/ext/sqlite3/sqlite3.c +++ b/ext/sqlite3/sqlite3.c @@ -298,6 +298,33 @@ PHP_METHOD(sqlite3, lastErrorMsg) } /* }}} */ +/* {{{ proto bool SQLite3::busyTimeout(int msecs) + Sets a busy handler that will sleep until database is not locked or timeout is reached. Passing a value less than or equal to zero turns off all busy handlers. */ +PHP_METHOD(sqlite3, busyTimeout) +{ + php_sqlite3_db_object *db_obj; + zval *object = getThis(); + long ms; + int return_code; + db_obj = (php_sqlite3_db_object *)zend_object_store_get_object(object TSRMLS_CC); + + SQLITE3_CHECK_INITIALIZED(db_obj, db_obj->initialised, SQLite3) + + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &ms)) { + return; + } + + return_code = sqlite3_busy_timeout(db_obj->db, ms); + if (return_code != SQLITE_OK) { + php_sqlite3_error(db_obj, "Unable to set busy timeout: %d, %s", return_code, sqlite3_errmsg(db_obj->db)); + RETURN_FALSE; + } + + RETURN_TRUE; +} +/* }}} */ + + #ifndef SQLITE_OMIT_LOAD_EXTENSION /* {{{ proto bool SQLite3::loadExtension(String Shared Library) Attempts to load an SQLite extension library. */ @@ -1652,6 +1679,10 @@ ZEND_BEGIN_ARG_INFO(arginfo_sqlite3_open, 0) ZEND_ARG_INFO(0, encryption_key) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO(arginfo_sqlite3_busytimeout, 0) + ZEND_ARG_INFO(0, ms) +ZEND_END_ARG_INFO() + #ifndef SQLITE_OMIT_LOAD_EXTENSION ZEND_BEGIN_ARG_INFO(arginfo_sqlite3_loadextension, 0) ZEND_ARG_INFO(0, shared_library) @@ -1736,6 +1767,7 @@ static zend_function_entry php_sqlite3_class_methods[] = { PHP_ME(sqlite3, lastInsertRowID, arginfo_sqlite3_void, ZEND_ACC_PUBLIC) PHP_ME(sqlite3, lastErrorCode, arginfo_sqlite3_void, ZEND_ACC_PUBLIC) PHP_ME(sqlite3, lastErrorMsg, arginfo_sqlite3_void, ZEND_ACC_PUBLIC) + PHP_ME(sqlite3, busyTimeout, arginfo_sqlite3_busytimeout, ZEND_ACC_PUBLIC) #ifndef SQLITE_OMIT_LOAD_EXTENSION PHP_ME(sqlite3, loadExtension, arginfo_sqlite3_loadextension, ZEND_ACC_PUBLIC) #endif -- 2.50.1