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
3033static 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