~clint-fewbar/ubuntu/natty/php5/merge-5.3.3-3

« back to all changes in this revision

Viewing changes to ext/pdo/pdo_stmt.c

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2010-01-26 14:09:58 UTC
  • mfrom: (1.1.16 upstream) (0.3.6 sid)
  • Revision ID: james.westby@ubuntu.com-20100126140958-sos69zwa00q2nt19
Tags: 5.2.12.dfsg.1-2ubuntu1
* Merge from debian testing.  Remaining changes:
  - debian/control, debian/rules: Disable a few build dependencies and
    accompanying binary packages which we do not want to support in main:
    + firebird2-dev/php5-interbase (we have a seperate php-interbase source)
    + libc-client/php5-imap (we have a seperate php-imap source)
    + libmcrypt-dev/php5-mcrypt (seperate php-mcrypt source)
    + readline support again, now that the libedit issue is fixed.
  - debian/control: Add build dependency: libedit-dev (>= 2.9.cvs.20050518-1)
    CLI readline support.
  - debian/rules:
    + Correctly mangle PHP5_* macros for lpia
  - debian/control:
    + Rename Vcs-Browser & Vcs-Git to XS-Original-Vcs-Browser & XS-Original-Vcs-Git (LP: #323731).
  - debian/control: Move php5-suhoshin to Suggests.
  - debian/rules: Fix broken symlink for pear.
  - main/php_version.h: updated with Ubuntu version info
  - debian/patches/series: Re-enable the 033-we_WANT_libtool.patch patch
  - debian/rules, debian/source_php5.py: Install apport hook. 
* Dropped patches: CVE-2009-3557.patch and CVE-2009-3558.patch, no longer needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
  +----------------------------------------------------------------------+
19
19
*/
20
20
 
21
 
/* $Id: pdo_stmt.c 288013 2009-09-03 22:53:25Z mbeccati $ */
 
21
/* $Id: pdo_stmt.c 292003 2009-12-11 22:30:46Z felipe $ */
22
22
 
23
23
/* The PDO Statement Handle Class */
24
24
 
509
509
                        /* no changes were made */
510
510
                        stmt->active_query_string = stmt->query_string;
511
511
                        stmt->active_query_stringlen = stmt->query_stringlen;
 
512
                        ret = 1;
512
513
                } else if (ret == -1) {
513
514
                        /* something broke */
514
515
                        PDO_HANDLE_STMT_ERR();
1102
1103
                        }
1103
1104
                }
1104
1105
 
 
1106
                switch (how) {
 
1107
                        case PDO_FETCH_CLASS:
 
1108
                                if (ce->constructor && !(flags & PDO_FETCH_PROPS_LATE)) {
 
1109
                                        stmt->fetch.cls.fci.object_pp = &return_value;
 
1110
                                        stmt->fetch.cls.fcc.object_pp = &return_value;
 
1111
                                        if (zend_call_function(&stmt->fetch.cls.fci, &stmt->fetch.cls.fcc TSRMLS_CC) == FAILURE) {
 
1112
                                                pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "could not call class constructor" TSRMLS_CC);
 
1113
                                                return 0;
 
1114
                                        } else {
 
1115
                                                if (stmt->fetch.cls.retval_ptr) {
 
1116
                                                        zval_ptr_dtor(&stmt->fetch.cls.retval_ptr);
 
1117
                                                }
 
1118
                                        }
 
1119
                                }
 
1120
                                if (flags & PDO_FETCH_CLASSTYPE) {
 
1121
                                        do_fetch_opt_finish(stmt, 0 TSRMLS_CC);
 
1122
                                        stmt->fetch.cls.ce = old_ce;
 
1123
                                        stmt->fetch.cls.ctor_args = old_ctor_args;
 
1124
                                        stmt->fetch.cls.fci.param_count = old_arg_count;
 
1125
                                }
 
1126
                                break;
 
1127
 
 
1128
                        default:
 
1129
                                break;
 
1130
                }
 
1131
 
1105
1132
                for (idx = 0; i < stmt->column_count; i++, idx++) {
1106
1133
                        zval *val;
1107
1134
                        MAKE_STD_ZVAL(val);
1235
1262
                }
1236
1263
                
1237
1264
                switch (how) {
1238
 
                        case PDO_FETCH_CLASS:
1239
 
                                if (ce->constructor && !(flags & PDO_FETCH_PROPS_LATE)) {
1240
 
                                        stmt->fetch.cls.fci.object_pp = &return_value;
1241
 
                                        stmt->fetch.cls.fcc.object_pp = &return_value;
1242
 
                                        if (zend_call_function(&stmt->fetch.cls.fci, &stmt->fetch.cls.fcc TSRMLS_CC) == FAILURE) {
1243
 
                                                pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "could not call class constructor" TSRMLS_CC);
1244
 
                                                return 0;
1245
 
                                        } else {
1246
 
                                                if (stmt->fetch.cls.retval_ptr) {
1247
 
                                                        zval_ptr_dtor(&stmt->fetch.cls.retval_ptr);
1248
 
                                                }
1249
 
                                        }
1250
 
                                }
1251
 
                                if (flags & PDO_FETCH_CLASSTYPE) {
1252
 
                                        do_fetch_opt_finish(stmt, 0 TSRMLS_CC);
1253
 
                                        stmt->fetch.cls.ce = old_ce;
1254
 
                                        stmt->fetch.cls.ctor_args = old_ctor_args;
1255
 
                                        stmt->fetch.cls.fci.param_count = old_arg_count;
1256
 
                                }
1257
 
                                break;
1258
 
 
1259
1265
                        case PDO_FETCH_FUNC:
1260
1266
                                stmt->fetch.func.fci.param_count = idx;
1261
1267
                                stmt->fetch.func.fci.retval_ptr_ptr = &retval;
1653
1659
static int register_bound_param(INTERNAL_FUNCTION_PARAMETERS, pdo_stmt_t *stmt, int is_param) /* {{{ */
1654
1660
{
1655
1661
        struct pdo_bound_param_data param = {0};
 
1662
        long param_type = PDO_PARAM_STR;
1656
1663
 
1657
1664
        param.paramno = -1;
1658
 
        param.param_type = PDO_PARAM_STR;
1659
1665
 
1660
1666
        if (FAILURE == zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC,
1661
 
                        "lz|llz!", &param.paramno, &param.parameter, &param.param_type, &param.max_value_len,
 
1667
                        "lz|llz!", &param.paramno, &param.parameter, &param_type, &param.max_value_len,
1662
1668
                        &param.driver_params)) {
1663
1669
                if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz|llz!", &param.name,
1664
 
                                &param.namelen, &param.parameter, &param.param_type, &param.max_value_len, 
 
1670
                                &param.namelen, &param.parameter, &param_type, &param.max_value_len, 
1665
1671
                                &param.driver_params)) {
1666
1672
                        return 0;
1667
1673
                }       
1668
1674
        }
 
1675
        
 
1676
        param.param_type = (int) param_type;
1669
1677
 
1670
1678
        if (param.paramno > 0) {
1671
1679
                --param.paramno; /* make it zero-based internally */
2597
2605
 
2598
2606
        MAKE_STD_ZVAL(return_value);
2599
2607
        RETVAL_NULL();
2600
 
                
2601
 
        if (Z_TYPE_P(member) == IS_LONG) {
2602
 
                if (Z_LVAL_P(member) >= 0 && Z_LVAL_P(member) < stmt->column_count) {
2603
 
                        fetch_value(stmt, return_value, Z_LVAL_P(member), NULL TSRMLS_CC);
2604
 
                }
2605
 
        } else {
2606
 
                convert_to_string(member);
2607
 
                /* TODO: replace this with a hash of available column names to column
2608
 
                 * numbers */
2609
 
                for (colno = 0; colno < stmt->column_count; colno++) {
2610
 
                        if (strcmp(stmt->columns[colno].name, Z_STRVAL_P(member)) == 0) {
2611
 
                                fetch_value(stmt, return_value, colno, NULL TSRMLS_CC);
2612
 
                                return_value->refcount = 0;
2613
 
                                return_value->is_ref = 0;
2614
 
                                return return_value;
2615
 
                        }
2616
 
                }
2617
 
                if (strcmp(Z_STRVAL_P(member), "queryString") == 0) {
2618
 
                        zval_ptr_dtor(&return_value);
2619
 
                        return std_object_handlers.read_property(object, member, IS_STRING TSRMLS_CC);
 
2608
        
 
2609
        if (stmt) {
 
2610
                if (Z_TYPE_P(member) == IS_LONG) {
 
2611
                        if (Z_LVAL_P(member) >= 0 && Z_LVAL_P(member) < stmt->column_count) {
 
2612
                                fetch_value(stmt, return_value, Z_LVAL_P(member), NULL TSRMLS_CC);
 
2613
                        }
 
2614
                } else {
 
2615
                        convert_to_string(member);
 
2616
                        /* TODO: replace this with a hash of available column names to column
 
2617
                         * numbers */
 
2618
                        for (colno = 0; colno < stmt->column_count; colno++) {
 
2619
                                if (strcmp(stmt->columns[colno].name, Z_STRVAL_P(member)) == 0) {
 
2620
                                        fetch_value(stmt, return_value, colno, NULL TSRMLS_CC);
 
2621
                                        return_value->refcount = 0;
 
2622
                                        return_value->is_ref = 0;
 
2623
                                        return return_value;
 
2624
                                }
 
2625
                        }
 
2626
                        if (strcmp(Z_STRVAL_P(member), "queryString") == 0) {
 
2627
                                zval_ptr_dtor(&return_value);
 
2628
                                return std_object_handlers.read_property(object, member, IS_STRING TSRMLS_CC);
 
2629
                        }
2620
2630
                }
2621
2631
        }
2622
2632
 
2636
2646
        pdo_stmt_t * stmt = (pdo_stmt_t *) zend_object_store_get_object(object TSRMLS_CC);
2637
2647
        int colno = -1;
2638
2648
 
2639
 
        if (Z_TYPE_P(member) == IS_LONG) {
2640
 
                return Z_LVAL_P(member) >= 0 && Z_LVAL_P(member) < stmt->column_count;
2641
 
        } else {
2642
 
                convert_to_string(member);
 
2649
        if (stmt) {
 
2650
                if (Z_TYPE_P(member) == IS_LONG) {
 
2651
                        return Z_LVAL_P(member) >= 0 && Z_LVAL_P(member) < stmt->column_count;
 
2652
                } else {
 
2653
                        convert_to_string(member);
2643
2654
 
2644
 
                /* TODO: replace this with a hash of available column names to column
2645
 
                 * numbers */
2646
 
                for (colno = 0; colno < stmt->column_count; colno++) {
2647
 
                        if (strcmp(stmt->columns[colno].name, Z_STRVAL_P(member)) == 0) {
2648
 
                                return 1;
 
2655
                        /* TODO: replace this with a hash of available column names to column
 
2656
                         * numbers */
 
2657
                        for (colno = 0; colno < stmt->column_count; colno++) {
 
2658
                                if (strcmp(stmt->columns[colno].name, Z_STRVAL_P(member)) == 0) {
 
2659
                                        return 1;
 
2660
                                }
2649
2661
                        }
2650
2662
                }
2651
2663
        }
2663
2675
        pdo_stmt_t * stmt = (pdo_stmt_t *) zend_object_store_get_object(object TSRMLS_CC);
2664
2676
        int i;
2665
2677
 
 
2678
        if (stmt == NULL) {
 
2679
                return NULL;
 
2680
        }
 
2681
        
2666
2682
        for (i = 0; i < stmt->column_count; i++) {
2667
2683
                zval *val;
2668
2684
                MAKE_STD_ZVAL(val);