Skip to content

Commit 9651d2d

Browse files
committed
Introduce ibase.default_trans_params and printer
1 parent 6c1ad7a commit 9651d2d

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

interbase.c

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,67 @@ static PHP_INI_DISP(php_ibase_password_displayer_cb)
706706
}
707707
}
708708

709+
#define PUTS_TP(str) do { \
710+
if(has_puts) { \
711+
PUTS(" | "); \
712+
} \
713+
PUTS(str); \
714+
has_puts = true; \
715+
} while (0)
716+
717+
static PHP_INI_DISP(php_ibase_trans_displayer)
718+
{
719+
bool has_puts = false;
720+
char *value;
721+
722+
if (type == ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
723+
value = ZSTR_VAL(ini_entry->orig_value);
724+
} else if (ini_entry->value) {
725+
value = ZSTR_VAL(ini_entry->value);
726+
} else {
727+
value = NULL;
728+
}
729+
730+
if (value) {
731+
zend_long trans_argl = atol(value);
732+
733+
if (trans_argl != PHP_IBASE_DEFAULT) {
734+
/* access mode */
735+
if (PHP_IBASE_READ == (trans_argl & PHP_IBASE_READ)) {
736+
PUTS_TP("IBASE_READ");
737+
} else if (PHP_IBASE_WRITE == (trans_argl & PHP_IBASE_WRITE)) {
738+
PUTS_TP("IBASE_WRITE");
739+
}
740+
741+
/* isolation level */
742+
if (PHP_IBASE_COMMITTED == (trans_argl & PHP_IBASE_COMMITTED)) {
743+
PUTS_TP("IBASE_COMMITTED");
744+
if (PHP_IBASE_REC_VERSION == (trans_argl & PHP_IBASE_REC_VERSION)) {
745+
PUTS_TP("IBASE_REC_VERSION");
746+
} else if (PHP_IBASE_REC_NO_VERSION == (trans_argl & PHP_IBASE_REC_NO_VERSION)) {
747+
PUTS_TP("IBASE_REC_NO_VERSION");
748+
}
749+
} else if (PHP_IBASE_CONSISTENCY == (trans_argl & PHP_IBASE_CONSISTENCY)) {
750+
PUTS_TP("IBASE_CONSISTENCY");
751+
} else if (PHP_IBASE_CONCURRENCY == (trans_argl & PHP_IBASE_CONCURRENCY)) {
752+
PUTS_TP("IBASE_CONCURRENCY");
753+
}
754+
755+
/* lock resolution */
756+
if (PHP_IBASE_NOWAIT == (trans_argl & PHP_IBASE_NOWAIT)) {
757+
PUTS_TP("IBASE_NOWAIT");
758+
} else if (PHP_IBASE_WAIT == (trans_argl & PHP_IBASE_WAIT)) {
759+
PUTS_TP("IBASE_WAIT");
760+
if (PHP_IBASE_LOCK_TIMEOUT == (trans_argl & PHP_IBASE_LOCK_TIMEOUT)) {
761+
PUTS_TP("IBASE_LOCK_TIMEOUT");
762+
}
763+
}
764+
} else {
765+
PUTS_TP("IBASE_DEFAULT");
766+
}
767+
}
768+
}
769+
709770
/* {{{ startup, shutdown and info functions */
710771
PHP_INI_BEGIN()
711772
PHP_INI_ENTRY_EX("ibase.allow_persistent", "1", PHP_INI_SYSTEM, NULL, zend_ini_boolean_displayer_cb)
@@ -718,6 +779,7 @@ PHP_INI_BEGIN()
718779
PHP_INI_ENTRY("ibase.timestampformat", IB_DEF_DATE_FMT " " IB_DEF_TIME_FMT, PHP_INI_ALL, NULL)
719780
PHP_INI_ENTRY("ibase.dateformat", IB_DEF_DATE_FMT, PHP_INI_ALL, NULL)
720781
PHP_INI_ENTRY("ibase.timeformat", IB_DEF_TIME_FMT, PHP_INI_ALL, NULL)
782+
STD_PHP_INI_ENTRY_EX("ibase.default_trans_params", "0", PHP_INI_ALL, OnUpdateLongGEZero, default_trans_params, zend_ibase_globals, ibase_globals, php_ibase_trans_displayer)
721783
PHP_INI_END()
722784

723785
static PHP_GINIT_FUNCTION(ibase)

php_ibase_includes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ ZEND_BEGIN_MODULE_GLOBALS(ibase)
6969
zend_long num_links, num_persistent;
7070
char errmsg[MAX_ERRMSG];
7171
zend_long sql_code;
72+
zend_long default_trans_params;
7273
ZEND_END_MODULE_GLOBALS(ibase)
7374

7475
ZEND_EXTERN_MODULE_GLOBALS(ibase)

0 commit comments

Comments
 (0)