Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'rt88185'

  • Loading branch information...
commit 5a8e357a3d81c416a48616941a8b3eafe249c82d 2 parents 5badfc7 + 84f356d
Yanick Champoux yanick authored
Showing with 40 additions and 27 deletions.
  1. +2 −0  Changes
  2. +17 −15 dbdimp.c
  3. +3 −3 dbdimp.h
  4. +18 −9 oci8.c
2  Changes
View
@@ -4,6 +4,8 @@ Revision history for DBD::Oracle
- Recognizes __CYGWIN64__. (RT88709, reported by Witold Petriczek)
- CHOOSE hint is deprecated. (RT91217, reported by Andy Bucksch,
fix by Martin J Evans)
+ - Set UTF8 flag per-connection. (RT88185, reported by Heinrich Mislik, patch by Martin
+ J. Evans)
1.70 2014-02-12
- promote 1.69_02 to stable.
32 dbdimp.c
View
@@ -44,8 +44,6 @@ 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;
@@ -548,14 +546,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, &charsetid,(size_t) 0, OCI_NLS_CHARSET_ID, 0, &rsize ,status );
+ OCINlsEnvironmentVariableGet_log_stat(imp_dbh, &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, &ncharsetid,(size_t) 0, OCI_NLS_NCHARSET_ID, 0, &rsize ,status );
+ OCINlsEnvironmentVariableGet_log_stat(imp_dbh, &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.");
@@ -583,7 +581,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,
- charsetid, ncharsetid, status );
+ imp_dbh->charsetid, imp_dbh->ncharsetid, status );
if (status != OCI_SUCCESS) {
oci_error(dbh, NULL, status,
@@ -620,11 +618,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) charsetid = new_charsetid;
- if (new_ncharsetid) ncharsetid = new_ncharsetid;
+ if (new_charsetid) imp_dbh->charsetid = new_charsetid;
+ if (new_ncharsetid) imp_dbh->ncharsetid = new_ncharsetid;
imp_dbh->envhp = NULL;
OCIEnvNlsCreate_log_stat(imp_dbh, &imp_dbh->envhp, init_mode, 0, NULL, NULL, NULL, 0, 0,
- charsetid, ncharsetid, status );
+ imp_dbh->charsetid, imp_dbh->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");
@@ -653,7 +651,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, &charsetid, (ub4)0 ,
+ OCIAttrGet_log_stat(imp_dbh, imp_dbh->envhp, OCI_HTYPE_ENV, &imp_dbh->charsetid, (ub4)0 ,
OCI_ATTR_ENV_CHARSET_ID, imp_dbh->errhp, status);
if (status != OCI_SUCCESS) {
@@ -661,7 +659,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, &ncharsetid, (ub4)0 ,
+ OCIAttrGet_log_stat(imp_dbh, imp_dbh->envhp, OCI_HTYPE_ENV, &imp_dbh->ncharsetid, (ub4)0 ,
OCI_ATTR_ENV_NCHARSET_ID, imp_dbh->errhp, status);
if (status != OCI_SUCCESS) {
@@ -678,13 +676,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),charsetid );
- OCINlsCharSetIdToName(imp_dbh->envhp,ncharsetname, sizeof(ncharsetname),ncharsetid );
+ OCINlsCharSetIdToName(imp_dbh->envhp,charsetname, sizeof(charsetname),imp_dbh->charsetid );
+ OCINlsCharSetIdToName(imp_dbh->envhp,ncharsetname, sizeof(ncharsetname),imp_dbh->ncharsetid );
PerlIO_printf(
DBIc_LOGPIO(imp_dbh),
" charset id=%d, name=%s, ncharset id=%d, name=%s"
" (csid: utf8=%d al32utf8=%d)\n",
- charsetid,charsetname, ncharsetid,ncharsetname, utf8_csid, al32utf8_csid);
+ imp_dbh->charsetid,charsetname, imp_dbh->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 ");
@@ -1651,7 +1649,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;
@@ -2933,6 +2931,7 @@ 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;
@@ -3302,6 +3301,7 @@ 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,6 +3595,7 @@ 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;
@@ -4017,6 +4018,7 @@ 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];
@@ -4026,7 +4028,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(ncharsetid) ) {
+ if (ftype == 112 && CS_IS_UTF8(imp_dbh->ncharsetid) ) {
return ora_blob_read_mb_piece(sth, imp_sth, fbh, bufsv,
offset, len, destoffset);
}
6 dbdimp.h
View
@@ -74,6 +74,8 @@ 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)
@@ -291,8 +293,6 @@ 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) ? ncharsetid : charsetid)
+ ((csform==SQLCS_NCHAR) ? imp_dbh->ncharsetid : imp_dbh->charsetid)
#define CSFORM_IMPLIES_UTF8(csform) \
CS_IS_UTF8( CSFORM_IMPLIED_CSID( csform ) )
27 oci8.c
View
@@ -815,7 +815,7 @@ oci_fetch_options(ub4 fetchtype)
static sb4
-oci_error_get(imp_xxh_t *imp_xxh,
+oci_error_get(imp_sth_t *imp_sth,
OCIError *errhp, sword status, char *what, SV *errstr, int debug)
{
dTHX;
@@ -838,12 +838,12 @@ oci_error_get(imp_xxh_t *imp_xxh,
}
while( ++recno
- && OCIErrorGet_log_stat(imp_xxh, errhp, recno, (text*)NULL, &eg_errcode, errbuf,
+ && OCIErrorGet_log_stat(imp_sth, 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_xxh),
+ PerlIO_printf(DBIc_LOGPIO(imp_sth),
" 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),
@@ -870,16 +870,18 @@ oci_error_get(imp_xxh_t *imp_xxh,
int
-oci_error_err(SV *h, OCIError *errhp, sword status, char *what, sb4 force_err)
+oci_error_err(SV *sth, OCIError *errhp, sword status, char *what, sb4 force_err)
{
dTHX;
- D_imp_xxh(h);
+ D_imp_sth(sth);
+ D_imp_dbh_from_sth;
+
sb4 errcode;
SV *errstr_sv = sv_newmortal();
SV *errcode_sv = sv_newmortal();
- errcode = oci_error_get(imp_xxh, errhp, status, what, errstr_sv,
- DBIc_DBISTATE(imp_xxh)->debug);
+ errcode = oci_error_get(imp_sth, errhp, status, what, errstr_sv,
+ DBIc_DBISTATE(imp_sth)->debug);
if (CSFORM_IMPLIES_UTF8(SQLCS_IMPLICIT)) {
#ifdef sv_utf8_decode
sv_utf8_decode(errstr_sv);
@@ -898,7 +900,7 @@ oci_error_err(SV *h, OCIError *errhp, sword status, char *what, sb4 force_err)
errcode = (status != 0) ? status : -10000;
sv_setiv(errcode_sv, errcode);
- DBIh_SET_ERR_SV(h, imp_xxh, errcode_sv, errstr_sv, &PL_sv_undef, &PL_sv_undef);
+ DBIh_SET_ERR_SV(sth, (imp_xxh_t *)imp_sth, errcode_sv, errstr_sv, &PL_sv_undef, &PL_sv_undef);
return 0; /* always returns 0 */
}
@@ -1745,6 +1747,7 @@ 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;
@@ -1861,6 +1864,7 @@ 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;
@@ -1999,7 +2003,9 @@ static int
fetch_lob(SV *sth, imp_sth_t *imp_sth, OCILobLocator* lobloc, int ftype, SV *dest_sv, char *name)
{
dTHX;
- ub4 loblen = 0;
+ D_imp_dbh_from_sth;
+
+ ub4 loblen = 0;
ub4 buflen = 0;
ub4 amtp = 0;
sword status;
@@ -2722,6 +2728,7 @@ 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;
@@ -2765,6 +2772,7 @@ 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;
@@ -4404,6 +4412,7 @@ 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;
Please sign in to comment.
Something went wrong with that request. Please try again.