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