Skip to content

Commit 425882e

Browse files
committed
Some tweaks ready for the upcoming 1.0 release.
1 parent 76b3007 commit 425882e

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

ext/sqlite/package.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
Programs that link with the SQLite library can have SQL database access
2929
without running a separate RDBMS process.
3030
This extension allows you to access SQLite databases from within PHP.
31+
32+
Windows binary available from:
33+
http://snaps.php.net/win32/PECL_STABLE/php_sqlite.dll
3134
</description>
3235
<license>PHP</license>
3336
<release>
@@ -51,6 +54,8 @@
5154

5255
Fixed some build issues for thread-safe builds.
5356

57+
Increase the default busy timeout interval to 60 seconds.
58+
5459
API is considered stabilized for 4.3.x; this is a pre-release before
5560
announcing stable version 1.0.
5661

ext/sqlite/sqlite.c

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include "config.h"
2525
#endif
2626

27-
#define PHP_SQLITE_MODULE_VERSION "0.9b"
27+
#define PHP_SQLITE_MODULE_VERSION "0.9-c"
2828

2929
#include "php.h"
3030
#include "php_ini.h"
@@ -39,7 +39,7 @@
3939
#include <sqlite.h>
4040

4141
#ifndef safe_emalloc
42-
#define safe_emalloc(a,b,c) emalloc((a)*(b)+(c))
42+
# define safe_emalloc(a,b,c) emalloc((a)*(b)+(c))
4343
#endif
4444

4545
#ifndef ZEND_ENGINE_2
@@ -384,7 +384,12 @@ static void php_sqlite_function_callback(sqlite_func *func, int argc, const char
384384
for (i = 0; i < argc; i++) {
385385
zargs[i] = emalloc(sizeof(zval *));
386386
MAKE_STD_ZVAL(*zargs[i]);
387-
ZVAL_STRING(*zargs[i], (char*)argv[i], 1);
387+
388+
if (argv[i] == NULL) {
389+
ZVAL_NULL(*zargs[i]);
390+
} else {
391+
ZVAL_STRING(*zargs[i], (char*)argv[i], 1);
392+
}
388393
}
389394
}
390395

@@ -402,6 +407,7 @@ static void php_sqlite_function_callback(sqlite_func *func, int argc, const char
402407
} else {
403408
switch (Z_TYPE_P(retval)) {
404409
case IS_STRING:
410+
/* TODO: for binary results, need to encode the string */
405411
sqlite_set_result_string(func, Z_STRVAL_P(retval), Z_STRLEN_P(retval));
406412
break;
407413
case IS_LONG:
@@ -472,7 +478,11 @@ static void php_sqlite_agg_step_function_callback(sqlite_func *func, int argc, c
472478
for (i = 0; i < argc; i++) {
473479
zargs[i+1] = emalloc(sizeof(zval *));
474480
MAKE_STD_ZVAL(*zargs[i+1]);
475-
ZVAL_STRING(*zargs[i+1], (char*)argv[i], 1);
481+
if (argv[i] == NULL) {
482+
ZVAL_NULL(*zargs[i+1]);
483+
} else {
484+
ZVAL_STRING(*zargs[i+1], (char*)argv[i], 1);
485+
}
476486
}
477487

478488
res = call_user_function_ex(EG(function_table),
@@ -641,6 +651,9 @@ PHP_MINIT_FUNCTION(sqlite)
641651
REGISTER_LONG_CONSTANT("SQLITE_MISUSE", SQLITE_MISUSE, CONST_CS|CONST_PERSISTENT);
642652
REGISTER_LONG_CONSTANT("SQLITE_NOLFS", SQLITE_NOLFS, CONST_CS|CONST_PERSISTENT);
643653
REGISTER_LONG_CONSTANT("SQLITE_AUTH", SQLITE_AUTH, CONST_CS|CONST_PERSISTENT);
654+
#ifdef SQLITE_FORMAT
655+
REGISTER_LONG_CONSTANT("SQLITE_FORMAT", SQLITE_FORMAT, CONST_CS|CONST_PERSISTENT);
656+
#endif
644657
REGISTER_LONG_CONSTANT("SQLITE_ROW", SQLITE_ROW, CONST_CS|CONST_PERSISTENT);
645658
REGISTER_LONG_CONSTANT("SQLITE_DONE", SQLITE_DONE, CONST_CS|CONST_PERSISTENT);
646659

@@ -691,9 +704,9 @@ static struct php_sqlite_db *php_sqlite_open(char *filename, int mode, char *per
691704
/* register the PHP functions */
692705
sqlite_create_function(sdb, "php", -1, php_sqlite_generic_function_callback, 0);
693706

694-
/* set default busy handler; keep retrying up until 1/2 second has passed,
707+
/* set default busy handler; keep retrying up until 1 minute has passed,
695708
* then fail with a busy status code */
696-
sqlite_busy_timeout(sdb, 500);
709+
sqlite_busy_timeout(sdb, 60000);
697710

698711
/* authorizer hook so we can enforce safe mode
699712
* Note: the declaration of php_sqlite_authorizer is correct for 2.8.2 of libsqlite,

0 commit comments

Comments
 (0)