Commit Graph

141 Commits

Author SHA1 Message Date
Simonov Denis
eb3e7a2c0c
ext/pdo_firebird: Fixed GH-15604 Always make input parameters nullable (#15605)
Fixes #15604
Closes #15605
2024-08-31 17:06:41 +09:00
Peter Kokot
7ebdd7d05a
Trim trailing whitespace (#15649)
[skip ci]
2024-08-30 01:20:56 +02:00
Simonov Denis
8487ddb8a3
pdo_firebird: Cleanup code (GH-15510)
Since we're requiring fbclient >= 3.0 anyway, we:

* Remove unneeded `#if FB_API_VER >= 25`, `#if FB_API_VER >= 30`,
  `#ifdef SQL_BOOLEAN`

* Simplify support for new types for query input parameters.
  Support force_null for them.

* fbclient 3.0+ does not have a limit on the length of a SQL query of 64 KB.
  The new limit is 10 MB, no one in their right mind would transmit a query of such length.
2024-08-27 11:35:04 +02:00
Simonov Denis
225034dbbc
pdo_firebird: Formatting time zone types
As a follow-up to the commit which introduced support for Firebird 4.0+
data types[1], we add support for formats for types with time zones.

Since this uses the newer Firebird C++ API, pdo_firebird now requires a
C++ compiler to be built.

[1] <https://github.com/php/php-src/pull/14897>

Co-authored-by: Christoph M. Becker <cmbecker69@gmx.de>

Closes GH-15230.
2024-08-13 01:25:48 +02:00
Simonov Denis
00e45887fa
PDO_Firebird: Supported Firebird 4.0 datatypes (#14897)
Five new data types are now available: INT128, DEC16, DEC34, TIMESTAMP_TZ, TIME_TZ.
These are available starting with Firebird 4.0.

closes #14897
2024-07-23 22:34:21 +09:00
Niels Dossche
810999ae31
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix bogus fallthrough path in firebird_handle_get_attribute()
2024-07-22 18:33:41 +02:00
Niels Dossche
46924ac9fa
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix bogus fallthrough path in firebird_handle_get_attribute()
2024-07-22 18:33:32 +02:00
Niels Dossche
b8e9c5ba6a
Fix bogus fallthrough path in firebird_handle_get_attribute()
If getting the version fails, we should return -1 according to
php_pdo_driver.h:259, not fall through to another attribute.

Closes GH-15066.
2024-07-22 18:33:03 +02:00
Saki Takamachi
f4391d4d2c
Fixed segmentation fault when attribute value was not set (#15065) 2024-07-23 01:17:21 +09:00
Saki Takamachi
c550d341ff
ext/pdo_firebird: Added getApiVersion() and removed from getAttribute (#15004) 2024-07-18 11:17:52 +09:00
Saki Takamachi
4cb82b039e
ext/pdo_firebird: Do not implement new constants in PDO core (#14995) 2024-07-18 08:12:17 +09:00
Saki Takamachi
d55ef3f339
ext/pdo_firebird: Added Pdo\Firebird::ATTR_API_VERSION (#14916)
closes #14916
2024-07-17 20:32:37 +09:00
Arnaud Le Blanc
11accb5cdf
Preferably include from build dir (#13516)
* Include from build dir first

This fixes out of tree builds by ensuring that configure artifacts are included
from the build dir.

Before, out of tree builds would preferably include files from the src dir, as
the include path was defined as follows (ignoring includes from ext/ and sapi/) :

    -I$(top_builddir)/main
    -I$(top_srcdir)
    -I$(top_builddir)/TSRM
    -I$(top_builddir)/Zend
    -I$(top_srcdir)/main
    -I$(top_srcdir)/Zend
    -I$(top_srcdir)/TSRM
    -I$(top_builddir)/

As a result, an out of tree build would include configure artifacts such as
`main/php_config.h` from the src dir.

After this change, the include path is defined as follows:

    -I$(top_builddir)/main
    -I$(top_builddir)
    -I$(top_srcdir)/main
    -I$(top_srcdir)
    -I$(top_builddir)/TSRM
    -I$(top_builddir)/Zend
    -I$(top_srcdir)/Zend
    -I$(top_srcdir)/TSRM

* Fix extension include path for out of tree builds

* Include config.h with the brackets form

`#include "config.h"` searches in the directory containing the including-file
before any other include path. This can include the wrong config.h when building
out of tree and a config.h exists in the source tree.

Using `#include <config.h>` uses exclusively the include path, and gives
priority to the build dir.
2024-06-26 00:26:43 +02:00
Matteo Beccati
715b9aaa09
Implemented PDO Driver specific SQL parsers
RFC: http://wiki.php.net/rfc/pdo_driver_specific_parsers
2024-06-17 23:31:24 +02:00
Peter Kokot
df481ef941
Simplify PDO include paths (#14444)
PDO include paths can be simplified and synced as done in other
extensions: either the project root directory or the phpincludedir (for
the system installation). The 'ext' include is automatically appended
when doing phpize build. In php-src it is only present on Windows build.
The PHP_CHECK_PDO_INCLUDES is left intact working as before and checks
if PDO headers are found.
2024-06-03 12:56:21 +02:00
Saki Takamachi
fc14f17a20
remove ZWSP 2024-04-10 10:02:24 +09:00
Saki Takamachi
5dfb2d95ea
[pdo_firebird] Added pdo_firebird_check_liveness handler (#12757) 2023-12-20 15:37:39 +00:00
Saki Takamachi
834cb64403
Feature: ext/pdo_firebird: Add transaction isolation level and mode settings (#12815)
* Added transaction isolation level and access mode

* Raise a ValueError if an invalid value is passed to PDO::FB_TRANSACTION_ISOLATION_LEVEL.
2023-12-07 17:34:55 +00:00
Saki Takamachi
866aa12bcd
ext/pdo: Fixed PDO::setAttribute() and PDO::getAttribute() (#12793) 2023-12-04 16:05:30 +00:00
Saki Takamachi
dfaf7986de
[pdo_firebird] Transaction management optimization (#12741)
take2 of #12657

## About Firebird transaction

Firebird is a full transactional database, so the DB itself does not support autocommit mode. (Strictly, there is an autocommit mode, but it is a different concept from the "autocommit" that we are used to with MySQL and others.)

Therefore, a transaction must have started before any operation is performed, and autocommit mode had to be emulated in PHP.

I made sure that a transaction always exists when in autocommit mode. Since the `in_transacntion` function does not work as expected, I have introduced `H->in_manually_txn` to determine whether a transaction is being manually manipulated.

## There are two types of commit/rollback

(I'm not talking about two-phase commit. This change does not take into account two-phase commit.)

There are `isc_commit_retaining` which starts a transaction again in the same context immediately after committing, and `isc_commit_transaction` which closes the transaction as is.

Similarly, there are two types of rollback.

-----------

Due to the default value of the transaction isolation level, autocommit mode may obtain unintended results.
Regarding this, it would be too large to include support for transaction isolation levels in this PR, so I will leave it as is for now.
2023-11-27 03:38:48 +00:00
SakiTakamachi
04f8c1bda8 Optimized error handling 2023-11-22 17:11:49 +00:00
SakiTakamachi
54b12bcdb4 Unified function naming conventions 2023-11-22 17:11:49 +00:00
Saki Takamachi
239379b75b
ext/pdo_firebird: Output correct error messages 2023-11-20 13:21:43 +00:00
Ilija Tovilo
9d5f2f1343
Use new ZSTR_INIT_LITERAL macro (#10879) 2023-03-20 16:19:05 +01:00
Dmitry Stogov
067df26344 Use memrchr() when available
On x86_64 glibc memrchr() uses SSE/AVX CPU extensions and works much
faster then naive loop. On x86 32-bit we still use inlined version.

memrchr() is a GNU extension. Its prototype  becomes available when
<string.h> is included with defined _GNU_SOURCE macro. Previously, we
defined it in "php_config.h", but some sources may include <string.h>
befire it. To avod mess we also pass -D_GNU_SOURCE to C compiler.
2021-11-24 16:13:34 +03:00
Stanislav Malyshev
d72e82bfc0
Merge branch 'PHP-8.0'
* PHP-8.0:
  Update NEWS
  Fix #76448: Stack buffer overflow in firebird_info_cb
  Fix #76449: SIGSEGV in firebird_handle_doer
  Fix #76450: SIGSEGV in firebird_stmt_execute
  Fix #76452: Crash while parsing blob data in firebird_fetch_blob
  Fix #81122: SSRF bypass in FILTER_VALIDATE_URL
2021-06-27 21:40:02 -07:00
Stanislav Malyshev
892674ef70
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Update NEWS
  Fix #76448: Stack buffer overflow in firebird_info_cb
  Fix #76449: SIGSEGV in firebird_handle_doer
  Fix #76450: SIGSEGV in firebird_stmt_execute
  Fix #76452: Crash while parsing blob data in firebird_fetch_blob
  Fix #81122: SSRF bypass in FILTER_VALIDATE_URL
2021-06-27 21:39:23 -07:00
Stanislav Malyshev
2327e3d36a
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Update NEWS
  Fix #76448: Stack buffer overflow in firebird_info_cb
  Fix #76449: SIGSEGV in firebird_handle_doer
  Fix #76450: SIGSEGV in firebird_stmt_execute
  Fix #76452: Crash while parsing blob data in firebird_fetch_blob
  Fix #81122: SSRF bypass in FILTER_VALIDATE_URL
2021-06-27 21:36:55 -07:00
Christoph M. Becker
67afa32541
Fix #76448: Stack buffer overflow in firebird_info_cb
We ensure not to overflow the stack allocated buffer by using `strlcat`.
2021-06-20 22:01:06 -07:00
Christoph M. Becker
08da7c7372
Fix #76449: SIGSEGV in firebird_handle_doer
We need to verify that the `result_size` is not larger than our buffer,
and also should make sure that the `len` which is passed to
`isc_vax_integer()` has a permissible value; otherwise we bail out.
2021-06-20 21:59:51 -07:00
KsaR
01b3fc03c3
Update http->https in license (#6945)
1. Update: http://www.php.net/license/3_01.txt to https, as there is anyway server header "Location:" to https.
2. Update few license 3.0 to 3.01 as 3.0 states "php 5.1.1, 4.1.1, and earlier".
3. In some license comments is "at through the world-wide-web" while most is without "at", so deleted.
4. fixed indentation in some files before |
2021-05-06 12:16:35 +02:00
George Peter Banyard
5caaf40b43
Introduce pseudo-keyword ZEND_FALLTHROUGH
And use it instead of comments
2021-04-07 00:46:29 +01:00
George Peter Banyard
ebaeb93c3f Add API to fetch bool value for PDO attribute values
Closes GH-6766
2021-03-17 00:58:01 +00:00
George Peter Banyard
c465462e91 Use standard PDO way for fetching integer attribute values 2021-03-17 00:58:01 +00:00
George Peter Banyard
94ea8e247b Refactor PDO doer handler to use zend_string 2021-01-19 11:42:39 +00:00
Nikita Popov
3e01f5afb1 Replace zend_bool uses with bool
We're starting to see a mix between uses of zend_bool and bool.
Replace all usages with the standard bool type everywhere.

Of course, zend_bool is retained as an alias.
2021-01-15 12:33:06 +01:00
George Peter Banyard
63cda0fea8 Refactor PDO's quoter handler to return a zend_string
Closes GH-6547
2021-01-07 15:53:48 +00:00
George Peter Banyard
1a58611ae5 Voidify PDO's fetch_error handler 2021-01-06 10:20:57 +00:00
George Peter Banyard
60a61afd3c Boolify PDO's preparer handler 2021-01-06 10:20:57 +00:00
George Peter Banyard
53ba72ec03 Voidify PDO's closer handler 2021-01-06 10:20:57 +00:00
George Peter Banyard
954d3743cc Boolify PDO's quoter handler 2021-01-06 10:21:06 +00:00
George Peter Banyard
43f69160cf Boolify PDO's set_attribute driver function 2021-01-06 10:20:59 +00:00
George Peter Banyard
d04adf60be Boolify PDO's transaction handlers
This includes begin(), commit(), rollBack(), and inTransaction()
2021-01-06 10:20:57 +00:00
Nikita Popov
caa710037e Rewrite PDO result binding
Instead of requiring the type to be determined in advance by the
describer function and then requiring get_col to return a buffer
of appropriate type, allow get_col to return an arbitrary zval.
See UPGRADING.INTERNALS for a more detailed description of the
change.

This makes the result fetching simpler, more efficient and more
flexible. The general possibility already existed via the special
PDO_PARAM_ZVAL type, but the usage was very inconvenient and/or
inefficient. Now it's possible to easily implement behavior like
"return int if it fits, otherwise string" and to avoid any kind
of complex management of temporary buffers.

This also fixes bug #40913 (our second highest voted bug of all
time, for some reason). PARAM_LOB result bindings will now
consistently return a stream resource, independently of the used
database driver.

I've tried my best to update all PDO drivers for this change, but
some of the changes may be broken, as I cannot test or even build
some of these drivers (in particular PDO dblib and PDO oci).
Fixes are appreciated -- a working CI setup would be even more
appreciated ;)
2020-12-22 15:56:34 +01:00
Christoph M. Becker
58d459f1ef Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #80521: Parameters with underscores no longer recognized
2020-12-16 20:06:01 +01:00
Christoph M. Becker
1860ef22eb Fix #80521: Parameters with underscores no longer recognized
We have to use the proper value for the bitmask.
2020-12-16 20:04:52 +01:00
Nikita Popov
2d51c203f0 PDO: Store/pass query_string as zend_string
Rather than storing char* + size_t, use a zend_string*. Also
avoid various copies of the query string.
2020-12-14 10:43:28 +01:00
Nikita Popov
c288b5294b Fix compile warnings in PDO Firebird 2020-12-14 10:36:36 +01:00
Nikita Popov
e735de6eae Add GC support for PDO driver data
Add a get_gc method that can be implemented by drivers, which can
be used to add additional zvals to the GC buffer.

Implement GC support for PDO SQLite callbacks in particular.

Closes GH-6262.
2020-10-12 13:00:41 +02:00
Simonov Denis
17a789e27c Fix #64937: Firebird PDO preprocessing sql
This patch fixes some problems with preprocessing SQL queries.

* The new algorithm takes into account single-line and multi-line
  comments and ignores the ":" and "?" Parameter markers in them.

* The algorithm allows the EXECUTE BLOCK statement to be processed
  correctly. For this statement, it is necessary to search for
  parameter markers between EXECUTE BLOCK and AS, the rest should be
  left as is.

The SQL preprocessing code has been ported from Firebird to handle
EXECUTE STATEMENT.

Closes GH-4920.
2020-09-25 00:07:57 +02:00