Skip to content

Commit ecc9310

Browse files
committed
Shortcut return when driver doesn't support setting attributes
1 parent dbfbb15 commit ecc9310

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

ext/pdo/pdo_dbh.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,11 @@ static bool pdo_dbh_attribute_set(pdo_dbh_t *dbh, zend_long attr, zval *value) /
699699
{
700700
zend_long lval;
701701

702+
if (!dbh->methods->set_attribute) {
703+
pdo_raise_impl_error(dbh, NULL, "IM001", "driver does not support setting attributes");
704+
return false;
705+
}
706+
702707
switch (attr) {
703708
case PDO_ATTR_ERRMODE:
704709
PDO_GET_LONG_PARAM(value);
@@ -813,21 +818,12 @@ static bool pdo_dbh_attribute_set(pdo_dbh_t *dbh, zend_long attr, zval *value) /
813818
;
814819
}
815820

816-
if (!dbh->methods->set_attribute) {
817-
goto fail;
818-
}
819-
820821
PDO_DBH_CLEAR_ERR();
821822
if (dbh->methods->set_attribute(dbh, attr, value)) {
822823
return true;
823824
}
824825

825-
fail:
826-
if (!dbh->methods->set_attribute) {
827-
pdo_raise_impl_error(dbh, NULL, "IM001", "driver does not support setting attributes");
828-
} else {
829-
PDO_HANDLE_DBH_ERR();
830-
}
826+
PDO_HANDLE_DBH_ERR();
831827
return false;
832828
}
833829
/* }}} */

0 commit comments

Comments
 (0)