Commit Graph

334 Commits

Author SHA1 Message Date
Ilija Tovilo
fb257ee83c
Upgrade master to Ubuntu 24.04 (GH-16704) 2024-11-07 16:32:45 +01:00
Christoph M. Becker
94ac1cd1df
Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-16450: PDO_ODBC can inject garbage into field values
2024-10-31 16:18:25 +01:00
Christoph M. Becker
331bd9571a
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-16450: PDO_ODBC can inject garbage into field values
2024-10-31 16:17:50 +01:00
Christoph M. Becker
03bd17bb48
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-16450: PDO_ODBC can inject garbage into field values
2024-10-31 16:16:29 +01:00
Christoph M. Becker
c9eafc1954
Fix GH-16450: PDO_ODBC can inject garbage into field values
A previous bug fix[1] relied on ODBC drivers to properly count down the
`StrLen_or_IndPtr` argument for consecutive calls to `SQLGetData()`.
Apparently, not all drivers handle this correctly, so we cannot assert
they do.  Instead we fall back to the old behavior for drivers which
would violate the assertion.

A test against SQLServer (which we currently use in CI) would not make
sense, since the respective drivers do not exhibit that behavior.
Instead we target the regression test especially to a MS Access
database.

Since there is apparently no way to easily create an MS Access database
programmatically, we commit a minimal empty DB which is used for the
regression test, and could also be used by other test cases.

[1] <bccca0b53aa60a62e2988c750fc73c02d109e642>

Closes GH-16587.
2024-10-31 16:15:17 +01:00
Christoph M. Becker
d812c96456
Fix pdoodbc_002.phpt to not try to load PDO_odbc (GH-16096)
In the `--EXTENSIONS--` section, names of extension are handled case-
sensitively.
2024-09-28 15:12:08 +02:00
Christoph M. Becker
50b3a0d011
Add comments about internal headers (GH-15689)
A common convention is to name internal C header files as `*_int.h`.
Since a couple of these are actually installed, we add comments that
this is not supposed to happen, (a) to avoid installing further
internal headers, and (b) to pave the way to fix this in the next major
PHP version.

Somewhat special is php_gmp_int.h, where "int" is meant as abbreviation
for "interface".

Another common convention is appending `_priv` or `_private`, but since
there have not been any issues regarding these headers so far, we
refrain from adding respective comments to these headers.

Anyhow, it might be a good idea to introduce some common naming
convention for such internal/private headers.
2024-09-08 16:11:25 +02:00
DanielEScherzer
53cb89670c
Generated arginfo header files: remove empty zend_function_entry arrays (#15705)
When a class (or enum) has no methods, rather than using an array that only
contains `ZEND_FE_END`, use `NULL` for the functions. The implementation of
class registration for internal classes, `do_register_internal_class()` in
zend_API.c, already skips classes where the functions are `NULL`. By removing
these unneeded arrays, we can reduce the size of the header files, while also
removing an unneeded call to zend_register_functions() for each internal class
with no extra methods.
2024-09-03 23:19:53 +02:00
Máté Kocsis
8d12f666ae
Fix registration of internal readonly child classes (#15459)
Currently, internal classes are registered with the following code:

INIT_CLASS_ENTRY(ce, "InternalClass", class_InternalClass_methods);
class_entry = zend_register_internal_class_ex(&ce, NULL);
class_entry->ce_flags |= ...;

This has worked well so far, except if InternalClass is readonly. It is because some inheritance checks are run by zend_register_internal_class_ex before ZEND_ACC_READONLY_CLASS is added to ce_flags.

The issue is fixed by adding a zend_register_internal_class_with_flags() zend API function that stubs can use from now on. This function makes sure to add the flags before running any checks. Since the new API is not available in lower PHP versions, gen_stub.php has to keep support for the existing API for PHP 8.3 and below.
2024-08-24 12:36:54 +02:00
Peter Kokot
6050a99cb8
Autotools: Sync CS in pdo_odbc (#15466)
- Obsolete backticks replaced with $(...)
- Few redundant double quotes around variables removed
- AS_VAR_IF used
- indentation synced
2024-08-17 18:39:31 +02:00
Peter Kokot
cdf0a9b9a0
Autotools: Use AS_CASE in ext/pdo_odbc (#15355) 2024-08-12 14:21:20 +02:00
Peter Kokot
693ec809b9
Autotools: Remove PDO dependency related errors (#15347)
Follow-up of GH-15344 (687eb9125a)

This removes the customized error messages in PDO extensions when PDO is
not enabled (--disable-all or --disable-pdo) in favor of the default
error done by PHP_ADD_EXTENSION_DEP.
2024-08-11 21:35:36 +02:00
Peter Kokot
dcdcb3cbfe
Autotools: Replace AC_MSG_ERROR with AC_MSG_FAILURE (#15209)
This replaces the AC_MSG_ERROR with AC_MSG_FAILURE, where appropriate.

The AC_MSG_ERROR outputs given message and exits the configure step. The
AC_MSG_FAILURE does the same but also automatically outputs additional
message "See 'config.log' for more details." which might help directing
the user where to look further.

The AC_MSG_ERROR is used for errors where current test step isn't logged
in the config.log and wouldn't make sense, and AC_MSG_FAILURE is mostly
used in cases of library checks, compilation tests, headers checked with
AC_CHECK_HEADER* and similar tests that are also logged in the
config.log.

AC_MSG_ERROR([Sanity check failed.]) output:

```
configure: error: Sanity check failed.
```

AC_MSG_FAILURE([Sanity check failed.]) output:

```
configure: error: in '/path/to/php-src':
configure: error: Sanity check failed.
See 'config.log' for more details
```
2024-08-04 07:36:37 +02:00
Peter Kokot
1ceadaed52
Autotools: Normalize and quote all PHP_NEW_EXTENSION arguments (#15144)
This adds Autoconf quote characters to all PHP_NEW_EXTENSION arguments
and syncs the CS across the php-src Autotools build system.
2024-07-29 00:14:59 +02:00
Peter Kokot
2b97c84d4c
Autotools: Quote PHP_CHECK_LIBRARY arguments (#15136)
This syncs the quotes across the PHP_CHECK_LIBRARY macro arguments.
2024-07-28 18:39:14 +02:00
Saki Takamachi
acd6ac3324
Fixed parent class of stub (#14990) 2024-07-17 21:38:59 +09:00
Calvin Buckley
6635948b7a
Check for iODBC and unixODBC with pkg-config in PDO_ODBC (#14963)
* Check for iODBC and unixODBC with pkg-config in PDO_ODBC

PDO_ODBC required that these backends had their path specified manually,
which was clumsy and contrary to how procedural ODBC checked it. This
adds a pkg-config based path to check for these backends that ignores
the 'dir' part of the flag, so i.e. --with-pdo-odbc=unixODBC should pick
it up from the correct location.

Generic and the special ibm-db2 usecase should be unaffected. The header
situation is unfortunately ugly, and has a workaround; this should also
be cleaned up.

* Move check for valid headers to after

* Use existing CFLAGS for PDO_ODBC header check

...instead of a separate funny variable. It does mean we have to save
and restore the value of CPPFLAGS, as AC_CHECK_HEADERS and friends rely
on that variable instead of CFLAGS.

Co-authored-by: Peter Kokot <peterkokot@gmail.com>

* Move PDO_ODBC_TYPE to AC_DEFINE, simplify CFLAGS handling

The variable PDO_ODBC_INCLUDE becomes redundant, as is the CFLAGS
override for PHP_NEW_EXTENSION if we call PHP_EVAL_INCLINE in the
generic case.

Co-authored-by: Peter Kokot <peterkokot@gmail.com>

* Use same variable names so evals can be combined

* Fix identation

* Suggested shell syntax cleanups

---------

Co-authored-by: Peter Kokot <peterkokot@gmail.com>
2024-07-16 00:40:02 +02:00
Peter Kokot
520787bb93
Autotools: Refactor PDO_ODBC_CHECK_HEADER (#14935)
- Macro renamed to PHP_PDO_ODBC_CHECK_HEADER
- AC_DEFINE_UNQUOTED used instead of PHP_DEF_HAVE
- help texts added to CPP macro definitions
- CS synced a bit
2024-07-13 06:52:25 +02:00
Peter Kokot
bee84c0468
Autotools: Quote PHP_SUBST arguments in extensions (#14748) 2024-07-02 06:56:18 +02: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
Calvin Buckley
cb8a744b7a Merge branch 'PHP-8.3'
* PHP-8.3:
  [skip ci] update NEWS for GH-14457
  [skip ci] update NEWS for GH-14457
  Remove use of SDWORD and SWORD in ODBC extensions (GH-14457)
2024-06-04 12:51:06 -03:00
Calvin Buckley
05fbea8513 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  [skip ci] update NEWS for GH-14457
  Remove use of SDWORD and SWORD in ODBC extensions (GH-14457)
2024-06-04 12:49:36 -03:00
Calvin Buckley
c15f5a2a6f
Remove use of SDWORD and SWORD in ODBC extensions (GH-14457)
* Remove usage of SDWORD, replace with SQLINTEGER

Some different driver managers disagree if this should be 4 or 8 bytes
in size. SQLGetDiagRec expects this to be an SQLINTEGER, so we should
just use that explicitly instead of hoping that it's the same size.

Fixes GH-14367

* Replace SWORD with SQLSMALLINT

While this hasn't caused issues like the SQLINTEGER/SDWORD confusion
has, we should use what SQLDescrimeParam calls for, which is
SQLSMALLINT.
2024-06-04 12:46:19 -03: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
Máté Kocsis
6ec4220148
Amend PDO driver-specific class names (#14069)
As suggested in https://externals.io/message/123166
2024-05-30 20:15:42 +02:00
Máté Kocsis
10957e498c
Do not generate frameless info items when func info generation is disabled
While here, I fixed newlines around arginfo and function entry generation. Previously, newlines were repeated.
2024-02-18 11:39:00 +01:00
Máté Kocsis
d6a0b3af68
Implement PDO driver-specific subclasses
RFC: https://wiki.php.net/rfc/pdo_driver_specific_subclasses
Closes GH-12804

Co-Authored-By: Danack <Danack@basereality.com>
2024-01-11 23:22:41 +01:00
Gina Peter Banyard
284b66be46
Merge branch 'PHP-8.3'
* PHP-8.3:
  add PDO::ATTR_AUTOCOMMIT to getAttribute
  Fix GH-12767: Fixed to be able to change autocommit mode using setAttribute
2023-12-18 00:28:14 +00:00
Gina Peter Banyard
dcef7039e8
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  add PDO::ATTR_AUTOCOMMIT to getAttribute
  Fix GH-12767: Fixed to be able to change autocommit mode using setAttribute
2023-12-18 00:27:58 +00:00
SakiTakamachi
2553ffeaa0
add PDO::ATTR_AUTOCOMMIT to getAttribute
Signed-off-by: Gina Peter Banyard <girgias@php.net>
2023-12-18 00:26:32 +00:00
SakiTakamachi
933dccb79b
Fix GH-12767: Fixed to be able to change autocommit mode using setAttribute
Signed-off-by: Gina Peter Banyard <girgias@php.net>
2023-12-18 00:26:32 +00:00
Saki Takamachi
866aa12bcd
ext/pdo: Fixed PDO::setAttribute() and PDO::getAttribute() (#12793) 2023-12-04 16:05:30 +00:00
Peter Kokot
63ae7635c4
Remove ODBCRouter artifacts (#12846)
ODBCRouter flavor in odbc extension(s) was removed in PHP 7.3 via
398be731e6.
2023-12-01 10:26:33 +00:00
Ilija Tovilo
5aeada0ee3
Fix potentially uninitialized warning on release build 2023-11-15 13:14:55 +01:00
Ilija Tovilo
1e5241d49b
[skip ci] Re-unparallelize odbc tests
SQL Server frequently deadlocks. Parallelization of these jobs, at least in CI,
is not worthwhile because there are enough tests to run in parallel for the few
workers available.
2023-11-09 11:22:15 +01:00
Saki Takamachi
61c251d7bc
Add XLEAK for some msodbcsql tests (#12615) 2023-11-07 18:11:54 +01:00
Saki Takamachi
bbe1222956
Fix GH-12296: [odbc] [pdo_odbc] Optimized odbc connection string creating (#12306)
Declare and initialize on one line

changed to use php_memnistr

store strlen(db) in a variable

Added a semicolon to the end of dsn.

If there is a semicolon at the end of the original dsn, it will be duplicated, so it will be removed.

Add condition when authentication information is null
2023-11-04 13:46:17 +00:00
Máté Kocsis
f4a5db3e08
Parallelize pdo tests (dblib, firebird, oci, odbc, pgsql) (#12395)
Co-authored-by: George Peter Banyard <girgias@php.net>
Co-authored-by: Jorg Adam Sowa <jorg.sowa@gmail.com>
2023-10-28 12:35:57 +01:00
Ilija Tovilo
f39b5c4c25
Close PHP tags in tests
Closes GH-12422
2023-10-18 17:34:10 +02:00
Máté Kocsis
462792ee51 Expose PDO_ODBC_TYPE to userland 2023-08-23 21:20:41 +02:00
Máté Kocsis
8726ae0601 Improve and fix ext/odbc tests
Some test failures are fixed, parallelization is enabled, section order is fixed.
2023-08-23 21:20:41 +02:00
Niels Dossche
c822c2dddd Merge branch 'PHP-8.2'
* PHP-8.2:
  Remove CTE flag from array_diff_ukey(), which was added by mistake
  Fix missing and inconsistent error check on SQLAllocHandle
2023-03-15 21:47:34 +01:00
Niels Dossche
ff2f882c09 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix missing and inconsistent error check on SQLAllocHandle
2023-03-15 21:38:12 +01:00
nielsdos
c4c8d6ced7 Fix missing and inconsistent error check on SQLAllocHandle
* Missing check: SQLAllocHandle() for the environment wasn't checked in
  pdo_odbc_handle_factory(). Add a check similar to the other ones for
  SQLAllocHandle().
* Inconsistent check: one of the SQLAllocHandle() calls wasn't checked
  for SQL_SUCCESS_WITH_INFO. However, looking at the other uses and the
  documentation we should probably check this as well.

Furthermore, since there was a mix of "SQLAllocHandle: reason" and
"SQLAllocHandle (reason)" in the error reporting, I made them
consistently use the first option as that seems to be the most used for
error reporting in this file.

Closes GH-10740.
2023-03-15 21:36:50 +01:00
Christoph M. Becker
87f1f5dc02
Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix GH-9372: HY010 when binding overlong parameter
2022-10-19 11:37:30 +02:00
Christoph M. Becker
f5aaa8f187
Fix GH-9372: HY010 when binding overlong parameter
If `SQLPutData()` *fails*, we should not call `SQLParamData()` again,
because that yields the confusing `HY010` (Function sequence error).
Instead we properly handle `SQLPutData()` errors.

For the given case (paramter length > column length), some drivers let
`SQLPutData()` fail, while others do not.  Either behavior seems to
conform to the ODBC specification.  Anyhow, we do not want to silently
truncate the given parameter, since that would break the behavior for
drivers which do not fail, but still don't simply truncate the given
parameter.  So it is finally up to userland to avoid passing overlong
parameters – with this patch they at least get useful information about
the actual issue.

Closes GH-9541.
2022-10-19 11:37:05 +02:00
Tim Düsterhus
03fd405423
Use php_info_print_table_header for actual column headers only (#9485)
Using php_info_print_table_header() for "Foo: bar" looks odd and out of place,
because the whole line is colored. It is also questionable from a HTML
semantics point of view, because it does not described the columns that follow.

The use of this across extensions is inconsistent. It was part of the skeleton,
but ext/date or ext/json already use a regular row.
2022-09-06 08:48:22 +02:00
Calvin Buckley
f3a14d1b1a
Fix GH-9347: Current ODBC liveness checks may be inadequate
We implement SQL_ATTR_CONNECTION_DEAD for ODBC and PDO_ODBC.

This is semantically appropriate and should be used whenever the
driver supports it. In the event that it fails or says the connection
isn't dead (which may be inaccurate in some cases), try the old
heuristic.

Closes GH-9353.
2022-08-29 18:32:31 +02:00
Christoph M. Becker
e7f6acd068
Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix handling of single-key connection strings
2022-06-13 14:44:49 +02:00