From 1ef5f5e9aba4b9014ae3e9bbfec23edff082ecea Mon Sep 17 00:00:00 2001 From: Yanick Champoux Date: Wed, 23 Apr 2014 10:00:52 -0400 Subject: [PATCH] Revert "possible fix for rt 88185 - UTF-8 flag incorrect with multiple connections" This reverts commit 957f54750ba8c1972beabd1dcd305bd6c47c4586. --- dbdimp.c | 32 +++++++++++++++----------------- dbdimp.h | 6 +++--- oci8.c | 27 +++++++++------------------ 3 files changed, 27 insertions(+), 38 deletions(-) diff --git a/dbdimp.c b/dbdimp.c index ed07eaed..3f8ab82d 100644 --- a/dbdimp.c +++ b/dbdimp.c @@ -44,6 +44,8 @@ int ora_ncs_buff_mtpl = 4; /* a mulitplyer for ncs clob buffers */ #define ARRAY_BIND_MIXED (ARRAY_BIND_NATIVE|ARRAY_BIND_UTF8) +ub2 charsetid = 0; +ub2 ncharsetid = 0; ub2 us7ascii_csid = 1; ub2 utf8_csid = 871; ub2 al32utf8_csid = 873; @@ -546,14 +548,14 @@ dbd_db_login6(SV *dbh, imp_dbh_t *imp_dbh, char *dbname, char *uid, char *pwd, S { size_t rsize = 0; /* Get CLIENT char and nchar charset id values */ - OCINlsEnvironmentVariableGet_log_stat(imp_dbh, &imp_dbh->charsetid,(size_t) 0, OCI_NLS_CHARSET_ID, 0, &rsize ,status ); + OCINlsEnvironmentVariableGet_log_stat(imp_dbh, &charsetid,(size_t) 0, OCI_NLS_CHARSET_ID, 0, &rsize ,status ); if (status != OCI_SUCCESS) { oci_error(dbh, NULL, status, "OCINlsEnvironmentVariableGet(OCI_NLS_CHARSET_ID) Check NLS settings etc."); return 0; } - OCINlsEnvironmentVariableGet_log_stat(imp_dbh, &imp_dbh->ncharsetid,(size_t) 0, OCI_NLS_NCHARSET_ID, 0, &rsize ,status ); + OCINlsEnvironmentVariableGet_log_stat(imp_dbh, &ncharsetid,(size_t) 0, OCI_NLS_NCHARSET_ID, 0, &rsize ,status ); if (status != OCI_SUCCESS) { oci_error(dbh, NULL, status, "OCINlsEnvironmentVariableGet(OCI_NLS_NCHARSET_ID) Check NLS settings etc."); @@ -581,7 +583,7 @@ dbd_db_login6(SV *dbh, imp_dbh_t *imp_dbh, char *dbname, char *uid, char *pwd, S }*/ OCIEnvNlsCreate_log_stat(imp_dbh, &imp_dbh->envhp, init_mode, 0, NULL, NULL, NULL, 0, 0, - imp_dbh->charsetid, imp_dbh->ncharsetid, status ); + charsetid, ncharsetid, status ); if (status != OCI_SUCCESS) { oci_error(dbh, NULL, status, @@ -618,11 +620,11 @@ dbd_db_login6(SV *dbh, imp_dbh_t *imp_dbh, char *dbname, char *uid, char *pwd, S } if (new_charsetid || new_ncharsetid) { /* reset the ENV with the new charset from above*/ - if (new_charsetid) imp_dbh->charsetid = new_charsetid; - if (new_ncharsetid) imp_dbh->ncharsetid = new_ncharsetid; + if (new_charsetid) charsetid = new_charsetid; + if (new_ncharsetid) ncharsetid = new_ncharsetid; imp_dbh->envhp = NULL; OCIEnvNlsCreate_log_stat(imp_dbh, &imp_dbh->envhp, init_mode, 0, NULL, NULL, NULL, 0, 0, - imp_dbh->charsetid, imp_dbh->ncharsetid, status ); + charsetid, ncharsetid, status ); if (status != OCI_SUCCESS) { oci_error(dbh, NULL, status, "OCIEnvNlsCreate. Check ORACLE_HOME (Linux) env var or PATH (Windows) and or NLS settings, permissions, etc"); @@ -651,7 +653,7 @@ dbd_db_login6(SV *dbh, imp_dbh_t *imp_dbh, char *dbname, char *uid, char *pwd, S } OCIHandleAlloc_ok(imp_dbh, imp_dbh->envhp, &imp_dbh->errhp, OCI_HTYPE_ERROR, status); - OCIAttrGet_log_stat(imp_dbh, imp_dbh->envhp, OCI_HTYPE_ENV, &imp_dbh->charsetid, (ub4)0 , + OCIAttrGet_log_stat(imp_dbh, imp_dbh->envhp, OCI_HTYPE_ENV, &charsetid, (ub4)0 , OCI_ATTR_ENV_CHARSET_ID, imp_dbh->errhp, status); if (status != OCI_SUCCESS) { @@ -659,7 +661,7 @@ dbd_db_login6(SV *dbh, imp_dbh_t *imp_dbh, char *dbname, char *uid, char *pwd, S return 0; } - OCIAttrGet_log_stat(imp_dbh, imp_dbh->envhp, OCI_HTYPE_ENV, &imp_dbh->ncharsetid, (ub4)0 , + OCIAttrGet_log_stat(imp_dbh, imp_dbh->envhp, OCI_HTYPE_ENV, &ncharsetid, (ub4)0 , OCI_ATTR_ENV_NCHARSET_ID, imp_dbh->errhp, status); if (status != OCI_SUCCESS) { @@ -676,13 +678,13 @@ dbd_db_login6(SV *dbh, imp_dbh_t *imp_dbh, char *dbname, char *uid, char *pwd, S if (DBIc_DBISTATE(imp_dbh)->debug >= 3 || dbd_verbose >= 3 ) { oratext charsetname[OCI_NLS_MAXBUFSZ]; oratext ncharsetname[OCI_NLS_MAXBUFSZ]; - OCINlsCharSetIdToName(imp_dbh->envhp,charsetname, sizeof(charsetname),imp_dbh->charsetid ); - OCINlsCharSetIdToName(imp_dbh->envhp,ncharsetname, sizeof(ncharsetname),imp_dbh->ncharsetid ); + OCINlsCharSetIdToName(imp_dbh->envhp,charsetname, sizeof(charsetname),charsetid ); + OCINlsCharSetIdToName(imp_dbh->envhp,ncharsetname, sizeof(ncharsetname),ncharsetid ); PerlIO_printf( DBIc_LOGPIO(imp_dbh), " charset id=%d, name=%s, ncharset id=%d, name=%s" " (csid: utf8=%d al32utf8=%d)\n", - imp_dbh->charsetid,charsetname, imp_dbh->ncharsetid,ncharsetname, utf8_csid, al32utf8_csid); + charsetid,charsetname, ncharsetid,ncharsetname, utf8_csid, al32utf8_csid); #ifdef ORA_OCI_112 if (imp_dbh->using_drcp) PerlIO_printf(DBIc_LOGPIO(imp_dbh)," Using DRCP Connection\n "); @@ -1649,7 +1651,7 @@ int dbd_rebind_ph_varchar2_table(SV *sth, imp_sth_t *imp_sth, phs_t *phs) { dTHX; - D_imp_dbh_from_sth; + /*D_imp_dbh_from_sth ;*/ sword status; int trace_level = DBIc_DBISTATE(imp_sth)->debug; AV *arr; @@ -2931,7 +2933,6 @@ static int dbd_rebind_ph(SV *sth, imp_sth_t *imp_sth, phs_t *phs) { dTHX; - D_imp_dbh_from_sth; /*ub2 *alen_ptr = NULL;*/ sword status; int done = 0; @@ -3301,7 +3302,6 @@ void dbd_phs_sv_complete(imp_sth_t *imp_sth, phs_t *phs, SV *sv, I32 debug) { dTHX; - D_imp_dbh_from_sth; char *note = ""; /* XXX doesn't check arcode for error, caller is expected to */ @@ -3595,7 +3595,6 @@ do_bind_array_exec(sth, imp_sth, phs,utf8,parma_index,tuples_utf8_av,tuples_stat int parma_index; { dTHX; - D_imp_dbh_from_sth; sword status; ub1 csform; ub2 csid; @@ -4018,7 +4017,6 @@ int dbd_st_blob_read(SV *sth, imp_sth_t *imp_sth, int field, long offset, long len, SV *destrv, long destoffset) { dTHX; - D_imp_dbh_from_sth; ub4 retl = 0; SV *bufsv; imp_fbh_t *fbh = &imp_sth->fbh[field]; @@ -4028,7 +4026,7 @@ dbd_st_blob_read(SV *sth, imp_sth_t *imp_sth, int field, long offset, long len, sv_setpvn(bufsv,"",0); /* ensure it's writable string */ #ifdef UTF8_SUPPORT - if (ftype == 112 && CS_IS_UTF8(imp_dbh->ncharsetid) ) { + if (ftype == 112 && CS_IS_UTF8(ncharsetid) ) { return ora_blob_read_mb_piece(sth, imp_sth, fbh, bufsv, offset, len, destoffset); } diff --git a/dbdimp.h b/dbdimp.h index e5371f76..b7eb3705 100644 --- a/dbdimp.h +++ b/dbdimp.h @@ -74,8 +74,6 @@ struct imp_dbh_st { int max_nested_cursors; /* limit on cached nested cursors per stmt */ int array_chunk_size; /* the max size for an array bind */ ub4 server_version; /* version of Oracle server */ - ub2 charsetid; - ub2 ncharsetid; }; #define DBH_DUP_OFF sizeof(dbih_dbc_t) @@ -293,6 +291,8 @@ extern int dbd_verbose; extern int oci_warn; extern int ora_objects; extern int ora_ncs_buff_mtpl; +extern ub2 charsetid; +extern ub2 ncharsetid; extern ub2 us7ascii_csid; extern ub2 utf8_csid; extern ub2 al32utf8_csid; @@ -308,7 +308,7 @@ extern ub2 al16utf16_csid; #define CSFORM_IMPLIED_CSID(csform) \ - ((csform==SQLCS_NCHAR) ? imp_dbh->ncharsetid : imp_dbh->charsetid) + ((csform==SQLCS_NCHAR) ? ncharsetid : charsetid) #define CSFORM_IMPLIES_UTF8(csform) \ CS_IS_UTF8( CSFORM_IMPLIED_CSID( csform ) ) diff --git a/oci8.c b/oci8.c index 74fe94d7..46a69e8e 100644 --- a/oci8.c +++ b/oci8.c @@ -815,7 +815,7 @@ oci_fetch_options(ub4 fetchtype) static sb4 -oci_error_get(imp_sth_t *imp_sth, +oci_error_get(imp_xxh_t *imp_xxh, OCIError *errhp, sword status, char *what, SV *errstr, int debug) { dTHX; @@ -838,12 +838,12 @@ oci_error_get(imp_sth_t *imp_sth, } while( ++recno - && OCIErrorGet_log_stat(imp_sth, errhp, recno, (text*)NULL, &eg_errcode, errbuf, + && OCIErrorGet_log_stat(imp_xxh, errhp, recno, (text*)NULL, &eg_errcode, errbuf, (ub4)sizeof(errbuf), OCI_HTYPE_ERROR, eg_status) != OCI_NO_DATA && eg_status != OCI_INVALID_HANDLE && recno < 100) { if (debug >= 4 || recno>1/*XXX temp*/) - PerlIO_printf(DBIc_LOGPIO(imp_sth), + PerlIO_printf(DBIc_LOGPIO(imp_xxh), " OCIErrorGet after %s (er%ld:%s): %d, %ld: %s\n", what ? what : "", (long)recno, (eg_status==OCI_SUCCESS) ? "ok" : oci_status_name(eg_status), @@ -870,18 +870,16 @@ oci_error_get(imp_sth_t *imp_sth, int -oci_error_err(SV *sth, OCIError *errhp, sword status, char *what, sb4 force_err) +oci_error_err(SV *h, OCIError *errhp, sword status, char *what, sb4 force_err) { dTHX; - D_imp_sth(sth); - D_imp_dbh_from_sth; - + D_imp_xxh(h); sb4 errcode; SV *errstr_sv = sv_newmortal(); SV *errcode_sv = sv_newmortal(); - errcode = oci_error_get(imp_sth, errhp, status, what, errstr_sv, - DBIc_DBISTATE(imp_sth)->debug); + errcode = oci_error_get(imp_xxh, errhp, status, what, errstr_sv, + DBIc_DBISTATE(imp_xxh)->debug); if (CSFORM_IMPLIES_UTF8(SQLCS_IMPLICIT)) { #ifdef sv_utf8_decode sv_utf8_decode(errstr_sv); @@ -900,7 +898,7 @@ oci_error_err(SV *sth, OCIError *errhp, sword status, char *what, sb4 force_err) errcode = (status != 0) ? status : -10000; sv_setiv(errcode_sv, errcode); - DBIh_SET_ERR_SV(sth, (imp_xxh_t *)imp_sth, errcode_sv, errstr_sv, &PL_sv_undef, &PL_sv_undef); + DBIh_SET_ERR_SV(h, imp_xxh, errcode_sv, errstr_sv, &PL_sv_undef, &PL_sv_undef); return 0; /* always returns 0 */ } @@ -1747,7 +1745,6 @@ ora_blob_read_mb_piece(SV *sth, imp_sth_t *imp_sth, imp_fbh_t *fbh, SV *dest_sv, long offset, ub4 len, long destoffset) { dTHX; - D_imp_dbh_from_sth; ub4 loblen = 0; ub4 buflen; ub4 amtp = 0; @@ -1864,7 +1861,6 @@ ora_blob_read_piece(SV *sth, imp_sth_t *imp_sth, imp_fbh_t *fbh, SV *dest_sv, long offset, UV len, long destoffset) { dTHX; - D_imp_dbh_from_sth; ub4 loblen = 0; ub4 buflen; ub4 amtp = 0; @@ -2003,9 +1999,7 @@ static int fetch_lob(SV *sth, imp_sth_t *imp_sth, OCILobLocator* lobloc, int ftype, SV *dest_sv, char *name) { dTHX; - D_imp_dbh_from_sth; - - ub4 loblen = 0; + ub4 loblen = 0; ub4 buflen = 0; ub4 amtp = 0; sword status; @@ -2728,7 +2722,6 @@ fetch_clbk_lob(SV *sth, imp_fbh_t *fbh,SV *dest_sv){ dTHX; D_imp_sth(sth); - D_imp_dbh_from_sth; fb_ary_t *fb_ary = fbh->fb_ary; ub4 actual_bufl=imp_sth->piece_size*(fb_ary->piece_count)+fb_ary->bufl; @@ -2772,7 +2765,6 @@ fetch_get_piece(SV *sth, imp_fbh_t *fbh,SV *dest_sv) { dTHX; D_imp_sth(sth); - D_imp_dbh_from_sth; fb_ary_t *fb_ary = fbh->fb_ary; ub4 buflen = fb_ary->bufl; ub4 actual_bufl = 0; @@ -4412,7 +4404,6 @@ static int init_lob_refetch(SV *sth, imp_sth_t *imp_sth) { dTHX; - D_imp_dbh_from_sth; SV *sv; SV *sql_select; HV *lob_cols_hv = NULL;