DBD-MaxDB
view release on metacpan or search on metacpan
t/117execute.t
t/118emptyresultset.t
t/119bind_param_inout.t
t/120fetchrow_array.t
t/121fetchrow_arrayref.t
t/122fetchrow_hashref.t
t/123fetchall_arrayref.t
t/130bind_col.t
t/131bind_columns.t
t/133blobfetch.t
t/134unicode.t
t/135ChopBlanks.t
t/136AutoCommit.t
t/137stmtstdproperties2.t
t/138severalstmts.t
t/139fetchAllTypes.t
t/142UndefParameter.t
t/143BooleanTypeHandling.t
t/144simpleunicode.t
t/145simple8bitascii.t
t/lib.pl
t/MaxDB.dbtest
t/MaxDB.mtest
t/MaxDBTest.pm
t/mysql_00base.t
t/mysql_10dsnlist.t
t/mysql_20createdrop.t
t/mysql_30insertfetch.t
t/mysql_40bindparam.t
Makefile.PL view on Meta::CPAN
print "\n";
sub MY::post_constants {
my ($self) = shift;
my $sqldbc_sl_name = 'libSQLDBC_C.'.$Config{so};
'
# copy some files
inst_libdbdsqldbc = ' . File::Spec->catdir ($self->{INST_LIB}, 'DBD/MaxDB') . '
getinfo_pm = ' . File::Spec->catfile($self->{INST_LIB}, 'DBD/MaxDB', 'GetInfo.pm') . '
typeinfoascii_pm = ' . File::Spec->catfile($self->{INST_LIB}, 'DBD/MaxDB', 'TypeInfoAscii.pm') . '
typeinfounicode_pm = ' . File::Spec->catfile($self->{INST_LIB}, 'DBD/MaxDB', 'TypeInfoUnicode.pm') . '
inst_libdbdsqldbc_c_sl = ' . File::Spec->catdir ($self->{INST_ARCHAUTODIR}, '') . '
libdbdsqldbc_c_sl = ' . File::Spec->catfile($self->{INST_ARCHAUTODIR}, '', $sqldbc_sl_name) . '
config :: $(getinfo_pm) $(typeinfoascii_pm) $(typeinfounicode_pm) $(libdbdsqldbc_c_sl)
@$(NOOP)
$(getinfo_pm): GetInfo.pm
$(NOECHO) $(MKPATH) $(inst_libdbdsqldbc)
$(NOECHO) $(RM_F) $(getinfo_pm)
$(CP) GetInfo.pm $(getinfo_pm)
$(typeinfoascii_pm): TypeInfoAscii.pm
$(NOECHO) $(MKPATH) $(inst_libdbdsqldbc)
$(NOECHO) $(RM_F) $(typeinfoascii_pm)
$(CP) TypeInfoAscii.pm $(typeinfoascii_pm)
$(typeinfounicode_pm): TypeInfoUnicode.pm
$(NOECHO) $(MKPATH) $(inst_libdbdsqldbc)
$(NOECHO) $(RM_F) $(typeinfounicode_pm)
$(CP) TypeInfoUnicode.pm $(typeinfounicode_pm)
$(libdbdsqldbc_c_sl): '.$SQLDBC_sl.'
$(NOECHO) $(MKPATH) $(inst_libdbdsqldbc_c_sl)
$(NOECHO) $(RM_F) $(libdbdsqldbc_c_sl)
$(CP) '.$SQLDBC_sl.' $(libdbdsqldbc_c_sl)
';
}
# ====================================================================
sub checkSQLDBCSDK {
my ($dbh, $sqltype) = @_;
# create a "blank" statement handle
my $sth = DBI::_new_sth($dbh, { 'Statement' => "SQLGetTypeInfo" });
# print "SQL Type is $sqltype\n";
_GetTypeInfo($dbh, $sth, $sqltype) or return undef;
$sth;
}
sub type_info_all {
my ($dbh) = @_;
my $res = DBD::MaxDB::db::_isunicode($dbh);
if ($res) {
require DBD::MaxDB::TypeInfoUnicode;
return $DBD::MaxDB::TypeInfoUnicode::type_info_all;
} else {
require DBD::MaxDB::TypeInfoAscii;
return $DBD::MaxDB::TypeInfoAscii::type_info_all;
}
}
}
=item C<maxdb_sdkversion (string, read-only)>
Gets the version of the MaxDB SQLDBC software development kit used by the driver.
=item C<maxdb_sqlmode (string)>
Gets/Sets the SQL mode of the current connection. Possible values are
C<ORACLE | INTERNAL>.
=item C<maxdb_unicode (boolean, read-only)>
Indicates whether the current connection supports unicode (true) or not (false)
=back
=head2 Statement Handle Attributes
The driver supports all of the DBI statement handle attributes provided by DBI.
Additionally the driver provides some MaxDB specific statement handle attributes.
=over 4
or die "Can't create table $DBI::err $DBI::errstr\n";
$sth = $dbh->prepare("INSERT INTO defaultvalues (ID) values (?)")
or die "Can't prepare statement $DBI::err $DBI::errstr\n";
$res = $sth->execute($DBD::MaxDB::DEFAULT_PARAMETER)
or die "Can't execute statement $DBI::err $DBI::errstr\n";
...
=head1 UNICODE
DBD::MaxDB supports Unicode. Perl's internal unicode format is UTF-8
but MaxDB uses UCS-2. Therefor the support is limited to UTF-8 characters
that also contained in the UCS-2 standard.
=head2 Perl and Unicode
Perl began implementing Unicode with version 5.6. But if you plan to use Unicode
it is strongly recomended to use perl 5.8.2 or later. Details about using
unicode in perl can you find in the perl documentation:
perldoc perluniintro
perldoc perlunicode
=head2 MaxDB and Unicode
MaxDB supports the code attribute Unicode for the data type CHAR and is able to
display various presentation codes in Unicode format. As well as storing data in Unicode,
you can also store the names of database objects (for example, table or column names) in
Unicode and display these with the database tools in the desired presentation code.
= head2 Installing a Unicode-Enabled Database
MODULE = DBD::MaxDB PACKAGE = DBD::MaxDB::db
void
_ping(dbh)
SV * dbh
CODE:
ST(0) = dbd_maxdb_db_ping(dbh)? &sv_yes : &sv_no;
void
_isunicode(dbh)
SV * dbh
CODE:
ST(0) = dbd_maxdb_db_isunicode(dbh)? &sv_yes : &sv_no;
void
_getSQLMode(dbh)
SV * dbh
CODE:
ST(0) = dbd_maxdb_db_getSQLMode(dbh);
void
_getVersion(dbh)
SV * dbh
{ SQLDBC_INTERNAL, {"INTERNAL" ,sizeof("INTERNAL")-1}},
{ SQLDBC_ORACLE, {"O" ,sizeof("O")-1}},
{ SQLDBC_ORACLE, {"ORACLE" ,sizeof("ORACLE")-1}}
};
#define DBD_MAXDB_SQLMODETABLESIZE (sizeof(dbh_sqlmodeTab) /sizeof(dbd_maxdb_cmdKeywordTable))
typedef enum {
dbd_maxdb_option_autocommit = 1,
dbd_maxdb_option_isolationlevel = 2,
dbd_maxdb_option_kernelversion = 3,
dbd_maxdb_option_unicodedb = 4,
dbd_maxdb_option_sdkversion = 5,
dbd_maxdb_option_sqlmode = 6,
dbd_maxdb_option_libraryversion = 7,
dbd_maxdb_option_readlongcomplete = 8,
dbd_maxdb_option_unknown = -1
}dbd_maxdb_option;
static dbd_maxdb_cmdKeywordTable dbh_optionTab [ ]= {
{ dbd_maxdb_option_autocommit, {"AUTOCOMMIT" ,sizeof("AUTOCOMMIT")-1}},
{ dbd_maxdb_option_isolationlevel, {"MAXDB_ISOLATIONLEVEL" ,sizeof("MAXDB_ISOLATIONLEVEL")-1}},
{ dbd_maxdb_option_kernelversion, {"MAXDB_KERNELVERSION" ,sizeof("MAXDB_KERNELVERSION")-1}},
{ dbd_maxdb_option_libraryversion, {"MAXDB_LIBRARYVERSION" ,sizeof("MAXDB_LIBRARYVERSION")-1}},
{ dbd_maxdb_option_readlongcomplete, {"MAXDB_READ_LONG_COMPLETE" ,sizeof("MAXDB_READ_LONG_COMPLETE")-1}},
{ dbd_maxdb_option_sdkversion, {"MAXDB_SDKVERSION" ,sizeof("MAXDB_SDKVERSION")-1}},
{ dbd_maxdb_option_sqlmode, {"MAXDB_SQLMODE" ,sizeof("MAXDB_SQLMODE")-1}},
{ dbd_maxdb_option_unicodedb, {"MAXDB_UNICODE" ,sizeof("MAXDB_UNICODE")-1}},
};
#define DBD_MAXDB_OPTIONTABLESIZE (sizeof(dbh_optionTab) /sizeof(dbd_maxdb_cmdKeywordTable))
static SQLDBC_Int4 analyzeKeyword(char* pIdentifier, SQLDBC_Int4 IdentLength, dbd_maxdb_cmdKeywordTable myCMDKeywTab[] ,SQLDBC_Int4 numElementsTab){
SQLDBC_Int4 m,pos,compareLength,begin = 1; /*lower bound of search scope*/
SQLDBC_Int4 end = numElementsTab; /*upper bound of search scope*/
char UpperIdentifier[DBD_MAXDB_MAX_KEYWORD_LEN]; /*pIdentifier in upper cases*/
break;
}
case dbd_maxdb_option_isolationlevel:{
result = sv_2mortal(newSViv(SQLDBC_Connection_getTransactionIsolation (imp_dbh->m_connection)));
break;
}
case dbd_maxdb_option_kernelversion:{
result = sv_2mortal(newSViv(SQLDBC_Connection_getKernelVersion(imp_dbh->m_connection)));
break;
}
case dbd_maxdb_option_unicodedb:{
result = (SQLDBC_Connection_isUnicodeDatabase (imp_dbh->m_connection))?&PL_sv_yes:&PL_sv_no;
break;
}
case dbd_maxdb_option_readlongcomplete:{
result = (imp_dbh->m_readlongcompletly)?&PL_sv_yes:&PL_sv_no;
break;
}
case dbd_maxdb_option_libraryversion :{
char* msg = SQLDBC_Environment_getLibraryVersion (imp_drh->m_maxDBEnv);
result = sv_2mortal(newSVpv(msg, strlen(msg)));
dTHR;
#endif
D_imp_dbh(dbh);
DBD_MAXDB_METHOD_ENTER (imp_dbh, dbd_maxdb_db_ping);
DBD_MAXDB_METHOD_RETURN (imp_dbh, dbd_maxdb_db_ping, (SQLDBC_Connection_isConnected (imp_dbh->m_connection)?1:0));
}
/***************************************************************************
*
* Name: dbd_maxdb_db_isunicode
*
* Purpose: tests if database is unicode or not.
*
* Input: dbh - connect handle
*
* Returns: TRUE if the database is an unicode database, FALSE otherwise;
* do_error will be called in the latter case
*
**************************************************************************/
int dbd_maxdb_db_isunicode(SV* dbh){
#if defined(dTHR)
dTHR;
#endif
D_imp_dbh(dbh);
DBD_MAXDB_METHOD_ENTER (imp_dbh, dbd_maxdb_db_isunicode);
DBD_MAXDB_METHOD_RETURN (imp_dbh, dbd_maxdb_db_isunicode, (SQLDBC_Connection_isUnicodeDatabase (imp_dbh->m_connection)?1:0));
}
/***************************************************************************
*
* Name: dbd_maxdb_db_getSQLMode
*
* Purpose: retrieves the SQL Mode of the underlaying database.
*
* Input: dbh - connect handle
*
int dbd_maxdb_db_rollback(SV* dbh, imp_dbh_t* imp_dbh);
int dbd_maxdb_db_disconnect(SV* dbh, imp_dbh_t* imp_dbh);
int dbd_maxdb_db_STORE_attrib(SV* dbh, imp_dbh_t* imp_dbh, SV* keysv, SV* valuesv);
SV* dbd_maxdb_db_FETCH_attrib(SV* dbh, imp_dbh_t* imp_dbh, SV* keysv) ;
void dbd_maxdb_db_destroy(SV* dbh, imp_dbh_t* imp_dbh);
int dbd_maxdb_st_prepare(SV* sth, imp_sth_t* imp_sth, char* statement, SV* attribs);
int dbd_st_blob_read (SV *sth, imp_sth_t *imp_sth, int field, long offset, long len, SV *destrv, long destoffset);
int dbd_maxdb_db_STORE_attrib(SV* dbh, imp_dbh_t* imp_dbh, SV* keysv, SV* valuesv);
void dbd_maxdb_st_destroy(SV* sth, imp_sth_t* imp_sth);
int dbd_maxdb_db_ping(SV* dbh);
int dbd_maxdb_db_isunicode(SV* dbh);
void dbd_maxdb_init(dbistate_t* dbistate);
int dbd_maxdb_bind_ph (SV *sth, imp_sth_t *imp_sth, SV *param, SV *value,
IV sql_type, SV *attribs, int is_inout, IV maxlen);
AV* dbd_maxdb_st_fetch(SV* sth, imp_sth_t* imp_sth);
SV* dbd_maxdb_st_FETCH_attrib(SV* sth, imp_sth_t* imp_sth, SV* keysv);
int dbd_maxdb_st_STORE_attrib(SV* sth, imp_sth_t* imp_sth, SV* keysv, SV* valuesv);
int dbd_maxdb_db_executeInternal( SV *dbh, SV *sth, char *statement );
int dbd_maxdb_db_executeUpdate( SV *dbh, SV *statement );
SV* dbd_maxdb_st_cancel( SV *sth);
t/116bind_param.t view on Meta::CPAN
my $sth;
my $rc;
print "1..$tests\n";
# prepare
MaxDBTest::beginTest("connect");
my $dbh = DBI->connect() or die "Can't connect $DBI::err $DBI::errstr\n";
MaxDBTest::loginfo("We have a " . (($dbh->{'MAXDB_UNICODE'}) ? "unicode" : "ascii") . " database");
MaxDBTest::endTest();
MaxDBTest::beginTest("drop table");
MaxDBTest::dropTable($dbh, "GerosTestTable");
MaxDBTest::endTest();
MaxDBTest::beginTest("create table with several columns ()");
if ($dbh->{'MAXDB_UNICODE'}) {
$dbh->do("CREATE TABLE GerosTestTable (i INTEGER, la LONG ASCII, vc VARCHAR(50) ASCII, lu LONG UNICODE, vcu VARCHAR(50) UNICODE)") or die "CREATE TABLE failed $DBI::err $DBI::errstr\n";
} else {
t/134unicode.t view on Meta::CPAN
#!perl -w -I./t
#/*!
# @file 134unicode.t
# @author GeroD
# @ingroup dbd::MaxDB
# @brief insert and fetch unicode data (as ascii and unicode)
#
#\if EMIT_LICENCE
#
# ========== licence begin GPL
# Copyright (C) 2001-2004 SAP AG
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
t/134unicode.t view on Meta::CPAN
# run
my ($origla, $origvc) = ("la string", "vc string");
MaxDBTest::beginTest("insert one row as ascii");
if ($dbh->{'MAXDB_UNICODE'}) {
$dbh->do(qq{INSERT INTO GerosTestTable (la, vc, i) VALUES ('$origla', '$origvc', 1)}) or MaxDBTest::logerror(qq{do INSERT failed $DBI::err $DBI::errstr});
}
MaxDBTest::endTest();
MaxDBTest::beginTest("?? fetch as unicode and compare");
MaxDBTest::endTest();
MaxDBTest::beginTest("fetch as ascii and compare");
if ($dbh->{'MAXDB_UNICODE'}) {
my ($resla, $resvc) = $dbh->selectrow_array(qq{SELECT la, vc FROM GerosTestTable});
if (($origla ne $resla) || ($origvc ne $resvc)) {
MaxDBTest::logerror(qq{wrong data returned: ('$resla', '$resvc'). Expected was ('$origla', '$origvc')});
}
}
MaxDBTest::endTest();
MaxDBTest::beginTest("?? insert another row as unicode");
MaxDBTest::endTest();
MaxDBTest::beginTest("?? fetch as ascii and compare");
MaxDBTest::endTest();
# release
MaxDBTest::beginTest("drop table");
t/144simpleunicode.t view on Meta::CPAN
#!perl -w -I./t
#/*!
# @file 144simpleunicode.t
# @author MarcoP
# @ingroup dbd::MaxDB
# @brief simple unicode test
#
#\if EMIT_LICENCE
#
# ========== licence begin GPL
# Copyright (C) 2001-2004 SAP AG
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
t/144simpleunicode.t view on Meta::CPAN
print "1..0 # Skipped: DBI_DSN is undefined\n";
exit;
}
}
print "1..$tests\n";
MaxDBTest::beginTest("primary connect");
my $dbh = DBI->connect() or die "Can't connect $DBI::err $DBI::errstr\n";
MaxDBTest::endTest();
my $unicodesupport = $dbh->{"MAXDB_UNICODE"};
my $username;
if ($unicodesupport) {
$username = eval q{ "äü\x{8f6f}\x{4ef6}\x{5f00}\x{53d1}\x{5546}\x{662f}\x{82f1}\x{96c4}" };
$username = "\"".$username."\"";
$password = eval q{ "äüö" };
# $password = eval q{ "\x{8f6f}\x{4ef6}\x{5f00}" };
$password = "\"".$password."\"";
} else {
$username = "abc123";
$password = "abc123";
}
#print "username $username\n" if $unicodesupport;
MaxDBTest::beginTest("drop/create user\n");
$dbh->do(qq{DROP USER $username});
$dbh->do(qq{CREATE USER $username PASSWORD $password DBA NOT EXCLUSIVE}) or die "CREATE USER failed $DBI::err $DBI::errstr\n";
MaxDBTest::endTest();
MaxDBTest::beginTest("connect with unicode user\n");
$dbh = DBI->connect($ENV{DBI_DSN}, $username, $password, {}) or die "Can't connect $DBI::err $DBI::errstr\n";
MaxDBTest::endTest();
MaxDBTest::beginTest("drop table\n");
MaxDBTest::dropTable($dbh, $username);
MaxDBTest::endTest();
MaxDBTest::beginTest("create table (two integer columns)\n");
my $cmd = "CREATE TABLE ".$username." ("
."C_CHARASCII Char (10) ASCII,"
."C_CHARBYTE Char (6) BYTE,";
if ($unicodesupport) {
$cmd.= "C_CHARUNICODE Char (10) UNICODE,";
} else {
$cmd.="C_CHARUNICODE Char (10),";
}
$cmd.="C_VARCHARASCII Varchar (10) ASCII,"
."C_VARCHARBYTE Varchar (10) BYTE,";
if ($unicodesupport) {
$cmd.="C_VARCHARUNICODE Varchar (10) UNICODE,";
}else{
$cmd.="C_VARCHARUNICODE Varchar (10),";
}
$cmd.="C_LONGASCII Long ASCII,"
."C_LONGBYTE Long BYTE";
if ($unicodesupport) {
$cmd.=",C_LONGUNICODE Long UNICODE" ;
}else{
$cmd.=",C_LONGUNICODE Long";
}
$cmd.=")" ;
$dbh->do($cmd);
MaxDBTest::endTest();
my $stringAscii = eval q{ "äüöabc123" };
my $stringByte = eval q{ "abc123" };
my $stringutf8;
if ($unicodesupport) {
$stringutf8 = eval q{ "\x{8f6f}\x{4ef6}\x{5f00}\x{53d1}\x{5546}\x{662f}\x{82f1}\x{96c4}" };
}else{
$stringutf8 = eval q{ "äüöß" };
}
MaxDBTest::beginTest("insert one row");
$sth = $dbh->prepare("INSERT INTO ".$username." VALUES (?,?,?,?,?,?,?,?,?)") or die "INSERT failed $DBI::err $DBI::errstr\n";
MaxDBTest::endTest();
MaxDBTest::beginTest("bind parameters with valid index");
$sth->bind_param(1, $stringAscii) or die "bind_param failed (column 1) $DBI::err $DBI::errstr";
t/145simple8bitascii.t view on Meta::CPAN
#!perl -w -I./t
#/*!
# @file 145simple8bitascii.t
# @author MarcoP
# @ingroup dbd::MaxDB
# @brief simple unicode test
#
#\if EMIT_LICENCE
#
# ========== licence begin GPL
# Copyright (C) 2001-2004 SAP AG
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
t/145simple8bitascii.t view on Meta::CPAN
print "1..0 # Skipped: DBI_DSN is undefined\n";
exit;
}
}
print "1..$tests\n";
MaxDBTest::beginTest("primary connect");
my $dbh = DBI->connect() or die "Can't connect $DBI::err $DBI::errstr\n";
MaxDBTest::endTest();
my $unicodesupport = $dbh->{"MAXDB_UNICODE"};
my $username;
if ($unicodesupport) {
$username = eval q{ "äüöß" };
$username = "\"".$username."\"";
$password = eval q{ "äüö" };
# $password = eval q{ "\x{8f6f}\x{4ef6}\x{5f00}" };
$password = "\"".$password."\"";
} else {
$username = "äüöß";
$password = "äöü";
}
#print "username $username\n" if $unicodesupport;
MaxDBTest::beginTest("drop/create user\n");
$dbh->do(qq{DROP USER $username});
$dbh->do(qq{CREATE USER $username PASSWORD $password DBA NOT EXCLUSIVE}) or die "CREATE USER failed $DBI::err $DBI::errstr\n";
MaxDBTest::endTest();
MaxDBTest::beginTest("connect with unicode user\n");
$dbh = DBI->connect($ENV{DBI_DSN}, $username, $password, {}) or die "Can't connect $DBI::err $DBI::errstr\n";
MaxDBTest::endTest();
MaxDBTest::beginTest("drop table\n");
MaxDBTest::dropTable($dbh, $username);
MaxDBTest::endTest();
MaxDBTest::beginTest("create table (two integer columns)\n");
my $cmd = "CREATE TABLE ".$username." ("
."C_CHARASCII Char (10) ASCII,"
."C_CHARBYTE Char (6) BYTE,";
if ($unicodesupport) {
$cmd.= "C_CHARUNICODE Char (10) UNICODE,";
} else {
$cmd.="C_CHARUNICODE Char (10),";
}
$cmd.="C_VARCHARASCII Varchar (10) ASCII,"
."C_VARCHARBYTE Varchar (10) BYTE,";
if ($unicodesupport) {
$cmd.="C_VARCHARUNICODE Varchar (10) UNICODE,";
}else{
$cmd.="C_VARCHARUNICODE Varchar (10),";
}
$cmd.="C_LONGASCII Long ASCII,"
."C_LONGBYTE Long BYTE";
if ($unicodesupport) {
$cmd.=",C_LONGUNICODE Long UNICODE" ;
}else{
$cmd.=",C_LONGUNICODE Long";
}
$cmd.=")" ;
$dbh->do($cmd);
MaxDBTest::endTest();
my $stringAscii = eval q{ "äüöabc123" };
my $stringByte = eval q{ "abc123" };
my $stringutf8;
if ($unicodesupport) {
$stringutf8 = eval q{ "äüößäüößäü" };
}else{
$stringutf8 = eval q{ "äüöß" };
}
MaxDBTest::beginTest("insert one row");
$sth = $dbh->prepare("INSERT INTO ".$username." VALUES (?,?,?,?,?,?,?,?,?)") or die "INSERT failed $DBI::err $DBI::errstr\n";
MaxDBTest::endTest();
MaxDBTest::beginTest("bind parameters with valid index");
$sth->bind_param(1, $stringAscii) or die "bind_param failed (column 1) $DBI::err $DBI::errstr";
( run in 0.654 second using v1.01-cache-2.11-cpan-88abd93f124 )