Diff for /embedaddon/php/ext/pdo_mysql/mysql_driver.c between versions 1.1.1.1 and 1.1.1.2

version 1.1.1.1, 2012/02/21 23:47:59 version 1.1.1.2, 2012/05/29 12:34:41
Line 36 Line 36
 #endif  #endif
 #include "zend_exceptions.h"  #include "zend_exceptions.h"
   
#if PDO_USE_MYSQLND#if defined(PDO_USE_MYSQLND)
 #       define pdo_mysql_init(persistent) mysqlnd_init(persistent)  #       define pdo_mysql_init(persistent) mysqlnd_init(persistent)
 #else  #else
 #       define pdo_mysql_init(persistent) mysql_init(NULL)  #       define pdo_mysql_init(persistent) mysql_init(NULL)
 #endif  #endif
   
 #if !defined(HAVE_MYSQL_SQLSTATE) && !defined(PDO_USE_MYSQLND)  
 static const char *pdo_mysql_get_sqlstate(unsigned int my_errno) { /* {{{ */  
         switch (my_errno) {  
                 /* import auto-generated case: code */  
 #include "php_pdo_mysql_sqlstate.h"  
         default: return "HY000";  
         }  
 }  
 /* }}} */  
 #endif  
   
 /* {{{ _pdo_mysql_error */  /* {{{ _pdo_mysql_error */
 int _pdo_mysql_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, const char *file, int line TSRMLS_DC)  int _pdo_mysql_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, const char *file, int line TSRMLS_DC)
 {  {
Line 72  int _pdo_mysql_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, Line 61  int _pdo_mysql_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt,
                 einfo   = &H->einfo;                  einfo   = &H->einfo;
         }          }
   
 #if defined(HAVE_MYSQL_STMT_PREPARE) || defined(PDO_USE_MYSQLND)  
         if (S && S->stmt) {          if (S && S->stmt) {
                 einfo->errcode = mysql_stmt_errno(S->stmt);                  einfo->errcode = mysql_stmt_errno(S->stmt);
        }        } else {
        else 
#endif 
        { 
                 einfo->errcode = mysql_errno(H->server);                  einfo->errcode = mysql_errno(H->server);
         }          }
   
Line 112  int _pdo_mysql_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, Line 97  int _pdo_mysql_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt,
                 PDO_DBG_RETURN(0);                  PDO_DBG_RETURN(0);
         }          }
   
 #if defined(HAVE_MYSQL_SQLSTATE) || defined(PDO_USE_MYSQLND)  
 # if defined(HAVE_MYSQL_STMT_PREPARE) || defined(PDO_USE_MYSQLND)  
         if (S && S->stmt) {          if (S && S->stmt) {
                 strcpy(*pdo_err, mysql_stmt_sqlstate(S->stmt));                  strcpy(*pdo_err, mysql_stmt_sqlstate(S->stmt));
        } else        } else {
# endif 
        { 
                 strcpy(*pdo_err, mysql_sqlstate(H->server));                  strcpy(*pdo_err, mysql_sqlstate(H->server));
         }          }
 #else  
         strcpy(*pdo_err, pdo_mysql_get_sqlstate(einfo->errcode));  
 #endif  
   
         if (!dbh->methods) {          if (!dbh->methods) {
                 PDO_DBG_INF("Throwing exception");                  PDO_DBG_INF("Throwing exception");
Line 187  static int mysql_handle_preparer(pdo_dbh_t *dbh, const Line 165  static int mysql_handle_preparer(pdo_dbh_t *dbh, const
 {  {
         pdo_mysql_db_handle *H = (pdo_mysql_db_handle *)dbh->driver_data;          pdo_mysql_db_handle *H = (pdo_mysql_db_handle *)dbh->driver_data;
         pdo_mysql_stmt *S = ecalloc(1, sizeof(pdo_mysql_stmt));          pdo_mysql_stmt *S = ecalloc(1, sizeof(pdo_mysql_stmt));
 #if defined(HAVE_MYSQL_STMT_PREPARE) || defined(PDO_USE_MYSQLND)  
         char *nsql = NULL;          char *nsql = NULL;
         int nsql_len = 0;          int nsql_len = 0;
         int ret;          int ret;
         int server_version;          int server_version;
 #endif  
                   
         PDO_DBG_ENTER("mysql_handle_preparer");          PDO_DBG_ENTER("mysql_handle_preparer");
         PDO_DBG_INF_FMT("dbh=%p", dbh);          PDO_DBG_INF_FMT("dbh=%p", dbh);
Line 206  static int mysql_handle_preparer(pdo_dbh_t *dbh, const Line 182  static int mysql_handle_preparer(pdo_dbh_t *dbh, const
                 goto end;                  goto end;
         }          }
   
 #if defined(HAVE_MYSQL_STMT_PREPARE) || defined(PDO_USE_MYSQLND)  
         server_version = mysql_get_server_version(H->server);          server_version = mysql_get_server_version(H->server);
         if (server_version < 40100) {          if (server_version < 40100) {
                 goto fallback;                  goto fallback;
Line 255  static int mysql_handle_preparer(pdo_dbh_t *dbh, const Line 230  static int mysql_handle_preparer(pdo_dbh_t *dbh, const
   
         if (S->num_params) {          if (S->num_params) {
                 S->params_given = 0;                  S->params_given = 0;
#ifdef PDO_USE_MYSQLND#if defined(PDO_USE_MYSQLND)
                 S->params = NULL;                  S->params = NULL;
 #else  #else
                 S->params = ecalloc(S->num_params, sizeof(MYSQL_BIND));                  S->params = ecalloc(S->num_params, sizeof(MYSQL_BIND));
Line 270  static int mysql_handle_preparer(pdo_dbh_t *dbh, const Line 245  static int mysql_handle_preparer(pdo_dbh_t *dbh, const
         PDO_DBG_RETURN(1);          PDO_DBG_RETURN(1);
   
 fallback:  fallback:
 #endif  
 end:  end:
         stmt->supports_placeholders = PDO_PLACEHOLDER_NONE;          stmt->supports_placeholders = PDO_PLACEHOLDER_NONE;
                   
Line 296  static long mysql_handle_doer(pdo_dbh_t *dbh, const ch Line 270  static long mysql_handle_doer(pdo_dbh_t *dbh, const ch
                         PDO_DBG_RETURN(H->einfo.errcode ? -1 : 0);                          PDO_DBG_RETURN(H->einfo.errcode ? -1 : 0);
                 } else {                  } else {
   
 #if defined(HAVE_MYSQL_NEXT_RESULT) || defined(PDO_USE_MYSQLND)  
                         /* MULTI_QUERY support - eat up all unfetched result sets */                          /* MULTI_QUERY support - eat up all unfetched result sets */
                         MYSQL_RES* result;                          MYSQL_RES* result;
                         while (mysql_more_results(H->server)) {                          while (mysql_more_results(H->server)) {
Line 308  static long mysql_handle_doer(pdo_dbh_t *dbh, const ch Line 281  static long mysql_handle_doer(pdo_dbh_t *dbh, const ch
                                         mysql_free_result(result);                                          mysql_free_result(result);
                                 }                                  }
                         }                          }
 #endif  
                         PDO_DBG_RETURN((int)c);                          PDO_DBG_RETURN((int)c);
                 }                  }
         }          }
Line 324  static char *pdo_mysql_last_insert_id(pdo_dbh_t *dbh,  Line 296  static char *pdo_mysql_last_insert_id(pdo_dbh_t *dbh, 
         *len = strlen(id);          *len = strlen(id);
         PDO_DBG_RETURN(id);          PDO_DBG_RETURN(id);
 }  }
/* }}} */ /* }}} */
   
 /* {{{ mysql_handle_quoter */  /* {{{ mysql_handle_quoter */
 static int mysql_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, int unquotedlen, char **quoted, int *quotedlen, enum pdo_param_type paramtype  TSRMLS_DC)  static int mysql_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, int unquotedlen, char **quoted, int *quotedlen, enum pdo_param_type paramtype  TSRMLS_DC)
Line 463  static int pdo_mysql_get_attribute(pdo_dbh_t *dbh, lon Line 435  static int pdo_mysql_get_attribute(pdo_dbh_t *dbh, lon
                         break;                          break;
                 case PDO_ATTR_SERVER_INFO: {                  case PDO_ATTR_SERVER_INFO: {
                         char *tmp;                          char *tmp;
#ifdef PDO_USE_MYSQLND#if defined(PDO_USE_MYSQLND)
                         unsigned int tmp_len;                          unsigned int tmp_len;
   
                         if (mysqlnd_stat(H->server, &tmp, &tmp_len) == PASS) {                          if (mysqlnd_stat(H->server, &tmp, &tmp_len) == PASS) {
Line 584  static int pdo_mysql_handle_factory(pdo_dbh_t *dbh, zv Line 556  static int pdo_mysql_handle_factory(pdo_dbh_t *dbh, zv
 #endif  #endif
                 ;                  ;
   
#ifdef PDO_USE_MYSQLND#if defined(PDO_USE_MYSQLND)
         int dbname_len = 0;          int dbname_len = 0;
         int password_len = 0;          int password_len = 0;
 #endif  #endif
Line 624  static int pdo_mysql_handle_factory(pdo_dbh_t *dbh, zv Line 596  static int pdo_mysql_handle_factory(pdo_dbh_t *dbh, zv
                 char *init_cmd = NULL;                  char *init_cmd = NULL;
 #ifndef PDO_USE_MYSQLND  #ifndef PDO_USE_MYSQLND
                 char *default_file = NULL, *default_group = NULL;                  char *default_file = NULL, *default_group = NULL;
                 long compress = 0;  
 #endif  #endif
#if defined(HAVE_MYSQL_STMT_PREPARE) || defined(PDO_USE_MYSQLND)                long compress = 0;
                 char *ssl_key = NULL, *ssl_cert = NULL, *ssl_ca = NULL, *ssl_capath = NULL, *ssl_cipher = NULL;                  char *ssl_key = NULL, *ssl_cert = NULL, *ssl_ca = NULL, *ssl_capath = NULL, *ssl_cipher = NULL;
 #endif  
                 H->buffered = pdo_attr_lval(driver_options, PDO_MYSQL_ATTR_USE_BUFFERED_QUERY, 1 TSRMLS_CC);                  H->buffered = pdo_attr_lval(driver_options, PDO_MYSQL_ATTR_USE_BUFFERED_QUERY, 1 TSRMLS_CC);
   
                 H->emulate_prepare = pdo_attr_lval(driver_options,                  H->emulate_prepare = pdo_attr_lval(driver_options,
Line 706  static int pdo_mysql_handle_factory(pdo_dbh_t *dbh, zv Line 676  static int pdo_mysql_handle_factory(pdo_dbh_t *dbh, zv
                         }                          }
                         efree(default_group);                          efree(default_group);
                 }                  }
#endif
                 compress = pdo_attr_lval(driver_options, PDO_MYSQL_ATTR_COMPRESS, 0 TSRMLS_CC);                  compress = pdo_attr_lval(driver_options, PDO_MYSQL_ATTR_COMPRESS, 0 TSRMLS_CC);
                 if (compress) {                  if (compress) {
                         if (mysql_options(H->server, MYSQL_OPT_COMPRESS, 0)) {                          if (mysql_options(H->server, MYSQL_OPT_COMPRESS, 0)) {
Line 714  static int pdo_mysql_handle_factory(pdo_dbh_t *dbh, zv Line 684  static int pdo_mysql_handle_factory(pdo_dbh_t *dbh, zv
                                 goto cleanup;                                  goto cleanup;
                         }                          }
                 }                  }
#endif
#if defined(HAVE_MYSQL_STMT_PREPARE) || defined(PDO_USE_MYSQLND) 
                 ssl_key = pdo_attr_strval(driver_options, PDO_MYSQL_ATTR_SSL_KEY, NULL TSRMLS_CC);                  ssl_key = pdo_attr_strval(driver_options, PDO_MYSQL_ATTR_SSL_KEY, NULL TSRMLS_CC);
                 ssl_cert = pdo_attr_strval(driver_options, PDO_MYSQL_ATTR_SSL_CERT, NULL TSRMLS_CC);                  ssl_cert = pdo_attr_strval(driver_options, PDO_MYSQL_ATTR_SSL_CERT, NULL TSRMLS_CC);
                 ssl_ca = pdo_attr_strval(driver_options, PDO_MYSQL_ATTR_SSL_CA, NULL TSRMLS_CC);                  ssl_ca = pdo_attr_strval(driver_options, PDO_MYSQL_ATTR_SSL_CA, NULL TSRMLS_CC);
Line 740  static int pdo_mysql_handle_factory(pdo_dbh_t *dbh, zv Line 709  static int pdo_mysql_handle_factory(pdo_dbh_t *dbh, zv
                                 efree(ssl_cipher);                                  efree(ssl_cipher);
                         }                          }
                 }                  }
 #endif  
         }          }
   
 #ifdef PDO_MYSQL_HAS_CHARSET  #ifdef PDO_MYSQL_HAS_CHARSET

Removed from v.1.1.1.1  
changed lines
  Added in v.1.1.1.2


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>