Commit graph

356 commits

Author SHA1 Message Date
Niels Dossche
6d15475815 sqlite3: Split off column name cache generation
Also no need to reset the cache unconditionally in fetchAll().
2025-06-24 22:09:54 +02:00
Niels Dossche
e7678cdaa4 sqlite3: Use Z_TRY_ADDREF 2025-06-24 22:09:54 +02:00
David Carlier
375316d0e2
ext/sqlite3: Sqlite3Result::fetchAll()
support associative and indexes arrays for results.

close GH-1884
2025-06-23 08:01:31 +01:00
David Carlier
22bd2ae63f
ext/sqlite3: explain statement support addition.
similar to what have been done for pdo/sqlite as having statement
explain support to simulate how a query would operate or
for more advanced users, analysing the VM routines used
for possible optimisations.

close GH-18853
2025-06-23 07:57:45 +01:00
Jakub Zelenka
89934b405e
Merge branch 'PHP-8.4' 2025-06-21 20:17:15 +02:00
Jakub Zelenka
bbac59148c
Merge branch 'PHP-8.3' into PHP-8.4 2025-06-21 20:16:13 +02:00
Jakub Zelenka
a36b8fdc94
Fix GH-13264: fgets() and stream_get_line() do not return false on filter fatal error
This happens because there are no checks in php_stream_fill_read_buffer
calls. This should not fail always but only on fatal error so special
flag is needed for that.

Closes GH-18778
2025-06-21 20:13:09 +02:00
David Carlier
058c0348fd
ext/sqlite3: adding busy() call.
checks if the prepared statement had been fetched but did not complete yet.

close GH-18843
2025-06-13 06:08:44 +01:00
David CARLIER
bd8c770439
ext/sqlite3: querySingle amd fetchArray methods optimisations. (#18385)
pre-allocated size for the former and packed array.
2025-04-21 16:37:34 +01:00
Niels Dossche
1fa15abe92
Remove pointless call to zval_ptr_dtor() in sqlite3 (#17906)
This is IS_LONG.
2025-02-23 21:04:47 +01:00
Niels Dossche
6a4b0c922c
Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix memory leaks in pdo_sqlite callback registration
  Fix cycle leak in sqlite3 setAuthorizer()
2025-02-23 16:36:06 +01:00
Niels Dossche
76035090b6
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix cycle leak in sqlite3 setAuthorizer()
2025-02-23 16:35:25 +01:00
Niels Dossche
353f21487f
Fix cycle leak in sqlite3 setAuthorizer()
Closes GH-17903.
2025-02-23 16:34:41 +01:00
Niels Dossche
9ee08999f4 Convert initialised to bool 2025-02-10 08:42:11 +01:00
Niels Dossche
dbf7d4402c Convert is_prepared_statement to bool 2025-02-10 08:42:11 +01:00
Niels Dossche
5eae6d1405 Don't store the object zval directly 2025-02-10 08:42:11 +01:00
Niels Dossche
c0d910d506 Get rid of always-false intern checks
These checks are always false because we're receiving a valid
zend_object.
2025-02-10 08:42:11 +01:00
Niels Dossche
bc74cff479 Get rid of unnecessary wrapping a statement in a free list object
This simplifies the code and reduces memory usage.
2025-02-10 08:42:11 +01:00
Niels Dossche
43ac692a09 Use faster string operations in sqlite3 2025-02-10 08:42:11 +01:00
Niels Dossche
b2c891f88e
Avoid string duplications in sqlite drivers (#17115)
These string duplications are necessary to unregister the callback
later. We can just keep using zend_string to avoid memory duplications.
2024-12-18 17:32:11 +01:00
Gina Peter Bnayard
5853cdb73d Use "must not" instead of "cannot" wording 2024-08-21 21:12:17 +01:00
Gina Peter Bnayard
e7c4d54d65 Use new helper function for "cannot be empty" ValueErrors 2024-08-21 21:12:17 +01: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
Gina Peter Banyard
fd2d869642
Clean-up some more headers (#14416)
Remove unused headers (such as php_ini.h for extensions that don't define INI settings)
Use more specific headers when possible
2024-06-08 17:15:36 +01:00
David CARLIER
47c41d4a0f
ext/sqlite: Sqlite3Stmt::bindParam/bindValue named parameters change. (#14393)
memmove seems unnecessary on `:` autoprepend.
2024-05-31 21:34:37 +01:00
Cristian Rodríguez
8e62e2b829
Mark multple functions as static (#13864)
* Mark many functions as static

Multiple functions are missing the static qualifier.

* remove unused struct sigactions

struct sigaction act, old_term, old_quit, old_int;
all unused.

* optimizer: minXOR and maxXOR are unused
2024-05-22 13:11:46 +02:00
Gina Peter Banyard
6303d1fc6a
ext/sqlite3: Use new F ZPP modifier (#14040) 2024-05-01 15:38:48 +01:00
Niels Dossche
700fbca58d
Change getThis() into ZEND_THIS where possible (#13641) 2024-03-08 22:19:06 +01:00
Niels Dossche
d463d215e1
Minor sqlite3 cleanups (#13141)
* Remove always-true stmt_obj->db_obj condition

This is always true because SQLITE3_CHECK_INITIALIZED checks this.

* Remove always-true param_number check

This is always true because we return early when the value < 1.
2024-01-13 20:47:04 +01:00
Máté Kocsis
2cd8f3e625
Retain a RETURN_THROWS() in ext/sqlite3 2023-12-04 22:52:20 +01:00
Niels Dossche
49980ee89d Use zend_get_gc_buffer_add_fcc() 2023-09-09 20:00:01 +02:00
Niels Dossche
1d59b37742 Fix build with sqlite3 gc and fci/fcc api 2023-09-09 16:07:10 +02:00
Niels Dossche
cb6fac5b8a Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-11878: SQLite3 callback functions cause a memory leak with a callable array
2023-09-09 15:35:03 +02:00
Niels Dossche
6851c7b867 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix GH-11878: SQLite3 callback functions cause a memory leak with a callable array
2023-09-09 15:34:38 +02:00
Niels Dossche
07a9d2fb32 Fix GH-11878: SQLite3 callback functions cause a memory leak with a callable array
In this test file, the free_obj handler is called with a refcount of 2,
caused by the fact we do a GC_ADDREF() to increase its refcount while
its refcount is still 1 because the Foo object hasn't been destroyed yet
(due to the cycle caused by the sqlite function callback).
Solve this by introducing a get_gc handler.

Closes GH-11881.
2023-09-09 15:33:50 +02:00
Ilija Tovilo
3fb09940fc
Revert "Skip profiling of sqlite3_step"
This reverts commit bb31a75321.

It doesn't seem like this actually fixed the problem.
2023-09-07 10:35:06 +02:00
Ilija Tovilo
bb31a75321
Skip profiling of sqlite3_step
It looks like sqlite3_step can vary quite drastically from one request to the
next. This seems to be caused by more or fewer calls to sqlite3VdbeSorterWrite.
It would be great if we could find a way to make execution of this function more
consistent, but at this point I don't know how.

Closes GH-12130
2023-09-05 17:38:00 +02:00
Niels Dossche
bb9fb3c59b Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix replaced error handling in SQLite3Stmt::__construct
2023-07-07 10:29:52 +02:00
Niels Dossche
ca661f2c34 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix replaced error handling in SQLite3Stmt::__construct
2023-07-07 10:27:42 +02:00
Niels Dossche
824d1f95ad Fix replaced error handling in SQLite3Stmt::__construct
The error handling is replaced using zend_replace_error_handling(), but
when SQLITE3_CHECK_INITIALIZED() returns early, the old error handling
isn't restored.

In the past, SQLITE3_CHECK_INITIALIZED() threw a warning when the check
failed. This was replaced a few years ago with an error exception. So we
can fix the bug by just removing the replacing error handling as it
accomplishes nothing anymore.

Closes GH-11607.
2023-07-07 10:24:54 +02:00
BohwaZ
ddd9a08f56
[RFC] Transition SQLite3 to exceptions (#11058)
* Deprecate warnings in SQLite3, change returned exception class to SQLite3Exception

RFC: https://wiki.php.net/rfc/sqlite3_exceptions

Co-authored-by: Tim Düsterhus <timwolla@googlemail.com>
2023-07-03 14:30:52 +01:00
nielsdos
035105b252 Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix GH-11451: Invalid associative array containing duplicate keys
2023-06-15 21:56:40 +02:00
nielsdos
29a96e09b2 Fix GH-11451: Invalid associative array containing duplicate keys
It used the "add_new" variant which assumes the key doesn't already
exist. But in case of duplicate keys we have to take the last result.

Closes GH-11453.
2023-06-15 21:56:06 +02:00
Max Kellermann
1287747a9a
ext: make various internal functions static (#10650)
Namely in:
* ext/date
* ext/libxml
* ext/dba
* ext/curl
2023-02-21 15:51:41 +00:00
Max Kellermann
263b22f374
Make lots of string pointers const (#10646)
This allows using string literals without implicitly casting away the
`const`.
2023-02-21 14:01:37 +00:00
Christoph M. Becker
568ed4721e
Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix #81742: open_basedir bypass in SQLite3 by using file URI
2022-12-06 16:01:24 +01:00
Christoph M. Becker
830180341b
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix #81742: open_basedir bypass in SQLite3 by using file URI
2022-12-06 16:00:49 +01:00
Christoph M. Becker
2f6b9e6c63
Fix #81742: open_basedir bypass in SQLite3 by using file URI
A previous fix[1] was not sufficient to catch all potential file URIs,
because the patch did not cater to URL encoding.  Properly parsing and
decoding the URI may yield a different result than the handling of
SQLite3, so we play it safe, and reject any file URIs if open_basedir
is configured.

[1] <https://bugs.php.net/bug.php?id=77967>

Closes GH-10018.
2022-12-06 15:59:52 +01:00
George Peter Banyard
32d3cae19f
Handle trampolines correctly in new FCC API + usages (#9877) 2022-11-22 17:12:53 +00:00
George Peter Banyard
d105958603 Only use FCC for SQLite3 user defined authorizer 2022-11-02 14:52:54 +00:00