Home > Archive > Oracle PERL DBD > June 2005 > [svn:dbd-oracle] rev 503 - dbd-oracle/trunk









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author [svn:dbd-oracle] rev 503 - dbd-oracle/trunk
timbo@cvs.perl.org

2005-06-03, 8:27 pm

Author: timbo
Date: Tue Oct 19 14:35:37 2004
New Revision: 503

Modified:
dbd-oracle/trunk/Oracle.xs
dbd-oracle/trunk/dbdimp.h
dbd-oracle/trunk/mkta.pl
dbd-oracle/trunk/oci8.c
Log:
Replace uses of DBD_SET_UTF8_FORM with underlying CSFORM_IMPLIES_UTF8 logic for greater clarity.
Replace uses of UTF8_FIXUP_CSID with:
csid = (SvUTF8(sv) && !CS_IS_UTF8(csid)) ? utf8_csid : CSFORM_IMPLIED_CSID(
csform);
Pass csid to LobWrite/Append functions.


Modified: dbd-oracle/trunk/Oracle.xs
====================
====================
====================
==================
--- dbd-oracle/trunk/Oracle.xs (original)
+++ dbd-oracle/trunk/Oracle.xs Tue Oct 19 14:35:37 2004
@@ -153,14 +153,17 @@
return;
}
#ifdef OCI_ATTR_CHARSET_ID
+ /* Effectively only used so AL32UTF8 works properly */
OCILobCharSetId_log_
stat( imp_dbh->envhp, imp_dbh->errhp, locator, &csid, status );
if (status != OCI_SUCCESS) {
oci_error(dbh, imp_dbh->errhp, status, "OCILobCharSetId");
ST(0) = &sv_undef;
return;
}
- UTF8_FIXUP_CSID( csid ,csform ,"ora_lob_write" );
-#endif
+#endif /* OCI_ATTR_CHARSET_ID */
+ /* if data is utf8 but charset isn't then switch to utf8 csid */
+ csid = (SvUTF8(data) && !CS_IS_UTF8(csid)) ? utf8_csid : CSFORM_IMPLIED_CSID(
csform);
+
OCILobWrite_log_stat
(imp_dbh->svchp, imp_dbh->errhp, locator,
&amtp, (ub4)offset,
bufp, (ub4)data_len, OCI_ONE_PIECE,
@@ -204,19 +207,21 @@
return;
}
#ifdef OCI_ATTR_CHARSET_ID
+ /* Effectively only used so AL32UTF8 works properly */
OCILobCharSetId_log_
stat( imp_dbh->envhp, imp_dbh->errhp, locator, &csid, status );
if (status != OCI_SUCCESS) {
oci_error(dbh, imp_dbh->errhp, status, "OCILobCharSetId");
ST(0) = &sv_undef;
return;
}
- UTF8_FIXUP_CSID( csid ,csform ,"ora_lob_append" );
-#endif
+#endif /* OCI_ATTR_CHARSET_ID */
+ /* if data is utf8 but charset isn't then switch to utf8 csid */
+ csid = (SvUTF8(data) && !CS_IS_UTF8(csid)) ? utf8_csid : CSFORM_IMPLIED_CSID(
csform);
#if !defined(ORA_OCI_8) && defined(OCI_HTYPE_DI
RPATH_FN_CTX) /* Oracle is >= 9.0 */
OCILobWriteAppend_lo
g_stat(imp_dbh->svchp, imp_dbh->errhp, locator,
&amtp, bufp, (ub4)data_len, OCI_ONE_PIECE,
NULL, NULL,
- (ub2)0, csform , status);
+ csid, csform, status);
if (status != OCI_SUCCESS) {
oci_error(dbh, imp_dbh->errhp, status, "OCILobWriteAppend");
ST(0) = &sv_undef;
@@ -238,7 +243,7 @@
&amtp, startp,
bufp, (ub4)data_len, OCI_ONE_PIECE,
NULL, NULL,
- (ub2)0, csform , status);
+ csid, csform , status);
if (status != OCI_SUCCESS) {
oci_error(dbh, imp_dbh->errhp, status, "OCILobWrite");
ST(0) = &sv_undef;
@@ -283,20 +288,10 @@
dest_sv = &sv_undef;
return;
}
-#ifdef OCI_ATTR_CHARSET_ID
- OCILobCharSetId_log_
stat( imp_dbh->envhp, imp_dbh->errhp, locator, &csid, status );
- if (status != OCI_SUCCESS) {
- oci_error(dbh, imp_dbh->errhp, status, "OCILobCharSetId");
- dest_sv = &sv_undef;
- return;
- }
- UTF8_FIXUP_CSID( csid ,csform ,"ora_lob_read" );
-#endif
OCILobRead_log_stat(
imp_dbh->svchp, imp_dbh->errhp, locator,
&amtp, (ub4)offset, /* offset starts at 1 */
bufp, (ub4)bufp_len,
0, 0, (ub2)0, csform, status);
-
if (status != OCI_SUCCESS) {
oci_error(dbh, imp_dbh->errhp, status, "OCILobRead");
dest_sv = &sv_undef;
@@ -304,7 +299,9 @@
else {
SvCUR(dest_sv) = amtp; /* always bytes here */
*SvEND(dest_sv) = '\0';
- DBD_SET_UTF8_FORM(d
est_sv,csform);
+ if (CSFORM_IMPLIES_UTF8
(csform))
+ SvUTF8_on(dest_sv);
+
}
ST(0) = dest_sv;


Modified: dbd-oracle/trunk/dbdimp.h
====================
====================
====================
==================
--- dbd-oracle/trunk/dbdimp.h (original)
+++ dbd-oracle/trunk/dbdimp.h Tue Oct 19 14:35:37 2004
@@ -218,16 +218,12 @@
extern int ora_fetchtest;

#ifdef UTF8_SUPPORT
-extern ub2 utf8_csid;
extern ub2 charsetid;
extern ub2 ncharsetid;
-extern ub2 cs_is_utf8;
+extern ub2 utf8_csid;
extern ub2 al32utf8_csid;
extern ub2 al16utf16_csid;

-int set_utf8(SV *sv); /* defined in oci8.c should I move it to dbdimp.c? */
-
-
#define CS_IS_UTF8( cs ) \
( ( cs == utf8_csid ) || ( cs == al32utf8_csid ) )

@@ -248,12 +244,8 @@
#define CSFORM_IMPLIES_UTF8(
csform) \
CS_IS_UTF8( CSFORM_IMPLIED_CSID(
csform ) )

-#define DBD_SET_UTF8_FORM(sv
,csform) \
- (CSFORM_IMPLIES_UTF8
(csform) ? SvUTF8_on(sv) : 0)
-
#else /* UTF8_SUPPORT */
-#define DBD_SET_UTF8_FORM(sv
,csform) 0
-#define UTF8_FIXUP_CSID(csid
,csform,where) 0
+#define UTF8_FIXUP_CSID(csid
,csform,where)
#endif /* UTF8_SUPPORT */



Modified: dbd-oracle/trunk/mkta.pl
====================
====================
====================
==================
--- dbd-oracle/trunk/mkta.pl (original)
+++ dbd-oracle/trunk/mkta.pl Tue Oct 19 14:35:37 2004
@@ -16,8 +16,10 @@
my @sid = DBI-> data_sources('Oracle
');
s/^dbi:Oracle://i for @sid;

+# set TEST_FILES env var to override which tests are run
my $opt_full = 0;
my $opt_dir = "mkta";
+my $opt_tf = $ENV{TEST_FILES};

my $seq = 0;
my $dbuser = $ENV{ORACLE_USERID} || 'scott/tiger';
@@ -47,10 +49,14 @@
}
mkdir $opt_dir, 0771 unless -d $opt_dir;
print "$sid: testing with @$charsets ...\n";
+
+ system("make") == 0
+ or die "$0 aborted - make failed\n";
system("rm -f $opt_dir/$sid-*-*.log");

for my $ochar (@$charsets) {
for my $nchar (@$charsets) {
+ next if $nchar eq ''; # because empty acts same as ochar
my ($tag, $fh) = start_test($sid, $ochar, $nchar);
$running{$tag} = $fh;
push @run, $tag;
@@ -65,7 +71,7 @@
push @fail, $tag if $?;
delete $running{$tag};
}
- warn "$sid: completed.\n";
+ print "$sid: completed.\n";
print "\n";
}

@@ -76,12 +82,14 @@
local $ENV& #123;DBD_ORACLE_SEQ}
= ++$seq; # unique id for parallel runs
my $tag = join "-", map { $_ || "unset" } ($sid, $ochar, $nchar);
my $fh = gensym();
- open $fh, "make test > $opt_dir/$tag.log 2>&1 && rm $opt_dir/$tag.log |";
+ my @make_opts;
+ push @make_opts, " TEST_FILES='$opt_tf'
" if $opt_tf;
+ open $fh, "make test @make_opts > $opt_dir/$tag.log 2>&1 && rm $opt_dir/$tag.log |";
return ($tag, $fh);
}


-warn "Skipped due to $_: @{ $skipped{$_} }\n" for keys %skipped;
-
-warn "Failed: @fail\n" if @fail;
+print "Skipped due to $_: @{ $skipped{$_} }\n" for keys %skipped;

+print "Failed: @fail\n" if @fail;
+print "done.\n"

Modified: dbd-oracle/trunk/oci8.c
====================
====================
====================
==================
--- dbd-oracle/trunk/oci8.c (original)
+++ dbd-oracle/trunk/oci8.c Tue Oct 19 14:35:37 2004
@@ -549,7 +549,8 @@
}
}
sv_setpvn(dest_sv, p, (STRLEN)datalen);
- DBD_SET_UTF8_FORM(d
est_sv,fbh->csform);
+ if (CSFORM_IMPLIES_UTF8
(fbh->csform))
+ SvUTF8_on(dest_sv);
} else {
#else
{
@@ -733,8 +734,8 @@
SvCUR_set(dest_sv, byte_destoffset+amtp
);
*SvEND(dest_sv) = '\0'; /* consistent with perl sv_setpvn etc */
SvPOK_on(dest_sv);
- if (ftype == 112)
- DBD_SET_UTF8_FORM(d
est_sv,csform);
+ if (ftype == 112 && CSFORM_IMPLIES_UTF8(
csform))
+ SvUTF8_on(dest_sv)
;

return 1;
}
@@ -757,6 +758,8 @@
typename = "CLOB";
else if (ftype == 113)
typename = "BLOB";
+ else if (ftype == 114)
+ typename = "BFILE";
else {
oci_error(sth, imp_sth->errhp, OCI_ERROR,
"blob_read not currently supported for non-LOB types with OCI 8 "
@@ -839,8 +842,8 @@
sv_set_undef(dest_sv
); /* signal error */
return 0;
}
- if (ftype == 112)
- DBD_SET_UTF8_FORM(de
st_sv,csform);
+ if (ftype == 112 && CSFORM_IMPLIES_UTF8(
csform))
+ SvUTF8_on(dest_sv);
}
else {
assert(amtp == 0);
@@ -935,22 +938,12 @@

if (loblen > 0) {
ub1 csform = 0;
- ub2 csid = 0;
OCILobCharSetForm_lo
g_stat(imp_sth->envhp, imp_sth->errhp, lobloc, &csform, status );
if (status != OCI_SUCCESS) {
oci_error(sth, imp_sth->errhp, status, "OCILobCharSetForm");
sv_set_undef(dest_sv
);
return 0;
}
-#ifdef OCI_ATTR_CHARSET_ID
- OCILobCharSetId_log
_stat(imp_sth->envhp, imp_sth->errhp, lobloc, &csid, status );
- if (status != OCI_SUCCESS) {
- oci_error(sth, imp_sth->errhp, status, "OCILobCharSetId");
- sv_set_undef(dest_sv
);
- return 0;
- }
- UTF8_FIXUP_CSID( csid ,csform ,"fetch_func_auto_lob" );
-#endif /* OCI_ATTR_CHARSET_ID */

if (fbh->dbtype == 114) {
OCILobFileOpen_log_s
tat(imp_sth->svchp, imp_sth->errhp, lobloc,
@@ -984,8 +977,8 @@
/* tell perl what we've put in its dest_sv */
SvCUR(dest_sv) = amtp;
*SvEND(dest_sv) = '\0';
- if (fbh->ftype != 113) /* Don't set UTF8 on BLOBs */
- DBD_SET_UTF8_FORM(de
st_sv,csform);
+ if (fbh->ftype == 112 && CSFORM_IMPLIES_UTF8(
csform)) /* Don't set UTF8 on BLOBs */
+ SvUTF8_on(dest_sv);
ora_free_templob(sth
, imp_sth, lobloc);
}
else { /* LOB length is 0 */
@@ -1448,7 +1441,8 @@
--datalen;
}
sv_setpvn(sv, p, (STRLEN)datalen);
- DBD_SET_UTF8_FORM(
sv, fbh->csform); /* XXX */
+ if (CSFORM_IMPLIES_UTF8
(fbh->csform))
+ SvUTF8_on(sv);
}

} else if (rc == 1405) { /* field is null - return undef */
@@ -1464,7 +1458,8 @@
/* but it'll only be accessible via prior bind_column() */
sv_setpvn(sv, (char*)&fb_ary->abuf[0],
fb_ary->arlen[0]);
- DBD_SET_UTF8_FORM(sv
,fbh->csform);
+ if (CSFORM_IMPLIES_UTF8
(fbh->csform))
+ SvUTF8_on(sv);
}
if (ora_dbtype_is_long(
fbh->dbtype)) /* double check */
hint = ", LongReadLen too small and/or LongTruncOk not set";
@@ -1736,7 +1731,8 @@
lob_cols_hv = newHV();
sv = newSViv(col_dbtype);

(void)sv_setpvn(sv, col_name, col_name_len);
- DBD_SET_UTF8_FORM(s
v, SQLCS_IMPLICIT);
+ if (CSFORM_IMPLIES_UTF8
(SQLCS_IMPLICIT))
+ SvUTF8_on(sv);
(void)SvIOK_on(sv); /* "what a wonderful hack!" */
hv_store(lob_cols_hv
, col_name,col_name_le
n, sv,0);
OCIDescriptorFree(co
lhd, OCI_DTYPE_PARAM);
@@ -1949,8 +1945,6 @@
imp_fbh_t *fbh = &lr->fbh_ary[i];
int rc = fbh->fb_ary->arcode[0];
phs_t *phs = (phs_t*)fbh->special;
- ub1 csform = 0;
- ub2 csid = SQLCS_IMPLICIT;
ub4 amtp;

SvUPGRADE(phs->sv, SVt_PV); /* just in case */
@@ -1961,22 +1955,20 @@
}
else if (amtp > 0) { /* since amtp==0 & OCI_ONE_PIECE fail (OCI 8.0.4) */
if( ! fbh->csid ) {
+ ub1 csform = SQLCS_IMPLICIT;
+ ub2 csid = 0;
OCILobCharSetForm_lo
g_stat( imp_sth->envhp, errhp, (OCILobLocator*)fbh->desc_h, &csform, status );
- if (status != OCI_SUCCESS) {
+ if (status != OCI_SUCCESS)
return oci_error(sth, errhp, status, "OCILobCharSetForm");
- }
#ifdef OCI_ATTR_CHARSET_ID
+ /* Effectively only used so AL32UTF8 works properly */
OCILobCharSetId_log_
stat( imp_sth->envhp, errhp, (OCILobLocator*)fbh->desc_h, &csid, status );
- if (status != OCI_SUCCESS) {
+ if (status != OCI_SUCCESS)
return oci_error(sth, errhp, status, "OCILobCharSetId");
- }
- /* if data is utf8 but charset isn't then switch to utf8 csid */
- if (SvUTF8(phs->sv) && !CS_IS_UTF8(csid))
- csid = utf8_csid; /* not al32utf8_csid here on purpose */
- UTF8_FIXUP_CSID( csid, csform, "post_execute_lobs" );
#endif /* OCI_ATTR_CHARSET_ID */
-
- fbh->csid = csid; /* for information only */
+ /* if data is utf8 but charset isn't then switch to utf8 csid */
+ csid = (SvUTF8(phs->sv) && !CS_IS_UTF8(csid)) ? utf8_csid : CSFORM_IMPLIED_CSID(
csform);
+ fbh->csid = csid;
fbh->csform = csform;
}

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com