Author: byterock
Date: Thu Jul 8 10:54:18 2010
New Revision: 14236
Modified:
dbd-oracle/branches/DRCP_1.25/Oracle.pm
dbd-oracle/branches/DRCP_1.25/dbdimp.c
dbd-oracle/branches/DRCP_1.25/oci8.c
dbd-oracle/branches/DRCP_1.25/t/31lob.t
Log:
Working version ready to be merged back into tunk
Modified: dbd-oracle/branches/DRCP_1.25/Oracle.pm
==============================================================================
--- dbd-oracle/branches/DRCP_1.25/Oracle.pm (original)
+++ dbd-oracle/branches/DRCP_1.25/Oracle.pm Thu Jul 8 10:54:18 2010
@@ -248,27 +248,27 @@
# and populate internal handle data.
- if (exists $ENV{ORA_POOL_CLASS}) {
- $attr->{ora_pool_class} = $ENV{ORA_POOL_CLASS}
+ if (exists $ENV{ORA_DRCP_CLASS}) {
+ $attr->{ora_drcp_class} = $ENV{ORA_DRCP_CLASS}
}
- if($attr->{ora_pool_class}){
- # if using ora_pool_class it cannot contain more than 1024 bytes
+ if($attr->{ora_drcp_class}){
+ # if using ora_drcp_class it cannot contain more than 1024 bytes
# and cannot contain a *
- if (index($attr->{ora_pool_class},'*') !=-1){
- croak("ora_pool_class cannot contain a '*'!");
+ if (index($attr->{ora_drcp_class},'*') !=-1){
+ Carp::croak("ora_drcp_class cannot contain a '*'!");
}
- if (length($attr->{ora_pool_class}) > 1024){
- croak("ora_pool_class mut be less than 1024 characters!");
+ if (length($attr->{ora_drcp_class}) > 1024){
+ Carp::croak("ora_drcp_class must be less than 1024 characters!");
}
}
- if (exists $ENV{ORA_POOL_MIN}) {
- $attr->{ora_pool_min} = $ENV{ORA_POOL_MIN}
+ if (exists $ENV{ORA_DRCP_MIN}) {
+ $attr->{ora_drcp_min} = $ENV{ORA_DRCP_MIN}
}
- if (exists $ENV{ORA_POOL_MAX}) {
- $attr->{ora_pool_max} = $ENV{ORA_POOL_MAX}
+ if (exists $ENV{ORA_DRCP_MAX}) {
+ $attr->{ora_drcp_max} = $ENV{ORA_DRCP_MAX}
}
- if (exists $ENV{ORA_POOL_INCR}) {
- $attr->{ora_pool_incr} = $ENV{ORA_POOL_INCR}
+ if (exists $ENV{ORA_DRCP_INCR}) {
+ $attr->{ora_drcp_incr} = $ENV{ORA_DRCP_INCR}
}
DBD::Oracle::db::_login($dbh, $dbname, $user, $auth, $attr)
@@ -1371,7 +1371,9 @@
$dbh = DBI->connect('dbi:Oracle:','username@DB:POOLED','password')
$dbh = DBI->connect('dbi:Oracle:DB','username','password',{ora_drcp=>1})
-
+
+ $dbh = DBI->connect('dbi:Oracle:DB','username','password',{ora_drcp=>1, ora_drcp_class=>'my_app', ora_drcp_min=>10})
+
$dbh = DBI->connect('dbi:Oracle:host=foobar;sid=ORCL;port=1521;SERVER=POOLED', 'scott/tiger', '')
$dbh = DBI->connect('dbi:Oracle:', q{scott/tiger@(DESCRIPTION=
@@ -1559,7 +1561,47 @@
For convenience I have added support for a 'ORA_DRCP'
environment variable that you can use at the OS level to set this
-value. If used it will take the value at the connect stage.
+value.
+
+=item ora_drcp_class
+
+If you are using DRCP, you can set a CONNECTION_CLASS for your pools as well.
+As sessions from a DRCP cannot be shared by users, you can use this
+setting to identify the same user across different applications. OCI will ensure that
+session belonging to a 'class' are not shared ourside the class'.
+
+The values for ora_drcp_class cannot contain an '*' and must be les taht 1024 characters.
+
+This value can be set at the enviormnet level with 'ORA_DRCP_CLASS'.
+
+=item ora_drcp_min
+
+Is an optional value that specifies the minimum number of sessions that are initialy opened.
+New sessions are only opend after this value has been reached.
+
+The default value is '4' and any value above '0' is valid.
+
+Generally, it should be set to the number of concurrent statements the application is planning
+or expecting to run.
+
+This value can be set at the enviormnet level with 'ORA_DRCP_MIN'.
+
+=item ora_drcp_max
+
+Is an optional value that specifies the maximum number of sessions that can be open at one time.
+Once reached no more session can be opend until one becomes free. The default value
+is '40' and any value above '1' is valid. You should not set this value lower than ora_drcp_min as
+that will just waste resources.
+
+This value can be set at the enviormnet level with 'ORA_DRCP_MAX'.
+
+=item ora_drcp_incr
+
+Is an optional value that specifies the next increment for sessions to be started if the current number of
+sessions are less than ora_drcp_max. The default value is '2' and any value above '0' is valid as long
+as the value of ora_drcp_min + ora_drcp_incr is not greated than ora_drcp_max.
+
+This value can be set at the enviormnet level with 'ORA_DRCP_INCR'.
=item ora_session_mode
Modified: dbd-oracle/branches/DRCP_1.25/dbdimp.c
==============================================================================
--- dbd-oracle/branches/DRCP_1.25/dbdimp.c (original)
+++ dbd-oracle/branches/DRCP_1.25/dbdimp.c Thu Jul 8 10:54:18 2010
@@ -393,18 +393,19 @@
/* some connection pool atributes */
- if ((svp=DBD_ATTRIB_GET_SVP(attr, "ora_pool_class", 14)) && SvOK(*svp)) {
+ if ((svp=DBD_ATTRIB_GET_SVP(attr, "ora_drcp_class", 14)) && SvOK(*svp)) {
+ STRLEN svp_len;
if (!SvPOK(*svp))
- croak("ora_pool_class is not a string");
+ croak("ora_drcp_class is not a string");
imp_dbh->pool_class = (text *) SvPV (*svp, svp_len );
imp_dbh->pool_classl= (ub4) svp_len;
}
- if (DBD_ATTRIB_TRUE(attr,"ora_pool_min",12,svp))
- DBD_ATTRIB_GET_IV( attr, "ora_pool_min", 12, svp, imp_dbh->pool_min);
- if (DBD_ATTRIB_TRUE(attr,"ora_pool_max",12,svp))
- DBD_ATTRIB_GET_IV( attr, "ora_pool_max", 12, svp, imp_dbh->pool_max);
- if (DBD_ATTRIB_TRUE(attr,"ora_pool_incr",13,svp))
- DBD_ATTRIB_GET_IV( attr, "ora_pool_incr", 13, svp, imp_dbh->pool_incr);
+ if (DBD_ATTRIB_TRUE(attr,"ora_drcp_min",12,svp))
+ DBD_ATTRIB_GET_IV( attr, "ora_drcp_min", 12, svp, imp_dbh->pool_min);
+ if (DBD_ATTRIB_TRUE(attr,"ora_drcp_max",12,svp))
+ DBD_ATTRIB_GET_IV( attr, "ora_drcp_max", 12, svp, imp_dbh->pool_max);
+ if (DBD_ATTRIB_TRUE(attr,"ora_drcp_incr",13,svp))
+ DBD_ATTRIB_GET_IV( attr, "ora_drcp_incr", 13, svp, imp_dbh->pool_incr);
#endif /*ORA_OCI_112*/
/* check to see if DBD_verbose or ora_verbose is set*/
@@ -800,9 +801,6 @@
ub4 cred_type;
DBD_ATTRIB_GET_IV(attr, "ora_session_mode",16, sess_mode_type_sv, sess_mode_type);
-
-
-
#ifdef ORA_OCI_112
if (imp_dbh->using_drcp) { /* connect uisng a DRCP */
@@ -848,7 +846,7 @@
OCIAttrSet_log_stat(imp_dbh->authp, (ub4) OCI_HTYPE_AUTHINFO,
&purity, (ub4) 0,(ub4) OCI_ATTR_PURITY, imp_dbh->errhp, status);
- if (imp_dbh->pool_class) /*pool_class may ormay not be used */
+ if (imp_dbh->pool_class) /*pool_class may or may not be used */
OCIAttrSet_log_stat(imp_dbh->authp, (ub4) OCI_HTYPE_AUTHINFO,
(OraText *) imp_dbh->pool_class, (ub4) imp_dbh->pool_classl,
(ub4) OCI_ATTR_CONNECTION_CLASS, imp_dbh->errhp, status);
@@ -869,6 +867,15 @@
return 0;
}
+
+ if (DBIS->debug >= 4 || dbd_verbose >= 4 ) {
+ PerlIO_printf(DBILOGFP,"Using DRCP with session settings min=%d, max=%d, and increment=%d\n",imp_dbh->pool_min,
+ imp_dbh->pool_max,
+ imp_dbh->pool_incr);
+ if (imp_dbh->pool_class)
+ PerlIO_printf(DBILOGFP,"with connection class=%s\n",imp_dbh->pool_class);
+ }
+
}
else {
#endif
@@ -947,8 +954,8 @@
sword status;
OCITransCommit_log_stat(imp_dbh->svchp, imp_dbh->errhp, OCI_DEFAULT, status);
if (status != OCI_SUCCESS) {
- oci_error(dbh, imp_dbh->errhp, status, "OCITransCommit");
- return 0;
+ oci_error(dbh, imp_dbh->errhp, status, "OCITransCommit");
+ return 0;
}
return 1;
}
@@ -1129,6 +1136,7 @@
{
dTHX;
STRLEN kl;
+ STRLEN vl;
char *key = SvPV(keysv,kl);
int on = SvTRUE(valuesv);
int cacheit = 1;
@@ -1140,17 +1148,17 @@
else if (kl==8 && strEQ(key, "ora_drcp") ) {
imp_dbh->using_drcp = 1;
}
- else if (kl==14 && strEQ(key, "ora_pool_class") ) {
+ else if (kl==14 && strEQ(key, "ora_drcp_class") ) {
imp_dbh->pool_class = (text *) SvPV (valuesv, vl );
imp_dbh->pool_classl= (ub4) vl;
}
- else if (kl==12 && strEQ(key, "ora_pool_min") ) {
+ else if (kl==12 && strEQ(key, "ora_drcp_min") ) {
imp_dbh->pool_min = SvIV (valuesv);
}
- else if (kl==12 && strEQ(key, "ora_pool_max") ) {
+ else if (kl==12 && strEQ(key, "ora_drcp_max") ) {
imp_dbh->pool_max = SvIV (valuesv);
}
- else if (kl==13 && strEQ(key, "ora_pool_incr") ) {
+ else if (kl==13 && strEQ(key, "ora_drcp_incr") ) {
imp_dbh->pool_incr = SvIV (valuesv);
}
#endif
Modified: dbd-oracle/branches/DRCP_1.25/oci8.c
==============================================================================
--- dbd-oracle/branches/DRCP_1.25/oci8.c (original)
+++ dbd-oracle/branches/DRCP_1.25/oci8.c Thu Jul 8 10:54:18 2010
@@ -414,6 +414,7 @@
/*=============================Attribute Types===============================*/
#ifdef ORA_OCI_112
case OCI_ATTR_PURITY: return "OCI_ATTR_PURITY"; /* for DRCP session purity */
+ case OCI_ATTR_CONNECTION_CLASS return "OCI_ATTR_CONNECTION_CLASS"; /* for DRCP connection class */
#endif
case OCI_ATTR_FNCODE: return "OCI_ATTR_FNCODE"; /* the OCI function code */
case OCI_ATTR_OBJECT: return "OCI_ATTR_OBJECT"; /* is the environment initialized in object mode */
@@ -728,40 +729,43 @@
sword eg_status;
if (!SvOK(errstr))
- sv_setpv(errstr,"");
+ sv_setpv(errstr,"");
+
if (!errhp) {
- sv_catpv(errstr, oci_status_name(status));
- if (what) {
- sv_catpv(errstr, " ");
- sv_catpv(errstr, what);
- }
- return status;
+ sv_catpv(errstr, oci_status_name(status));
+ if (what) {
+ sv_catpv(errstr, " ");
+ sv_catpv(errstr, what);
+ }
+ return status;
}
while( ++recno
- && OCIErrorGet_log_stat(errhp, recno, (text*)NULL, &eg_errcode, errbuf,
+ && OCIErrorGet_log_stat(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(DBILOGFP, " OCIErrorGet after %s (er%ld:%s): %d, %ld: %s\n",
- what ? what : "<NULL>", (long)recno,
+ && eg_status != OCI_INVALID_HANDLE
+ && recno < 100) {
+ if (debug >= 4 || recno>1/*XXX temp*/)
+ PerlIO_printf(DBILOGFP, " 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),
status, (long)eg_errcode, errbuf);
- errcode = eg_errcode;
- sv_catpv(errstr, (char*)errbuf);
- if (*(SvEND(errstr)-1) == '\n')
- --SvCUR(errstr);
+
+ errcode = eg_errcode;
+ sv_catpv(errstr, (char*)errbuf);
+
+ if (*(SvEND(errstr)-1) == '\n')
+ --SvCUR(errstr);
}
+
if (what || status != OCI_ERROR) {
- sv_catpv(errstr, (debug<0) ? " (" : " (DBD ");
- sv_catpv(errstr, oci_status_name(status));
- if (what) {
- sv_catpv(errstr, ": ");
- sv_catpv(errstr, what);
- }
- sv_catpv(errstr, ")");
+ sv_catpv(errstr, (debug<0) ? " (" : " (DBD ");
+ sv_catpv(errstr, oci_status_name(status));
+ if (what) {
+ sv_catpv(errstr, ": ");
+ sv_catpv(errstr, what);
+ }
+ sv_catpv(errstr, ")");
}
return errcode;
}
@@ -788,11 +792,11 @@
/* DBIc_ERR *must* be SvTRUE (for RaiseError etc), some */
/* errors, like OCI_INVALID_HANDLE, don't set errcode. */
if (force_err)
- errcode = force_err;
+ errcode = force_err;
if (status == OCI_SUCCESS_WITH_INFO)
- errcode = 0; /* record as a "warning" for DBI>=1.43 */
+ errcode = 0; /* record as a "warning" for DBI>=1.43 */
else if (errcode == 0)
- errcode = (status != 0) ? status : -10000;
+ errcode = (status != 0) ? status : -10000;
sv_setiv(errcode_sv, errcode);
DBIh_SET_ERR_SV(h, imp_xxh, errcode_sv, errstr_sv, &sv_undef, &sv_undef);
Modified: dbd-oracle/branches/DRCP_1.25/t/31lob.t
==============================================================================
--- dbd-oracle/branches/DRCP_1.25/t/31lob.t (original)
+++ dbd-oracle/branches/DRCP_1.25/t/31lob.t Thu Jul 8 10:54:18 2010
@@ -111,11 +111,12 @@
# write string > 32k
$large_value = 'ABCD' x 10_000;
-
+$dbh->{dbd_verbose}=15;
$dbh->ora_lob_write( $loc, 1, $large_value );
warn("\ntest5\n");
is( $dbh->ora_lob_length($loc), length($large_value), "returned length" );
warn("\ntest6\n");
+
is( $dbh->ora_lob_read( $loc, 1, length($large_value) ),
$large_value, "returned written value" );
warn("\ntest7\n");
@@ -123,7 +124,7 @@
SKIP: {
## test calling PL/SQL with LOB placeholder
my $plsql_testcount = 4;
-$dbh->{dbd_verbose}=15;
+
$stmt = "BEGIN ? := DBMS_LOB.GETLENGTH( ? ); END;";
$sth = $dbh->prepare( $stmt, { ora_auto_lob => 0 } );
$sth->bind_param_inout( 1, \$len, 16 );
@@ -146,7 +147,7 @@
}
warn("\ntest8 $len=".length($large_value)." \n");
# is( $len, length($large_value), "returned length via PL/SQL" );
-
+exit;
$dbh->{dbd_verbose}=0;
$stmt = "
DECLARE
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.