@@ -1643,12 +1643,12 @@ void php_oci_connection_descriptors_free(php_oci_connection *connection TSRMLS_D
1643
1643
* Fetch & print out error message if we get an error
1644
1644
* Returns an Oracle error number
1645
1645
*/
1646
- sb4 php_oci_error (OCIError * err_p , sword status TSRMLS_DC )
1646
+ sb4 php_oci_error (OCIError * err_p , sword errstatus TSRMLS_DC )
1647
1647
{
1648
1648
text * errbuf = (text * )NULL ;
1649
- sb4 errcode = 0 ;
1649
+ sb4 errcode = 0 ; /* Oracle error number */
1650
1650
1651
- switch (status ) {
1651
+ switch (errstatus ) {
1652
1652
case OCI_SUCCESS :
1653
1653
break ;
1654
1654
case OCI_SUCCESS_WITH_INFO :
@@ -1691,13 +1691,13 @@ sb4 php_oci_error(OCIError *err_p, sword status TSRMLS_DC)
1691
1691
php_error_docref (NULL TSRMLS_CC , E_WARNING , "OCI_CONTINUE ");
1692
1692
break ;
1693
1693
default :
1694
- php_error_docref (NULL TSRMLS_CC , E_WARNING , "Unknown OCI error code: %d" , status );
1694
+ php_error_docref (NULL TSRMLS_CC , E_WARNING , "Unknown OCI error code: %d" , errstatus );
1695
1695
break ;
1696
1696
}
1697
1697
1698
1698
#ifdef HAVE_OCI8_DTRACE
1699
1699
if (DTRACE_OCI8_ERROR_ENABLED ()) {
1700
- DTRACE_OCI8_ERROR (status , errcode );
1700
+ DTRACE_OCI8_ERROR (( int ) errstatus , ( long ) errcode );
1701
1701
}
1702
1702
#endif /* HAVE_OCI8_DTRACE */
1703
1703
@@ -2210,20 +2210,24 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char
2210
2210
*/
2211
2211
static int php_oci_connection_ping (php_oci_connection * connection TSRMLS_DC )
2212
2212
{
2213
+ sword errstatus ;
2214
+
2215
+ OCI_G (errcode ) = 0 ; /* assume ping is successful */
2216
+
2213
2217
/* Use OCIPing instead of OCIServerVersion. If OCIPing returns ORA-1010 (invalid OCI operation)
2214
2218
* such as from Pre-10.1 servers, the error is still from the server and we would have
2215
2219
* successfully performed a roundtrip and validated the connection. Use OCIServerVersion for
2216
2220
* Pre-10.2 clients
2217
2221
*/
2218
2222
#if ((OCI_MAJOR_VERSION > 10 ) || ((OCI_MAJOR_VERSION == 10 ) && (OCI_MINOR_VERSION >= 2 ))) /* OCIPing available 10.2 onwards */
2219
- PHP_OCI_CALL_RETURN (OCI_G ( errcode ) , OCIPing , (connection -> svc , OCI_G (err ), OCI_DEFAULT ));
2223
+ PHP_OCI_CALL_RETURN (errstatus , OCIPing , (connection -> svc , OCI_G (err ), OCI_DEFAULT ));
2220
2224
#else
2221
2225
char version [256 ];
2222
2226
/* use good old OCIServerVersion() */
2223
- PHP_OCI_CALL_RETURN (OCI_G ( errcode ) , OCIServerVersion , (connection -> svc , OCI_G (err ), (text * )version , sizeof (version ), OCI_HTYPE_SVCCTX ));
2227
+ PHP_OCI_CALL_RETURN (errstatus , OCIServerVersion , (connection -> svc , OCI_G (err ), (text * )version , sizeof (version ), OCI_HTYPE_SVCCTX ));
2224
2228
#endif
2225
2229
2226
- if (OCI_G ( errcode ) == OCI_SUCCESS ) {
2230
+ if (errstatus == OCI_SUCCESS ) {
2227
2231
return 1 ;
2228
2232
} else {
2229
2233
sb4 error_code = 0 ;
@@ -2234,10 +2238,9 @@ static int php_oci_connection_ping(php_oci_connection *connection TSRMLS_DC)
2234
2238
if (error_code == 1010 ) {
2235
2239
return 1 ;
2236
2240
}
2241
+ OCI_G (errcode ) = error_code ;
2237
2242
}
2238
2243
2239
- /* ignore errors here, just return failure
2240
- * php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); */
2241
2244
return 0 ;
2242
2245
}
2243
2246
/* }}} */
@@ -2248,17 +2251,17 @@ static int php_oci_connection_ping(php_oci_connection *connection TSRMLS_DC)
2248
2251
*/
2249
2252
static int php_oci_connection_status (php_oci_connection * connection TSRMLS_DC )
2250
2253
{
2251
- ub4 ss = 0 ;
2254
+ ub4 ss = OCI_SERVER_NOT_CONNECTED ;
2255
+ sword errstatus ;
2252
2256
2253
2257
/* get OCI_ATTR_SERVER_STATUS */
2254
- PHP_OCI_CALL_RETURN (OCI_G ( errcode ) , OCIAttrGet , ((dvoid * )connection -> server , OCI_HTYPE_SERVER , (dvoid * )& ss , (ub4 * )0 , OCI_ATTR_SERVER_STATUS , OCI_G (err )));
2258
+ PHP_OCI_CALL_RETURN (errstatus , OCIAttrGet , ((dvoid * )connection -> server , OCI_HTYPE_SERVER , (dvoid * )& ss , (ub4 * )0 , OCI_ATTR_SERVER_STATUS , OCI_G (err )));
2255
2259
2256
- if (OCI_G ( errcode ) == OCI_SUCCESS && ss == OCI_SERVER_NORMAL ) {
2260
+ if (errstatus == OCI_SUCCESS && ss == OCI_SERVER_NORMAL ) {
2257
2261
return 1 ;
2258
2262
}
2259
2263
2260
- /* ignore errors here, just return failure
2261
- * php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); */
2264
+ /* ignore errors here, just return failure */
2262
2265
return 0 ;
2263
2266
}
2264
2267
/* }}} */
@@ -2269,14 +2272,17 @@ static int php_oci_connection_status(php_oci_connection *connection TSRMLS_DC)
2269
2272
*/
2270
2273
int php_oci_connection_rollback (php_oci_connection * connection TSRMLS_DC )
2271
2274
{
2272
- PHP_OCI_CALL_RETURN (connection -> errcode , OCITransRollback , (connection -> svc , connection -> err , (ub4 ) 0 ));
2275
+ sword errstatus ;
2276
+
2277
+ PHP_OCI_CALL_RETURN (errstatus , OCITransRollback , (connection -> svc , connection -> err , (ub4 ) 0 ));
2273
2278
connection -> rb_on_disconnect = 0 ;
2274
2279
2275
- if (connection -> errcode != OCI_SUCCESS ) {
2276
- connection -> errcode = php_oci_error (connection -> err , connection -> errcode TSRMLS_CC );
2280
+ if (errstatus != OCI_SUCCESS ) {
2281
+ connection -> errcode = php_oci_error (connection -> err , errstatus TSRMLS_CC );
2277
2282
PHP_OCI_HANDLE_ERROR (connection , connection -> errcode );
2278
2283
return 1 ;
2279
2284
}
2285
+ connection -> errcode = 0 ; /* retain backwards compat with OCI8 1.4 */
2280
2286
return 0 ;
2281
2287
}
2282
2288
/* }}} */
@@ -2287,14 +2293,17 @@ int php_oci_connection_rollback(php_oci_connection *connection TSRMLS_DC)
2287
2293
*/
2288
2294
int php_oci_connection_commit (php_oci_connection * connection TSRMLS_DC )
2289
2295
{
2290
- PHP_OCI_CALL_RETURN (connection -> errcode , OCITransCommit , (connection -> svc , connection -> err , (ub4 ) 0 ));
2296
+ sword errstatus ;
2297
+
2298
+ PHP_OCI_CALL_RETURN (errstatus , OCITransCommit , (connection -> svc , connection -> err , (ub4 ) 0 ));
2291
2299
connection -> rb_on_disconnect = 0 ;
2292
2300
2293
- if (connection -> errcode != OCI_SUCCESS ) {
2294
- connection -> errcode = php_oci_error (connection -> err , connection -> errcode TSRMLS_CC );
2301
+ if (errstatus != OCI_SUCCESS ) {
2302
+ connection -> errcode = php_oci_error (connection -> err , errstatus TSRMLS_CC );
2295
2303
PHP_OCI_HANDLE_ERROR (connection , connection -> errcode );
2296
2304
return 1 ;
2297
2305
}
2306
+ connection -> errcode = 0 ; /* retain backwards compat with OCI8 1.4 */
2298
2307
return 0 ;
2299
2308
}
2300
2309
/* }}} */
@@ -2462,13 +2471,16 @@ int php_oci_connection_release(php_oci_connection *connection TSRMLS_DC)
2462
2471
*/
2463
2472
int php_oci_password_change (php_oci_connection * connection , char * user , int user_len , char * pass_old , int pass_old_len , char * pass_new , int pass_new_len TSRMLS_DC )
2464
2473
{
2465
- PHP_OCI_CALL_RETURN (connection -> errcode , OCIPasswordChange , (connection -> svc , connection -> err , (text * )user , user_len , (text * )pass_old , pass_old_len , (text * )pass_new , pass_new_len , OCI_DEFAULT ));
2474
+ sword errstatus ;
2475
+
2476
+ PHP_OCI_CALL_RETURN (errstatus , OCIPasswordChange , (connection -> svc , connection -> err , (text * )user , user_len , (text * )pass_old , pass_old_len , (text * )pass_new , pass_new_len , OCI_DEFAULT ));
2466
2477
2467
- if (connection -> errcode != OCI_SUCCESS ) {
2468
- connection -> errcode = php_oci_error (connection -> err , connection -> errcode TSRMLS_CC );
2478
+ if (errstatus != OCI_SUCCESS ) {
2479
+ connection -> errcode = php_oci_error (connection -> err , errstatus TSRMLS_CC );
2469
2480
PHP_OCI_HANDLE_ERROR (connection , connection -> errcode );
2470
2481
return 1 ;
2471
2482
}
2483
+ connection -> errcode = 0 ; /* retain backwards compat with OCI8 1.4 */
2472
2484
connection -> passwd_changed = 1 ;
2473
2485
return 0 ;
2474
2486
}
@@ -2503,12 +2515,13 @@ void php_oci_client_get_version(char **version TSRMLS_DC)
2503
2515
*/
2504
2516
int php_oci_server_get_version (php_oci_connection * connection , char * * version TSRMLS_DC )
2505
2517
{
2518
+ sword errstatus ;
2506
2519
char version_buff [256 ];
2507
2520
2508
- PHP_OCI_CALL_RETURN (connection -> errcode , OCIServerVersion , (connection -> svc , connection -> err , (text * )version_buff , sizeof (version_buff ), OCI_HTYPE_SVCCTX ));
2521
+ PHP_OCI_CALL_RETURN (errstatus , OCIServerVersion , (connection -> svc , connection -> err , (text * )version_buff , sizeof (version_buff ), OCI_HTYPE_SVCCTX ));
2509
2522
2510
- if (connection -> errcode != OCI_SUCCESS ) {
2511
- connection -> errcode = php_oci_error (connection -> err , connection -> errcode TSRMLS_CC );
2523
+ if (errstatus != OCI_SUCCESS ) {
2524
+ connection -> errcode = php_oci_error (connection -> err , errstatus TSRMLS_CC );
2512
2525
PHP_OCI_HANDLE_ERROR (connection , connection -> errcode );
2513
2526
return 1 ;
2514
2527
}
@@ -2806,6 +2819,7 @@ static php_oci_spool *php_oci_create_spool(char *username, int username_len, cha
2806
2819
zend_bool iserror = 0 ;
2807
2820
ub4 poolmode = OCI_DEFAULT ; /* Mode to be passed to OCISessionPoolCreate */
2808
2821
OCIAuthInfo * spoolAuth = NULL ;
2822
+ sword errstatus ;
2809
2823
2810
2824
/* Allocate sessionpool out of persistent memory */
2811
2825
session_pool = (php_oci_spool * ) calloc (1 , sizeof (php_oci_spool ));
@@ -2830,10 +2844,10 @@ static php_oci_spool *php_oci_create_spool(char *username, int username_len, cha
2830
2844
}
2831
2845
2832
2846
/* Allocate the pool handle */
2833
- PHP_OCI_CALL_RETURN (OCI_G ( errcode ) , OCIHandleAlloc , (session_pool -> env , (dvoid * * ) & session_pool -> poolh , OCI_HTYPE_SPOOL , (size_t ) 0 , (dvoid * * ) 0 ));
2847
+ PHP_OCI_CALL_RETURN (errstatus , OCIHandleAlloc , (session_pool -> env , (dvoid * * ) & session_pool -> poolh , OCI_HTYPE_SPOOL , (size_t ) 0 , (dvoid * * ) 0 ));
2834
2848
2835
- if (OCI_G ( errcode ) != OCI_SUCCESS ) {
2836
- php_oci_error (OCI_G (err ), OCI_G ( errcode ) TSRMLS_CC );
2849
+ if (errstatus != OCI_SUCCESS ) {
2850
+ OCI_G ( errcode ) = php_oci_error (OCI_G (err ), errstatus TSRMLS_CC );
2837
2851
iserror = 1 ;
2838
2852
goto exit_create_spool ;
2839
2853
}
@@ -2842,10 +2856,10 @@ static php_oci_spool *php_oci_create_spool(char *username, int username_len, cha
2842
2856
* generic bug which can free up the OCI_G(err) variable before destroying connections. We
2843
2857
* cannot use this for other roundtrip calls as there is no way the user can access this error
2844
2858
*/
2845
- PHP_OCI_CALL_RETURN (OCI_G ( errcode ) , OCIHandleAlloc , ((dvoid * ) session_pool -> env , (dvoid * * )& (session_pool -> err ), (ub4 ) OCI_HTYPE_ERROR ,(size_t ) 0 , (dvoid * * ) 0 ));
2859
+ PHP_OCI_CALL_RETURN (errstatus , OCIHandleAlloc , ((dvoid * ) session_pool -> env , (dvoid * * )& (session_pool -> err ), (ub4 ) OCI_HTYPE_ERROR ,(size_t ) 0 , (dvoid * * ) 0 ));
2846
2860
2847
- if (OCI_G ( errcode ) != OCI_SUCCESS ) {
2848
- php_oci_error (OCI_G (err ), OCI_G ( errcode ) TSRMLS_CC );
2861
+ if (errstatus != OCI_SUCCESS ) {
2862
+ OCI_G ( errcode ) = php_oci_error (OCI_G (err ), errstatus TSRMLS_CC );
2849
2863
iserror = 1 ;
2850
2864
goto exit_create_spool ;
2851
2865
}
@@ -2859,42 +2873,42 @@ static php_oci_spool *php_oci_create_spool(char *username, int username_len, cha
2859
2873
2860
2874
#if ((OCI_MAJOR_VERSION > 11 ) || ((OCI_MAJOR_VERSION == 11 ) && (OCI_MINOR_VERSION >= 2 )))
2861
2875
/* {{{ Allocate auth handle for session pool */
2862
- PHP_OCI_CALL_RETURN (OCI_G ( errcode ) , OCIHandleAlloc , (session_pool -> env , (dvoid * * )& (spoolAuth ), OCI_HTYPE_AUTHINFO , 0 , NULL ));
2876
+ PHP_OCI_CALL_RETURN (errstatus , OCIHandleAlloc , (session_pool -> env , (dvoid * * )& (spoolAuth ), OCI_HTYPE_AUTHINFO , 0 , NULL ));
2863
2877
2864
- if (OCI_G ( errcode ) != OCI_SUCCESS ) {
2865
- php_oci_error (OCI_G (err ), OCI_G ( errcode ) TSRMLS_CC );
2878
+ if (errstatus != OCI_SUCCESS ) {
2879
+ OCI_G ( errcode ) = php_oci_error (OCI_G (err ), errstatus TSRMLS_CC );
2866
2880
iserror = 1 ;
2867
2881
goto exit_create_spool ;
2868
2882
}
2869
2883
/* }}} */
2870
2884
2871
2885
/* {{{ Set the edition attribute on the auth handle */
2872
2886
if (OCI_G (edition )) {
2873
- PHP_OCI_CALL_RETURN (OCI_G ( errcode ), OCIAttrSet , ((dvoid * ) spoolAuth , (ub4 ) OCI_HTYPE_AUTHINFO , (dvoid * ) OCI_G (edition ), (ub4 )(strlen (OCI_G (edition ))), (ub4 )OCI_ATTR_EDITION , OCI_G (err )));
2887
+ PHP_OCI_CALL_RETURN (errstatus , OCIAttrSet , ((dvoid * ) spoolAuth , (ub4 ) OCI_HTYPE_AUTHINFO , (dvoid * ) OCI_G (edition ), (ub4 )(strlen (OCI_G (edition ))), (ub4 )OCI_ATTR_EDITION , OCI_G (err )));
2874
2888
2875
- if (OCI_G ( errcode ) != OCI_SUCCESS ) {
2876
- php_oci_error (OCI_G (err ), OCI_G ( errcode ) TSRMLS_CC );
2889
+ if (errstatus != OCI_SUCCESS ) {
2890
+ OCI_G ( errcode ) = php_oci_error (OCI_G (err ), errstatus TSRMLS_CC );
2877
2891
iserror = 1 ;
2878
2892
goto exit_create_spool ;
2879
2893
}
2880
2894
}
2881
2895
/* }}} */
2882
2896
2883
2897
/* {{{ Set the driver name attribute on the auth handle */
2884
- PHP_OCI_CALL_RETURN (OCI_G ( errcode ) , OCIAttrSet , ((dvoid * ) spoolAuth , (ub4 ) OCI_HTYPE_AUTHINFO , (dvoid * ) PHP_OCI8_DRIVER_NAME , (ub4 ) sizeof (PHP_OCI8_DRIVER_NAME )- 1 , (ub4 ) OCI_ATTR_DRIVER_NAME , OCI_G (err )));
2898
+ PHP_OCI_CALL_RETURN (errstatus , OCIAttrSet , ((dvoid * ) spoolAuth , (ub4 ) OCI_HTYPE_AUTHINFO , (dvoid * ) PHP_OCI8_DRIVER_NAME , (ub4 ) sizeof (PHP_OCI8_DRIVER_NAME )- 1 , (ub4 ) OCI_ATTR_DRIVER_NAME , OCI_G (err )));
2885
2899
2886
- if (OCI_G ( errcode ) != OCI_SUCCESS ) {
2887
- php_oci_error (OCI_G (err ), OCI_G ( errcode ) TSRMLS_CC );
2900
+ if (errstatus != OCI_SUCCESS ) {
2901
+ OCI_G ( errcode ) = php_oci_error (OCI_G (err ), errstatus TSRMLS_CC );
2888
2902
iserror = 1 ;
2889
2903
goto exit_create_spool ;
2890
2904
}
2891
2905
/* }}} */
2892
2906
2893
2907
/* {{{ Set the auth handle on the session pool */
2894
- PHP_OCI_CALL_RETURN (OCI_G ( errcode ), OCIAttrSet , ((dvoid * ) (session_pool -> poolh ),(ub4 ) OCI_HTYPE_SPOOL , (dvoid * ) spoolAuth , (ub4 )0 , (ub4 )OCI_ATTR_SPOOL_AUTH , OCI_G (err )));
2908
+ PHP_OCI_CALL_RETURN (errstatus , OCIAttrSet , ((dvoid * ) (session_pool -> poolh ),(ub4 ) OCI_HTYPE_SPOOL , (dvoid * ) spoolAuth , (ub4 )0 , (ub4 )OCI_ATTR_SPOOL_AUTH , OCI_G (err )));
2895
2909
2896
- if (OCI_G ( errcode ) != OCI_SUCCESS ) {
2897
- php_oci_error (OCI_G (err ), OCI_G ( errcode ) TSRMLS_CC );
2910
+ if (errstatus != OCI_SUCCESS ) {
2911
+ OCI_G ( errcode ) = php_oci_error (OCI_G (err ), errstatus TSRMLS_CC );
2898
2912
iserror = 1 ;
2899
2913
goto exit_create_spool ;
2900
2914
}
@@ -2904,10 +2918,10 @@ static php_oci_spool *php_oci_create_spool(char *username, int username_len, cha
2904
2918
/* Create the homogeneous session pool - We have different session pools for every different
2905
2919
* username, password, charset and dbname.
2906
2920
*/
2907
- PHP_OCI_CALL_RETURN (OCI_G ( errcode ) , OCISessionPoolCreate ,(session_pool -> env , OCI_G (err ), session_pool -> poolh , (OraText * * )& session_pool -> poolname , & session_pool -> poolname_len , (OraText * )dbname , (ub4 )dbname_len , 0 , UB4MAXVAL , 1 ,(OraText * )username , (ub4 )username_len , (OraText * )password ,(ub4 )password_len , poolmode ));
2921
+ PHP_OCI_CALL_RETURN (errstatus , OCISessionPoolCreate ,(session_pool -> env , OCI_G (err ), session_pool -> poolh , (OraText * * )& session_pool -> poolname , & session_pool -> poolname_len , (OraText * )dbname , (ub4 )dbname_len , 0 , UB4MAXVAL , 1 ,(OraText * )username , (ub4 )username_len , (OraText * )password ,(ub4 )password_len , poolmode ));
2908
2922
2909
- if (OCI_G ( errcode ) != OCI_SUCCESS ) {
2910
- php_oci_error (OCI_G (err ), OCI_G ( errcode ) TSRMLS_CC );
2923
+ if (errstatus != OCI_SUCCESS ) {
2924
+ OCI_G ( errcode ) = php_oci_error (OCI_G (err ), errstatus TSRMLS_CC );
2911
2925
iserror = 1 ;
2912
2926
}
2913
2927
@@ -3477,11 +3491,11 @@ static sword php_oci_ping_init(php_oci_connection *connection, OCIError *errh TS
3477
3491
*
3478
3492
* DTrace output for connections that may have become invalid and marked for reopening
3479
3493
*/
3480
- void php_oci_dtrace_check_connection (php_oci_connection * connection , sword errcode , ub4 serverStatus )
3494
+ void php_oci_dtrace_check_connection (php_oci_connection * connection , sb4 errcode , ub4 serverStatus )
3481
3495
{
3482
3496
#ifdef HAVE_OCI8_DTRACE
3483
3497
if (DTRACE_OCI8_CHECK_CONNECTION_ENABLED ()) {
3484
- DTRACE_OCI8_CHECK_CONNECTION (connection , connection && connection -> is_open ? 1 : 0 , (int )errcode , (unsigned long )serverStatus );
3498
+ DTRACE_OCI8_CHECK_CONNECTION (connection , connection && connection -> is_open ? 1 : 0 , (long )errcode , (unsigned long )serverStatus );
3485
3499
}
3486
3500
#endif /* HAVE_OCI8_DTRACE */
3487
3501
}
0 commit comments