wez             Fri Dec 15 05:03:03 2006 UTC

  Modified files:              
    /php-src/ext/pdo_sqlite     pdo_sqlite.c php_pdo_sqlite.h 
                                php_pdo_sqlite_int.h sqlite_driver.c 
                                sqlite_statement.c 
  Log:
  merge php5 pdo_sqlite into head; this source compiles on both php5 and php6.
  
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/pdo_sqlite/pdo_sqlite.c?r1=1.13&r2=1.14&diff_format=u
Index: php-src/ext/pdo_sqlite/pdo_sqlite.c
diff -u php-src/ext/pdo_sqlite/pdo_sqlite.c:1.13 
php-src/ext/pdo_sqlite/pdo_sqlite.c:1.14
--- php-src/ext/pdo_sqlite/pdo_sqlite.c:1.13    Sun Jan  1 13:09:53 2006
+++ php-src/ext/pdo_sqlite/pdo_sqlite.c Fri Dec 15 05:03:02 2006
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: pdo_sqlite.c,v 1.13 2006/01/01 13:09:53 sniper Exp $ */
+/* $Id: pdo_sqlite.c,v 1.14 2006/12/15 05:03:02 wez Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -31,7 +31,7 @@
 #include "php_pdo_sqlite_int.h"
 #include "zend_exceptions.h"
 
-#define PHP_PDO_SQLITE_MODULE_VERSION  "0.9"
+#define PHP_PDO_SQLITE_MODULE_VERSION  "1.0.1"
 
 /* {{{ pdo_sqlite_functions[] */
 zend_function_entry pdo_sqlite_functions[] = {
@@ -100,7 +100,7 @@
        "(bundled) "
 #endif
                PHP_PDO_SQLITE_MODULE_VERSION 
-               " $Id: pdo_sqlite.c,v 1.13 2006/01/01 13:09:53 sniper Exp $");
+               " $Id: pdo_sqlite.c,v 1.14 2006/12/15 05:03:02 wez Exp $");
        php_info_print_table_row(2, "SQLite Library", sqlite3_libversion());
        php_info_print_table_end();
 }
http://cvs.php.net/viewvc.cgi/php-src/ext/pdo_sqlite/php_pdo_sqlite.h?r1=1.3&r2=1.4&diff_format=u
Index: php-src/ext/pdo_sqlite/php_pdo_sqlite.h
diff -u php-src/ext/pdo_sqlite/php_pdo_sqlite.h:1.3 
php-src/ext/pdo_sqlite/php_pdo_sqlite.h:1.4
--- php-src/ext/pdo_sqlite/php_pdo_sqlite.h:1.3 Sun Jan  1 13:09:53 2006
+++ php-src/ext/pdo_sqlite/php_pdo_sqlite.h     Fri Dec 15 05:03:02 2006
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_pdo_sqlite.h,v 1.3 2006/01/01 13:09:53 sniper Exp $ */
+/* $Id: php_pdo_sqlite.h,v 1.4 2006/12/15 05:03:02 wez Exp $ */
 
 
 #ifndef PHP_PDO_SQLITE_H
http://cvs.php.net/viewvc.cgi/php-src/ext/pdo_sqlite/php_pdo_sqlite_int.h?r1=1.4&r2=1.5&diff_format=u
Index: php-src/ext/pdo_sqlite/php_pdo_sqlite_int.h
diff -u php-src/ext/pdo_sqlite/php_pdo_sqlite_int.h:1.4 
php-src/ext/pdo_sqlite/php_pdo_sqlite_int.h:1.5
--- php-src/ext/pdo_sqlite/php_pdo_sqlite_int.h:1.4     Sun Jan  1 13:09:53 2006
+++ php-src/ext/pdo_sqlite/php_pdo_sqlite_int.h Fri Dec 15 05:03:02 2006
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_pdo_sqlite_int.h,v 1.4 2006/01/01 13:09:53 sniper Exp $ */
+/* $Id: php_pdo_sqlite_int.h,v 1.5 2006/12/15 05:03:02 wez Exp $ */
 
 #ifndef PHP_PDO_SQLITE_INT_H
 #define PHP_PDO_SQLITE_INT_H
@@ -62,8 +62,13 @@
 extern pdo_driver_t pdo_sqlite_driver;
 
 extern int _pdo_sqlite_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, const char 
*file, int line TSRMLS_DC);
-#define pdo_sqlite_error(s) _pdo_sqlite_error(s, NULL, __FILE__, __LINE__ 
TSRMLS_CC)
-#define pdo_sqlite_error_stmt(s) _pdo_sqlite_error(stmt->dbh, stmt, __FILE__, 
__LINE__ TSRMLS_CC)
+extern int _pdo_sqlite_error_msg(pdo_dbh_t *dbh, pdo_stmt_t *stmt, const char 
*sqlstate, const char *msg, 
+                                       const char *file, int line TSRMLS_DC);
+#define pdo_sqlite_error(dbh) _pdo_sqlite_error(dbh, NULL, __FILE__, __LINE__ 
TSRMLS_CC)
+#define pdo_sqlite_errmsg(dbh, st, msg) _pdo_sqlite_error_msg(dbh, NULL, st, 
msg, __FILE__, __LINE__ TSRMLS_CC)
+#define pdo_sqlite_error_stmt(stmt) _pdo_sqlite_error(stmt->dbh, stmt, 
__FILE__, __LINE__ TSRMLS_CC)
+#define pdo_sqlite_errmsg_stmt(stmt, st, msg) _pdo_sqlite_error_msg(stmt->dbh, 
stmt, st, msg, __FILE__, __LINE__ TSRMLS_CC)
+
 
 extern struct pdo_stmt_methods sqlite_stmt_methods;
 #endif
http://cvs.php.net/viewvc.cgi/php-src/ext/pdo_sqlite/sqlite_driver.c?r1=1.31&r2=1.32&diff_format=u
Index: php-src/ext/pdo_sqlite/sqlite_driver.c
diff -u php-src/ext/pdo_sqlite/sqlite_driver.c:1.31 
php-src/ext/pdo_sqlite/sqlite_driver.c:1.32
--- php-src/ext/pdo_sqlite/sqlite_driver.c:1.31 Sun Dec 10 02:32:17 2006
+++ php-src/ext/pdo_sqlite/sqlite_driver.c      Fri Dec 15 05:03:02 2006
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: sqlite_driver.c,v 1.31 2006/12/10 02:32:17 pajoye Exp $ */
+/* $Id: sqlite_driver.c,v 1.32 2006/12/15 05:03:02 wez Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -31,6 +31,30 @@
 #include "php_pdo_sqlite_int.h"
 #include "zend_exceptions.h"
 
+int _pdo_sqlite_error_msg(pdo_dbh_t *dbh, pdo_stmt_t *stmt, const char 
*sqlstate, const char *msg, 
+                                       const char *file, int line TSRMLS_DC)
+{
+       pdo_sqlite_db_handle *H = (pdo_sqlite_db_handle *)dbh->driver_data;
+       pdo_error_type *pdo_err = stmt ? &stmt->error_code : &dbh->error_code;
+       pdo_sqlite_error_info *einfo = &H->einfo;
+
+       einfo->errcode = SQLITE_ERROR;
+       einfo->file = file;
+       einfo->line = line;
+       einfo->errmsg = pestrdup(msg, dbh->is_persistent);
+       if (sqlstate) {
+               strcpy(*pdo_err, sqlstate);
+       } else {
+               strcpy(*pdo_err, "HY000");
+       }
+
+       if (!dbh->methods) {
+               zend_throw_exception_ex(php_pdo_get_exception(), 0 TSRMLS_CC, 
"SQLSTATE[%s] [%d] %s",
+                               *pdo_err, einfo->errcode, einfo->errmsg);
+       }
+       return einfo->errcode;
+}
+
 int _pdo_sqlite_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, const char *file, int 
line TSRMLS_DC) /* {{{ */
 {
        pdo_sqlite_db_handle *H = (pdo_sqlite_db_handle *)dbh->driver_data;
@@ -78,13 +102,8 @@
        }
 
        if (!dbh->methods) {
-#if PHP_VERSION_ID > 50200
                zend_throw_exception_ex(php_pdo_get_exception(), 0 TSRMLS_CC, 
"SQLSTATE[%s] [%d] %s",
                                *pdo_err, einfo->errcode, einfo->errmsg);
-#else
-               zend_throw_exception_ex(php_pdo_get_exception(TSRMLS_C), 0 
TSRMLS_CC, "SQLSTATE[%s] [%d] %s",
-                               *pdo_err, einfo->errcode, einfo->errmsg);
-#endif
        }
        
        return einfo->errcode;
@@ -203,7 +222,7 @@
        }
 }
 
-static char *pdo_sqlite_last_insert_id(pdo_dbh_t *dbh, const char *name, 
unsigned int *len TSRMLS_DC)
+static char *pdo_sqlite_last_insert_id(pdo_dbh_t *dbh, const char *name, int 
*len TSRMLS_DC)
 {
        pdo_sqlite_db_handle *H = (pdo_sqlite_db_handle *)dbh->driver_data;
        char *id;
@@ -471,11 +490,6 @@
        char *func_name;
        int func_name_len;
        long argc = -1;
-#ifdef IS_UNICODE
-       zval cbname;
-#else
-       char *cbname;
-#endif
        pdo_dbh_t *dbh;
        pdo_sqlite_db_handle *H;
        int ret;
@@ -488,21 +502,10 @@
        dbh = zend_object_store_get_object(getThis() TSRMLS_CC);
        PDO_CONSTRUCT_CHECK;
 
-       if (!zend_is_callable(callback, 0, &cbname)) {
-#ifdef IS_UNICODE
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "function '%R' is 
not callable", Z_TYPE(cbname), Z_UNIVAL(cbname));
-               zval_dtor(&cbname);
-#else
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "function '%s' is 
not callable", cbname);
-               efree(cbname);
-#endif
+       if (!zend_is_callable(callback, 0, NULL)) {
+               pdo_sqlite_errmsg(dbh, NULL, "callback is not callable");
                RETURN_FALSE;
        }
-#ifdef IS_UNICODE
-       zval_dtor(&cbname);
-#else
-       efree(cbname);
-#endif
        
        H = (pdo_sqlite_db_handle *)dbh->driver_data;
 
@@ -556,11 +559,6 @@
        char *func_name;
        int func_name_len;
        long argc = -1;
-#ifdef IS_UNICODE
-       zval cbname;
-#else
-       char *cbname;
-#endif
        pdo_dbh_t *dbh;
        pdo_sqlite_db_handle *H;
        int ret;
@@ -573,36 +571,14 @@
        dbh = zend_object_store_get_object(getThis() TSRMLS_CC);
        PDO_CONSTRUCT_CHECK;
 
-       if (!zend_is_callable(step_callback, 0, &cbname)) {
-#ifdef IS_UNICODE
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "function '%R' is 
not callable", Z_TYPE(cbname), Z_UNIVAL(cbname));
-               zval_dtor(&cbname);
-#else
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "function '%s' is 
not callable", cbname);
-               efree(cbname);
-#endif
+       if (!zend_is_callable(step_callback, 0, NULL)) {
+               pdo_sqlite_errmsg(dbh, NULL, "step callback is not callable");
                RETURN_FALSE;
        }
-#ifdef IS_UNICODE
-       zval_dtor(&cbname);
-#else
-       efree(cbname);
-#endif
-       if (!zend_is_callable(fini_callback, 0, &cbname)) {
-#ifdef IS_UNICODE
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "function '%R' is 
not callable", Z_TYPE(cbname), Z_UNIVAL(cbname));
-               zval_dtor(&cbname);
-#else
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "function '%s' is 
not callable", cbname);
-               efree(cbname);
-#endif
+       if (!zend_is_callable(fini_callback, 0, NULL)) {
+               pdo_sqlite_errmsg(dbh, NULL, "fini callback is not callable");
                RETURN_FALSE;
        }
-#ifdef IS_UNICODE
-       zval_dtor(&cbname);
-#else
-       efree(cbname);
-#endif
        
        H = (pdo_sqlite_db_handle *)dbh->driver_data;
 
@@ -686,6 +662,13 @@
                        return NULL;
                }
 
+#if PHP_MAJOR_VERSION < 6
+               if (PG(safe_mode) && (!php_checkuid(fullpath, NULL, 
CHECKUID_CHECK_FILE_AND_DIR))) {
+                       efree(fullpath);
+                       return NULL;
+               }
+#endif
+
                if (php_check_open_basedir(fullpath TSRMLS_CC)) {
                        efree(fullpath);
                        return NULL;
@@ -742,13 +725,9 @@
        filename = make_filename_safe(dbh->data_source TSRMLS_CC);
 
        if (!filename) {
-#if PHP_VERSION_ID > 50200
                zend_throw_exception_ex(php_pdo_get_exception(), 0 TSRMLS_CC,
-                       "open_basedir prohibits opening %s", dbh->data_source);
-#else
-               zend_throw_exception_ex(php_pdo_get_exception(TSRMLS_C), 0 
TSRMLS_CC,
-                       "open_basedir prohibits opening %s", dbh->data_source);
-#endif
+                       "safe_mode/open_basedir prohibits opening %s",
+                       dbh->data_source);
                goto cleanup;
        }
 
@@ -760,7 +739,11 @@
                goto cleanup;
        }
 
-       if ((PG(open_basedir) && *PG(open_basedir))) {
+       if (
+#if PHP_MAJOR_VERSION < 6
+               PG(safe_mode) || 
+#endif
+                       (PG(open_basedir) && *PG(open_basedir))) {
                sqlite3_set_authorizer(H->db, authorizer, NULL);
        }
 
http://cvs.php.net/viewvc.cgi/php-src/ext/pdo_sqlite/sqlite_statement.c?r1=1.21&r2=1.22&diff_format=u
Index: php-src/ext/pdo_sqlite/sqlite_statement.c
diff -u php-src/ext/pdo_sqlite/sqlite_statement.c:1.21 
php-src/ext/pdo_sqlite/sqlite_statement.c:1.22
--- php-src/ext/pdo_sqlite/sqlite_statement.c:1.21      Mon Nov 27 12:13:02 2006
+++ php-src/ext/pdo_sqlite/sqlite_statement.c   Fri Dec 15 05:03:02 2006
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: sqlite_statement.c,v 1.21 2006/11/27 12:13:02 tony2001 Exp $ */
+/* $Id: sqlite_statement.c,v 1.22 2006/12/15 05:03:02 wez Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -94,7 +94,6 @@
                                }
 
                                switch (PDO_PARAM_TYPE(param->param_type)) {
-                                       case PDO_PARAM_LOB:
                                        case PDO_PARAM_STMT:
                                                return 0;
 
@@ -104,7 +103,23 @@
                                                }
                                                pdo_sqlite_error_stmt(stmt);
                                                return 0;
-                                               
+                                       
+                                       case PDO_PARAM_LOB:
+                                               if (Z_TYPE_P(param->parameter) 
== IS_RESOURCE) {
+                                                       php_stream *stm;
+                                                       
php_stream_from_zval_no_verify(stm, &param->parameter);
+                                                       if (stm) {
+                                                               
SEPARATE_ZVAL_IF_NOT_REF(&param->parameter);
+                                                               
Z_TYPE_P(param->parameter) = IS_STRING;
+                                                               
Z_STRLEN_P(param->parameter) = php_stream_copy_to_mem(stm,
+                                                                       
&Z_STRVAL_P(param->parameter), PHP_STREAM_COPY_ALL, 0);
+                                                       } else {
+                                                               
pdo_raise_impl_error(stmt->dbh, stmt, "HY105", "Expected a stream resource" 
TSRMLS_CC);
+                                                               return 0;
+                                                       }
+                                               }
+                                               /* fall through */
+               
                                        case PDO_PARAM_STR:
                                        default:
                                                if (Z_TYPE_P(param->parameter) 
== IS_NULL) {
@@ -114,9 +129,9 @@
                                                } else {
                                                        
convert_to_string(param->parameter);
                                                        if(SQLITE_OK == 
sqlite3_bind_text(S->stmt, param->paramno + 1,
-                                                               
Z_STRVAL_P(param->parameter),
-                                                               
Z_STRLEN_P(param->parameter),
-                                                               SQLITE_STATIC)) 
{
+                                                                       
Z_STRVAL_P(param->parameter),
+                                                                       
Z_STRLEN_P(param->parameter),
+                                                                       
SQLITE_STATIC)) {
                                                                return 1;       
                                                        }
                                                }

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to