Skip to content

Commit 466ddc8

Browse files
committed
build fix attempt 2
1 parent 12d404b commit 466ddc8

File tree

2 files changed

+34
-14
lines changed

2 files changed

+34
-14
lines changed

ext/pdo_sqlite/pdo_sqlite.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#include "ext/pdo/php_pdo_driver.h"
2727
#include "php_pdo_sqlite.h"
2828
#include "php_pdo_sqlite_int.h"
29-
#include "zend_enum.h"
3029
#include "zend_exceptions.h"
3130
#include "pdo_sqlite_arginfo.h"
3231

ext/pdo_sqlite/sqlite_statement.c

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
#include "php_pdo_sqlite.h"
2727
#include "php_pdo_sqlite_int.h"
2828

29+
#if defined(__APPLE__)
30+
#include <Availability.h>
31+
#endif
2932

3033
static int pdo_sqlite_stmt_dtor(pdo_stmt_t *stmt)
3134
{
@@ -389,8 +392,17 @@ static int pdo_sqlite_stmt_get_attribute(pdo_stmt_t *stmt, zend_long attr, zval
389392
break;
390393
case PDO_SQLITE_ATTR_EXPLAIN_STATEMENT:
391394
#if SQLITE_VERSION_NUMBER >= 3041000
392-
ZVAL_LONG(val, (zend_long)sqlite3_stmt_isexplain(S->stmt));
393-
return 1;
395+
#if defined(__APPLE__)
396+
if (__builtin_available(macOS 14.2, *)) {
397+
#endif
398+
ZVAL_LONG(val, (zend_long)sqlite3_stmt_isexplain(S->stmt));
399+
return 1;
400+
#if defined(__APPLE__)
401+
} else {
402+
zend_value_error("explain statement unsupported");
403+
return 0;
404+
}
405+
#endif
394406
#else
395407
zend_value_error("explain statement unsupported");
396408
return 0;
@@ -409,19 +421,28 @@ static int pdo_sqlite_stmt_set_attribute(pdo_stmt_t *stmt, zend_long attr, zval
409421
switch (attr) {
410422
case PDO_SQLITE_ATTR_EXPLAIN_STATEMENT:
411423
#if SQLITE_VERSION_NUMBER >= 3041000
412-
if (Z_TYPE_P(zval) != IS_LONG) {
413-
zend_type_error("explain mode must be of type int");
414-
return 0;
415-
}
416-
if (Z_TYPE_P(zval) < 0 || Z_TYPE_P(zval) > 2) {
417-
zend_value_error("explain mode must be one of the EXPLAIN_MODE_* constants");
418-
return 0;
419-
}
420-
if (sqlite3_stmt_explain(S->stmt, (int)Z_LVAL_P(zval)) != SQLITE_OK) {
424+
#if defined(__APPLE__)
425+
if (__builtin_available(macOS 14.2, *)) {
426+
#endif
427+
if (Z_TYPE_P(zval) != IS_LONG) {
428+
zend_type_error("explain mode must be of type int");
429+
return 0;
430+
}
431+
if (Z_TYPE_P(zval) < 0 || Z_TYPE_P(zval) > 2) {
432+
zend_value_error("explain mode must be one of the EXPLAIN_MODE_* constants");
433+
return 0;
434+
}
435+
if (sqlite3_stmt_explain(S->stmt, (int)Z_LVAL_P(zval)) != SQLITE_OK) {
436+
return 0;
437+
}
438+
439+
return 1;
440+
#if defined(__APPLE__)
441+
} else {
442+
zend_value_error("explain statement unsupported");
421443
return 0;
422444
}
423-
424-
return 1;
445+
#endif
425446
#else
426447
zend_value_error("explain statement unsupported");
427448
return 0;

0 commit comments

Comments
 (0)