mirror of
https://github.com/php/php-src.git
synced 2025-08-15 13:38:49 +02:00
ext/sqlite3: adding busy() call.
checks if the prepared statement had been fetched but did not complete yet. close GH-18843
This commit is contained in:
parent
71a254489c
commit
058c0348fd
6 changed files with 57 additions and 1 deletions
4
NEWS
4
NEWS
|
@ -240,6 +240,10 @@ PHP NEWS
|
|||
. Fix overall theorical overflows on zend_string buffer allocations.
|
||||
(David Carlier/nielsdos)
|
||||
|
||||
- Sqlite:
|
||||
. Added Sqlite3Stmt::busy to check if a statement is still being executed.
|
||||
(David Carlier)
|
||||
|
||||
- Standard:
|
||||
. Fixed crypt() tests on musl when using --with-external-libcrypt
|
||||
(Michael Orlitzky).
|
||||
|
|
|
@ -393,6 +393,10 @@ PHP 8.5 UPGRADE NOTES
|
|||
. ReflectionConstant::getAttributes() was introduced.
|
||||
RFC: https://wiki.php.net/rfc/attributes-on-constants
|
||||
|
||||
- Sqlite:
|
||||
. Sqlite3Stmt::busy to check if a statement had been fetched
|
||||
but not completely.
|
||||
|
||||
- Standard:
|
||||
. Added array_first() and array_last().
|
||||
RFC: https://wiki.php.net/rfc/array_first_last
|
||||
|
|
|
@ -1479,6 +1479,23 @@ PHP_METHOD(SQLite3Stmt, readOnly)
|
|||
}
|
||||
/* }}} */
|
||||
|
||||
PHP_METHOD(SQLite3Stmt, busy)
|
||||
{
|
||||
php_sqlite3_stmt *stmt_obj;
|
||||
zval *object = ZEND_THIS;
|
||||
stmt_obj = Z_SQLITE3_STMT_P(object);
|
||||
|
||||
ZEND_PARSE_PARAMETERS_NONE();
|
||||
|
||||
SQLITE3_CHECK_INITIALIZED(stmt_obj->db_obj, stmt_obj->initialised, SQLite3);
|
||||
SQLITE3_CHECK_INITIALIZED_STMT(stmt_obj->stmt, SQLite3Stmt);
|
||||
|
||||
if (sqlite3_stmt_busy(stmt_obj->stmt)) {
|
||||
RETURN_TRUE;
|
||||
}
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
/* bind parameters to a statement before execution */
|
||||
static int php_sqlite3_bind_params(php_sqlite3_stmt *stmt_obj) /* {{{ */
|
||||
{
|
||||
|
|
|
@ -272,6 +272,8 @@ class SQLite3Stmt
|
|||
|
||||
/** @tentative-return-type */
|
||||
public function reset(): bool {}
|
||||
|
||||
public function busy(): bool {}
|
||||
}
|
||||
|
||||
/** @not-serializable */
|
||||
|
|
7
ext/sqlite3/sqlite3_arginfo.h
generated
7
ext/sqlite3/sqlite3_arginfo.h
generated
|
@ -1,5 +1,5 @@
|
|||
/* This is a generated file, edit the .stub.php file instead.
|
||||
* Stub hash: edf910997672a2b8d8b5c25e8a7a4ff1c135e7b1 */
|
||||
* Stub hash: 28132e0e4df61f19dc4b23a7c9f79be6b3e40a8e */
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SQLite3___construct, 0, 0, 1)
|
||||
ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0)
|
||||
|
@ -144,6 +144,9 @@ ZEND_END_ARG_INFO()
|
|||
|
||||
#define arginfo_class_SQLite3Stmt_reset arginfo_class_SQLite3_close
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SQLite3Stmt_busy, 0, 0, _IS_BOOL, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SQLite3Result___construct, 0, 0, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
|
@ -202,6 +205,7 @@ ZEND_METHOD(SQLite3Stmt, getSQL);
|
|||
ZEND_METHOD(SQLite3Stmt, paramCount);
|
||||
ZEND_METHOD(SQLite3Stmt, readOnly);
|
||||
ZEND_METHOD(SQLite3Stmt, reset);
|
||||
ZEND_METHOD(SQLite3Stmt, busy);
|
||||
ZEND_METHOD(SQLite3Result, __construct);
|
||||
ZEND_METHOD(SQLite3Result, numColumns);
|
||||
ZEND_METHOD(SQLite3Result, columnName);
|
||||
|
@ -253,6 +257,7 @@ static const zend_function_entry class_SQLite3Stmt_methods[] = {
|
|||
ZEND_ME(SQLite3Stmt, paramCount, arginfo_class_SQLite3Stmt_paramCount, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(SQLite3Stmt, readOnly, arginfo_class_SQLite3Stmt_readOnly, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(SQLite3Stmt, reset, arginfo_class_SQLite3Stmt_reset, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(SQLite3Stmt, busy, arginfo_class_SQLite3Stmt_busy, ZEND_ACC_PUBLIC)
|
||||
ZEND_FE_END
|
||||
};
|
||||
|
||||
|
|
24
ext/sqlite3/tests/sqlite3_stmt_busy.phpt
Normal file
24
ext/sqlite3/tests/sqlite3_stmt_busy.phpt
Normal file
|
@ -0,0 +1,24 @@
|
|||
--TEST--
|
||||
SQLite3_stmt::busy
|
||||
--EXTENSIONS--
|
||||
sqlite3
|
||||
--SKIPIF--
|
||||
<?php
|
||||
$version = SQLite3::version();
|
||||
if ($version['versionNumber'] < 3007004) die("skip");
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once(__DIR__ . '/new_db.inc');
|
||||
$db->exec('CREATE TABLE test_busy (a string);');
|
||||
$db->exec('INSERT INTO test_busy VALUES ("interleaved"), ("statements")');
|
||||
$st = $db->prepare('SELECT a FROM test_busy');
|
||||
var_dump($st->busy());
|
||||
$r = $st->execute();
|
||||
$r->fetchArray();
|
||||
var_dump($st->busy());
|
||||
?>
|
||||
--EXPECT--
|
||||
bool(false)
|
||||
bool(true)
|
Loading…
Add table
Add a link
Reference in a new issue