DBD-Oracle

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

    - Support for ORA_SYSBACKUP, ORA_SYSDG and ORA_SYSKM. (RT#91473,
        Kris Lemaire)

    [BUG FIXES]

   - OCI_THREADED setting had been accidentally removed, causing potential
    crashes when using threads. (RT#92229, Martin J. Evans, reported
    by Detlef Lütticke)

  - When using fetch*_hashref the values are decoded but
    not the keys so if you have unicode column names they were not
    returned correctly.  (RT#92134, Martin J. Evans, reported by
    Marcel Montes)


1.69_01 2014-01-14

  [BUG FIXES]

  - Fix RT91698. If you bound an output parameter to a scalar and
    repeatedly called execute the memory allocated in your bound

Changes  view on Meta::CPAN

 - Minor fix to avoid use of uninitialised variable in 31lob.t (Martin J. Evans)

 [DOCUMENTATION]
 - clarification of when StrictlyTyped/DiscardString can be used and
   LongReadLen (Martin J. Evans)

 - Documented the 3rd type of placeholder and rewrote the existing
   pod for placeholders (Martin J. Evans).

1.42      2012-03-13
 - skip rt74753-utf8-encoded.t if db is not unicode

1.40      2012-03-08
 - promote 1.39_00 to official release

1.39_00   2012-02-24

 [BUG FIXES]
 - TAF supports now conditional to presence of OCI_ATTR_TAF_ENABLED
    [RT73798]
 - detect broken Win32::TieRegistry (patch by Rafael Kitover (Caelum))

Changes  view on Meta::CPAN

  Added extended nvarchar support from Jan Mach
  Added support for the TYPE attribute on bind_col and the new DBI bind_col attributes StrictlyTyped and DiscardString from Martin J. Evans
  Added ora_ncs_buff_mtpl and environment var ORA_DBD_NCS_BUFFER so we can control the size of the buffer when doing nclob reads
  Fix for rt.cpan.org Ticket #=49741 Oracle.h has commented out params in OCIXMLTypeCreateFromSrc from Kartik Thakore
  Added from rt.cpan.org Ticket #=49436 Patch to add support for a few Oracle data types to type_info_all from David Hull
  Added from rt.cpan.org Ticket #=49435 Patch to add support for a few Oracle data types to dbd_describe from David Hull
  Fix for rt.cpan.org Ticket #=49331 Bad code example in POD from John Scoles
  Added support for looking up OCI_DTYPE_PARAM Attributes
  Added support for looking up csform values
  Fix for rt.cpan.org Ticket #=46763,46998 enhancement -Rowcache size is now being properly implemented with row fetch buffer from John Scoles
  Fix for rt.cpan.org Ticket #=46438 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 hangs 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

* Changes in DBD-Oracle 1.23(svn rev 12724)

  Fix from rt.cpan.org ticket #=44788 bool in_lite should be char in_literal

Changes  view on Meta::CPAN

* Changes in DBD-Oracle 1.17 (svn rev 2487)   7th February 2006

  NOTE: With this release of DBD::Oracle pythian.com (http://www.pythian.com)
  are taking on the role of lead maintainer - with my support and gratitude.
  John Scoles at pythian.com is now the man in the hot seat for support and
  maintenance!

  Fixed automatic csform setting for some UTF8 cases and for Oracle 8.0
  Fixed truncation error on fetch into UTF8 charset thanks to Honza Pazdziora.
  Fixed INTERVAL DAY TO SECOND thanks to Honza Pazdziora.
  Fixed unicode tests for cygwin thanks to Andy Hassall.
  Fixed undef warnings when connecting with undef $user.
  Fixed undef warnings from $dbh->get_info(18);
  Fixed LOB streaming example thanks to Pablo Zorzoli.

  Added support for nested cursors in select lists thanks to Charles Jardine.
  Added "Trailing Spaces" section to docs thanks to Michael A Chase.
  Added support for binary floats/doubles thanks to Dennis Box.
  Added INSTANCE_NAME, SERVER and SERVICE_NAME as valid connect keywords
    in the 'dbi:Oracle:x=y' short form of connecting without tnsnames.ora.
    For example 'dbi:Oracle:host=localhost;service_name=xe;server=dedicated'

Changes  view on Meta::CPAN


  Added automatic support for UTF-8 for both NLS_LANG and NLS_NCHAR
    Many thanks to Lincoln Baxter who did most of the hard work and testing
    and to Jeff Urlwin and others who also helped out.
    Perl 5.8.x and Oracle 9+ are highly recommended if you want to use Unicode.
    See POD for more information and documentation.
  Added support for "... RETURNING lob_locator_column INTO ?"
    using $sth->bind_param_inout(2, \$loc, 0, {ora_type => ORA_BLOB});
  Added bind_param() ora_csform, ora_csid, and ora_maxdata_size attributes.
  Added bind_param() support for SQL_BLOB & SQL_CLOB thanks to Stephen Clouse.
  Added $dbh->ora_can_unicode and $dbh->ora_nls_parameters thanks to Andy Hassall.

  Documentation changes:
    Corrected typo in ora_lob_read() example thanks to Johannes Wierny.
    Corrected LOB example thanks to Sascha Pfalz and Thomas Upton.
    Updated README.macosx thanks to Hilmar Lapp.
    Updated README.hpux thanks to Gram Ludlow and Lincoln Baxter.
    Added $dbh->reauthenticate($user,$pass) docs thanks to Andy Hassall.
    Added $dbh->{ora_parse_error_offset} docs thanks to Andy Hassall.
    Added gcc example to README.aix thanks to Adrian Terranova.
    Added INSERT ... RETURNING ... example prompted by Steven Lembark.

Makefile.PL  view on Meta::CPAN

$opts{DEFINE} .= ' -Xa' if $Config{cc} eq 'clcc';	# CenterLine CC







$opts{DEFINE} .= ' -DUTF8_SUPPORT' if ($] >= 5.006);

# Use OCIEnvNlsCreate if available for best unicode behaviour
#$opts{DEFINE} .= ' -DNEW_OCI_INIT' if $client_version >= 9.2;
$opts{DEFINE} .= ($^O ne 'VMS')
	? " -DORA_OCI_VERSION=\\\"$client_version_full\\\""
	: " -DORA_OCI_VERSION=\"$client_version_full\"";
# force additional special behavior for oci 8.  For now, this means
# emulating OciLobWriteAppend
# use this if, for some reason the default handling for this function
# doesn't work or you are building a binary release for distribution
# to machines with older client libraries.

README.mkdn  view on Meta::CPAN

## **CompatMode**

Type: boolean, inherited

The CompatMode attribute is used by emulation layers (such as Oraperl) to enable compatible behaviour in the underlying driver (e.g., DBD::Oracle) for this handle. Not normally set by application code.

It also has the effect of disabling the 'quick FETCH' of attribute values from the handles attribute cache. So all attribute values are handled by the drivers own FETCH method. This makes them slightly slower but is useful for special-purpose drivers...

# ORACLE-SPECIFIC DATABASE HANDLE METHODS

## **ora\_can\_unicode ( \[ $refresh \] )**

Returns a number indicating whether either of the database character sets
is a Unicode encoding. Calls ora\_nls\_parameters() and passes the optional
$refresh parameter to it.

0 = Neither character set is a Unicode encoding.

1 = National character set is a Unicode encoding.

2 = Database character set is a Unicode encoding.

README.mkdn  view on Meta::CPAN

# UNICODE

DBD::Oracle now supports Unicode UTF-8. There are, however, a number
of issues you should be aware of, so please read all this section
carefully.

In this section we'll discuss "Perl and Unicode", then "Oracle and
Unicode", and finally "DBD::Oracle and Unicode".

Information about Unicode in general can be found at:
[http://www.unicode.org/](http://www.unicode.org/). It is well worth reading because there are
many misconceptions about Unicode and you may be holding some of them.

## Perl and Unicode

Perl began implementing Unicode with version 5.6, but the implementation
did not mature until version 5.8 and later. If you plan to use Unicode
you are _strongly_ urged to use Perl 5.8.2 or later and to _carefully_ read
the Perl documentation on Unicode:

    perldoc perluniintro    # in Perl 5.8 or later
    perldoc perlunicode

And then read it again.

Perl's internal Unicode format is UTF-8
which corresponds to the Oracle character set called AL32UTF8.

## Oracle and Unicode

Oracle supports many characters sets, including several different forms
of Unicode.  These include:

README.mkdn  view on Meta::CPAN


AL32UTF8 should be used in preference to UTF8 if it works for you,
which it should for Oracle 9.2 or later. If you're using an old
version of Oracle that doesn't support AL32UTF8 then you should
avoid using any Unicode characters that require surrogates, in other
words characters beyond the Unicode BMP (Basic Multilingual Plane).

That's because the character set that Oracle calls "UTF8" doesn't
conform to the UTF-8 standard in its handling of surrogate characters.
Technically the encoding that Oracle calls "UTF8" is known as "CESU-8".
Here are a couple of extracts from [http://www.unicode.org/reports/tr26/](http://www.unicode.org/reports/tr26/):

    CESU-8 is useful in 8-bit processing environments where binary
    collation with UTF-16 is required. It is designed and recommended
    for use only within products requiring this UTF-16 binary collation
    equivalence. It is not intended nor recommended for open interchange.

    As a very small percentage of characters in a typical data stream
    are expected to be supplementary characters, there is a strong
    possibility that CESU-8 data may be misinterpreted as UTF-8.
    Therefore, all use of CESU-8 outside closed implementations is

dbdimp.c  view on Meta::CPAN

					return 0;
				}
			}

#ifdef ORA_OCI_112
			if (!imp_dbh->using_drcp)
#endif
				if (!imp_drh->envhp)	/* cache first envhp info drh as future default */
					imp_drh->envhp = imp_dbh->envhp;

			/* update the hard-coded csid constants for unicode charsets */
			utf8_csid	   = OCINlsCharSetNameToId(imp_dbh->envhp, (void*)"UTF8");
			al32utf8_csid  = OCINlsCharSetNameToId(imp_dbh->envhp, (void*)"AL32UTF8");
			al16utf16_csid = OCINlsCharSetNameToId(imp_dbh->envhp, (void*)"AL16UTF16");
		}

#ifdef ORA_OCI_112
		if (imp_dbh->using_drcp) {
			/* Try looking up session pool again, in case ora_charsetid/ora_ncharsetid were used to specify previously used charset IDs from the NLS environment. */
			SV *key_sv = pool_key(imp_dbh, dbname, uid, pwd, charsetid, ncharsetid);

dbdimp.c  view on Meta::CPAN

			}
		}
		if(SvUTF8(item) ){
			flag_data_is_utf8=1;
			if (trace_level >= 3 || dbd_verbose >= 3 ){
                PerlIO_printf(
                    DBIc_LOGPIO(imp_sth),
                    "dbd_rebind_ph_varchar2_table(): is_utf8(array[%d])=true\n", i);
			}
			if (csform != SQLCS_NCHAR) {
			/* try to default csform to avoid translation through non-unicode */
			if (CSFORM_IMPLIES_UTF8(SQLCS_NCHAR))		/* prefer NCHAR */
				csform = SQLCS_NCHAR;
			else if (CSFORM_IMPLIES_UTF8(SQLCS_IMPLICIT))
				csform = SQLCS_IMPLICIT;
			/* else leave csform == 0 */
			if (trace_level  || dbd_verbose >= 3 )
				PerlIO_printf(
                    DBIc_LOGPIO(imp_sth),
                    "dbd_rebind_ph_varchar2_table(): rebinding %s with UTF8 value %s",
                    phs->name,
					(csform == SQLCS_NCHAR)	? "so setting csform=SQLCS_IMPLICIT" :
					(csform == SQLCS_IMPLICIT) ? "so setting csform=SQLCS_NCHAR" :
					"but neither CHAR nor NCHAR are unicode\n");
			}
		}else{
			if (trace_level >= 3 || dbd_verbose >= 3 ){
                PerlIO_printf(
                    DBIc_LOGPIO(imp_sth),
                    "dbd_rebind_ph_varchar2_table(): is_utf8(array[%d])=false\n", i);
			}
		}
		}
	}

dbdimp.c  view on Meta::CPAN

		oci_error(sth, imp_sth->errhp, status, "OCIBindDynamic");
		return 0;
	}
	}

	/* some/all of the following should perhaps move into dbd_phs_in() */

	csform = phs->csform;

	if (!csform && SvUTF8(phs->sv)) {
		/* try to default csform to avoid translation through non-unicode */
		if (CSFORM_IMPLIES_UTF8(SQLCS_IMPLICIT))		/* prefer IMPLICIT */
 			csform = SQLCS_IMPLICIT;
		else if (CSFORM_IMPLIES_UTF8(SQLCS_NCHAR))
			csform = SQLCS_NCHAR;	/* else leave csform == 0 */
	if (trace_level || dbd_verbose >= 3)
		PerlIO_printf(
            DBIc_LOGPIO(imp_sth),
            "dbd_rebind_ph() (2): rebinding %s with UTF8 value %s", phs->name,
		(csform == SQLCS_IMPLICIT) ? "so setting csform=SQLCS_IMPLICIT" :
		(csform == SQLCS_NCHAR)	? "so setting csform=SQLCS_NCHAR" :
		"but neither CHAR nor NCHAR are unicode\n");
	}

	if (csform) {
		/* set OCI_ATTR_CHARSET_FORM before we get the default OCI_ATTR_CHARSET_ID */
		OCIAttrSet_log_stat(imp_sth, phs->bndhp, (ub4) OCI_HTYPE_BIND,
		&csform, (ub4) 0, (ub4) OCI_ATTR_CHARSET_FORM, imp_sth->errhp, status);
		if ( status != OCI_SUCCESS ) {
			oci_error(sth, imp_sth->errhp, status, ora_sql_error(imp_sth,"OCIAttrSet (OCI_ATTR_CHARSET_FORM)"));
			return 0;
		}

dbdimp.c  view on Meta::CPAN

					(dvoid *)phs, dbd_phs_out, status);
	if (status != OCI_SUCCESS) {
		oci_error(sth, imp_sth->errhp, status, "OCIBindDynamic");
		return 0;
	}
	/* copied and adapted from dbd_rebind_ph */

	csform = phs->csform;

	if (!csform && (utf8 & ARRAY_BIND_UTF8)) {
		/* try to default csform to avoid translation through non-unicode */
		if (CSFORM_IMPLIES_UTF8(SQLCS_IMPLICIT))				/* prefer IMPLICIT */
			csform = SQLCS_IMPLICIT;
		else if (CSFORM_IMPLIES_UTF8(SQLCS_NCHAR))
			csform = SQLCS_NCHAR;   /* else leave csform == 0 */
		if (trace_level || dbd_verbose >= 3 )
			PerlIO_printf(
                DBIc_LOGPIO(imp_sth),
                "do_bind_array_exec() (2): rebinding %s with UTF8 value %s", phs->name,
				(csform == SQLCS_IMPLICIT) ? "so setting csform=SQLCS_IMPLICIT" :
				(csform == SQLCS_NCHAR)	? "so setting csform=SQLCS_NCHAR" :
				 "but neither CHAR nor NCHAR are unicode\n");
	}

	if (csform) {
		/* set OCI_ATTR_CHARSET_FORM before we get the default OCI_ATTR_CHARSET_ID */
		OCIAttrSet_log_stat(imp_sth, phs->bndhp, (ub4) OCI_HTYPE_BIND,
			&csform, (ub4) 0, (ub4) OCI_ATTR_CHARSET_FORM, imp_sth->errhp, status);
		if ( status != OCI_SUCCESS ) {
			oci_error(sth, imp_sth->errhp, status, ora_sql_error(imp_sth,"OCIAttrSet (OCI_ATTR_CHARSET_FORM)"));
			return 0;
		}

lib/DBD/Oracle.pm  view on Meta::CPAN


        DBD::Oracle::db->install_method($_) for qw/
            ora_lob_read
            ora_lob_write
            ora_lob_append
            ora_lob_trim
            ora_lob_length
            ora_lob_chunk_size
            ora_lob_is_init
            ora_nls_parameters
            ora_can_unicode
            ora_can_taf
            ora_db_startup
            ora_db_shutdown
        /;

        DBD::Oracle::st->install_method($_) for qw/
            ora_fetch_scroll
            ora_scroll_position
            ora_ping
            ora_stmt_type_name

lib/DBD/Oracle.pm  view on Meta::CPAN

               SELECT parameter, value FROM v$nls_parameters
            }) or return;
            $dbh->{ora_nls_parameters} = { map { $_->[0] => $_->[1] } @$nls_parameters };
        }

        # return copy of params to protect against accidental editing
        my %nls = %{$dbh->{ora_nls_parameters}};
        return \%nls;
    }

    sub ora_can_unicode {
        my $dbh = shift;
        my $refresh = shift;
        # 0 = No Unicode support.
        # 1 = National character set is Unicode-based.
        # 2 = Database character set is Unicode-based.
        # 3 = Both character sets are Unicode-based.

        return $dbh->{ora_can_unicode}
            if defined $dbh->{ora_can_unicode} && !$refresh;

        my $nls = $dbh->ora_nls_parameters($refresh);

        $dbh->{ora_can_unicode}  = 0;
        $dbh->{ora_can_unicode} += 1 if $nls->{NLS_NCHAR_CHARACTERSET} =~ m/UTF/;
        $dbh->{ora_can_unicode} += 2 if $nls->{NLS_CHARACTERSET}       =~ m/UTF/;

        return $dbh->{ora_can_unicode};
    }

}   # end of package DBD::Oracle::db


{   package                     # hide from PAUSE
    DBD::Oracle::st;            # ====== STATEMENT ======


   sub bind_param_inout_array {

lib/DBD/Oracle.pm  view on Meta::CPAN

=head2 B<CompatMode>

Type: boolean, inherited

The CompatMode attribute is used by emulation layers (such as Oraperl) to enable compatible behaviour in the underlying driver (e.g., DBD::Oracle) for this handle. Not normally set by application code.

It also has the effect of disabling the 'quick FETCH' of attribute values from the handles attribute cache. So all attribute values are handled by the drivers own FETCH method. This makes them slightly slower but is useful for special-purpose drivers...

=head1 ORACLE-SPECIFIC DATABASE HANDLE METHODS

=head2 B<ora_can_unicode ( [ $refresh ] )>

Returns a number indicating whether either of the database character sets
is a Unicode encoding. Calls ora_nls_parameters() and passes the optional
$refresh parameter to it.

0 = Neither character set is a Unicode encoding.

1 = National character set is a Unicode encoding.

2 = Database character set is a Unicode encoding.

lib/DBD/Oracle.pm  view on Meta::CPAN

=head1 UNICODE

DBD::Oracle now supports Unicode UTF-8. There are, however, a number
of issues you should be aware of, so please read all this section
carefully.

In this section we'll discuss "Perl and Unicode", then "Oracle and
Unicode", and finally "DBD::Oracle and Unicode".

Information about Unicode in general can be found at:
L<http://www.unicode.org/>. It is well worth reading because there are
many misconceptions about Unicode and you may be holding some of them.

=head2 Perl and Unicode

Perl began implementing Unicode with version 5.6, but the implementation
did not mature until version 5.8 and later. If you plan to use Unicode
you are I<strongly> urged to use Perl 5.8.2 or later and to I<carefully> read
the Perl documentation on Unicode:

   perldoc perluniintro    # in Perl 5.8 or later
   perldoc perlunicode

And then read it again.

Perl's internal Unicode format is UTF-8
which corresponds to the Oracle character set called AL32UTF8.

=head2 Oracle and Unicode

Oracle supports many characters sets, including several different forms
of Unicode.  These include:

lib/DBD/Oracle.pm  view on Meta::CPAN


AL32UTF8 should be used in preference to UTF8 if it works for you,
which it should for Oracle 9.2 or later. If you're using an old
version of Oracle that doesn't support AL32UTF8 then you should
avoid using any Unicode characters that require surrogates, in other
words characters beyond the Unicode BMP (Basic Multilingual Plane).

That's because the character set that Oracle calls "UTF8" doesn't
conform to the UTF-8 standard in its handling of surrogate characters.
Technically the encoding that Oracle calls "UTF8" is known as "CESU-8".
Here are a couple of extracts from L<http://www.unicode.org/reports/tr26/>:

  CESU-8 is useful in 8-bit processing environments where binary
  collation with UTF-16 is required. It is designed and recommended
  for use only within products requiring this UTF-16 binary collation
  equivalence. It is not intended nor recommended for open interchange.

  As a very small percentage of characters in a typical data stream
  are expected to be supplementary characters, there is a strong
  possibility that CESU-8 data may be misinterpreted as UTF-8.
  Therefore, all use of CESU-8 outside closed implementations is

t/15nls.t  view on Meta::CPAN

    plan skip_all => 'Unable to connect to Oracle';
}

my ( $nls_parameters_before, $nls_parameters_after );
my $old_date_format = 'HH24:MI:SS DD/MM/YYYY';
my $new_date_format = 'YYYYMMDDHH24MISS';

ok( $dbh->do("alter session set nls_date_format='$old_date_format'"),
    'set date format' );

like( $dbh->ora_can_unicode, qr/^[0123]/, 'ora_can_unicode' );

ok( $nls_parameters_before = $dbh->ora_nls_parameters,
    'fetch ora_nls_parameters' );
is( ref($nls_parameters_before),
    'HASH', 'check ora_nls_parameters returned hashref' );
is( $nls_parameters_before->{'NLS_DATE_FORMAT'},
    $old_date_format, 'check returned nls_date_format' );

ok( $dbh->do("alter session set nls_date_format='$new_date_format'"),
    'alter date format' );

t/20select.t  view on Meta::CPAN

}
else {
    plan skip_all => "Unable to connect to oracle\n";
}

# test simple select statements with [utf8]

my $utf8_test = ( $] >= 5.006 )
  && client_ochar_is_utf8(
  )    # for correct output (utf8 bind vars should be fine regardless)
  && ( $dbh->ora_can_unicode() & 2 );
diag('Including unicode data in test') if $utf8_test;

unless ( create_test_table( 'str CHAR(10)', 1 ) ) {
    BAIL_OUT("Unable to create test table ($DBI::errstr)\n");
    print "1..0\n";
    exit 0;
}

my ( $sth, $p1, $p2, $tmp, @tmp );

for (@test_sets) {

t/20select.t  view on Meta::CPAN

END {
    eval { drop_table($dbh) }
}

sub run_select_tests {
    my ( $type_name, $field_len ) = @_;

    my $data0;
    if ($utf8_test) {
        $data0 = eval q{ "0\x{263A}xyX" }
          ;   #this includes the smiley from perlunicode (lab) BTW: it is busted
    }
    else {
        $data0 = "0\177x\0X";
    }
    my $data1 = '1234567890';
    my $data2 = '2bcdefabcd';

  SKIP: {
        if ( !create_test_table( "lng $type_name", 1 ) ) {

t/22nchar_al32utf8.t  view on Meta::CPAN


use Test::More;

use DBI qw(:sql_types);
use DBD::Oracle qw( :ora_types ORA_OCI SQLCS_NCHAR );

my $dbh;
$| = 1;
SKIP: {

    plan skip_all => 'Unable to run unicode test, perl version is less than 5.6'
      unless ( $] >= 5.006 );
    plan skip_all => 'Oracle charset tests unreliable for Oracle 8 client'
      if ORA_OCI() < 9.0 and !$ENV{DBD_ALL_TESTS};

    set_nls_nchar( ( ORA_OCI >= 9.2 ) ? 'AL32UTF8' : 'UTF8', 1 );
    $dbh = db_handle();

    plan skip_all => 'Unable to connect to Oracle' unless $dbh;
    plan skip_all => 'Database NCHAR character set is not Unicode'
      unless db_nchar_is_utf($dbh);

t/22nchar_utf8.t  view on Meta::CPAN


use Test::More;

use DBI qw(:sql_types);
use DBD::Oracle qw( :ora_types ORA_OCI SQLCS_NCHAR );

my $dbh;
$| = 1;
SKIP: {

    plan skip_all => 'Unable to run unicode test, perl version is less than 5.6'
      unless ( $] >= 5.006 );
    plan skip_all => 'Oracle charset tests unreliable for Oracle 8 client'
      if ORA_OCI() < 9.0 and !$ENV{DBD_ALL_TESTS};

    set_nls_nchar( ( ORA_OCI >= 9.2 ) ? 'AL32UTF8' : 'UTF8', 1 );
    $dbh = db_handle();

    plan skip_all => 'Unable to connect to Oracle' unless $dbh;
    plan skip_all => 'Database NCHAR character set is not Unicode'
      unless db_nchar_is_utf($dbh);

    # testing utf8 with nchar columns

    show_db_charsets($dbh);
    my $tdata = test_data('wide_nchar');

    if ( $dbh->ora_can_unicode & 1 ) {
        push( @{ $tdata->{rows} }, extra_wide_rows() );

        # added 2 rows with extra wide chars to test data
    }

    my $testcount = 0    #create table
      + insert_test_count($tdata) + select_test_count($tdata) * 1;

    plan tests => $testcount;
    show_test_data( $tdata, 0 );

t/23wide_db.t  view on Meta::CPAN


use Test::More;

use DBI qw(:sql_types);
use DBD::Oracle qw( :ora_types ORA_OCI SQLCS_NCHAR );

my $dbh;
$| = 1;
SKIP: {

    plan skip_all => 'Unable to run unicode test, perl version is less than 5.6'
      unless ( $] >= 5.006 );
    plan skip_all => 'Oracle charset tests unreliable for Oracle 8 client'
      if ORA_OCI() < 9.0 and !$ENV{DBD_ALL_TESTS};

   #!  #force Ncharset to NON UTF8! we are testing a wide database where someone
   #!  #perversely sets nchar to non utf8, and nls_lang to utf8....
    set_nls_lang_charset( ( ORA_OCI >= 9.2 ) ? 'AL32UTF8' : 'UTF8', 1 );

#!  #set_nls_nchar( 'WE8ISO8859P1' ,1 ); #it breaks and it is stupid to do this... doc it XXX
    $dbh = db_handle();

t/23wide_db_8bit.t  view on Meta::CPAN


use Test::More;

use DBI qw(:sql_types);
use DBD::Oracle qw( :ora_types ORA_OCI SQLCS_NCHAR );

my $dbh;
$| = 1;
SKIP: {

    plan skip_all => 'Unable to run unicode test, perl version is less than 5.6'
      unless ( $] >= 5.006 );
    plan skip_all => 'Oracle charset tests unreliable for Oracle 8 client'
      if ORA_OCI() < 9.0 and !$ENV{DBD_ALL_TESTS};

    set_nls_lang_charset( 'WE8MSWIN1252', 1 );
    $dbh = db_handle();

    plan skip_all => 'Unable to connect to Oracle' unless $dbh;
    plan skip_all => 'Database character set is not Unicode'
      unless db_ochar_is_utf($dbh);

t/23wide_db_al32utf8.t  view on Meta::CPAN

    test_data show_test_data select_rows
    create_table insert_rows dump_table
    set_nls_lang_charset db_ochar_is_utf
    insert_test_count select_test_count
/;

my $dbh;
$| = 1;
SKIP: {

    plan skip_all => 'Unable to run unicode test, perl version is less than 5.6'
        unless ( $] >= 5.006 );
    plan skip_all => 'Oracle charset tests unreliable for Oracle 8 client'
        if ORA_OCI() < 9.0 and !$ENV{DBD_ALL_TESTS};

    set_nls_lang_charset( (ORA_OCI >= 9.2) ? 'AL32UTF8' : 'UTF8', 1 );
    $dbh = db_handle();

    plan skip_all => 'Unable to connect to Oracle' unless $dbh;
    plan skip_all => 'Database character set is not Unicode' unless db_ochar_is_utf($dbh) ;
    # testing utf8 with char columns (wide mode database)

t/30long.t  view on Meta::CPAN

    [ 'CLOB',     ORA_CLOB,    0 ],
    [ 'BLOB',     ORA_BLOB,    0 ],
);
push @test_sets, [ 'NCLOB', ORA_CLOB, 0 ]
  unless ORA_OCI() < 9.0 or $ENV{DBD_ALL_TESTS};

my $table = table();
my $use_utf8_data;    # set per test_set below
my %warnings;

my @skip_unicode;
push @skip_unicode, 'Perl < 5.6 ' if $] < 5.006;
push @skip_unicode, 'Oracle client < 9.0 '
  if ORA_OCI() < 9.0 and !$ENV{DBD_ALL_TESTS};

# Set size of test data (in 10KB units)
#        Minimum value 3 (else tests fail because of assumptions)
#        Normal  value 8 (to test old 64KB threshold well)
my $sz = 8;

my ( $p1, $p2, $tmp, @tmp );

my $dbh = db_handle( { PrintError => 0 } )

t/30long.t  view on Meta::CPAN


sub use_utf8_data {
    my ( $dbh, $type_name ) = @_;

    return 0
      unless ( $type_name =~ m/^CLOB/i
        and db_ochar_is_utf($dbh) && client_ochar_is_utf8() )
      or ( $type_name =~ m/^NCLOB/i
        and db_nchar_is_utf($dbh) && client_nchar_is_utf8() );

    return 1 unless @skip_unicode;

    warn "Skipping Unicode data tests: @skip_unicode\n"
      if !$warnings{use_utf8_data}++;
}

sub run_long_tests {
    my ( $dbh, $type_name, $type_num ) = @_;
    my ($sth);
    my $append_len;
  SKIP:
    {    #it all

t/lib/DBDOracleTestLib.pm  view on Meta::CPAN


    # Non-BMP characters require use of surrogates with UTF-16
    # So U+10304 becomes U+D800 followed by U+DF04 (I think) in UTF-16.
    #
    # When encoded as standard UTF-8, which Oracle calls AL32UTF8, it should
    # be a single UTF-8 code point (that happens to occupy 4 bytes).
    #
    # When encoded as "CESU-8", which Oracle calls "UTF8", each surrogate
    # is treated as a code point so you get 2 UTF-8 code points
    # (that happen to occupy 3 bytes each). That is not valid UTF-8.
    # See http://www.unicode.org/reports/tr26/ for more information.
    return unless ORA_OCI >= 9.2;    # need AL32UTF8 for these to work
    return (
        [ "\x{10304}", 'SMP Plane 1 wide char' ],    # OLD ITALIC LETTER E
        [ "\x{20301}", 'SIP Plane 2 wide char' ]
        ,    # CJK Unified Ideographs Extension B
    );
}

{

t/lib/DBDOracleTestLib.pm  view on Meta::CPAN

        # These are not safe for db's with US7ASCII
        #       [ "\x{A1}", "upside down bang" ],
        #       [ "\x{A2}", "cent char"        ],
        #       [ "\x{A3}", "british pound"    ],
    ];

sub _narrow_data    # Assuming WE8ISO8859P1 or WE8MSWIN1252 character set
{
    my $highbitset = [

        # These non-unicode strings are not safe if client charset is utf8
        # because we have to let oracle assume they're utf8 but they're not
        [ chr(161), 'upside down bang' ],
        [ chr(162), 'cent char'        ],
        [ chr(163), 'british pound'    ],
    ];
    [
        [ 'a',    'lowercase a' ],
        [ 'b',    'lowercase b' ],
        [ chr(3), 'control-C'   ],
        ( _nls_local_has_utf8() ) ? () : @$highbitset

t/lib/DBDOracleTestLib.pm  view on Meta::CPAN

    note($out);
    my $ora_client_version = ORA_OCI();
    $out =
      sprintf
      "Client $ora_client_version NLS_LANG is '%s', NLS_NCHAR is '%s'\n",
      ora_env_var('NLS_LANG')  || '<unset>',
      ora_env_var('NLS_NCHAR') || '<unset>';
    note($out);
}

sub db_ochar_is_utf { return shift->ora_can_unicode & 2 }
sub db_nchar_is_utf { return shift->ora_can_unicode & 1 }

sub client_ochar_is_utf8 {
    my $NLS_LANG = ora_env_var('NLS_LANG') || q();
    $NLS_LANG =~ s/.*\.//;
    return $NLS_LANG =~ m/utf8/i;
}

sub client_nchar_is_utf8 {
    my $NLS_LANG = ora_env_var('NLS_LANG') || q();
    $NLS_LANG =~ s/.*\.//;

t/lib/DBDOracleTestLib.pm  view on Meta::CPAN

      if $^O eq 'cygwin';
}

sub _byte_string {
    my $ret = join( '|', unpack( 'C*', $_[0] ) );
    return $ret;
}

sub nice_string {
    my @raw_chars = ( utf8::is_utf8( $_[0] ) )
      ? unpack( 'U*', $_[0] )     # unpack unicode characters
      : unpack( 'C*', $_[0] );    # not unicode, so unpack as bytes
    my @chars = map {
        $_ > 255
          ?                       # if wide character...
          sprintf( "\\x{%04X}", $_ )
          :                       # \x{...}
          chr($_) =~ /[[:cntrl:]]/
          ?                       # else if control character ...
          sprintf( "\\x%02X", $_ )
          :                       # \x..
          chr($_)                 # else as themselves



( run in 0.454 second using v1.01-cache-2.11-cpan-f29a10751f0 )