Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:32946 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 62224 invoked by uid 1010); 23 Oct 2007 22:35:48 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 62209 invoked from network); 23 Oct 2007 22:35:48 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Oct 2007 22:35:48 -0000 X-Host-Fingerprint: 80.197.188.103 0x50c5bc67.odnxx5.adsl-dhcp.tele.dk Received: from [80.197.188.103] ([80.197.188.103:22673] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A5/51-03376-4477E174 for ; Tue, 23 Oct 2007 18:35:48 -0400 Message-ID: To: internals@lists.php.net Reply-To: "Lars Westermann" References: Date: Wed, 24 Oct 2007 00:35:43 +0200 Lines: 220 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.3138 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198 X-RFC2646: Format=Flowed; Response X-Posted-By: 80.197.188.103 Subject: Re: PDO Firebird bugfixes (firebird_driver.c) From: Lars.Westermann@privat.dk ("Lars Westermann") ext/pdo_firebird/firebird_driver.c: diff -u -r1.17.2.2.2.4 firebird_driver.c --- firebird_driver.c 27 Feb 2007 03:28:16 -0000 1.17.2.2.2.4 +++ firebird_driver.c 18 Oct 2007 20:01:47 -0000 @@ -114,6 +114,16 @@ RECORD_ERROR(dbh); } + if (H->date_format) { + efree(H->date_format); + } + if (H->time_format) { + efree(H->time_format); + } + if (H->timestamp_format) { + efree(H->timestamp_format); + } + pefree(H, dbh->is_persistent); return 0; @@ -482,6 +492,30 @@ dbh->auto_commit = Z_BVAL_P(val); } return 1; + + case PDO_FB_ATTR_DATE_FORMAT: + convert_to_string(val); + if (H->date_format) { + efree(H->date_format); + } + spprintf(&H->date_format, 0, "%s", Z_STRVAL_P(val)); + return 1; + + case PDO_FB_ATTR_TIME_FORMAT: + convert_to_string(val); + if (H->time_format) { + efree(H->time_format); + } + spprintf(&H->time_format, 0, "%s", Z_STRVAL_P(val)); + return 1; + + case PDO_FB_ATTR_TIMESTAMP_FORMAT: + convert_to_string(val); + if (H->timestamp_format) { + efree(H->timestamp_format); + } + spprintf(&H->timestamp_format, 0, "%s", Z_STRVAL_P(val)); + return 1; } return 0; } @@ -500,7 +534,7 @@ /* }}} */ /* called by PDO to get a driver-specific dbh attribute */ -static int firebird_handle_get_attribute(pdo_dbh_t const *dbh, long attr, zval *val TSRMLS_DC) /* {{{ */ +static int firebird_handle_get_attribute(pdo_dbh_t *dbh, long attr, zval *val TSRMLS_DC) /* {{{ */ { pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data; @@ -615,7 +649,7 @@ char dpb_buffer[256] = { isc_dpb_version1 }, *dpb; dpb = dpb_buffer + 1; - + /* loop through all the provided arguments and set dpb fields accordingly */ for (i = 0; i < sizeof(dpb_flags); ++i) { if (dpb_values[i] && buf_len > 0) { @@ -627,15 +661,14 @@ } /* fire it up baby! */ - if (isc_attach_database(H->isc_status, 0, vars[0].optval, &H->db,(short)(dpb-dpb_buffer), - dpb_buffer)) { + if (isc_attach_database(H->isc_status, 0, vars[0].optval, &H->db,(short)(dpb-dpb_buffer), dpb_buffer)) { break; } dbh->methods = &firebird_methods; dbh->native_case = PDO_CASE_UPPER; dbh->alloc_own_columns = 1; - + ret = 1; } while (0); @@ -646,6 +679,14 @@ } } + if (!dbh->methods) { + char errmsg[512]; + ISC_STATUS *s = H->isc_status; + isc_interprete(errmsg, &s); + zend_throw_exception_ex(php_pdo_get_exception(), 0 TSRMLS_CC, "SQLSTATE[%s] [%d] %s", + "HY000", (short) H->isc_status[1], errmsg); + } + if (!ret) { firebird_handle_closer(dbh TSRMLS_CC); } @@ -654,6 +695,7 @@ } /* }}} */ + pdo_driver_t pdo_firebird_driver = { /* {{{ */ PDO_DRIVER_HEADER(firebird), pdo_firebird_handle_factory