[svn:dbd-oracle] r13454 - dbd-oracle/trunk

[email protected]
Newsgroups perl.dbd.oracle.changes
Message-ID <[email protected]>
Author: byterock
Date: Thu Oct 29 10:53:06 2009
New Revision: 13454

Modified:
   dbd-oracle/trunk/Changes
   dbd-oracle/trunk/Oracle.pm
   dbd-oracle/trunk/dbdimp.c
   dbd-oracle/trunk/dbdimp.h
   dbd-oracle/trunk/oci8.c
   dbd-oracle/trunk/ocitrace.h

Log:
 a big check in this time a 

  Added support for looking up OCI_DTYPE_PARAM Attributes
  Added support for looking up csform values 
  Fix for rt.cpan.org Tickets  66763,46998,46448 ,47503

and a big enhancement where we now use a proper row buffer so we can fetch a large number of records in a round trip to the server rather than the single fetch we were using in previous version.

This should speed things up greatly

Modified: dbd-oracle/trunk/Changes
==============================================================================
--- dbd-oracle/trunk/Changes	(original)
+++ dbd-oracle/trunk/Changes	Thu Oct 29 10:53:06 2009
@@ -1,6 +1,11 @@
 =head1 Changes in DBD-Oracle 1.24(svn rev???)
-  Fix for rt.cpan.org ticke  #=46613: bugfix - sig-abort on nested objects with ora_objects=1 from TomasP
-  Fix for rt.cpan.org Ticket #=46661: DBD::Oracle hungs when insert/update with LOB and quoted table name from APLA
+  Added support for looking up OCI_DTYPE_PARAM Attributes
+  Added support for looking up csform values 
+  Fix for rt.cpan.org Ticke  #=46763,46998 enhancement -Rowcache size is now being properly implimented with row fetch buffer from John Scoles 
+  Fix for rt.cpan.org Ticket #=46448 enhancement -Errors returned by procedures are now unicode strings from Martin Evans, John Scoles and Tim Bunce
+  Fix for rt.cpan.org Ticket #=47503 bugfix - using more than 1 LOB in insert broken from APLA
+  Fix for rt.cpan.org Ticket #=46613 bugfix - sig-abort on nested objects with ora_objects=1 from TomasP
+  Fix for rt.cpan.org Ticket #=46661 DBD::Oracle hungs when insert/update with LOB and quoted table name from APLA
   Fix for rt.cpan.org Ticket #=46246 fetching from nested cursor (returned from procedure) leads to application crash (abort) from John Scoles
   Fix for rt.cpan.org Ticket #=46016  LOBs bound with ora_field broken from RKITOVER
   Fix for bug in 58object.t when test run as externally identified user from Charles Jardine

Modified: dbd-oracle/trunk/Oracle.pm
==============================================================================
--- dbd-oracle/trunk/Oracle.pm	(original)
+++ dbd-oracle/trunk/Oracle.pm	Thu Oct 29 10:53:06 2009
@@ -322,7 +322,7 @@
                  ora_session_mode	=> undef,
                  ora_verbose		=> undef,
                  ora_oci_success_warn	=> undef,
-                 ora_objects	=> undef
+                 ora_objects		=> undef,
                  };
     }
    
@@ -930,20 +930,23 @@
     }
 
     sub private_attribute_info {
-        return { ora_lengths 		=> undef,
-                 ora_types   		=> undef,
-                 ora_rowid		=> undef,
-                 ora_est_row_width	=> undef,
-                 ora_type               => undef,
-                 ora_field              => undef,
-                 ora_csform		=> undef,
-                 ora_maxdata_size	=> undef,
-                 ora_parse_lang		=> undef,
-                 ora_placeholders	=> undef,
-                 ora_auto_lob		=> undef,
-                 ora_check_sql		=> undef
-                };
-    }
+	return {ora_lengths		=> undef,
+		ora_types		=> undef,
+		ora_rowid		=> undef,
+		ora_est_row_width	=> undef,
+		ora_type		=> undef,
+		ora_field		=> undef,
+		ora_csform		=> undef,
+		ora_maxdata_size	=> undef,
+		ora_parse_lang		=> undef,
+		ora_placeholders	=> undef,
+		ora_auto_lob		=> undef,
+		ora_check_sql		=> undef,
+		ora_row_cache_off	=> undef,
+		ora_prefetch_rows	=> undef,
+		ora_prefetch_memory	=> undef,
+		};
+   }
    
 }
 
@@ -1329,7 +1332,7 @@
 Oracle technical support (and not the dbi-users mailing list). Thanks.
 Thanks to Mark Dedlow for this information.
 
-=head2 Constants
+=head1 Constants
 
 =over 4
 
@@ -1393,6 +1396,9 @@
 
   OCI_STMT_SCROLLABLE_READONLY 
 
+
+=head1 Attributes
+
 =head2 Connect Attributes
 
 =over 4
@@ -1675,16 +1681,27 @@
 
 See L</Scrollable Cursors> for more details.
 
+=item ora_prefetch_rows
+
+Sets the number of rows to be prefetched. If it is not set, then the default value is 1.
+See L</Prefetching Rows> for more details.
+
 =item ora_prefetch_memory
 
-Sets the memory level for top level rows to be prefetched. Rows up to the specified top level row 
-count C<RowCacheSize> are fetched if it occupies no more than the specified memory usage limit. The default value is 0, 
-which means that memory size is not included in computing the number of rows to prefetch. If
-the C<RowCacheSize> value is set to 0 or a negative number when using this value then only 
-the memory value entered is used to compute the number of rows to prefetch.
+Sets the memory level for rows to be prefetched. The application then fetches as many rows as will fit into that much memory.
+See L</Prefetching Rows> for more details.
+
+=item ora_row_cache_off
 
+By default DBD::Oracle will use a row cache when fetching to cut down the number of round 
+trips to the server. If you do not want to use an array fetch set this value to any value other than 0;
 See L</Prefetching Rows> for more details.
 
+=item 
+
+You can customize the value of the row cache with this value.  By default it will normlly be set to the 
+RowCacheSize or one cles to it.
+
 =item ora_verbose
 
 Use this value to enable DBD::Oracle only tracing.  Simply set the attribute to the trace level you desire.
@@ -1767,9 +1784,77 @@
 Specify internal data representation. Currently is supported only for
 ORA_NUMBER_TABLE.
 
+=head1 Optimizing Results
+
+=head2 Prepare postponed till execute
+
+The DBD::Oracle module can avoid an explicit 'describe' operation
+prior to the execution of the statement unless the application requests
+information about the results (such as $sth->{NAME}). This reduces
+communication with the server and increases performance (reducing the
+number of PARSE_CALLS inside the server).
+
+However, it also means that SQL errors are not detected until
+C<execute()> (or $sth->{NAME} etc) is called instead of when
+C<prepare()> is called. Note that if the describe is triggered by the
+use of $sth->{NAME} or a similar attribute and the describe fails then
+I<an exception is thrown> even if C<RaiseError> is false!
+
+Set L</ora_check_sql> to 0 in prepare() to enable this behaviour.
+
+=head1 Prefetching & Row Caching 
+
+DBD::Oracle now supports both Server pre-fetch and Client side row caching. By defualt both 
+are trurned on to give optimum performance. Most of the time one can just let DBD::Oracle
+figure out the best optimization. 
+
+=head2 Row Caching
+
+Row caching occures on the client side and the object of it is to cut down the number of round 
+trips made to the server when fetching rows. At each fetch a set number of rows will be retreived
+from the server and stored locally. Further calls the server are made only when the end of the 
+local buffer(cache) is reached.
+
+Rows up to the specified top level row 
+count C<RowCacheSize> are fetched if it occupies no more than the specified memory usage limit. 
+The default value is 0, which means that memory size is not included in computing the number of rows to prefetch. If
+the C<RowCacheSize> value is set to a negative number then the positive value of RowCacheSize is used 
+to compute the number of rows to prefetch.
+
+By default C<RowCacheSize> is automaticaly set. If you want to totaly turn off prefetching set this to 1.
+
+
+
+=head2 Row Prefetching
+
+Row prefetching occurs on the server side and uses the DBI database handle attribute C<RowCacheSize> and or the 
+Prepare Attribute 'ora_prefetch_memory'. Tweaking these values may yield improved performance. 
+
+   $dbh->{RowCacheSize} = 100;
+   $sth=$dbh->prepare($SQL,{ora_exe_mode=>OCI_STMT_SCROLLABLE_READONLY,ora_prefetch_memory=>10000});
+   
+In the above example 10 rows will be prefetched up to a maximum of 10000 bytes of data.  The Oracle® Call Interface Programmer's Guide,
+suggests a good row cache value for a scrollable cursor is about 20% of expected size of the record set. 
+
+The prefetch settings tell the DBD::Oracle to grab x rows (or x-bytes) when it needs to get new rows. This happens on the first 
+fetch that sets the current_positon to any value other than 0. In the above example if we do a OCI_FETCH_FIRST the first 10 rows are
+loaded into the buffer and DBD::Oracle will not have to go back to the server for more rows. When record 11 is fetched DBD::Oracle
+fetches and returns this row and the next 9 rows are loaded into the buffer. In this case if you fetch backwards from 10 to 1 
+no server round trips are made.
+
+With large record sets it is best not to attempt to go to the last record as this may take some time, A large buffer size might even slow down
+the fetch. If you must get the number of rows in a large record set you might try using an few large OCI_FETCH_ABSOLUTEs and then an OCI_FETCH_LAST,
+this might save some time. So if you had a record set of 10000 rows and you set the buffer to 5000 and did a OCI_FETCH_LAST one would fetch the first 5000 rows into the buffer then the next 5000 rows.  
+If one requires only the first few rows there is no need to set a large prefetch value.  
+
+If the ora_prefetch_memory less than 1 or not present then memory size is not included in computing the 
+number of rows to prefetch otherwise the number of rows will be limited to memory size. Likewise if the RowCacheSize is less than 1 it
+is not included in the computing of the prefetch rows.  
 
 =back
 
+=head1 Spaces & Padding
+
 =head2 Trailing Spaces
 
 Please note that only the Oracle OCI 8 strips trailing spaces from VARCHAR placeholder
@@ -2687,23 +2772,6 @@
 
 =back
 
-=head1 Prepare postponed till execute
-
-The DBD::Oracle module can avoid an explicit 'describe' operation
-prior to the execution of the statement unless the application requests
-information about the results (such as $sth->{NAME}). This reduces
-communication with the server and increases performance (reducing the
-number of PARSE_CALLS inside the server).
-
-However, it also means that SQL errors are not detected until
-C<execute()> (or $sth->{NAME} etc) is called instead of when
-C<prepare()> is called. Note that if the describe is triggered by the
-use of $sth->{NAME} or a similar attribute and the describe fails then
-I<an exception is thrown> even if C<RaiseError> is false!
-
-Set L</ora_check_sql> to 0 in prepare() to enable this behaviour.
-
-
 =head1 Scrollable Cursors
 
 Oracle supports the concept of a 'Scrollable Cursor' which is defined as a 'Result Set' where
@@ -2918,33 +2986,6 @@
 When using scrollable cursors it is required that you use the $sth->finish() method when you are done with the cursor as this type of
 cursor has to be explicitly canceled on the server. If you do not do this you may cause resource problems on your database.  
 
-=head2 Prefetching Rows
-
-One can override the DBD::Oracle's default pre-fetch values by using the DBI database handle attribute C<RowCacheSize> and or the 
-Prepare Attribute 'ora_prefetch_memory'. Tweaking these values may yield improved performance. 
-
-   $dbh->{RowCacheSize} = 10;
-   $sth=$dbh->prepare($SQL,{ora_exe_mode=>OCI_STMT_SCROLLABLE_READONLY,ora_prefetch_memory=>10000});
-   
-In the above example 10 rows will be prefetched up to a maximum of 10000 bytes of data.  The Oracle® Call Interface Programmer's Guide,
-suggests a good row cache value for a scrollable cursor is about 20% of expected size of the record set. 
-
-The prefetch settings tell the DBD::Oracle to grab x rows (or x-bytes) when it needs to get new rows. This happens on the first 
-fetch that sets the current_positon to any value other than 0. In the above example if we do a OCI_FETCH_FIRST the first 10 rows are
-loaded into the buffer and DBD::Oracle will not have to go back to the server for more rows. When record 11 is fetched DBD::Oracle
-fetches and returns this row and the next 9 rows are loaded into the buffer. In this case if you fetch backwards from 10 to 1 
-no server round trips are made.
-
-With large record sets it is best not to attempt to go to the last record as this may take some time, A large buffer size might even slow down
-the fetch. If you must get the number of rows in a large record set you might try using an few large OCI_FETCH_ABSOLUTEs and then an OCI_FETCH_LAST,
-this might save some time. So if you had a record set of 10000 rows and you set the buffer to 5000 and did a OCI_FETCH_LAST one would fetch the first 5000 rows into the buffer then the next 5000 rows.  
-If one requires only the first few rows there is no need to set a large prefetch value.  
-
-If the ora_prefetch_memory less than 1 or not present then memory size is not included in computing the 
-number of rows to prefetch otherwise the number of rows will be limited to memory size. Likewise if the RowCacheSize is less than 1 it
-is not included in the computing of the prefetch rows.  
-
-
 =head1 LOBs and LONGs
 
 The key to working with LOBs (CLOB, BLOBs) is to remember the value of an Oracle LOB column is not the content of the LOB. It's a

Modified: dbd-oracle/trunk/dbdimp.c
==============================================================================
--- dbd-oracle/trunk/dbdimp.c	(original)
+++ dbd-oracle/trunk/dbdimp.c	Thu Oct 29 10:53:06 2009
@@ -379,6 +379,8 @@
 		DBD_ATTRIB_GET_IV(  attr, "dbd_verbose",  11, svp, dbd_verbose);
 	if (DBD_ATTRIB_TRUE(attr,"ora_verbose",11,svp))
 		DBD_ATTRIB_GET_IV(  attr, "ora_verbose",  11, svp, dbd_verbose);
+
+
 	if (DBD_ATTRIB_TRUE(attr,"ora_oci_success_warn",20,svp))
 		DBD_ATTRIB_GET_IV(  attr, "ora_oci_success_warn",  20, svp, oci_warn);
 	if (DBD_ATTRIB_TRUE(attr,"ora_objects",11,svp))
@@ -1024,6 +1026,9 @@
 	else if (kl==12 && strEQ(key, "RowCacheSize")) {
 		retsv = newSViv(imp_dbh->RowCacheSize);
 	}
+	else if (kl==11 && strEQ(key, "RowsInCache")) {
+			retsv = newSViv(imp_dbh->RowsInCache);
+	}
 	else if (kl==22 && strEQ(key, "ora_max_nested_cursors")) {
 		retsv = newSViv(imp_dbh->max_nested_cursors);
 	}
@@ -1642,12 +1647,12 @@
 
 	if (trace_level >= 3 || dbd_verbose >= 3 )
 		PerlIO_printf(DBILOGFP, "dbd_rebind_ph_varchar2_table(): bind %s <== %s "
-			"(%s, %s, csid %d->%d->%d, ftype %d, csform %d->%d, maxlen %lu, maxdata_size %lu)\n",
+			"(%s, %s, csid %d->%d->%d, ftype %d, csform %d (%s)->%d (%s), maxlen %lu, maxdata_size %lu)\n",
 			phs->name, neatsvpv(phs->sv,0),
 			(phs->is_inout) ? "inout" : "in",
 			flag_data_is_utf8 ? "is-utf8" : "not-utf8",
 			phs->csid_orig, phs->csid, csid,
-			phs->ftype, phs->csform, csform,
+			phs->ftype, phs->csform,oci_csform_name(phs->csform), csform,oci_csform_name(csform),
 			(unsigned long)phs->maxlen, (unsigned long)phs->maxdata_size);
 
 
@@ -2445,7 +2450,6 @@
 
 	 /* force stmt_type since OCIAttrGet(OCI_ATTR_STMT_TYPE) doesn't work! */
 		imp_sth_csr->stmt_type = OCI_STMT_SELECT;
-		imp_sth_csr->rs_array_on=1;	/* turn on array fetch for ref cursors */
  		DBIc_IMPSET_on(imp_sth_csr);
 
 	 /* set ACTIVE so dbd_describe doesn't do explicit OCI describe */
@@ -2542,9 +2546,9 @@
 	ub2 csid;
 
 	if (trace_level >= 5 || dbd_verbose >= 5 )
-		PerlIO_printf(DBILOGFP, "dbd_rebind_ph() (1): rebinding %s as %s (%s, ftype %d (%s), csid %d, csform %d, inout %d)\n",
+		PerlIO_printf(DBILOGFP, "dbd_rebind_ph() (1): rebinding %s as %s (%s, ftype %d (%s), csid %d, csform %d(%s), inout %d)\n",
 		phs->name, (SvPOK(phs->sv) ? neatsvpv(phs->sv,10) : "NULL"),(SvUTF8(phs->sv) ? "is-utf8" : "not-utf8"),
-		phs->ftype,sql_typecode_name(phs->ftype),phs->csid, phs->csform, phs->is_inout);
+		phs->ftype,sql_typecode_name(phs->ftype),phs->csid, phs->csform,oci_csform_name(phs->csform), phs->is_inout);
 
 	switch (phs->ftype) {
 		case ORA_VARCHAR2_TABLE:
@@ -2653,12 +2657,12 @@
 
 	if (trace_level >= 3 || dbd_verbose >= 3 )
 		PerlIO_printf(DBILOGFP, "dbd_rebind_ph(): bind %s <== %s "
-		"(%s, %s, csid %d->%d->%d, ftype %d (%s), csform %d->%d, maxlen %lu, maxdata_size %lu)\n",
+		"(%s, %s, csid %d->%d->%d, ftype %d (%s), csform %d(%s)->%d(%s), maxlen %lu, maxdata_size %lu)\n",
 		  phs->name, neatsvpv(phs->sv,10),
 		  (phs->is_inout) ? "inout" : "in",
 		  (SvUTF8(phs->sv) ? "is-utf8" : "not-utf8"),
 		  phs->csid_orig, phs->csid, csid,
-		  phs->ftype,sql_typecode_name(phs->ftype), phs->csform, csform,
+		  phs->ftype,sql_typecode_name(phs->ftype), phs->csform, oci_csform_name(phs->csform), csform, oci_csform_name(csform),
 		  (unsigned long)phs->maxlen, (unsigned long)phs->maxdata_size);
 
 
@@ -3040,9 +3044,8 @@
 		if (debug >= 2 || dbd_verbose >= 3 )
 			PerlIO_printf(DBILOGFP,"Statement Execute Mode is %d (%s)\n",imp_sth->exe_mode,oci_exe_mode(imp_sth->exe_mode));
 
-
 		OCIStmtExecute_log_stat(imp_sth->svchp, imp_sth->stmhp, imp_sth->errhp,
-					(ub4)(is_select ? 0 : 1),
+					(ub4)(is_select ? 0: 1),
 					0, 0, 0,(ub4)imp_sth->exe_mode,status);
 
 
@@ -3058,6 +3061,9 @@
 		DBIc_ACTIVE_on(imp_sth);
 		DBIc_ROW_COUNT(imp_sth) = 0; /* reset (possibly re-exec'ing) */
 		row_count = 0;
+		/*reinit the rs_array as well
+		  as we may have more thatn one exe on a prepare*/
+		rs_array_init(imp_sth);
 	}
 	else {
 		OCIAttrGet_stmhp_stat(imp_sth, &row_count, 0, OCI_ATTR_ROW_COUNT, status);
@@ -3224,12 +3230,12 @@
 
 	if (trace_level >= 3 || dbd_verbose >= 3 )
 		PerlIO_printf(DBILOGFP, "do_bind_array_exec(): bind %s <== [array of values] "
-			"(%s, %s, csid %d->%d->%d, ftype %d (%s), csform %d->%d, maxlen %lu, maxdata_size %lu)\n",
+			"(%s, %s, csid %d->%d->%d, ftype %d (%s), csform %d (%s)->%d (%s), maxlen %lu, maxdata_size %lu)\n",
 			phs->name,
 			(phs->is_inout) ? "inout" : "in",
 			(utf8 ? "is-utf8" : "not-utf8"),
 			phs->csid_orig, phs->csid, csid,
-			phs->ftype,sql_typecode_name(phs->ftype), phs->csform, csform,
+			phs->ftype,sql_typecode_name(phs->ftype), phs->csform,oci_csform_name(phs->csform), csform,oci_csform_name(csform),
 			(unsigned long)phs->maxlen, (unsigned long)phs->maxdata_size);
 
 

Modified: dbd-oracle/trunk/dbdimp.h
==============================================================================
--- dbd-oracle/trunk/dbdimp.h	(original)
+++ dbd-oracle/trunk/dbdimp.h	Thu Oct 29 10:53:06 2009
@@ -41,7 +41,8 @@
 	OCISession	*authp;
 	int proc_handles;		   /* If true, srvhp, svchp, and authp handles
 								   are owned by ProC and must not be freed. */
-	int RowCacheSize;
+	int RowCacheSize; /* both of these are defined by DBI spec*/
+	int RowsInCache;	/* this vaue is RO and cannot be set*/
 	int ph_type;		/* default oratype for placeholders */
 	ub1 ph_csform;		/* default charset for placeholders */
 	int parse_error_offset;	/* position in statement of last error */
@@ -78,7 +79,7 @@
 	ub4				piece_size;	/*used in callback to set the size of the piece to get*/
 	int				has_lobs;	/*Statement has bound LOBS */
     int				ret_lobs;	/*Statement returns LOBS */
-	lob_refetch_t	*lob_refetch;
+ 	lob_refetch_t	*lob_refetch;
 	int				nested_cursor;	/* cursors fetched from SELECTs */
 	AV				*bind_tuples;	/* Bind tuples in array execute, or NULL */
 	int				rowwise;		/* If true, bind_tuples is list of */
@@ -111,13 +112,15 @@
 	int 			fetch_orient;
 	int				fetch_offset;
 	int				fetch_position;
-	int 			prefetch_memory;   /* OCI_PREFETCH_MEMORY*/
+	int 			prefetch_memory;	/* OCI_PREFETCH_MEMORY*/
+	int				prefetch_rows;		/* OCI_PREFETCH_ROWS
 	/* array fetch: state variables */
-	bool			rs_array_on;		   /* if array to be used */
-	int				rs_array_size;		 /* array size */
-	int				rs_array_num_rows;	 /* num rows in last fetch */
-	int				rs_array_idx;		  /* index of current row */
-	sword			rs_array_status;	   /* status of last fetch */
+	int				row_cache_off;
+	int 			rs_fetch_count;		/*fetch count*/
+	int				rs_array_size;		/*array size local value for RowCacheSize as I do not want to change RowCacheSize */
+	int				rs_array_num_rows;	/* num rows in last fetch */
+	int				rs_array_idx;		/* index of current row */
+	sword			rs_array_status;	/* status of last fetch */
 };
 #define IMP_STH_EXECUTING	0x0001
 
@@ -306,8 +309,10 @@
 char *oci_bind_options _((ub4 options));
 char *oci_define_options _((ub4 options));
 char *oci_hdtype_name _((ub4 hdtype));
+char *oci_attr_name _((ub4 attr));
 char *oci_exe_mode _((ub4 mode));
 char *oci_col_return_codes _((int rc));
+char *oci_csform_name _((ub4 attr));
 int dbd_rebind_ph_lob _((SV *sth, imp_sth_t *imp_sth, phs_t *phs));
 
 int dbd_rebind_ph_nty _((SV *sth, imp_sth_t *imp_sth, phs_t *phs));
@@ -342,7 +347,7 @@
 void * oci_db_handle(imp_dbh_t *imp_dbh, int handle_type, int flags);
 void * oci_st_handle(imp_sth_t *imp_sth, int handle_type, int flags);
 void fb_ary_free(fb_ary_t *fb_ary);
-
+void rs_array_init(imp_sth_t *imp_sth);
 
 
 

Modified: dbd-oracle/trunk/oci8.c
==============================================================================
--- dbd-oracle/trunk/oci8.c	(original)
+++ dbd-oracle/trunk/oci8.c	Thu Oct 29 10:53:06 2009
@@ -242,7 +242,7 @@
 													the new length semantics, always bytes, is used by OCIEnvNlsCreate */
 		case OCI_NO_MUTEX_STMT:	return "NO_MUTEX_STMT";			/* Do not mutex stmt handle */
 		case OCI_MUTEX_ENV_ONLY:	return "MUTEX_ENV_ONLY";  /* Mutex only the environment handle */
-/*		case OCI_SUPPRESS_NLS_VALIDATION:  return "SUPPRESS_NLS_VALIDATION";	suppress nls validation*/
+/*		case OCI_SUPPRESS_NLS_VALIDATION:return "SUPPRESS_NLS_VALIDATION";	suppress nls validation*/
 													 /* 	  nls validation suppression is on by default;*/
 													  /*	use OCI_ENABLE_NLS_VALIDATION to disable it */
 /*		case OCI_MUTEX_TRY:				return "MUTEX_TRY";	 try and acquire mutex */
@@ -347,6 +347,360 @@
 	return SvPV(sv,na);
 }
 
+/*used to look up the name of a csform value
+  used only for debugging */
+char *
+oci_csform_name(ub4 attr)
+{
+	dTHX;
+	SV *sv;
+	switch (attr) {
+
+/* CHAR/NCHAR/VARCHAR2/NVARCHAR2/CLOB/NCLOB char set "form" information */
+	case SQLCS_IMPLICIT:			return "SQLCS_IMPLICIT";/* for CHAR, VARCHAR2, CLOB w/o a specified set */
+	case SQLCS_NCHAR:				return "SQLCS_NCHAR";/* for NCHAR, NCHAR VARYING, NCLOB */
+	case SQLCS_EXPLICIT:			return "SQLCS_EXPLICIT";/* for CHAR, etc, with "CHARACTER SET ..." syntax */
+	case SQLCS_FLEXIBLE:			return "SQLCS_FLEXIBLE";/* for PL/SQL "flexible" parameters */
+	case SQLCS_LIT_NULL:			return "SQLCS_LIT_NULL";/* for typecheck of NULL and empty_clob() lits */
+	}
+
+	sv = sv_2mortal(newSViv((IV)attr));
+	return SvPV(sv,na);
+}
+
+/*used to look up the name of a OCI_DTYPE_PARAM Attribute Types
+  used only for debugging */
+char *
+oci_dtype_attr_name(ub4 attr)
+{
+	dTHX;
+	SV *sv;
+	switch (attr) {
+/*=======================Describe Handle Parameter Attributes ===============*/
+	case OCI_ATTR_DATA_SIZE:			return "OCI_ATTR_DATA_SIZE";               /* maximum size of the data */
+	case OCI_ATTR_DATA_TYPE:			return "OCI_ATTR_DATA_TYPE"; /* the SQL type of the column/argument */
+	case OCI_ATTR_DISP_SIZE:			return "OCI_ATTR_DISP_SIZE"; /* the display size */
+	case OCI_ATTR_NAME:					return "OCI_ATTR_NAME"; /* the name of the column/argument */
+	case OCI_ATTR_PRECISION:			return "OCI_ATTR_PRECISION"; /* precision if number type */
+	case OCI_ATTR_SCALE:				return "OCI_ATTR_SCALE"; /* scale if number type */
+	case OCI_ATTR_IS_NULL:				return "OCI_ATTR_IS_NULL"; /* is it null ? */
+	case OCI_ATTR_TYPE_NAME: 			return "OCI_ATTR_TYPE_NAME"; 
+  /* name of the named data type or a package name for package private types */
+	case OCI_ATTR_SCHEMA_NAME: 			return "OCI_ATTR_SCHEMA_NAME";  /* the schema name */
+	case OCI_ATTR_SUB_NAME: 			return "OCI_ATTR_SUB_NAME";  /* type name if package private type */
+	case OCI_ATTR_POSITION:				return "OCI_ATTR_POSITION"; 
+	case OCI_ATTR_CHAR_USED:            return "OCI_ATTR_CHAR_USED";      /* char length semantics */
+	case OCI_ATTR_CHAR_SIZE:             return "OCI_ATTR_CHAR_SIZE";                /* char length */
+	case OCI_ATTR_CHARSET_ID:			return "OCI_ATTR_CHARSET_ID";                           /* Character Set ID */
+	case OCI_ATTR_CHARSET_FORM:			return "OCI_ATTR_CHARSET_FORM";                       /* Character Set Form */
+	}
+	
+	sv = sv_2mortal(newSViv((IV)attr));
+	return SvPV(sv,na);
+
+}
+
+/*used to look up the name of non a OCI_DTYPE_PARAM Attribute Types
+  used only for debugging */
+char *
+oci_attr_name(ub4 attr)
+{
+	dTHX;
+	SV *sv;
+	switch (attr) {
+	/*=============================Attribute Types===============================*/
+
+	
+	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 */
+	case OCI_ATTR_NONBLOCKING_MODE:		return "OCI_ATTR_NONBLOCKING_MODE";                   /* non blocking mode */
+	case OCI_ATTR_SQLCODE:				return "OCI_ATTR_SQLCODE";                                  /* the SQL verb */
+	case OCI_ATTR_ENV:					return "OCI_ATTR_ENV";                            /* the environment handle */
+	case OCI_ATTR_SERVER:				return "OCI_ATTR_SERVER";                               /* the server handle*/
+	case OCI_ATTR_SESSION:				return "OCI_ATTR_SESSION";                        /* the user session handle*/
+	case OCI_ATTR_TRANS:				return "OCI_ATTR_TRANS";                         /* the transaction handle */
+	case OCI_ATTR_ROW_COUNT:			return "OCI_ATTR_ROW_COUNT";                  /* the rows processed so far */
+	case OCI_ATTR_SQLFNCODE:			return "OCI_ATTR_SQLFNCODE";               /* the SQL verb of the statement */
+	case OCI_ATTR_PREFETCH_ROWS:		return "OCI_ATTR_PREFETCH_ROWS";    /* sets the number of rows to prefetch */
+	case OCI_ATTR_NESTED_PREFETCH_ROWS:	return "OCI_ATTR_NESTED_PREFETCH_ROWS"; /* the prefetch rows of nested table*/
+	case OCI_ATTR_PREFETCH_MEMORY:		return "OCI_ATTR_PREFETCH_MEMORY";         /* memory limit for rows fetched */
+	case OCI_ATTR_NESTED_PREFETCH_MEMORY:return "OCI_ATTR_NESTED_PREFETCH_MEMORY";   /* memory limit for nested rows */
+	case OCI_ATTR_CHAR_COUNT:			return "OCI_ATTR_CHAR_COUNT";
+	                    /* this specifies the bind and define size in characters */
+	case OCI_ATTR_PDSCL:				return "OCI_ATTR_PDSCL";                          /* packed decimal scale
+	case OCI_ATTR_FSPRECISION OCI_ATTR_PDSCL:return "";*/
+	                                          /* fs prec for datetime data types */
+	case OCI_ATTR_PDPRC:				return "OCI_ATTR_PDPRC";                         /* packed decimal format
+	case OCI_ATTR_LFPRECISION OCI_ATTR_PDPRC: return "";
+	                                          /* fs prec for datetime data types */
+	case OCI_ATTR_PARAM_COUNT:			return "OCI_ATTR_PARAM_COUNT";       /* number of column in the select list */
+	case OCI_ATTR_ROWID:				return "OCI_ATTR_ROWID";                                     /* the rowid */
+	case OCI_ATTR_CHARSET:				return "OCI_ATTR_CHARSET";                     /* the character set value */
+	case OCI_ATTR_NCHAR:				return "OCI_ATTR_NCHAR"; /* NCHAR type */
+	case OCI_ATTR_USERNAME:				return "OCI_ATTR_USERNAME"; /* username attribute */
+	case OCI_ATTR_PASSWORD:				return "OCI_ATTR_PASSWORD";                           /* password attribute */
+	case OCI_ATTR_STMT_TYPE:			return "OCI_ATTR_STMT_TYPE";                           /* statement type */
+	case OCI_ATTR_INTERNAL_NAME:		return "OCI_ATTR_INTERNAL_NAME";             /* user friendly global name */
+	case OCI_ATTR_EXTERNAL_NAME:		return "OCI_ATTR_EXTERNAL_NAME";      /* the internal name for global txn */
+	case OCI_ATTR_XID:					return "OCI_ATTR_XID";           /* XOPEN defined global transaction id */
+	case OCI_ATTR_TRANS_LOCK:			return "OCI_ATTR_TRANS_LOCK";                                            /* */
+	case OCI_ATTR_TRANS_NAME:			return "OCI_ATTR_TRANS_NAME";    /* string to identify a global transaction */
+	case OCI_ATTR_HEAPALLOC:			return "OCI_ATTR_HEAPALLOC";                /* memory allocated on the heap */
+	case OCI_ATTR_CHARSET_FORM:			return "OCI_ATTR_CHARSET_FORM";                       /* Character Set Form */
+	case OCI_ATTR_MAXDATA_SIZE:			return "OCI_ATTR_MAXDATA_SIZE";       /* Maximumsize of data on the server  */
+	case OCI_ATTR_CACHE_OPT_SIZE:		return "OCI_ATTR_CACHE_OPT_SIZE";              /* object cache optimal size */
+	case OCI_ATTR_CACHE_MAX_SIZE:		return "OCI_ATTR_CACHE_MAX_SIZE";   /* object cache maximum size percentage */
+	case OCI_ATTR_PINOPTION:			return "OCI_ATTR_PINOPTION";             /* object cache default pin option */
+	case OCI_ATTR_ALLOC_DURATION:		return "OCI_ATTR_ALLOC_DURATION";
+	                                 /* object cache default allocation duration */
+	case OCI_ATTR_PIN_DURATION:				return "OCI_ATTR_PIN_DURATION";        /* object cache default pin duration */
+	case OCI_ATTR_FDO:					return "OCI_ATTR_FDO";       /* Format Descriptor object attribute */
+	case OCI_ATTR_POSTPROCESSING_CALLBACK:		return "OCI_ATTR_POSTPROCESSING_CALLBACK";
+	                                         /* Callback to process outbind data */
+	case OCI_ATTR_POSTPROCESSING_CONTEXT:		return "OCI_ATTR_POSTPROCESSING_CONTEXT";
+	                                 /* Callback context to process outbind data */
+	case OCI_ATTR_ROWS_RETURNED:		return "OCI_ATTR_ROWS_RETURNED";
+	               /* Number of rows returned in current iter - for Bind handles */
+	case OCI_ATTR_FOCBK:				return "OCI_ATTR_FOCBK";              /* Failover Callback attribute */
+	case OCI_ATTR_IN_V8_MODE:			return "OCI_ATTR_IN_V8_MODE"; /* is the server/service context in V8 mode */
+	case OCI_ATTR_LOBEMPTY:				return "OCI_ATTR_LOBEMPTY";                              /* empty lob ? */
+	case OCI_ATTR_SESSLANG:				return "OCI_ATTR_SESSLANG";                  /* session language handle */
+
+	case OCI_ATTR_VISIBILITY:			return "OCI_ATTR_VISIBILITY";                     /* visibility */
+	case OCI_ATTR_RELATIVE_MSGID:		return "OCI_ATTR_RELATIVE_MSGID";            /* relative message id */
+	case OCI_ATTR_SEQUENCE_DEVIATION:	return "OCI_ATTR_SEQUENCE_DEVIATION";             /* sequence deviation */
+
+	case OCI_ATTR_CONSUMER_NAME:		return "OCI_ATTR_CONSUMER_NAME";                  /* consumer name */
+	case OCI_ATTR_DEQ_MODE:				return "OCI_ATTR_DEQ_MODE";                   /* dequeue mode */
+	case OCI_ATTR_NAVIGATION:			return "OCI_ATTR_NAVIGATION";                     /* navigation */
+	case OCI_ATTR_WAIT:					return "OCI_ATTR_WAIT";                           /* wait */
+	case OCI_ATTR_DEQ_MSGID:			return "OCI_ATTR_DEQ_MSGID";             /* dequeue message id */
+
+	case OCI_ATTR_PRIORITY:				return "OCI_ATTR_PRIORITY";                       /* priority */
+	case OCI_ATTR_DELAY:				return "OCI_ATTR_DELAY";                          /* delay */
+	case OCI_ATTR_EXPIRATION:			return "OCI_ATTR_EXPIRATION";                     /* expiration */
+	case OCI_ATTR_CORRELATION:			return "OCI_ATTR_CORRELATION";                 /* correlation id */
+	case OCI_ATTR_ATTEMPTS:				return "OCI_ATTR_ATTEMPTS";                 /* # of attempts */
+	case OCI_ATTR_RECIPIENT_LIST:		return "OCI_ATTR_RECIPIENT_LIST";                 /* recipient list */
+	case OCI_ATTR_EXCEPTION_QUEUE:		return "OCI_ATTR_EXCEPTION_QUEUE";           /* exception queue name */
+	case OCI_ATTR_ENQ_TIME:				return "OCI_ATTR_ENQ_TIME";/* enqueue time (only OCIAttrGet) */
+	case OCI_ATTR_MSG_STATE:			return "OCI_ATTR_MSG_STATE";/* message state (only OCIAttrGet) */
+	                                                   /* NOTE: 64-66 used below */
+	case OCI_ATTR_AGENT_NAME:			return "OCI_ATTR_AGENT_NAME";                 /* agent name */
+	case OCI_ATTR_AGENT_ADDRESS:		return "OCI_ATTR_AGENT_ADDRESS";                  /* agent address */
+	case OCI_ATTR_AGENT_PROTOCOL:		return "OCI_ATTR_AGENT_PROTOCOL";                /* agent protocol */
+
+	case OCI_ATTR_SENDER_ID:			return "OCI_ATTR_SENDER_ID";                      /* sender id */
+	case OCI_ATTR_ORIGINAL_MSGID:		return "OCI_ATTR_ORIGINAL_MSGID";           /* original message id */
+
+	case OCI_ATTR_QUEUE_NAME:			return "OCI_ATTR_QUEUE_NAME";                     /* queue name */
+	case OCI_ATTR_NFY_MSGID:			return "OCI_ATTR_NFY_MSGID";                     /* message id */
+	case OCI_ATTR_MSG_PROP:				return "OCI_ATTR_MSG_PROP";            /* message properties */
+
+	case OCI_ATTR_NUM_DML_ERRORS:		return "OCI_ATTR_NUM_DML_ERRORS";       /* num of errs in array DML */
+	case OCI_ATTR_DML_ROW_OFFSET:		return "OCI_ATTR_DML_ROW_OFFSET";       /* row offset in the array */
+
+	case OCI_ATTR_DATEFORMAT:			return "OCI_ATTR_DATEFORMAT";     /* default date format string */
+	case OCI_ATTR_BUF_ADDR:				return "OCI_ATTR_BUF_ADDR";                 /* buffer address */
+	case OCI_ATTR_BUF_SIZE:				return "OCI_ATTR_BUF_SIZE";                   /* buffer size */
+	case OCI_ATTR_DIRPATH_MODE:			return "OCI_ATTR_DIRPATH_MODE";  /* mode of direct path operation */
+	case OCI_ATTR_DIRPATH_NOLOG:		return "OCI_ATTR_DIRPATH_NOLOG";               /* nologging option */
+	case OCI_ATTR_DIRPATH_PARALLEL:		return "OCI_ATTR_DIRPATH_PARALLEL";    /* parallel (temp seg) option */
+	case OCI_ATTR_NUM_ROWS:				return "OCI_ATTR_NUM_ROWS"; /* number of rows in column array */
+	                                  /* NOTE that OCI_ATTR_NUM_COLS is a column
+	                                   * array attribute too.
+	                                   */
+	case OCI_ATTR_COL_COUNT:			return "OCI_ATTR_COL_COUNT";        /* columns of column array
+	                                                     processed so far.       */
+	case OCI_ATTR_STREAM_OFFSET:		return "OCI_ATTR_STREAM_OFFSET";  /* str off of last row processed
+	case OCI_ATTR_SHARED_HEAPALLO:				return "";    /* Shared Heap Allocation Size */
+
+	case OCI_ATTR_SERVER_GROUP:			return "OCI_ATTR_SERVER_GROUP";    /* server group name */
+
+	case OCI_ATTR_MIGSESSION:			return "OCI_ATTR_MIGSESSION";  /* migratable session attribute */
+
+	case OCI_ATTR_NOCACHE:				return "OCI_ATTR_NOCACHE";                /* Temporary LOBs */
+
+	case OCI_ATTR_MEMPOOL_SIZE:			return "OCI_ATTR_MEMPOOL_SIZE";                      /* Pool Size */
+	case OCI_ATTR_MEMPOOL_INSTNAME:		return "OCI_ATTR_MEMPOOL_INSTNAME";                /* Instance name */
+	case OCI_ATTR_MEMPOOL_APPNAME:		return "OCI_ATTR_MEMPOOL_APPNAME";               /* Application name */
+	case OCI_ATTR_MEMPOOL_HOMENAME:		return "OCI_ATTR_MEMPOOL_HOMENAME";            /* Home Directory name */
+	case OCI_ATTR_MEMPOOL_MODEL:		return "OCI_ATTR_MEMPOOL_MODEL";     /* Pool Model (proc,thrd,both)*/
+	case OCI_ATTR_MODES:				return "OCI_ATTR_MODES";                          /* Modes */
+
+	case OCI_ATTR_SUBSCR_NAME:			return "OCI_ATTR_SUBSCR_NAME";           /* name of subscription */
+	case OCI_ATTR_SUBSCR_CALLBACK:		return "OCI_ATTR_SUBSCR_CALLBACK";            /* associated callback */
+	case OCI_ATTR_SUBSCR_CTX:			return "OCI_ATTR_SUBSCR_CTX";   /* associated callback context */
+	case OCI_ATTR_SUBSCR_PAYLOAD:		return "OCI_ATTR_SUBSCR_PAYLOAD";             /* associated payload */
+	case OCI_ATTR_SUBSCR_NAMESPACE:		return "OCI_ATTR_SUBSCR_NAMESPACE";          /* associated namespace */
+
+	case OCI_ATTR_PROXY_CREDENTIALS:	return "OCI_ATTR_PROXY_CREDENTIALS";         /* Proxy user credentials */
+	case OCI_ATTR_INITIAL_CLIENT_ROLES:	return "OCI_ATTR_INITIAL_CLIENT_ROLES";      /* Initial client role list */
+
+	case OCI_ATTR_UNK:					return "OCI_ATTR_UNK";                  /* unknown attribute */
+	case OCI_ATTR_NUM_COLS:				return "OCI_ATTR_NUM_COLS";                  /* number of columns */
+	case OCI_ATTR_LIST_COLUMNS:			return "OCI_ATTR_LIST_COLUMNS";       /* parameter of the column list */
+	case OCI_ATTR_RDBA:					return "OCI_ATTR_RDBA";           /* DBA of the segment header */
+	case OCI_ATTR_CLUSTERED:			return "OCI_ATTR_CLUSTERED";      /* whether the table is clustered */
+	case OCI_ATTR_PARTITIONED:			return "OCI_ATTR_PARTITIONED";    /* whether the table is partitioned */
+	case OCI_ATTR_INDEX_ONLY:			return "OCI_ATTR_INDEX_ONLY";     /* whether the table is index only */
+	case OCI_ATTR_LIST_ARGUMENTS:		return "OCI_ATTR_LIST_ARGUMENTS";      /* parameter of the argument list */
+	case OCI_ATTR_LIST_SUBPROGRAMS:		return "OCI_ATTR_LIST_SUBPROGRAMS";    /* parameter of the subprogram list */
+	case OCI_ATTR_REF_TDO:				return "OCI_ATTR_REF_TDO";          /* REF to the type descriptor */
+	case OCI_ATTR_LINK:					return "OCI_ATTR_LINK";              /* the database link name */
+	case OCI_ATTR_MIN:					return "OCI_ATTR_MIN";                       /* minimum value */
+	case OCI_ATTR_MAX:					return "OCI_ATTR_MAX";                       /* maximum value */
+	case OCI_ATTR_INCR:					return "OCI_ATTR_INCR";                     /* increment value */
+	case OCI_ATTR_CACHE:				return "OCI_ATTR_CACHE";   /* number of sequence numbers cached */
+	case OCI_ATTR_ORDER:				return "OCI_ATTR_ORDER";     /* whether the sequence is ordered */
+	case OCI_ATTR_HW_MARK:				return "OCI_ATTR_HW_MARK";                     /* high-water mark */
+	case OCI_ATTR_TYPE_SCHEMA:			return "OCI_ATTR_TYPE_SCHEMA";                  /* type's schema name */
+	case OCI_ATTR_TIMESTAMP:			return "OCI_ATTR_TIMESTAMP";             /* timestamp of the object */
+	case OCI_ATTR_NUM_ATTRS:			return "OCI_ATTR_NUM_ATTRS";                /* number of sttributes */
+	case OCI_ATTR_NUM_PARAMS:			return "OCI_ATTR_NUM_PARAMS";                /* number of parameters */
+	case OCI_ATTR_OBJID:				return "OCI_ATTR_OBJID";       /* object id for a table or view */
+	case OCI_ATTR_PTYPE:				return "OCI_ATTR_PTYPE";           /* type of info described by */
+	case OCI_ATTR_PARAM:				return "OCI_ATTR_PARAM";                /* parameter descriptor */
+	case OCI_ATTR_OVERLOAD_ID:			return "OCI_ATTR_OVERLOAD_ID";     /* overload ID for funcs and procs */
+	case OCI_ATTR_TABLESPACE:			return "OCI_ATTR_TABLESPACE";                    /* table name space */
+	case OCI_ATTR_TDO:					return "OCI_ATTR_TDO";                       /* TDO of a type */
+	case OCI_ATTR_LTYPE:				return "OCI_ATTR_LTYPE";                           /* list type */
+	case OCI_ATTR_PARSE_ERROR_OFFSET:	return "OCI_ATTR_PARSE_ERROR_OFFSET";               /* Parse Error offset */
+	case OCI_ATTR_IS_TEMPORARY:			return "OCI_ATTR_IS_TEMPORARY";          /* whether table is temporary */
+	case OCI_ATTR_IS_TYPED:				return "OCI_ATTR_IS_TYPED";              /* whether table is typed */
+	case OCI_ATTR_DURATION:				return "OCI_ATTR_DURATION";         /* duration of temporary table */
+	case OCI_ATTR_IS_INVOKER_RIGHTS:	return "OCI_ATTR_IS_INVOKER_RIGHTS";                 /* is invoker rights */
+	case OCI_ATTR_OBJ_NAME:				return "OCI_ATTR_OBJ_NAME";           /* top level schema obj name */
+	case OCI_ATTR_OBJ_SCHEMA:			return "OCI_ATTR_OBJ_SCHEMA";                         /* schema name */
+	case OCI_ATTR_OBJ_ID:				return "OCI_ATTR_OBJ_ID";          /* top level schema object id */
+
+	case OCI_ATTR_DIRPATH_SORTED_INDEX:	return "OCI_ATTR_DIRPATH_SORTED_INDEX";/* index that data is sorted on */
+
+	            /* direct path index maint method (see oci8dp.h) */
+	case OCI_ATTR_DIRPATH_INDEX_MAINT_METHOD:	return "OCI_ATTR_DIRPATH_INDEX_MAINT_METHOD";
+
+	    /* parallel load: db file, initial and next extent sizes */
+
+	case OCI_ATTR_DIRPATH_FILE:			return "OCI_ATTR_DIRPATH_FILE";     /* DB file to load into */
+	case OCI_ATTR_DIRPATH_STORAGE_INITIAL:		return "OCI_ATTR_DIRPATH_STORAGE_INITIAL";       /* initial extent size */
+	case OCI_ATTR_DIRPATH_STORAGE_NEXT:	return "OCI_ATTR_DIRPATH_STORAGE_NEXT";          /* next extent size */
+
+
+	case OCI_ATTR_TRANS_TIMEOUT:		return "OCI_ATTR_TRANS_TIMEOUT";      /* transaction timeout */
+	case OCI_ATTR_SERVER_STATUS:		return "OCI_ATTR_SERVER_STATUS";/* state of the server handle */
+	case OCI_ATTR_STATEMENT:			return "OCI_ATTR_STATEMENT"; /* statement txt in stmt hdl */
+	                                /* statement should not be executed in cache
+	case OCI_ATTR_NO_CACHE:				return "";*/
+	case OCI_ATTR_DEQCOND:				return "OCI_ATTR_DEQCOND";         /* dequeue condition */
+	case OCI_ATTR_RESERVED_2:			return "OCI_ATTR_RESERVED_2";                  /* reserved */
+
+
+	case OCI_ATTR_SUBSCR_RECPT:			return "OCI_ATTR_SUBSCR_RECPT";/* recepient of subscription */
+	case OCI_ATTR_SUBSCR_RECPTPROTO:	return "OCI_ATTR_SUBSCR_RECPTPROTO";    /* protocol for recepient */
+
+	    /* 8.2 dpapi support of ADTs */
+	case OCI_ATTR_DIRPATH_EXPR_TYPE:	return "OCI_ATTR_DIRPATH_EXPR_TYPE";       /* expr type of OCI_ATTR_NAME */
+
+	case OCI_ATTR_DIRPATH_INPUT:		return "OCI_ATTR_DIRPATH_INPUT";    /* input in text or stream format
+	case OCI_DIRPATH_INPUT_TEXT:				return "";
+	case OCI_DIRPATH_INPUT_STREAM:				return "";
+	case OCI_DIRPATH_INPUT_UNKNOWN:				return "";	*/
+	case OCI_ATTR_LDAP_HOST:			return "OCI_ATTR_LDAP_HOST";             /* LDAP host to connect to */
+	case OCI_ATTR_LDAP_PORT:			return "OCI_ATTR_LDAP_PORT";              /* LDAP port to connect to */
+	case OCI_ATTR_BIND_DN:				return "OCI_ATTR_BIND_DN";                              /* bind DN */
+	case OCI_ATTR_LDAP_CRED:			return "OCI_ATTR_LDAP_CRED";       /* credentials to connect to LDAP */
+	case OCI_ATTR_WALL_LOC:				return "OCI_ATTR_WALL_LOC";               /* client wallet location */
+	case OCI_ATTR_LDAP_AUTH:			return "OCI_ATTR_LDAP_AUTH";           /* LDAP authentication method */
+	case OCI_ATTR_LDAP_CTX:				return "OCI_ATTR_LDAP_CTX";        /* LDAP adminstration context DN */
+	case OCI_ATTR_SERVER_DNS:			return "OCI_ATTR_SERVER_DNS";      /* list of registration server DNs */
+
+	case OCI_ATTR_DN_COUNT:				return "OCI_ATTR_DN_COUNT";             /* the number of server DNs */
+	case OCI_ATTR_SERVER_DN:			return "OCI_ATTR_SERVER_DN";                 /* server DN attribute */
+
+	case OCI_ATTR_MAXCHAR_SIZE:			return "OCI_ATTR_MAXCHAR_SIZE";    /* max char size of data */
+
+	case OCI_ATTR_CURRENT_POSITION:		return "OCI_ATTR_CURRENT_POSITION"; /* for scrollable result sets*/
+
+	/* Added to get attributes for ref cursor to statement handle */
+	case OCI_ATTR_RESERVED_3:			return "OCI_ATTR_RESERVED_3";                  /* reserved */
+	case OCI_ATTR_RESERVED_4:			return "OCI_ATTR_RESERVED_4";                  /* reserved */
+	case OCI_ATTR_DIRPATH_FN_CTX:		return "";  /* fn ctx ADT attrs or args */
+	case OCI_ATTR_DIGEST_ALGO:			return "OCI_ATTR_DIRPATH_FN_CTX";         /* digest algorithm */
+	case OCI_ATTR_CERTIFICATE:			return "OCI_ATTR_CERTIFICATE";               /* certificate */
+	case OCI_ATTR_SIGNATURE_ALGO:		return "OCI_ATTR_SIGNATURE_ALGO";       /* signature algorithm */
+	case OCI_ATTR_CANONICAL_ALGO:		return "OCI_ATTR_CANONICAL_ALGO";    /* canonicalization algo. */
+	case OCI_ATTR_PRIVATE_KEY:			return "OCI_ATTR_PRIVATE_KEY";               /* private key */
+	case OCI_ATTR_DIGEST_VALUE:			return "OCI_ATTR_DIGEST_VALUE";             /* digest value */
+	case OCI_ATTR_SIGNATURE_VAL:		return "OCI_ATTR_SIGNATURE_VAL";           /* signature value */
+	case OCI_ATTR_SIGNATURE:			return "OCI_ATTR_SIGNATURE";                 /* signature */
+
+	/* attributes for setting OCI stmt caching specifics in svchp */
+	case OCI_ATTR_STMTCACHESIZE :		return "OCI_ATTR_STMTCACHESIZE";     /* size of the stm cache */
+
+	/* --------------------------- Connection Pool Attributes ------------------ */
+	case OCI_ATTR_CONN_NOWAIT:			return "OCI_ATTR_CONN_NOWAIT";
+	case OCI_ATTR_CONN_BUSY_COUNT:		return "OCI_ATTR_CONN_BUSY_COUNT";
+	case OCI_ATTR_CONN_OPEN_COUNT:		return "OCI_ATTR_CONN_OPEN_COUNT";
+	case OCI_ATTR_CONN_TIMEOUT:			return "OCI_ATTR_CONN_TIMEOUT";
+	case OCI_ATTR_STMT_STATE:			return "OCI_ATTR_STMT_STATE";
+	case OCI_ATTR_CONN_MIN:				return "OCI_ATTR_CONN_MIN";
+	case OCI_ATTR_CONN_MAX:				return "OCI_ATTR_CONN_MAX";
+	case OCI_ATTR_CONN_INCR:			return "OCI_ATTR_CONN_INCR";
+
+	case OCI_ATTR_DIRPATH_OID:			return "OCI_ATTR_DIRPATH_OID";   /* loading into an OID col */
+
+	case OCI_ATTR_NUM_OPEN_STMTS:		return "OCI_ATTR_NUM_OPEN_STMTS";    /* open stmts in session */
+	case OCI_ATTR_DESCRIBE_NATIVE:		return "OCI_ATTR_DESCRIBE_NATIVE"; /* get native info via desc */
+
+	case OCI_ATTR_BIND_COUNT:			return "OCI_ATTR_BIND_COUNT";   /* number of bind postions */
+	case OCI_ATTR_HANDLE_POSITION:		return "OCI_ATTR_HANDLE_POSITION";/* pos of bind/define handle */
+	case OCI_ATTR_RESERVED_5:			return "OCI_ATTR_RESERVED_5";                 /* reserverd */
+	case OCI_ATTR_SERVER_BUSY:			return "OCI_ATTR_SERVER_BUSY"; /* call in progress on server*/
+
+	case OCI_ATTR_DIRPATH_SID:			return "OCI_ATTR_DIRPATH_SID";   /* loading into an SID col */
+	/* notification presentation for recipient */
+	case OCI_ATTR_SUBSCR_RECPTPRES:		return "OCI_ATTR_SUBSCR_RECPTPRES";
+	case OCI_ATTR_TRANSFORMATION:		return "OCI_ATTR_TRANSFORMATION"; /* AQ message transformation */
+
+	case OCI_ATTR_ROWS_FETCHED:			return "OCI_ATTR_ROWS_FETCHED"; /* rows fetched in last call */
+
+	/* --------------------------- Snapshot attributes ------------------------- */
+	case OCI_ATTR_SCN_BASE:				return "OCI_ATTR_SCN_BASE";          /* snapshot base */
+	case OCI_ATTR_SCN_WRAP:				return "OCI_ATTR_SCN_WRAP";            /* snapshot wrap */
+
+	/* --------------------------- Miscellanous attributes --------------------- */
+	case OCI_ATTR_RESERVED_6:			return "OCI_ATTR_RESERVED_6";                 /* reserved */
+	case OCI_ATTR_READONLY_TXN:			return "OCI_ATTR_READONLY_TXN";          /* txn is readonly */
+	case OCI_ATTR_RESERVED_7:			return "OCI_ATTR_RESERVED_7";                  /* reserved */
+	case OCI_ATTR_ERRONEOUS_COLUMN:		return "OCI_ATTR_ERRONEOUS_COLUMN"; /* position of erroneous col */
+	case OCI_ATTR_RESERVED_8:			return "OCI_ATTR_RESERVED_8";                  /* reserved */
+
+	/* -------------------- 8.2 dpapi support of ADTs continued ---------------- */
+	case OCI_ATTR_DIRPATH_OBJ_CONSTR:	return "OCI_ATTR_DIRPATH_OBJ_CONSTR"; /* obj type of subst obj tbl */
+
+	/************************FREE attribute     207      *************************/
+	/************************FREE attribute     208      *************************/
+	case OCI_ATTR_ENV_UTF16:			return "OCI_ATTR_ENV_UTF16";     /* is env in utf16 mode? */
+	case OCI_ATTR_RESERVED_9:			return "OCI_ATTR_RESERVED_9";          /* reserved for TMZ */
+	case OCI_ATTR_RESERVED_10:			return "OCI_ATTR_RESERVED_10";                 /* reserved */
+
+	/* Attr to allow setting of the stream version PRIOR to calling Prepare */
+	case OCI_ATTR_DIRPATH_STREAM_VERSION:	return "OCI_ATTR_DIRPATH_STREAM_VERSION";      /* version of the stream
+	case OCI_ATTR_RESERVED_11:				return "OCI_ATTR_RESERVED_11";                 /* reserved */
+
+	case OCI_ATTR_RESERVED_12:			return "OCI_ATTR_RESERVED_12";                 /* reserved */
+	case OCI_ATTR_RESERVED_13:			return "OCI_ATTR_RESERVED_13";                 /* reserved */
+
+	/* OCI_ATTR_RESERVED_14 */
+
+	case OCI_ATTR_RESERVED_15:			return "OCI_ATTR_RESERVED_15";                /* reserved */
+	case OCI_ATTR_RESERVED_16:			return "OCI_ATTR_RESERVED_16";                /* reserved */
+
+	}
+	sv = sv_2mortal(newSViv((IV)attr));
+	return SvPV(sv,na);
+}
+
 /*used to look up the name of a fetchtype constant
   used only for debugging */
 char *
@@ -538,6 +892,7 @@
 	/* a memory size, perhaps also default $RowCacheSize to a	*/
 	/* negative value. OCI_ATTR_PREFETCH_MEMORY */
 
+
 	if (!DBIc_ACTIVE(imp_dbh)) {
 		oci_error(sth, NULL, OCI_ERROR, "Database disconnected");
 		return 0;
@@ -561,7 +916,7 @@
 	imp_sth->auto_lob = 1;
 	imp_sth->exe_mode  = OCI_DEFAULT;
 
-		if (attribs) {
+	if (attribs) {
 		SV **svp;
 		IV ora_auto_lob = 1;
 		DBD_ATTRIB_GET_IV(  attribs, "ora_parse_lang", 14, svp, oparse_lng);
@@ -572,22 +927,26 @@
 		DBD_ATTRIB_GET_IV(  attribs, "ora_piece_lob", 13, svp, ora_piece_lob);
 		DBD_ATTRIB_GET_IV(  attribs, "ora_piece_size", 14, svp, ora_piece_size);
 
-		imp_sth->auto_lob = (ora_auto_lob) ? 1 : 0;
-		imp_sth->pers_lob = (ora_pers_lob) ? 1 : 0;
-		imp_sth->clbk_lob = (ora_clbk_lob) ? 1 : 0;
-		imp_sth->piece_lob = (ora_piece_lob) ? 1 : 0;
-		imp_sth->piece_size = (ora_piece_size) ? ora_piece_size : 0;
+		imp_sth->auto_lob	= (ora_auto_lob) ? 1 : 0;
+		imp_sth->pers_lob	= (ora_pers_lob) ? 1 : 0;
+		imp_sth->clbk_lob 	= (ora_clbk_lob) ? 1 : 0;
+		imp_sth->piece_lob	= (ora_piece_lob) ? 1 : 0;
+		imp_sth->piece_size	= (ora_piece_size) ? ora_piece_size : 0;
+		imp_sth->prefetch_rows 	= 0;
+		imp_sth->prefetch_memory= 0;
 		/* ora_check_sql only works for selects owing to Oracle behaviour */
 		DBD_ATTRIB_GET_IV(  attribs, "ora_check_sql", 13, svp, ora_check_sql);
 		DBD_ATTRIB_GET_IV(  attribs, "ora_exe_mode", 12, svp, imp_sth->exe_mode);
 		DBD_ATTRIB_GET_IV(  attribs, "ora_prefetch_memory",  19, svp, imp_sth->prefetch_memory);
+		DBD_ATTRIB_GET_IV(  attribs, "ora_prefetch_rows",  17, svp, imp_sth->prefetch_rows);
+		DBD_ATTRIB_GET_IV(  attribs, "ora_row_cache_off",  17, svp, imp_sth->row_cache_off);
 		DBD_ATTRIB_GET_IV(  attribs, "ora_verbose",  11, svp, dbd_verbose);
 		DBD_ATTRIB_GET_IV(  attribs, "ora_oci_success_warn",  20, svp, oci_warn);
 		DBD_ATTRIB_GET_IV(  attribs, "ora_objects",  11, svp, ora_objects);
 
 		if (!dbd_verbose)
 			DBD_ATTRIB_GET_IV(  attribs, "dbd_verbose",  11, svp, dbd_verbose);
-		}
+	}
 
 
  	/* scan statement for '?', ':1' and/or ':foo' style placeholders	*/
@@ -630,8 +989,8 @@
 	DBIc_IMPSET_on(imp_sth);
 
 	if (ora_check_sql) {
-	if (!dbd_describe(sth, imp_sth))
-		return 0;
+		if (!dbd_describe(sth, imp_sth))
+			return 0;
 	}
 	else {
 		/* set initial cache size by memory */
@@ -1025,7 +1384,6 @@
 
 		imp_sth_nested->stmhp = stmhp_nested;
 		imp_sth_nested->nested_cursor = 1;
-		imp_sth_nested->rs_array_on = 1;
 		imp_sth_nested->stmt_type = OCI_STMT_SELECT;
 
 		DBIc_IMPSET_on(imp_sth_nested);
@@ -1515,8 +1873,8 @@
 			0, 0, (ub2)0, csform, status);
 		if (DBIS->debug >= 3 || dbd_verbose >= 3 )
 			PerlIO_printf(DBILOGFP,
-			"		OCILobRead %s %s: csform %d, LOBlen %luc, LongReadLen %luc, BufLen %lub, Got %luc\n",
-				name, oci_status_name(status), csform, ul_t(loblen),
+			"		OCILobRead %s %s: csform %d (%s), LOBlen %luc, LongReadLen %luc, BufLen %lub, Got %luc\n",
+				name, oci_status_name(status), csform,oci_csform_name(csform), ul_t(loblen),
 				ul_t(imp_sth->long_readlen), ul_t(buflen), ul_t(amtp));
 
 		if (ftype == 114) {
@@ -1592,33 +1950,45 @@
 
 
 static int
-calc_cache_rows(int cache_rows, int num_fields, int est_width, int has_longs)
+calc_cache_rows(int cache_rows, int num_fields, int est_width, int has_longs,ub4 prefetch_memory)
 {
 	dTHX;
-	if (has_longs)			/* override/disable caching	*/
+	/* Use guessed average on-the-wire row width calculated above &	*/
+	/* add in overhead of 5 bytes per field plus 8 bytes per row.	*/
+	/* The n*5+8 was determined by studying SQL*Net v2 packets.	*/
+	/* It could probably benefit from a more detailed analysis.	*/
+
+	est_width += num_fields*5 + 8;
+
+	if (has_longs) {			/* override/disable caching	*/
 		cache_rows = 1;		/* else read_blob can't work	*/
-	else
+	}
+	else if (prefetch_memory) { /*set rows by memory*/
+
+		cache_rows=prefetch_memory/est_width;
+	}
+	else{
 		if (cache_rows == 0) {		/* automatically size the cache	*/
+		/* automatically size the cache	*/
 
-			/* Oracle packets on ethernet have max size of around 1460.	*/
-			/* We'll aim to fill our row cache with around 10 per go.	*/
-			/* Using 10 means any 'runt' packets will have less impact.	*/
-			int txfr_size  = 10 * 1460;	/* desired transfer/cache size	*/
-
-			/* Use guessed average on-the-wire row width calculated above &	*/
-			/* add in overhead of 5 bytes per field plus 8 bytes per row.	*/
-			/* The n*5+8 was determined by studying SQL*Net v2 packets.	*/
-			/* It could probably benefit from a more detailed analysis.	*/
-			est_width += num_fields*5 + 8;
-
-			cache_rows = txfr_size / est_width;		  /* (maybe 1 or 0)	*/
-
-			/* To ensure good performance with large rows (near or larger	*/
-			/* than our target transfer size) we set a minimum cache size.	*/
-			if (cache_rows < 6)	/* is cache a 'useful' size?	*/
-				cache_rows = (cache_rows > 0) ? 6 : 4;
+		/* Oracle packets on ethernet have max size of around 1460.	*/
+		/* We'll aim to fill our row cache with around 10 per go.	*/
+		/* Using 10 means any 'runt' packets will have less impact.	*/
+		/* orginally set up as above but playing around with newer versions*/
+		/* I found that 500 was much faster*/
+		int txfr_size  = 500 * 1460;	/* desired transfer/cache size	*/
+
+		cache_rows = txfr_size / est_width;		  /* (maybe 1 or 0)	*/
+
+		/* To ensure good performance with large rows (near or larger	*/
+		/* than our target transfer size) we set a minimum cache size.	*/
+		/* I made them all at least 10* what they were before this */
+		/* main reasoning this old value reprewneted a norm in the oralce 7~8 */
+		/* 9 to 11 can handel much much more */
+		if (cache_rows < 60)	/* is cache a 'useful' size?	*/
+			cache_rows = (cache_rows > 0) ? 60 : 40;
 		}
-
+	}
 	if (cache_rows > 10000000)	/* keep within Oracle's limits  */
 		cache_rows = 10000000;	/* seems it was ub2 at one time now ub4 this number is arbitary on my part*/
 
@@ -2265,41 +2635,78 @@
 void rs_array_init(imp_sth_t *imp_sth)
 {
 	dTHX;
-	if (imp_sth->rs_array_on!=1		||
+/*	if (imp_sth->rs_array_on!=1		||
 		imp_sth->rs_array_size<1	||
 		imp_sth->rs_array_size>128){
 
 		imp_sth->rs_array_on=0;
 		imp_sth->rs_array_size=1;
 
-	}
-	imp_sth->rs_array_num_rows=0;
-	imp_sth->rs_array_idx=0;
-	imp_sth->rs_array_status=OCI_SUCCESS;
+	}*/
+	imp_sth->rs_array_num_rows	=0;
+	imp_sth->rs_array_idx		=0;
+	imp_sth->rs_fetch_count		=0;
+	/*imp_sth->prefetch_rows		=0;
+	imp_sth->prefetch_memory	=0;*/
+	imp_sth->rs_array_status	=OCI_SUCCESS;
+
 	if (DBIS->debug >= 3 || dbd_verbose >= 3 )
-		PerlIO_printf(DBILOGFP, "	rs_array_init: rs_array_on=%d, rs_array_size=%d\n",imp_sth->rs_array_on,imp_sth->rs_array_size);
+		PerlIO_printf(DBILOGFP, "	rs_array_init:imp_sth->rs_array_size=%d, rs_array_idx=%d, prefetch_rows=%d, rs_array_status=%s\n",imp_sth->rs_array_size,imp_sth->rs_array_idx,imp_sth->prefetch_rows,oci_status_name(imp_sth->rs_array_status));
 }
 
 
-static int			/* --- Setup the row cache for this sth --- */
+
+
+
+
+
+
+
+
+
+
+
+
+
+/*static int			/* --- Setup the row cache for this sth --- */
 sth_set_row_cache(SV *h, imp_sth_t *imp_sth, int max_cache_rows, int num_fields, int has_longs)
 {
 	dTHX;
 	D_imp_dbh_from_sth;
 	D_imp_drh_from_dbh;
-	int num_errors	= 0;
-	ub4 cache_mem	= 0;
-	sb4 cache_rows	= 10000;/* set high so memory is the limit */
+	int num_errors		= 0;
+	ub4 prefetch_mem	= 0; /*Oracle prefetch memory buffer*/
+	sb4 prefetch_rows	= 0; /*Oracle prefetch Row Buffer*/
+	sb4 cache_rows		= 0;/* set high so memory is the limit */
 	sword status;
 
-	/* reworked this is little so the user can set up his own cache
-	  basically if rowcachesize or prefetch_mem is set it uses those values
-	  otherwise it does it itself
-	  no sure what happens in the last case but I lwft it in for now
-	  Also I think in later version of OCI this call does not really do anything
-	*/
+	if (imp_dbh->RowCacheSize){
+	  cache_rows=imp_dbh->RowCacheSize;
+	}
+
+	/* seems that RowCacheSize was incorrectly used in the past
+	   in the DBI Spect  RowCacheSize is to be used for a local row cache
+
+	   From DBI POD
+	      A hint to the driver indicating the size of the local
+	      row cache that the application would like the driver to
+	      use for future SELECT statements.
+
+	   so RowCacheSize is for a local cache to cut down on round trips
+
+	   The OCI doc state that both OCI_ATTR_PREFETCH_ROWS OCI_ATTR_PREFETCH_MEMORY
+	   sets up a cleint side cache but in earluer version that 1.24 we only selected
+	   one record at a time from the fetch this means a round trip (at least to the local cache)
+	   at each fetch.
+
+	   With the new array fetch we truly have a local cache so I will use it
+	   RowCacheSize to set the value of that cache or the array fetch*/
+
+
+
+	/* number of rows to cache	 if using oraperl  will leave this in for now*/
+
 
-	/* number of rows to cache	 if using oraperl */
 	if (SvOK(imp_drh->ora_cache_o)){
 		imp_sth->cache_rows = SvIV(imp_drh->ora_cache_o);
 	}
@@ -2307,53 +2714,52 @@
 		imp_sth->cache_rows = SvIV(imp_drh->ora_cache);
 	}
 
+	if (imp_dbh->RowCacheSize){ /* defalut value*/
+	  cache_rows=imp_dbh->RowCacheSize;
+	}
 
-	if (imp_sth->is_child  || imp_sth->ret_lobs){ /*ref cursors and sp only one row is allowed*/
-
-	       cache_rows  =1;
-		   cache_mem  =0;
-
-	} else if (imp_dbh->RowCacheSize || imp_sth->prefetch_memory){
-	/*user set values */
-		 cache_rows  =imp_dbh->RowCacheSize;
-		 cache_mem	=imp_sth->prefetch_memory;
-
-	} else if (imp_sth->cache_rows >= 0) {	/* set cache size by row count	*/
-
-		/* imp_sth->est_width needs to be set */
-		cache_mem  = 0;			 /* so memory isn't the limit */
+	prefetch_rows	=imp_sth->prefetch_rows;
+	prefetch_mem	=imp_sth->prefetch_memory;
 
-		cache_rows = calc_cache_rows(imp_sth->cache_rows,(int)num_fields, imp_sth->est_width, has_longs);
 
-		if (max_cache_rows && cache_rows > (signed long) max_cache_rows)
-			cache_rows = max_cache_rows;
+	if (!cache_rows) { /*start with this value if not set then set default cache */
 
-		imp_sth->cache_rows = cache_rows;	/* record updated value */
+		cache_rows=calc_cache_rows(imp_sth->cache_rows,(int)num_fields, imp_sth->est_width, has_longs,0);
 
-	}
-	else {				/* set cache size by memory	*/
-						/* not sure if we ever reach this*/
-		cache_mem  = -imp_sth->cache_rows; /* cache_mem always +ve here */
-		if (max_cache_rows &&  cache_rows > (signed long) max_cache_rows) {
-			cache_rows = max_cache_rows;
-			imp_sth->cache_rows = cache_rows;	/* record updated value only if max_cache_rows */
+		if(!prefetch_rows && !prefetch_mem){ /*if there are not prefetch rows make sure I set it here to the default*/
+			  prefetch_rows=cache_rows;
 		}
+	}
+	else if (imp_dbh->RowCacheSize < 0) {/* for compaibility with DBI doc negitive value here means use the value as memory*/
+		prefetch_mem	=-imp_dbh->RowCacheSize; /* cache_mem always +ve here */
+		prefetch_rows	=0;
+		cache_rows=calc_cache_rows(imp_sth->cache_rows,(int)num_fields, imp_sth->est_width, has_longs,prefetch_mem);
+		/*The above fucntion will set the cache_rows using memory as the limit*/
+	}
+	else {
 
+	   if (!prefetch_mem){
+			prefetch_rows = cache_rows; /*use the RowCacheSize*/
+	   }
 	}
 
+	if (cache_rows <= prefetch_rows){
+		cache_rows=prefetch_rows;
+		/* is prefetch_rows are greater than the RowCahceSize then use prefetch_rows*/
+	}
 
 	OCIAttrSet_log_stat(imp_sth->stmhp, OCI_HTYPE_STMT,
-						&cache_mem,  sizeof(cache_mem), OCI_ATTR_PREFETCH_MEMORY,
+						&prefetch_mem,  sizeof(prefetch_mem), OCI_ATTR_PREFETCH_MEMORY,
 						imp_sth->errhp, status);
 
 	if (status != OCI_SUCCESS) {
 		oci_error(h, imp_sth->errhp, status,
-				"OCIAttrSet OCI_ATTR_PREFETCH_ROWS/OCI_ATTR_PREFETCH_MEMORY");
+				"OCIAttrSet OCI_ATTR_PREFETCH_MEMORY");
 		++num_errors;
 	}
 
 	OCIAttrSet_log_stat(imp_sth->stmhp, OCI_HTYPE_STMT,
-					&cache_rows, sizeof(cache_rows), OCI_ATTR_PREFETCH_ROWS,
+					&prefetch_rows, sizeof(prefetch_rows), OCI_ATTR_PREFETCH_ROWS,
 				imp_sth->errhp, status);
 
 	if (status != OCI_SUCCESS) {
@@ -2361,13 +2767,33 @@
 		++num_errors;
 	}
 
-	if (imp_sth->rs_array_on && cache_rows>0)
-		imp_sth->rs_array_size=cache_rows>128?128:cache_rows;	/* restrict to 128 for now */
+/*    if (imp_sth->ret_lobs){
+		cache_rows=30;
 
-	if (DBIS->debug >= 3 || dbd_verbose >= 3 )
+	}
+*/
+	imp_sth->rs_array_size=cache_rows;
+
+    if (max_cache_rows){/* limited by a cursor or something else*/
+		imp_sth->rs_array_size=max_cache_rows;
+	}
+
+
+/*	if (imp_sth->row_cache_off){/*set the size of the Rows in Cache value
+		imp_dbh->RowsInCache =1;
+	}
+	 else {
+		imp_dbh->RowsInCache=imp_sth->rs_array_size;
+	}
+*/
+
+
+	if (DBIS->debug >= 3 || dbd_verbose >= 3 || oci_warn) /*will also display if oci_warn is on*/
 		PerlIO_printf(DBILOGFP,
-			"	row cache OCI_ATTR_PREFETCH_ROWS %lu, OCI_ATTR_PREFETCH_MEMORY %lu\n",
-			(unsigned long) (cache_rows), (unsigned long) (cache_mem));
+			"	cache settings RowCacheSize=%d, OCI_ATTR_PREFETCH_ROWS=%lu, OCI_ATTR_PREFETCH_MEMORY=%lu, Rows per Fetch=%d, Multiple Row Fetch=%s\n",
+			imp_dbh->RowCacheSize,(unsigned long) (prefetch_rows), (unsigned long) (prefetch_mem),cache_rows,(imp_sth->row_cache_off)?"Off":"On");
+
+
 
 	return num_errors;
 }
@@ -2375,7 +2801,6 @@
 
 
 /*recurses down the field's TDOs and saves the little bits it need for later use on a fetch fbh->obj */
-
 int
 describe_obj(SV *sth,imp_sth_t *imp_sth,OCIParam *parm,fbh_obj_t *obj,int level )
 {
@@ -2630,9 +3055,10 @@
 	D_imp_drh_from_dbh;
 	UV	long_readlen;
 	ub4 num_fields;
-	int num_errors = 0;
-	int has_longs = 0;
-	int est_width = 0;		/* estimated avg row width (for cache)	*/
+	int num_errors	= 0;
+	int has_longs	= 0;
+	int has_lobs	= 0;
+	int est_width	= 0;		/* estimated avg row width (for cache)	*/
 	int nested_cursors = 0;
 	ub4 i = 0;
 	sword status;
@@ -2652,6 +3078,7 @@
 	/* set long_readlen for SELECT or PL/SQL with output placeholders */
 	imp_sth->long_readlen = long_readlen;
 
+
 	if (imp_sth->stmt_type != OCI_STMT_SELECT) { /* XXX DISABLED, see num_fields test below */
 		if (DBIS->debug >= 3 || dbd_verbose >= 3 )
 			PerlIO_printf(DBILOGFP, "	dbd_describe skipped for %s\n",
@@ -2806,11 +3233,11 @@
 				}
 				else if (imp_sth->piece_lob){ /*get by peice with polling slowest*/
 
-					fbh->piece_lob	  = 1;
+					fbh->piece_lob		= 1;
 					fbh->define_mode	= OCI_DYNAMIC_FETCH; /* piecwise fetch*/
 					fbh->disize 		= imp_sth->long_readlen; /*user set max value for the fetch*/
 					fbh->piece_size		= imp_sth->piece_size; /*the size for each piece*/
-					fbh->fetch_cleanup = fetch_cleanup_pres_lobs; /* clean up buffer before each fetch*/
+					fbh->fetch_cleanup 	= fetch_cleanup_pres_lobs; /* clean up buffer before each fetch*/
 
 					if (!imp_sth->piece_size){ /*if not set use max value*/
 						imp_sth->piece_size=imp_sth->long_readlen;
@@ -2891,8 +3318,8 @@
 					}
 				}
 				break;
-			case	ORA_CLOB:				/* CLOB	& NCLOB	*/
-			case	ORA_BLOB:				/* BLOB		*/
+			case	ORA_CLOB:			/* CLOB	& NCLOB	*/
+			case	ORA_BLOB:			/* BLOB		*/
 			case	114:				/* BFILE	*/
 				fbh->ftype  	  = fbh->dbtype;
 				imp_sth->ret_lobs = 1;
@@ -2900,7 +3327,12 @@
 
 				if (imp_sth->pers_lob){  /*get as one peice fasted but limited to how big you can get.*/
 					fbh->pers_lob	= 1;
-					fbh->disize 	= fbh->disize+long_readlen; /*user set max value for the fetch*/
+					if (long_readlen){
+						fbh->disize 	= fbh->disize*10; /*default size*/
+					}
+					else {
+						fbh->disize 	= long_readlen;/*user set max value for the fetch*/
+					}
 					if (fbh->dbtype == ORA_CLOB){
 						fbh->ftype  = SQLT_CHR;
 					}
@@ -2923,6 +3355,7 @@
 						fbh->ftype = SQLT_BIN; /*other Binary*/
 					}
 					fbh->fetch_func = fetch_clbk_lob;
+					imp_sth->row_cache_off=1;
 				}
 				else if (imp_sth->piece_lob){ /*get by peice with polling slowest*/
 					fbh->piece_lob		= 1;
@@ -2940,6 +3373,7 @@
 						fbh->ftype = SQLT_BIN; /*other Binary */
 					}
 					fbh->fetch_func = fetch_get_piece;
+					imp_sth->row_cache_off=1;
 				}
 				else { /*auto lob fetch with locator by far the fastest*/
 					fbh->disize = fbh->dbsize *10 ;	/* XXX! */
@@ -2947,8 +3381,12 @@
 					fbh->bless  = "OCILobLocatorPtr";
 					fbh->desc_t = OCI_DTYPE_LOB;
 					OCIDescriptorAlloc_ok(imp_sth->envhp, &fbh->desc_h, fbh->desc_t);
+					imp_sth->row_cache_off=1;
 				}
 
+				if (fbh->csform == SQLCS_NCHAR){
+					imp_sth->row_cache_off=1;
+				}
 				break;
 
 #ifdef OCI_DTYPE_REF
@@ -2990,9 +3428,9 @@
 		if (DBIS->debug >= 3 || dbd_verbose >= 3 )
 			  PerlIO_printf(DBILOGFP,
 				"Described col %2d: dbtype %d(%s), scale %d, prec %d, nullok %d, name %s\n"
-				 "		  : dbsize %d, char_used %d, char_size %d, csid %d, csform %d, disize %d\n",
+				 "		  : dbsize %d, char_used %d, char_size %d, csid %d, csform %d(%s), disize %d\n",
 					i, fbh->dbtype, sql_typecode_name(fbh->dbtype),fbh->scale, fbh->prec, fbh->nullok, fbh->name,
-					fbh->dbsize, fbh->len_char_used, fbh->len_char_size, fbh->csid, fbh->csform, fbh->disize);
+					fbh->dbsize, fbh->len_char_used, fbh->len_char_size, fbh->csid,fbh->csform,oci_csform_name(fbh->csform), fbh->disize);
 
 		if (fbh->ftype == 5)	/* XXX need to handle wide chars somehow */
 			fbh->disize += 1;	/* allow for null terminator */
@@ -3014,12 +3452,14 @@
 	imp_sth->est_width = est_width;
 
 	sth_set_row_cache(h, imp_sth,
-			(nested_cursors) ? imp_dbh->max_nested_cursors / nested_cursors : 0,
+			(imp_dbh->max_nested_cursors) ? 0 :nested_cursors ,
 			(int)num_fields, has_longs );
 	/* Initialise cache counters */
 	imp_sth->in_cache  = 0;
 	imp_sth->eod_errno = 0;
-	rs_array_init(imp_sth);
+	/*rs_array_init(imp_sth);*/
+
+
 
 	/* now set up the oci call with define by pos*/
 	for(i=1; i <= num_fields; ++i) {
@@ -3028,12 +3468,12 @@
 		/* add space for STRING null term, or VAR len prefix */
 		sb4 define_len = (ftype==94||ftype==95) ? fbh->disize+4 : fbh->disize;
 		fb_ary_t  *fb_ary;
-
+		
 		if (fbh->clbk_lob || fbh->piece_lob  ){/*init the cb_abuf with this call*/
 			fbh->fb_ary = fb_ary_cb_alloc(imp_sth->piece_size,define_len, imp_sth->rs_array_size);
 
 		} else {
-				fbh->fb_ary = fb_ary_alloc(define_len, imp_sth->rs_array_size);
+			fbh->fb_ary = fb_ary_alloc(define_len, imp_sth->rs_array_size);
 		}
 
 		fb_ary = fbh->fb_ary;
@@ -3100,7 +3540,7 @@
 		if ( (fbh->dbtype == 1) && fbh->csform ) {
 		/* csform may be 0 when talking to Oracle 8.0 database*/
 			if (DBIS->debug >= 3 || dbd_verbose >= 3 )
-				PerlIO_printf(DBILOGFP, "	calling OCIAttrSet OCI_ATTR_CHARSET_FORM with csform=%d\n", fbh->csform );
+				PerlIO_printf(DBILOGFP, "	calling OCIAttrSet OCI_ATTR_CHARSET_FORM with csform=%d (%s)\n", fbh->csform,oci_csform_name(fbh->csform) );
 				OCIAttrSet_log_stat( fbh->defnp, (ub4) OCI_HTYPE_DEFINE, (dvoid *) &fbh->csform,
 						 (ub4) 0, (ub4) OCI_ATTR_CHARSET_FORM, imp_sth->errhp, status );
 			if (status != OCI_SUCCESS) {
@@ -3115,7 +3555,7 @@
 	if (DBIS->debug >= 3 || dbd_verbose >= 3 )
 		PerlIO_printf(DBILOGFP,
 			"	dbd_describe'd %d columns (row bytes: %d max, %d est avg, cache: %d)\n",
-			(int)num_fields, imp_sth->t_dbsize, imp_sth->est_width, imp_sth->cache_rows);
+			(int)num_fields, imp_sth->t_dbsize, imp_sth->est_width, imp_sth->prefetch_rows);
 
 	return (num_errors>0) ? 0 : 1;
 }
@@ -3125,6 +3565,7 @@
 dbd_st_fetch(SV *sth, imp_sth_t *imp_sth){
 	dTHX;
 	sword status;
+	D_imp_dbh_from_sth;
 	int num_fields = DBIc_NUM_FIELDS(imp_sth);
 	int ChopBlanks;
 	int err;
@@ -3160,11 +3601,12 @@
 		if (imp_sth->fetch_orient != OCI_DEFAULT) {
 			if (imp_sth->exe_mode!=OCI_STMT_SCROLLABLE_READONLY)
 				croak ("attempt to use a scrollable cursor without first setting ora_exe_mode to OCI_STMT_SCROLLABLE_READONLY\n") ;
+
 			if (DBIS->debug >= 4 || dbd_verbose >= 4 )
 				PerlIO_printf(DBILOGFP,"	Scrolling Fetch, postion before fetch=%d, Orientation = %s , Fetchoffset =%d\n",
 					imp_sth->fetch_position,oci_fetch_options(imp_sth->fetch_orient),imp_sth->fetch_offset);
-			OCIStmtFetch_log_stat(imp_sth->stmhp, imp_sth->errhp,1, imp_sth->fetch_orient,imp_sth->fetch_offset, status);
 
+			OCIStmtFetch_log_stat(imp_sth->stmhp, imp_sth->errhp,1, imp_sth->fetch_orient,imp_sth->fetch_offset, status);
 				/*this will work without a round trip so might as well open it up for all statments handles*/
 				/* defualt and OCI_FETCH_NEXT are the same so this avoids miscaluation on the next value*/
 			OCIAttrGet_stmhp_stat(imp_sth, &imp_sth->fetch_position, 0, OCI_ATTR_CURRENT_POSITION, status);
@@ -3172,27 +3614,44 @@
 			if (DBIS->debug >= 4 || dbd_verbose >= 4 )
 				PerlIO_printf(DBILOGFP,"	Scrolling Fetch, postion after fetch=%d\n",imp_sth->fetch_position);
 
-		} else {
-			if (imp_sth->rs_array_on) {	/* if array fetch on, fetch only if not in cache */
+		}
+		else {
+
+			if (imp_sth->row_cache_off){ /*Do not use array fetch or local cache */
+				OCIStmtFetch_log_stat(imp_sth->stmhp, imp_sth->errhp,1,(ub2)OCI_FETCH_NEXT, OCI_DEFAULT, status);
+				imp_sth->rs_fetch_count++;
+				imp_sth->rs_array_idx=0;
+
+			}
+			else {  /*Array Fetch the New Noraml Super speedy and very nice*/
+
+/* 			PerlIO_printf(DBILOGFP, "	dbd_st_fetch fields...a\n");*/
+				imp_dbh->RowsInCache--;
 				imp_sth->rs_array_idx++;
+					/*PerlIO_printf(DBILOGFP," \n imp_sth->rs_array_idx=%d,rs_array_num_rows=%d\n",imp_sth->rs_array_idx,imp_sth->rs_array_num_rows);
+*/
 				if (imp_sth->rs_array_num_rows<=imp_sth->rs_array_idx && (imp_sth->rs_array_status==OCI_SUCCESS || imp_sth->rs_array_status==OCI_SUCCESS_WITH_INFO)) {
+/* 			PerlIO_printf(DBILOGFP, "	dbd_st_fetch fields...b\n");*/
+
 					OCIStmtFetch_log_stat(imp_sth->stmhp,imp_sth->errhp,imp_sth->rs_array_size,(ub2)OCI_FETCH_NEXT,OCI_DEFAULT,status);
 					imp_sth->rs_array_status=status;
+					imp_sth->rs_fetch_count++;
 					if (oci_warn &&  (imp_sth->rs_array_status == OCI_SUCCESS_WITH_INFO)) {
 						oci_error(sth, imp_sth->errhp, status, "OCIStmtFetch");
 					}
 					OCIAttrGet_stmhp_stat(imp_sth, &imp_sth->rs_array_num_rows,0,OCI_ATTR_ROWS_FETCHED, status);
 					imp_sth->rs_array_idx=0;
+					imp_dbh->RowsInCache =imp_sth->rs_array_size;
+					if (DBIS->debug >= 4 || dbd_verbose >= 4 || oci_warn)
+						PerlIO_printf(DBILOGFP,"...Fetched %d rows\n",imp_sth->rs_array_num_rows);
+
 				}
+
 				if (imp_sth->rs_array_num_rows>imp_sth->rs_array_idx)	/* set status to success if rows in cache */
 					status=OCI_SUCCESS;
 				else
 					status=imp_sth->rs_array_status;
 			}
-			else {
-				OCIStmtFetch_log_stat(imp_sth->stmhp, imp_sth->errhp,1,(ub2)OCI_FETCH_NEXT, OCI_DEFAULT, status);
-				imp_sth->rs_array_idx=0;
-			}
 		}
 	}
 
@@ -3202,8 +3661,8 @@
 		if (status == OCI_NO_DATA) {
 			dTHR; 			/* for DBIc_ACTIVE_off	*/
 			DBIc_ACTIVE_off(imp_sth);	/* eg finish		*/
-			if (DBIS->debug >= 3 || dbd_verbose >= 3 )
-				PerlIO_printf(DBILOGFP, "	dbd_st_fetch no-more-data\n");
+			if (DBIS->debug >= 3 || dbd_verbose >= 3 || oci_warn)
+				PerlIO_printf(DBILOGFP, "	dbd_st_fetch no-more-data, fetch count=%d\n",imp_sth->rs_fetch_count-1);
 			return Nullav;
 		}
 		if (status != OCI_SUCCESS_WITH_INFO) {
@@ -3237,6 +3696,7 @@
 		ub1* row_data		= &fb_ary->abuf[0]+(fb_ary->bufl*imp_sth->rs_array_idx);
 		SV *sv 				= AvARRAY(av)[i]; /* Note: we (re)use the SV in the AV	*/;
 
+
 		if (DBIS->debug >= 4 || dbd_verbose >= 4 ) {
 			PerlIO_printf(DBILOGFP, "	field #%d with rc=%d(%s)\n",i+1,rc,oci_col_return_codes(rc));
 		}

Modified: dbd-oracle/trunk/ocitrace.h
==============================================================================
--- dbd-oracle/trunk/ocitrace.h	(original)
+++ dbd-oracle/trunk/ocitrace.h	Thu Oct 29 10:53:06 2009
@@ -239,8 +239,15 @@
 #define OCIAttrGet_log_stat(th,ht,ah,sp,at,eh,stat)					\
 	stat = OCIAttrGet(th,ht,ah,sp,at,eh);				\
 	(DBD_OCI_TRACEON) ? PerlIO_printf(DBD_OCI_TRACEFP,			\
-		"%sAttrGet(%p,%s,%p,%p,%lu,%p)=%s\n",			\
-		OciTp, (void*)th,oci_hdtype_name(ht),(void*)ah,pul_t(sp),ul_t(at),(void*)eh,\
+		"%sAttrGet(%p,%s,%p,%p,%s,%p)=%s\n",			\
+		OciTp, (void*)th,oci_hdtype_name(ht),(void*)ah,pul_t(sp),oci_attr_name(at),(void*)eh,\
+		oci_status_name(stat)),stat : stat
+
+#define OCIAttrGet_d_log_stat(th,ht,ah,sp,at,eh,stat)					\
+	stat = OCIAttrGet(th,ht,ah,sp,at,eh);				\
+	(DBD_OCI_TRACEON) ? PerlIO_printf(DBD_OCI_TRACEFP,			\
+		"%sAttrGet(%p,%s,%p,%p,%s,%p)=%s\n",			\
+		OciTp, (void*)th,oci_hdtype_name(ht),(void*)ah,pul_t(sp),oci_dtype_attr_name(at),(void*)eh,\
 		oci_status_name(stat)),stat : stat
 
  #define OCIAttrGet_parmap(imp_sth,dh, ht, p1, l, stat)				\
@@ -249,7 +256,7 @@
 
 
 #define OCIAttrGet_parmdp(imp_sth, parmdp, p1, l, a, stat)				\
-	OCIAttrGet_log_stat(parmdp, OCI_DTYPE_PARAM,			\
+	OCIAttrGet_d_log_stat(parmdp, OCI_DTYPE_PARAM,			\
 		(void*)(p1), (l), (a), imp_sth->errhp, stat)
 
 #define OCIAttrGet_stmhp_stat(imp_sth, p1, l, a, stat)					\
@@ -259,8 +266,8 @@
 #define OCIAttrSet_log_stat(th,ht,ah,s1,a,eh,stat)						\
 	stat=OCIAttrSet(th,ht,ah,s1,a,eh);				\
 	(DBD_OCI_TRACEON) ? PerlIO_printf(DBD_OCI_TRACEFP,			\
-		"%sAttrSet(%p,%s,%p,%lu,%lu,%p)=%s\n",			\
-		OciTp, (void*)th,oci_hdtype_name(ht),(void*)(ah),ul_t(s1),ul_t(a),(void*)eh,	\
+		"%sAttrSet(%p,%s, %p,%lu,Attr=%s,%p)=%s\n",			\
+		OciTp, (void*)th,oci_hdtype_name(ht),sl_t(ah),ul_t(s1),oci_attr_name(a),(void*)eh,	\
 		oci_status_name(stat)),stat : stat
 
 #define OCIBindByName_log_stat(sh,bp,eh,p1,pl,v,vs,dt,in,al,rc,mx,cu,md,stat)	\
@@ -456,9 +463,9 @@
 #define OCIParamGet_log_stat(hp,ht,eh,pp,ps,stat)						\
 	stat=OCIParamGet(hp,ht,eh,pp,ps);				\
 	(DBD_OCI_TRACEON) ? PerlIO_printf(DBD_OCI_TRACEFP,			\
-		"%sParamGet(%p,%lu,%p,%p,%lu)=%s\n",				\
+		"%sParamGet(%p,%lu,%p,%p,%lu,%s)=%s\n",				\
 		OciTp, (void*)hp,ul_t((ht)),(void*)eh,(void*)pp,ul_t(ps),	\
-		oci_status_name(stat)),stat : stat
+		oci_hdtype_name(ht),oci_status_name(stat)),stat : stat
 
 #define OCIServerAttach_log_stat(imp_dbh, dbname,md,stat)				 \
 	stat=OCIServerAttach( imp_dbh->srvhp, imp_dbh->errhp,		\
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.