Skip to content

Commit df5efa2

Browse files
committed
Fix #80150: Failure to fetch error message
In case of statement related errors, we need to pass the respective statement handle to `SQLError()`. Closes GH-6217.
1 parent f5afd0a commit df5efa2

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ PHP NEWS
1616
. Fixed bug #78470 (odbc_specialcolumns() no longer accepts $nullable). (cmb)
1717
. Fixed bug #80147 (BINARY strings may not be properly zero-terminated).
1818
(cmb)
19+
. Fixed bug #80150 (Failure to fetch error message). (cmb)
1920

2021
- OPcache:
2122
. Fixed bug #80083 (Optimizer pass 6 removes variables used for ibm_db2 data

ext/odbc/php_odbc.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3156,7 +3156,7 @@ PHP_FUNCTION(odbc_tables)
31563156
type, SAFE_SQL_NTS(type));
31573157

31583158
if (rc == SQL_ERROR) {
3159-
odbc_sql_error(conn, SQL_NULL_HSTMT, "SQLTables");
3159+
odbc_sql_error(conn, result->stmt, "SQLTables");
31603160
efree(result);
31613161
RETURN_FALSE;
31623162
}
@@ -3227,7 +3227,7 @@ PHP_FUNCTION(odbc_columns)
32273227
column, (SQLSMALLINT) column_len);
32283228

32293229
if (rc == SQL_ERROR) {
3230-
odbc_sql_error(conn, SQL_NULL_HSTMT, "SQLColumns");
3230+
odbc_sql_error(conn, result->stmt, "SQLColumns");
32313231
efree(result);
32323232
RETURN_FALSE;
32333233
}
@@ -3292,7 +3292,7 @@ PHP_FUNCTION(odbc_columnprivileges)
32923292
column, SAFE_SQL_NTS(column));
32933293

32943294
if (rc == SQL_ERROR) {
3295-
odbc_sql_error(conn, SQL_NULL_HSTMT, "SQLColumnPrivileges");
3295+
odbc_sql_error(conn, result->stmt, "SQLColumnPrivileges");
32963296
efree(result);
32973297
RETURN_FALSE;
32983298
}
@@ -3372,7 +3372,7 @@ PHP_FUNCTION(odbc_foreignkeys)
33723372
ftable, SAFE_SQL_NTS(ftable) );
33733373

33743374
if (rc == SQL_ERROR) {
3375-
odbc_sql_error(conn, SQL_NULL_HSTMT, "SQLForeignKeys");
3375+
odbc_sql_error(conn, result->stmt, "SQLForeignKeys");
33763376
efree(result);
33773377
RETURN_FALSE;
33783378
}
@@ -3434,7 +3434,7 @@ PHP_FUNCTION(odbc_gettypeinfo)
34343434
rc = SQLGetTypeInfo(result->stmt, data_type );
34353435

34363436
if (rc == SQL_ERROR) {
3437-
odbc_sql_error(conn, SQL_NULL_HSTMT, "SQLGetTypeInfo");
3437+
odbc_sql_error(conn, result->stmt, "SQLGetTypeInfo");
34383438
efree(result);
34393439
RETURN_FALSE;
34403440
}
@@ -3496,7 +3496,7 @@ PHP_FUNCTION(odbc_primarykeys)
34963496
table, SAFE_SQL_NTS(table) );
34973497

34983498
if (rc == SQL_ERROR) {
3499-
odbc_sql_error(conn, SQL_NULL_HSTMT, "SQLPrimaryKeys");
3499+
odbc_sql_error(conn, result->stmt, "SQLPrimaryKeys");
35003500
efree(result);
35013501
RETURN_FALSE;
35023502
}
@@ -3565,7 +3565,7 @@ PHP_FUNCTION(odbc_procedurecolumns)
35653565
col, SAFE_SQL_NTS(col) );
35663566

35673567
if (rc == SQL_ERROR) {
3568-
odbc_sql_error(conn, SQL_NULL_HSTMT, "SQLProcedureColumns");
3568+
odbc_sql_error(conn, result->stmt, "SQLProcedureColumns");
35693569
efree(result);
35703570
RETURN_FALSE;
35713571
}
@@ -3633,7 +3633,7 @@ PHP_FUNCTION(odbc_procedures)
36333633
proc, SAFE_SQL_NTS(proc) );
36343634

36353635
if (rc == SQL_ERROR) {
3636-
odbc_sql_error(conn, SQL_NULL_HSTMT, "SQLProcedures");
3636+
odbc_sql_error(conn, result->stmt, "SQLProcedures");
36373637
efree(result);
36383638
RETURN_FALSE;
36393639
}
@@ -3706,7 +3706,7 @@ PHP_FUNCTION(odbc_specialcolumns)
37063706
nullable);
37073707

37083708
if (rc == SQL_ERROR) {
3709-
odbc_sql_error(conn, SQL_NULL_HSTMT, "SQLSpecialColumns");
3709+
odbc_sql_error(conn, result->stmt, "SQLSpecialColumns");
37103710
efree(result);
37113711
RETURN_FALSE;
37123712
}
@@ -3776,7 +3776,7 @@ PHP_FUNCTION(odbc_statistics)
37763776
reserved);
37773777

37783778
if (rc == SQL_ERROR) {
3779-
odbc_sql_error(conn, SQL_NULL_HSTMT, "SQLStatistics");
3779+
odbc_sql_error(conn, result->stmt, "SQLStatistics");
37803780
efree(result);
37813781
RETURN_FALSE;
37823782
}
@@ -3839,7 +3839,7 @@ PHP_FUNCTION(odbc_tableprivileges)
38393839
table, SAFE_SQL_NTS(table));
38403840

38413841
if (rc == SQL_ERROR) {
3842-
odbc_sql_error(conn, SQL_NULL_HSTMT, "SQLTablePrivileges");
3842+
odbc_sql_error(conn, result->stmt, "SQLTablePrivileges");
38433843
efree(result);
38443844
RETURN_FALSE;
38453845
}

0 commit comments

Comments
 (0)