Commit Graph

248 Commits

Author SHA1 Message Date
Antony Dovgal
a46319d86d fix typos 2008-07-25 08:45:09 +00:00
Dmitry Stogov
691d4a6999 Fixed uninitialised data 2008-07-25 08:23:07 +00:00
Johannes Schlüter
be0793d2e7 MFH: Add mysqlnd support for PDO_mysql, fixes at least bug#41997,#42499,
pecl#12794, pecl#12401

# Running the tests:
# (Note: Doesn't work currnetly on HEAD, see:
#  http://news.php.net/php.qa/64378)
#
#  PDO_MYSQL_TEST_DSN  - DSN
#    For example: mysql:dbname=test;host=localhost;port=3306
#
#  PDO_MYSQL_TEST_HOST    - database host
#  PDO_MYSQL_TEST_DB      - database (schema) name
#  PDO_MYSQL_TEST_SOCKET  - database server socket
#  PDO_MYSQL_TEST_ENGINE  - storage engine to use
#  PDO_MYSQL_TEST_USER    - database user
#  PDO_MYSQL_TEST_PASS    - database user password
#  PDO_MYSQL_TEST_CHARSET - database charset
#
#  NOTE: if any of PDO_MYSQL_TEST_[HOST|DB|SOCKET|ENGINE|CHARSET] is
#  part of PDO_MYSQL_TEST_DSN, the values must match. That is, for example,
#  for PDO_MYSQL_TEST_DSN = mysql:dbname=test you MUST set PDO_MYSQL_TEST_DB=test.
2008-07-21 13:09:28 +00:00
Felipe Pena
f6cc283d46 - MFH: Add check for avoid segfault when trying instantiate PDORow manually 2008-05-14 12:32:21 +00:00
Felipe Pena
84a8bb038a MFH: New way for check void parameters 2008-03-10 22:15:36 +00:00
Johannes Schlüter
1aa32afa8a MFH: Fix get_parent_class() of PDORow instances 2008-03-03 19:00:45 +00:00
Ilia Alshanetsky
43bcf759d3 Better fix for bug #44189 2008-02-26 00:13:57 +00:00
Ilia Alshanetsky
e0388c5549 Fixed bug #44200 (A crash in PDO when no bound targets exists and yet
bound parameters are present)
2008-02-24 16:08:32 +00:00
Ilia Alshanetsky
3101edfd18 Fixed bug #44171 (Invalid FETCH_COLUMN index does not raise an error) 2008-02-20 03:11:43 +00:00
Ilia Alshanetsky
40dc00410d Missing patch bit from the FETCH_GROUP fix 2008-01-14 18:41:31 +00:00
Ilia Alshanetsky
fa1e1d249b Fixed a bug with PDO::FETCH_COLUMN|PDO::FETCH_GROUP mode when a column # by
which to group by data is specified.
2008-01-11 01:47:18 +00:00
Sebastian Bergmann
d1dded8751 MFH: Bump copyright year, 2 of 2. 2007-12-31 07:17:19 +00:00
Ilia Alshanetsky
204f9e1a74 Adjusted fix for bug #42978 2007-11-20 23:12:17 +00:00
Ilia Alshanetsky
48878f2ecd Fixed bug #42978 (mismatch between number of bound params and values causes
a crash in pdo_pgsql)
2007-11-20 14:22:27 +00:00
Ilia Alshanetsky
548c25ef1c Fixed bug #43139 PDO ignores ATTR_DEFAULT_FETCH_MODE in some cases with fetchAll() 2007-10-31 12:57:51 +00:00
Ilia Alshanetsky
3762dfc09f Fixed bug #42917 (PDO::FETCH_KEY_PAIR doesn't work with setFetchMode) 2007-10-11 20:54:41 +00:00
Yiduo (David) Wang
104290130e MFH: stmt->fetch.func.values is not a zval and should not be freed with FREE_ZVAL 2007-10-08 04:06:15 +00:00
Yiduo (David) Wang
4b4d634cb9 MFH: Added macros for managing zval refcounts and is_ref statuses 2007-10-07 05:22:07 +00:00
Dmitry Stogov
6c810b0d4c Improved memory usage by movig constants to read only memory. (Dmitry, Pierre) 2007-09-27 18:00:48 +00:00
Stanislav Malyshev
1f45d49a0c fix crash if stream is empty and reader function sets buffer as null 2007-09-12 21:21:18 +00:00
Hannes Magnusson
2fc92c9172 - Fixed bug #42452 (PDO classes do not expose Reflection API information)
- Fixed tests
2007-08-30 14:06:12 +00:00
Ilia Alshanetsky
c72d39f763 Fixed bug #41971 (PDOStatement::fetch and PDOStatement::setFetchMode causes
unexpected behavior).
2007-07-31 22:48:42 +00:00
Ilia Alshanetsky
20c4198341 Added test for KEY_PAIR code and fixed KEY_PAIR detection code 2007-07-22 15:50:17 +00:00
Ilia Alshanetsky
285316fcff Fixed PDO_FETCH_KEY_PAIR implementation for fetchAll() 2007-07-22 15:14:21 +00:00
Ilia Alshanetsky
dc1c6f74c8 Fixed bug #41698 (float parameters truncated to integer in prepared
statements).
2007-06-26 01:24:10 +00:00
Antony Dovgal
5e7b464517 typofix 2007-05-16 20:04:32 +00:00
Ilia Alshanetsky
efd7846d34 [DOC] Added PDO::FETCH_KEY_PAIR mode that will fetch a 2 column result set
into an associated array.
2007-05-16 19:33:57 +00:00
Antony Dovgal
9ab23a7e53 fix leaks in row_get_properties()
thanks to Kellen Bombardier for noticing
2007-04-17 17:00:16 +00:00
Antony Dovgal
c73225ab61 MFH: fix #40727 (segfault in PDO when failed to bind parameters) 2007-03-07 09:03:07 +00:00
Antony Dovgal
58e96c4c10 nullify param.parameter and avoid destroying it twice 2007-01-27 21:53:26 +00:00
Sebastian Bergmann
4223aa4d5e MFH: Bump year. 2007-01-01 09:36:18 +00:00
Ilia Alshanetsky
b7b0f4d988 Fixed bug #39759 (Can't use stored procedures fetching multiple result
sets in pdo_mysql).
2006-12-08 19:50:40 +00:00
Ilia Alshanetsky
7fb3715d43 Fixed bug #38319 (Remove bogus warnings from persistent PDO connections). 2006-12-04 03:07:44 +00:00
Ilia Alshanetsky
2d4b8e19e2 Fixed bug #39656 (crash when calling fetch() on a PDO statment object
after closeCursor()).
2006-11-28 16:27:53 +00:00
Ilia Alshanetsky
887b3484f7 Fixed bug #39398 (Booleans are not automatically translated to integers). 2006-11-07 17:57:17 +00:00
Antony Dovgal
b7f2d8f17e MFH: fix possible crash in free_statement() 2006-08-23 19:15:57 +00:00
Ilia Alshanetsky
43fca8a3f8 Fixed bug #38394 (PDO fails to recover from failed prepared statement
execution).
2006-08-09 14:45:00 +00:00
Ilia Alshanetsky
2b5a53d6b6 Fixed memory leak on unused bound name parameters. 2006-08-01 15:06:01 +00:00
Ilia Alshanetsky
c6ace95236 Fixed bug #37445 (Fixed crash in pdo_mysql resulting from premature object
destruction).
2006-07-31 20:18:11 +00:00
Antony Dovgal
168f53b72b fix bug #38253 (PDO produces segfault with default fetch mode)
add test
2006-07-30 11:19:56 +00:00
Antony Dovgal
3ff986ecf7 init vatiables 2006-06-20 13:26:01 +00:00
Antony Dovgal
e4a3732c91 no need to call zend_is_callable() if callable is known to be invalid
free fname on failure and plug possible leak
2006-05-30 09:46:59 +00:00
Marcus Boerger
7bbab02633 - MFH
. Fix iterator based access
  . Add new attribute ATTR_DEFAULT_FETCH_MODE: $bdh->setAttribute()
  . Add new fetch mode: FETCH_PROPS_LATE, this fills object member
    variables after calling the constructor (fixes #36428).
2006-05-11 22:43:44 +00:00
Antony Dovgal
ea53739d30 MFB: don't segfault if an exception has been thrown from the fetch handler 2006-04-22 19:10:53 +00:00
Wez Furlong
687e6ffc58 Add "ATTR_EMULATE_PREPARES" general attribute to replace the custom
attributes employed by mysql and postgres drivers.
No functional change.
2006-04-09 08:05:01 +00:00
Antony Dovgal
08e6fded56 prevent possible NULL dereference 2006-03-28 20:19:44 +00:00
Wez Furlong
fb7d5bd780 The fix for #35332 caused #35671 (and thus PECL #6504).
Partially back out that fix and introduce an extra optional step for drivers to
canonicalize the "name" that is used for registering parameters.
2006-03-27 20:51:01 +00:00
Ilia Alshanetsky
4ccd89d147 Properly calculate the size of the result array. 2006-03-19 17:35:36 +00:00
Antony Dovgal
5c7c11c41d MFH: check stream for NULL before writing to it
remove unnecessary semicolons
2006-03-18 22:24:05 +00:00
Ilia Alshanetsky
92ba7cccad Fixed memory leak on unused bind var. 2006-03-15 15:25:50 +00:00
Marcus Boerger
1d461a6bcc - MFH 2006-01-22 23:57:41 +00:00
Ilia Alshanetsky
64a7e46506 Fixed bug #35797 (segfault on PDOStatement::execute() with
zend.ze1_compatibility_mode = On).
2006-01-01 20:07:41 +00:00
foobar
5bd93221a8 bump year and license version 2006-01-01 12:51:34 +00:00
Ilia Alshanetsky
b83a0eb10c Fixed memory corruption when FETCH_LAZY mode is being used. 2005-12-17 20:00:00 +00:00
Ilia Alshanetsky
bdf9c4d15c Fixed bug #35694 (Improved error message for invalid fetch mode). 2005-12-15 22:33:02 +00:00
foobar
3e669bc950 MFH: nuke php3 legacy 2005-12-06 02:28:41 +00:00
Antony Dovgal
06c57b7d55 tweak fix a bit
(by request of Wez)
2005-12-01 20:39:12 +00:00
Antony Dovgal
59087fee52 MFH: fix #35508 (PDO fails when unknown fetch mode specified) 2005-12-01 19:59:58 +00:00
Wez Furlong
63dae4ee74 Fix #35431; LAZY fetch and fetchAll == crash.
Lazy makes no sense with fetchAll; disallow it.
2005-11-27 21:01:58 +00:00
Antony Dovgal
6543134dea MFH: fix #35430 (PDO crashes on incorrect FETCH_FUNC use) 2005-11-27 21:01:02 +00:00
Wez Furlong
426fb96cc9 Doh, need to canonicalize parameter names (by prefixing with :) before
attempting to remap them to positional args.
2005-11-26 21:20:52 +00:00
Wez Furlong
2618322506 Bug: when stringify fetch mode is on, and the driver returns a string instead
of a stream for a LOB parameter, PDO would incorrectly return NULL for that
column.
2005-11-25 03:23:17 +00:00
Wez Furlong
c2d53719c2 Fix for #35332.
The problem is caused by the user mixing positional and named parameters.
PDO was blindly adding the parameters, unaware that the same parameters were
already allocated by position.

What we do now is register the parameter with the driver before adding it to
any hash.  This gives the driver an opportunity to normalize the name and
parameter number.  PDO can then ensure that only one entry is occupied in the
hash for a given parameter.
2005-11-25 00:29:04 +00:00
Ilia Alshanetsky
8e49bacf95 Fixed bug #35358 (Incorrect error messages for PDO class constants). 2005-11-24 16:21:43 +00:00
Wez Furlong
0bd9518f8c Closes PECL #5944; binding an invalid parameter can lead to segfaults.
Modified patch provided by curt@php.net.
2005-11-16 06:32:33 +00:00
Ilia Alshanetsky
8e2de517bb Fixed bug #35135 (PDOStatment without related PDO object may crash). 2005-11-07 16:53:15 +00:00
Marcus Boerger
24a80c3ebf - Fix remaining memleaks
# all tests pass for me now for the first time in:
# pgsql, mysql, sqlite, sqlite2
2005-10-31 07:47:40 +00:00
Wez Furlong
b74698f135 fix misinterpretation of data when overriding types via bindColumn.
Very slightly modified patch from Marcus.
2005-10-31 03:23:38 +00:00
Wez Furlong
40c24a65c4 improve test portability.
improve infrastructure for LOB support.
2005-10-31 02:07:38 +00:00
Marcus Boerger
e7494a7e9e - Fix memleak 2005-10-30 22:17:52 +00:00
Wez Furlong
0139cd0e53 Closes PECL Bug #5772; FETCH_FUNC broken for mixed case function names 2005-10-29 03:11:46 +00:00
Wez Furlong
7af8089096 Closes PECL #5809; PDOStatement::execute(array(...)) would modify its args.
It should behave like bindValue() not bindParam().
2005-10-29 03:01:19 +00:00
Ilia Alshanetsky
6b46a441cd Fixed compiler warning 2005-10-25 03:53:25 +00:00
Ilia Alshanetsky
a5fe9808aa MFH: Fixed bug #34809 (FETCH_INTO in PDO crashes without a destination object). 2005-10-10 14:44:16 +00:00
Marcus Boerger
f3c44f6065 - MFH Fixed Bug #34590 User defined PDOStatement class can't implement
methods
- Reimplement Traversable interface
# If there is a problem with this i need a backtrace. As far as i can
# tell by gdb/valgrind/logic there is no error here. But missuse leads to
# the same error report casing the exclusion of interface Traversable.
2005-09-21 22:58:39 +00:00
Wez Furlong
8dc3e7b147 When populating bound columns, override the returned type with the type
specified by the user in their bind.
2005-09-11 20:32:28 +00:00
Wez Furlong
81151a5dbf remove traversable interface; apparently it's not enough, and this stuff is too
magical to figure out wtf should be added.
2005-09-11 14:27:10 +00:00
Wez Furlong
9c252b4b07 closes PECL #5027; PDO_FETCH_NAMED not handled via setFetchMode(). 2005-09-10 19:32:15 +00:00
Wez Furlong
efe24c0205 add __sleep and __wakeup functions to prevent serialize/deserialize from being used on PDO objects. Refs PECL #5217 2005-09-10 17:48:45 +00:00
Wez Furlong
0730fa2af9 Add PDOStatement::bindValue(), which is similar to bindParam(), except that
it binds the value of the zval at the time it is called, rather than keeping
a reference to the zval and taking the value at execute() time.
2005-09-10 15:32:04 +00:00
George Schlossnagle
248c30dad7 MFH. Protect against underflow - refs http://pecl.php.net/bugs/bug.php?id=5193 2005-09-01 14:44:11 +00:00
Ilia Alshanetsky
ecc34bddcc Fixed memory leak. 2005-08-03 18:26:16 +00:00
Wez Furlong
bf85bf515e add sanity checks 2005-07-27 14:18:01 +00:00
Marcus Boerger
d8eece2b43 - Add missing part to make colon in parameter binding optional 2005-07-22 14:31:20 +00:00
Wez Furlong
cfe1dc3b46 this looks like a much better fix for refcounting/shutdown in lazy objects. 2005-07-22 04:33:56 +00:00
Wez Furlong
882503110d fix leak (ugh, this nuance gets me every time) 2005-07-22 02:09:19 +00:00
Wez Furlong
3560bb9c2b Fixes #33785 for me 2005-07-22 01:34:43 +00:00
Wez Furlong
be88f5a960 make a start on a debugging function. 2005-07-18 14:46:55 +00:00
Wez Furlong
9240c5f521 remember ? -> :pdox mapping so that binds by position can be mapped to names if required. 2005-07-12 03:19:44 +00:00
Wez Furlong
664ebfa499 expand oracle null handling compatability by offering the ability to convert
NULLs into empty strings as well as the other way around.  It still doesn't
help a great deal in the long run, but at least the option is there.

Make sure hash tables are nulled out to avoid double freeing them.
2005-07-12 02:40:59 +00:00
Andrey Hristov
b3aa24ff98 fix a segfault with the following script:
<?php
$dbh = new PDO('mysql:dbname=test;host=localhost', "root", "secret");
$what = 1;
$stmt = $dbh->prepare('select a, b, c from t123 where a=:what');
$stmt->bindParam(1, $what, PDO_PARAM_INT, 12);
var_dump($stmt->execute());
var_dump($stmt->fetchObject());
?>
2005-07-11 14:14:56 +00:00
Wez Furlong
d3b653e97b Added:
proto bool PDOStatement::closeCursor()
Closes the cursor, leaving the statement ready for re-execution.

The purpose of the function is to free up the connection to the server so that
other queries may be issued, but leaving the statement in a state that it can
be re-executed.

This is implemented either as an optional driver specific method (allowing for
maximum efficiency), or as the generic PDO fallback if no driver specific
function is installed.

The PDO generic fallback is semantically the same as writing the following code
in your PHP script:

do {
	while ($stmt->fetch())
		;
	if (!$stmt->nextRowset())
		break;
} while (true);
2005-07-09 03:52:41 +00:00
Wez Furlong
38a02b6244 For named-parameter-to-named-parameter rewrites, we need to map the original
names to the new names.
2005-07-08 17:00:28 +00:00
Wez Furlong
8f31f0cfaa Fix a shutdown order issue I saw in the pgsql driver. Hope this doesn't mess
up something in the OCI driver; I think I've been here before.
2005-07-08 15:25:15 +00:00
Wez Furlong
49c1882837 Add a PDO_ATTR_STRINGIFY_FETCHES attribute, which is used to convert integer or
floating point values into strings during fetch.  This is a compatibility hack
for drivers that return native types rather than string representations.

We use this flag in the test suite to persuade postgres tests to pass.
2005-07-08 04:13:00 +00:00
Ilia Alshanetsky
86028ad122 Return an empty array rather then FALSE in fetchAll() on no results. 2005-07-07 15:14:10 +00:00
Wez Furlong
68caaadc6a Fix bug in bindColumn() for drivers that implement native prepared statements
and that use the PDO rewriter to handle non-native parameter syntax.
2005-07-07 12:45:40 +00:00
Dmitry Stogov
0eb0b781e0 Fixed memory leaks 2005-07-07 11:19:56 +00:00
Wez Furlong
d4a158260b Add PDO_FETCH_NAMED; closes PECL #4641 by providing a way to access columns
by name, even when multiple columns have the same name:

$sql = "SELECT 1 a, 2 a, 3 b, 4 c, 5 d, 6 c, 7 a";
echo "$sql\n";
print_r($db->query($sql)->fetchAll(PDO_FETCH_NAMED));

Array
(
    [0] => Array
        (
            [a] => Array
                (
                    [0] => 1
                    [1] => 2
                    [2] => 7
                )

            [b] => 3
            [c] => Array
                (
                    [0] => 4
                    [1] => 6
                )

            [d] => 5
        )
)

Also added two new attributes for use at prepare time;
PDO_ATTR_FETCH_TABLE_NAMES and PDO_ATTR_FETCH_CATALOG_NAMES instruct the driver
that the names of the columns that they return to PDO should include the table
and catalog names respectively.  Both attributes may be used together or
independently.  The catalog, table and column name components should be
separated by a . character.
2005-07-03 03:49:44 +00:00
Ilia Alshanetsky
6fd9e5a64f Fixed memory leak on PDO_FETCH_OBJ. 2005-07-02 17:19:58 +00:00