Skip to content

Commit

Permalink
Revert "possible fix for rt 88185 - UTF-8 flag incorrect with multipl…
Browse files Browse the repository at this point in the history
…e connections"

This reverts commit 957f547.
  • Loading branch information
Yanick Champoux committed Apr 23, 2014
1 parent e2fc06b commit 1ef5f5e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 38 deletions.
32 changes: 15 additions & 17 deletions dbdimp.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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.");
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -651,15 +653,15 @@ 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) {
oci_error(dbh, imp_dbh->errhp, status, "OCIAttrGet OCI_ATTR_ENV_CHARSET_ID");
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) {
Expand All @@ -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 ");
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 */

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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];
Expand All @@ -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);
}
Expand Down
6 changes: 3 additions & 3 deletions dbdimp.h
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand All @@ -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 ) )
Expand Down
27 changes: 9 additions & 18 deletions oci8.c
Expand Up @@ -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;
Expand All @@ -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 : "<NULL>", (long)recno,
(eg_status==OCI_SUCCESS) ? "ok" : oci_status_name(eg_status),
Expand All @@ -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);
Expand All @@ -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 */

}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 1ef5f5e

Please sign in to comment.