Commit 2ac02cf3 authored by Sergey Vojtovich's avatar Sergey Vojtovich

Merge patch for BUG#58079.

parents 444eabca 13bc5b3f
# Check for IBM i 6.1 or later
--disable_query_log
system uname -rv > $MYSQLTEST_VARDIR/tmp/version;
--disable_warnings
drop table if exists uname_vr;
--enable_warnings
create temporary table uname_vr (r int, v int);
--disable_warnings
eval LOAD DATA INFILE "$MYSQLTEST_VARDIR/tmp/version" into table uname_vr fields terminated by ' ';
--enable_warnings
let $ok = `select count(*) from uname_vr where v = 5 and r = 4`;
drop table uname_vr;
remove_file $MYSQLTEST_VARDIR/tmp/version;
--enable_query_log
if (!$ok)
{
skip "Need IBM i 5.4 or later";
}
# Check for IBM i 6.1 or later
--disable_query_log
system uname -rv > $MYSQLTEST_VARDIR/tmp/version;
--disable_warnings
drop table if exists uname_vr;
--enable_warnings
create temporary table uname_vr (r int, v int);
--disable_warnings
eval LOAD DATA INFILE "$MYSQLTEST_VARDIR/tmp/version" into table uname_vr fields terminated by ' ';
--enable_warnings
let $ok = `select count(*) from uname_vr where v > 5`;
drop table uname_vr;
remove_file $MYSQLTEST_VARDIR/tmp/version;
--enable_query_log
if (!$ok)
{
skip "Need IBM i 6.1 or later";
}
if (!`SELECT count(*) FROM information_schema.engines WHERE
(support = 'YES' OR support = 'DEFAULT') AND
engine = 'ibmdb2i'`)
{
skip Need ibmdb2i engine;
}
create schema `A12345_@$#`;
create table `A12345_@$#`.t1 (i int) engine=ibmdb2i;
show create table `A12345_@$#`.t1;
Table Create Table
t1 CREATE TABLE `t1` (
`i` int(11) DEFAULT NULL
) ENGINE=IBMDB2I DEFAULT CHARSET=latin1
select * from `A12345_@$#`.t1;
i
drop table `A12345_@$#`.t1;
drop schema `A12345_@$#`;
create table t1 (c char(10) collate utf8_swedish_ci, index(c)) engine=ibmdb2i;
drop table t1;
create table t1 (c char(10) collate ucs2_swedish_ci, index(c)) engine=ibmdb2i;
drop table t1;
create table t1 (c char(1) character set armscii8) engine=ibmdb2i;
ERROR HY000: Can't create table 'test.t1' (errno: 2504)
create table t1 (c char(1) character set eucjpms ) engine=ibmdb2i;
ERROR HY000: Can't create table 'test.t1' (errno: 2504)
create table ABC (i int) engine=ibmdb2i;
drop table ABC;
create table `1234567890ABC` (i int) engine=ibmdb2i;
drop table `1234567890ABC`;
create table `!@#$%` (i int) engine=ibmdb2i;
drop table `!@#$%`;
create table `ABCD#########` (i int) engine=ibmdb2i;
drop table `ABCD#########`;
create table `_` (i int) engine=ibmdb2i;
drop table `_`;
create table `abc##def` (i int) engine=ibmdb2i;
drop table `abc##def`;
set names utf8;
create table İ (s1 int) engine=ibmdb2i;
drop table İ;
create table İİ (s1 int) engine=ibmdb2i;
drop table İİ;
set names latin1;
drop table if exists t1;
create table t1 (c char(10), index(c)) collate ucs2_czech_ci engine=ibmdb2i;
insert into t1 values ("ch"),("h"),("i");
select * from t1 order by c;
c
h
ch
i
drop table t1;
create table t1 (c char(10), index(c)) collate utf8_czech_ci engine=ibmdb2i;
insert into t1 values ("ch"),("h"),("i");
select * from t1 order by c;
c
h
ch
i
drop table t1;
create table t1 (c char(10), index(c)) collate ucs2_danish_ci engine=ibmdb2i;
insert into t1 values("abc"),("abcd"),("aaaa");
select c from t1 order by c;
c
abc
abcd
aaaa
drop table t1;
create table t1 (c char(10), index(c)) collate utf8_danish_ci engine=ibmdb2i;
insert into t1 values("abc"),("abcd"),("aaaa");
select c from t1 order by c;
c
abc
abcd
aaaa
drop table t1;
drop table if exists t1;
create table t1 (c char(10), index(c)) charset macce engine=ibmdb2i;
insert into t1 values ("test");
select * from t1 order by c;
c
test
drop table t1;
set ibmdb2i_create_index_option=1;
drop schema if exists test1;
create schema test1;
use test1;
CREATE TABLE t1 (f int primary key, index(f)) engine=ibmdb2i;
drop table t1;
CREATE TABLE t1 (f char(10) collate utf8_bin primary key, index(f)) engine=ibmdb2i;
drop table t1;
CREATE TABLE t1 (f char(10) collate latin1_swedish_ci primary key, index(f)) engine=ibmdb2i;
drop table t1;
CREATE TABLE t1 (f char(10) collate latin1_swedish_ci primary key, i int, index i(i,f)) engine=ibmdb2i;
drop table t1;
create table fd (SQSSEQ CHAR(10)) engine=ibmdb2i;
select * from fd;
SQSSEQ
*HEX
*HEX
*HEX
*HEX
drop table fd;
create table ABC (i int) engine=ibmdb2i;
insert into ABC values(1);
create table abc (i int) engine=ibmdb2i;
insert into abc values (2);
select * from ABC;
i
1
drop table ABC;
drop table abc;
This diff is collapsed.
source suite/ibmdb2i/include/have_ibmdb2i.inc;
source include/have_case_sensitive_file_system.inc;
create schema `A12345_@$#`;
create table `A12345_@$#`.t1 (i int) engine=ibmdb2i;
show create table `A12345_@$#`.t1;
select * from `A12345_@$#`.t1;
drop table `A12345_@$#`.t1;
drop schema `A12345_@$#`;
source suite/ibmdb2i/include/have_ibmdb2i.inc;
source suite/ibmdb2i/include/have_i61.inc;
create table t1 (c char(10) collate utf8_swedish_ci, index(c)) engine=ibmdb2i;
drop table t1;
create table t1 (c char(10) collate ucs2_swedish_ci, index(c)) engine=ibmdb2i;
drop table t1;
--source suite/ibmdb2i/include/have_ibmdb2i.inc
--source suite/ibmdb2i/include/have_i54.inc
--error 1005
create table t1 (c char(1) character set armscii8) engine=ibmdb2i;
--error 1005
create table t1 (c char(1) character set eucjpms ) engine=ibmdb2i;
source suite/ibmdb2i/include/have_ibmdb2i.inc;
# Test RCDFMT generation for a variety of kinds of table names
create table ABC (i int) engine=ibmdb2i;
drop table ABC;
create table `1234567890ABC` (i int) engine=ibmdb2i;
drop table `1234567890ABC`;
create table `!@#$%` (i int) engine=ibmdb2i;
drop table `!@#$%`;
create table `ABCD#########` (i int) engine=ibmdb2i;
drop table `ABCD#########`;
create table `_` (i int) engine=ibmdb2i;
drop table `_`;
create table `abc##def` (i int) engine=ibmdb2i;
drop table `abc##def`;
set names utf8;
create table İ (s1 int) engine=ibmdb2i;
drop table İ;
create table İİ (s1 int) engine=ibmdb2i;
drop table İİ;
set names latin1;
source suite/ibmdb2i/include/have_ibmdb2i.inc;
source suite/ibmdb2i/include/have_i61.inc;
--disable_warnings
drop table if exists t1;
--enable_warnings
create table t1 (c char(10), index(c)) collate ucs2_czech_ci engine=ibmdb2i;
insert into t1 values ("ch"),("h"),("i");
select * from t1 order by c;
drop table t1;
create table t1 (c char(10), index(c)) collate utf8_czech_ci engine=ibmdb2i;
insert into t1 values ("ch"),("h"),("i");
select * from t1 order by c;
drop table t1;
create table t1 (c char(10), index(c)) collate ucs2_danish_ci engine=ibmdb2i;
insert into t1 values("abc"),("abcd"),("aaaa");
select c from t1 order by c;
drop table t1;
create table t1 (c char(10), index(c)) collate utf8_danish_ci engine=ibmdb2i;
insert into t1 values("abc"),("abcd"),("aaaa");
select c from t1 order by c;
drop table t1;
source suite/ibmdb2i/include/have_ibmdb2i.inc;
source suite/ibmdb2i/include/have_i61.inc;
--disable_warnings
drop table if exists t1;
--enable_warnings
create table t1 (c char(10), index(c)) charset macce engine=ibmdb2i;
insert into t1 values ("test");
select * from t1 order by c;
drop table t1;
source suite/ibmdb2i/include/have_ibmdb2i.inc;
# Confirm that ibmdb2i_create_index_option causes additional *HEX sorted indexes to be created for all non-binary keys.
set ibmdb2i_create_index_option=1;
--disable_warnings
drop schema if exists test1;
create schema test1;
use test1;
--enable_warnings
--disable_abort_on_error
--error 0,255
exec system "DLTF QGPL/FDOUT" > /dev/null;
--enable_abort_on_error
#No additional index because no string fields in key
CREATE TABLE t1 (f int primary key, index(f)) engine=ibmdb2i;
--error 255
exec system "DSPFD FILE(\"test1\"/PRIM0001) TYPE(*SEQ) OUTPUT(*OUTFILE) OUTFILE(QGPL/FDOUT) OUTMBR(*FIRST *ADD)" > /dev/null;
--error 255
exec system "DSPFD FILE(\"test1\"/\"f___H_t1\") TYPE(*SEQ) OUTPUT(*OUTFILE) OUTFILE(QGPL/FDOUT) OUTMBR(*FIRST *ADD)" > /dev/null;
drop table t1;
#No additional index because binary sorting
CREATE TABLE t1 (f char(10) collate utf8_bin primary key, index(f)) engine=ibmdb2i;
--error 255
exec system "DSPFD FILE(\"test1\"/PRIM0001) TYPE(*SEQ) OUTPUT(*OUTFILE) OUTFILE(QGPL/FDOUT) OUTMBR(*FIRST *ADD)" > /dev/null;
--error 255
exec system "DSPFD FILE(\"test1\"/\"f___H_t1\") TYPE(*SEQ) OUTPUT(*OUTFILE) OUTFILE(QGPL/FDOUT) OUTMBR(*FIRST *ADD)" > /dev/null;
drop table t1;
CREATE TABLE t1 (f char(10) collate latin1_swedish_ci primary key, index(f)) engine=ibmdb2i;
exec system "DSPFD FILE(\"test1\"/PRIM0001) TYPE(*SEQ) OUTPUT(*OUTFILE) OUTFILE(QGPL/FDOUT) OUTMBR(*FIRST *ADD)" > /dev/null;
exec system "DSPFD FILE(\"test1\"/\"f___H_t1\") TYPE(*SEQ) OUTPUT(*OUTFILE) OUTFILE(QGPL/FDOUT) OUTMBR(*FIRST *ADD)" > /dev/null;
drop table t1;
CREATE TABLE t1 (f char(10) collate latin1_swedish_ci primary key, i int, index i(i,f)) engine=ibmdb2i;
exec system "DSPFD FILE(\"test1\"/PRIM0001) TYPE(*SEQ) OUTPUT(*OUTFILE) OUTFILE(QGPL/FDOUT) OUTMBR(*FIRST *ADD)" > /dev/null;
exec system "DSPFD FILE(\"test1\"/\"i___H_t1\") TYPE(*SEQ) OUTPUT(*OUTFILE) OUTFILE(QGPL/FDOUT) OUTMBR(*FIRST *ADD)" > /dev/null;
drop table t1;
create table fd (SQSSEQ CHAR(10)) engine=ibmdb2i;
system system "CPYF FROMFILE(QGPL/FDOUT) TOFILE(\"test1\"/\"fd\") mbropt(*replace) fmtopt(*drop *map)" > /dev/null;
select * from fd;
drop table fd;
source suite/ibmdb2i/include/have_ibmdb2i.inc;
source include/have_case_sensitive_file_system.inc;
create table ABC (i int) engine=ibmdb2i;
insert into ABC values(1);
create table abc (i int) engine=ibmdb2i;
insert into abc values (2);
select * from ABC;
drop table ABC;
drop table abc;
source suite/ibmdb2i/include/have_ibmdb2i.inc;
source suite/ibmdb2i/include/have_i61.inc;
--disable_warnings
drop table if exists t1, ffd, fd;
--enable_warnings
--disable_abort_on_error
--error 0,255
exec system "DLTF QGPL/FFDOUT" > /dev/null;
--error 0,255
exec system "DLTF QGPL/FDOUT" > /dev/null;
--enable_abort_on_error
let $count= query_get_value(select count(*) from information_schema.COLLATIONS where COLLATION_NAME <> "binary", count(*),1);
while ($count)
{
let $collation = query_get_value(select COLLATION_NAME from information_schema.COLLATIONS where COLLATION_NAME <> "binary" order by COLLATION_NAME desc, COLLATION_NAME, $count);
error 0,1005,2504,2028;
eval CREATE TABLE t1 ($collation integer, c char(10), v varchar(20), index(c), index(v)) collate $collation engine=ibmdb2i;
if (!$mysql_errno)
{
insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
insert into t1 select * from t1;
explain select c,v from t1 force index(c) where c like "ab%";
explain select c,v from t1 force index(v) where v like "de%";
drop table t1;
eval create table t1 ($collation char(10) primary key) collate $collation engine=ibmdb2i;
system system "DSPFFD FILE(\"test\"/\"t1\") OUTPUT(*OUTFILE) OUTFILE(QGPL/FFDOUT) OUTMBR(*FIRST *ADD)" > /dev/null;
system system "DSPFD FILE(\"test\"/\"t1\") TYPE(*SEQ) OUTPUT(*OUTFILE) OUTFILE(QGPL/FDOUT) OUTMBR(*FIRST *ADD)" > /dev/null;
drop table t1;
}
dec $count;
}
create table ffd (WHCHD1 CHAR(20), WHCSID decimal(5,0)) engine=ibmdb2i;
system system "CPYF FROMFILE(QGPL/FFDOUT) TOFILE(\"test\"/\"ffd\") mbropt(*replace) fmtopt(*drop *map)" > /dev/null;
create table fd (SQSSEQ CHAR(10)) engine=ibmdb2i;
system system "CPYF FROMFILE(QGPL/FDOUT) TOFILE(\"test\"/\"fd\") mbropt(*replace) fmtopt(*drop *map)" > /dev/null;
create temporary table intermed (row integer key auto_increment, cs char(30), ccsid integer);
insert into intermed (cs, ccsid) select * from ffd;
create temporary table intermed2 (row integer key auto_increment, srtseq char(10));
insert into intermed2 (srtseq) select * from fd;
select ccsid, cs, srtseq from intermed inner join intermed2 on intermed.row = intermed2.row;
drop table ffd, fd;
# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
#
# 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; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
CHECK_INCLUDE_FILES(qlgusr.h HAVE_PASE_ENVIRONMENT)
IF(HAVE_PASE_ENVIRONMENT)
INCLUDE_DIRECTORIES(
${CMAKE_SOURCE_DIR}/include
${CMAKE_BINARY_DIR}/include
${CMAKE_SOURCE_DIR}/regex
${CMAKE_SOURCE_DIR}/sql
${CMAKE_CURRENT_SOURCE_DIR}
/afs/rchland.ibm.com/lande/shadow/dev2000/osxpf/v5r4m0f.xpf/cur/cmvc/base.pgm/my.xpf/apis
/afs/rchland.ibm.com/lande/shadow/dev2000/osxpf/v5r4m0.xpf/bld/cmvc/base.pgm/lg.xpf
/afs/rchland.ibm.com/lande/shadow/dev2000/osxpf/v5r4m0.xpf/bld/cmvc/base.pgm/tq.xpf
)
SET (IBMDB2I_SOURCES ha_ibmdb2i.cc db2i_ileBridge.cc db2i_conversion.cc
db2i_blobCollection.cc db2i_file.cc db2i_charsetSupport.cc
db2i_collationSupport.cc db2i_errors.cc db2i_constraints.cc
db2i_rir.cc db2i_sqlStatementStream.cc db2i_ioBuffers.cc db2i_myconv.cc)
MYSQL_ADD_PLUGIN(ibmdb2i ${IBMDB2I_SOURCES} STORAGE_ENGINE LINK_LIBRARIES iconv)
ENDIF(HAVE_PASE_ENVIRONMENT)
#
# Copyright (c) 2007, 2008, IBM Corporation.
# All rights reserved.
#
#
#called from the top level Makefile
MYSQLDATAdir = $(localstatedir)
MYSQLSHAREdir = $(pkgdatadir)
MYSQLBASEdir= $(prefix)
MYSQLLIBdir= $(pkglibdir)
pkgplugindir = $(pkglibdir)/plugin
INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include \
-I$(top_srcdir)/regex \
-I$(top_srcdir)/sql \
-I$(srcdir) \
-I$ /afs/rchland.ibm.com/lande/shadow/dev2000/osxpf/v5r4m0f.xpf/cur/cmvc/base.pgm/my.xpf/apis \
-I$ /afs/rchland.ibm.com/lande/shadow/dev2000/osxpf/v5r4m0.xpf/bld/cmvc/base.pgm/lg.xpf \
-I$ /afs/rchland.ibm.com/lande/shadow/dev2000/osxpf/v5r4m0.xpf/bld/cmvc/base.pgm/tq.xpf
WRAPLIBS=
LDADD =
DEFS = @DEFS@
noinst_HEADERS = ha_ibmdb2i.h db2i_collationSupport.h db2i_file.h \
db2i_ioBuffers.h db2i_blobCollection.h \
db2i_global.h db2i_misc.h db2i_charsetSupport.h db2i_errors.h \
db2i_iconv.h db2i_myconv.h db2i_safeString.h db2i_sqlStatementStream.h \
db2i_ileBridge.h db2i_validatedPointer.h
EXTRA_LTLIBRARIES = ha_ibmdb2i.la
pkgplugin_LTLIBRARIES = @plugin_ibmdb2i_shared_target@
ha_ibmdb2i_la_LIBADD = -liconv
ha_ibmdb2i_la_LDFLAGS = -module -rpath $(MYSQLLIBdir)
ha_ibmdb2i_la_CXXFLAGS= $(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN
ha_ibmdb2i_la_CFLAGS = $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
ha_ibmdb2i_la_SOURCES = ha_ibmdb2i.cc db2i_ileBridge.cc db2i_conversion.cc \
db2i_blobCollection.cc db2i_file.cc db2i_charsetSupport.cc \
db2i_collationSupport.cc db2i_errors.cc db2i_constraints.cc \
db2i_rir.cc db2i_sqlStatementStream.cc db2i_ioBuffers.cc \
db2i_myconv.cc
EXTRA_LIBRARIES = libibmdb2i.a
noinst_LIBRARIES = @plugin_ibmdb2i_static_target@
libibmdb2i_a_CXXFLAGS = $(AM_CXXFLAGS)
libibmdb2i_a_CFLAGS = $(AM_CFLAGS)
libibmdb2i_a_SOURCES= $(ha_ibmdb2i_la_SOURCES)
EXTRA_DIST = CMakeLists.txt plug.in
/*
Licensed Materials - Property of IBM
DB2 Storage Engine Enablement
Copyright IBM Corporation 2007,2008
All rights reserved
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
(a) Redistributions of source code must retain this list of conditions, the
copyright notice in section {d} below, and the disclaimer following this
list of conditions.
(b) Redistributions in binary form must reproduce this list of conditions, the
copyright notice in section (d) below, and the disclaimer following this
list of conditions, in the documentation and/or other materials provided
with the distribution.
(c) The name of IBM may not be used to endorse or promote products derived from
this software without specific prior written permission.
(d) The text of the required copyright notice is:
Licensed Materials - Property of IBM
DB2 Storage Engine Enablement
Copyright IBM Corporation 2007,2008
All rights reserved
THIS SOFTWARE IS PROVIDED BY IBM CORPORATION "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
SHALL IBM CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
#include "db2i_blobCollection.h"
/**
Return the size to use when allocating space for blob reads.
@param fieldIndex The field to allocate for
@param[out] shouldProtect Indicates whether storage protection should be
applied to the space, because the size returned is
smaller than the maximum possible size.
*/
uint32
BlobCollection::getSizeToAllocate(int fieldIndex, bool& shouldProtect)
{
Field* field = table->getMySQLTable()->field[fieldIndex];
uint fieldLength = field->max_display_length();
if (fieldLength <= MAX_FULL_ALLOCATE_BLOB_LENGTH)
{
shouldProtect = false;
return fieldLength;
}
shouldProtect = true;
uint curMaxSize = table->getBlobFieldActualSize(fieldIndex);
uint defaultAllocSize = min(defaultAllocation, fieldLength);
return max(defaultAllocSize, curMaxSize);
}
void
BlobCollection::generateBuffer(int fieldIndex)
{
DBUG_ASSERT(table->db2Field(fieldIndex).isBlob());
bool protect;
buffers[table->getBlobIdFromField(fieldIndex)].Malloc(getSizeToAllocate(fieldIndex, protect), protect);
return;
}
/**
Realloc the read buffer associated with a blob field.
This is used when the previous allocation for a blob field is found to be
too small (this is discovered when QMY_READ trips over the protected boundary
page).
@param fieldIndex The field to be reallocated
@param size The size of buffer to allocate for this field.
*/
ValidatedPointer<char>&
BlobCollection::reallocBuffer(int fieldIndex, size_t size)
{
ProtectedBuffer& buf = buffers[table->getBlobIdFromField(fieldIndex)];
if (size <= buf.allocLen())
return buf.ptr();
table->updateBlobFieldActualSize(fieldIndex, size);
DBUG_PRINT("BlobCollection::reallocBuffer",("PERF: reallocing %d to %d: ", fieldIndex, size));
bool protect;
buf.Free();
buf.Malloc(getSizeToAllocate(fieldIndex, protect), protect);
return buf.ptr();
}
/*
Licensed Materials - Property of IBM
DB2 Storage Engine Enablement
Copyright IBM Corporation 2007,2008
All rights reserved
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
(a) Redistributions of source code must retain this list of conditions, the
copyright notice in section {d} below, and the disclaimer following this
list of conditions.
(b) Redistributions in binary form must reproduce this list of conditions, the
copyright notice in section (d) below, and the disclaimer following this
list of conditions, in the documentation and/or other materials provided
with the distribution.
(c) The name of IBM may not be used to endorse or promote products derived from
this software without specific prior written permission.
(d) The text of the required copyright notice is:
Licensed Materials - Property of IBM
DB2 Storage Engine Enablement
Copyright IBM Corporation 2007,2008
All rights reserved
THIS SOFTWARE IS PROVIDED BY IBM CORPORATION "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
SHALL IBM CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
#ifndef DB2I_BLOBCOLLECTION_H
#define DB2I_BLOBCOLLECTION_H
#include "db2i_global.h"
#include "db2i_file.h"
/**
@class ProtectedBuffer
@brief Implements memory management for (optionally) protected buffers.
Buffers created with the protection option will have a guard page set on the
page following requested allocation size. The side effect is that the actual
allocation is up to 2*4096-1 bytes larger than the size requested by the
using code.
*/
class ProtectedBuffer
{
public:
ProtectedBuffer() : protectBuf(false)
{;}
void Malloc(size_t size, bool protect = false)
{
protectBuf = protect;
bufptr.alloc(size + (protectBuf ? 0x1fff : 0x0));
if ((void*)bufptr != NULL)
{
len = size;
if (protectBuf)
mprotect(protectedPage(), 0x1000, PROT_NONE);
#ifndef DBUG_OFF
// Prevents a problem with DBUG_PRINT over-reading in recent versions of
// MySQL
*((char*)protectedPage()-1) = 0;
#endif
}
}
void Free()
{
if ((void*)bufptr != NULL)
{
if (protectBuf)
mprotect(protectedPage(), 0x1000, PROT_READ | PROT_WRITE);
bufptr.dealloc();
}
}
~ProtectedBuffer()
{
Free();
}
ValidatedPointer<char>& ptr() {return bufptr;}
bool isProtected() const {return protectBuf;}
size_t allocLen() const {return len;}
private:
void* protectedPage()
{
return (void*)(((address64_t)(void*)bufptr + len + 0x1000) & ~0xfff);
}
ValidatedPointer<char> bufptr;
size_t len;
bool protectBuf;
};
/**
@class BlobCollection
@brief Manages memory allocation for reading blobs associated with a table.
Allocations are done on-demand and are protected with a guard page if less
than the max possible size is allocated.
*/
class BlobCollection
{
public:
BlobCollection(db2i_table* db2Table, uint32 defaultAllocSize) :
defaultAllocation(defaultAllocSize), table(db2Table)
{
buffers = new ProtectedBuffer[table->getBlobCount()];
}
~BlobCollection()
{
delete[] buffers;
}
ValidatedPointer<char>& getBufferPtr(int fieldIndex)
{
int blobIndex = table->getBlobIdFromField(fieldIndex);
if ((char*)buffers[blobIndex].ptr() == NULL)
generateBuffer(fieldIndex);
return buffers[blobIndex].ptr();
}
ValidatedPointer<char>& reallocBuffer(int fieldIndex, size_t size);
private:
uint32 getSizeToAllocate(int fieldIndex, bool& shouldProtect);
void generateBuffer(int fieldIndex);
db2i_table* table; // The table being read
ProtectedBuffer* buffers; // The buffers
uint32 defaultAllocation;
/* The default size to use when first allocating a buffer */
};
#endif
This diff is collapsed.
/*
Licensed Materials - Property of IBM
DB2 Storage Engine Enablement
Copyright IBM Corporation 2007,2008
All rights reserved
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
(a) Redistributions of source code must retain this list of conditions, the
copyright notice in section {d} below, and the disclaimer following this
list of conditions.
(b) Redistributions in binary form must reproduce this list of conditions, the
copyright notice in section (d) below, and the disclaimer following this
list of conditions, in the documentation and/or other materials provided
with the distribution.
(c) The name of IBM may not be used to endorse or promote products derived from
this software without specific prior written permission.
(d) The text of the required copyright notice is:
Licensed Materials - Property of IBM
DB2 Storage Engine Enablement
Copyright IBM Corporation 2007,2008
All rights reserved
THIS SOFTWARE IS PROVIDED BY IBM CORPORATION "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
SHALL IBM CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
#ifndef DB2I_CHARSETSUPPORT_H
#define DB2I_CHARSETSUPPORT_H
#include "db2i_global.h"
#include "mysql_priv.h"
#include <mysql/plugin.h>
#include "db2i_iconv.h"
/**
@enum enum_conversionDirection
Conversion directions for getConversion()
*/
enum enum_conversionDirection
{
toMySQL,
toDB2
};
int initCharsetSupport();
void doneCharsetSupport();
int32 convertIANAToDb2Ccsid(const char* parmIANADesc, uint16* db2Ccsid);
int32 getEncodingScheme(const uint16 inCcsid, int32& outEncodingScheme);
int32 getAssociatedCCSID(const uint16 inCcsid, const int inEncodingScheme, uint16* outCcsid);
int convToEbcdic(const char* input, char* output, size_t ilen);
int convFromEbcdic(const char* input, char* output, size_t ilen);
int32 getConversion(enum_conversionDirection direction, const CHARSET_INFO* cs, uint16 db2CCSID, iconv_t& conversion);
#endif
/*
Licensed Materials - Property of IBM
DB2 Storage Engine Enablement
Copyright IBM Corporation 2007,2008
All rights reserved
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
(a) Redistributions of source code must retain this list of conditions, the
copyright notice in section {d} below, and the disclaimer following this
list of conditions.
(b) Redistributions in binary form must reproduce this list of conditions, the
copyright notice in section (d) below, and the disclaimer following this
list of conditions, in the documentation and/or other materials provided
with the distribution.
(c) The name of IBM may not be used to endorse or promote products derived from
this software without specific prior written permission.
(d) The text of the required copyright notice is:
Licensed Materials - Property of IBM
DB2 Storage Engine Enablement
Copyright IBM Corporation 2007,2008
All rights reserved
THIS SOFTWARE IS PROVIDED BY IBM CORPORATION "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
SHALL IBM CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
#include "db2i_collationSupport.h"
#include "db2i_errors.h"
/*
The following arrays define a mapping between MySQL collation names and
corresponding IBM i sort sequences. The mapping is a 1-to-1 correlation
between corresponding array slots but is incomplete without case-sensitivity
markers dynamically added to the mySqlSortSequence names.
*/
#define MAX_COLLATION 87
static const char* mySQLCollation[MAX_COLLATION] =
{
{"ascii_general"},
{"ascii"},
{"big5_chinese"},
{"big5"},
{"cp1250_croatian"},
{"cp1250_general"},
{"cp1250_polish"},
{"cp1250"},
{"cp1251_bulgarian"},
{"cp1251_general"},
{"cp1251"},
{"cp1256_general"},
{"cp1256"},
{"cp850_general"},
{"cp850"},
{"cp852_general"},
{"cp852"},
{"cp932_japanese"},
{"cp932"},
{"euckr_korean"},
{"euckr"},
{"gb2312_chinese"},
{"gb2312"},
{"gbk_chinese"},
{"gbk"},
{"greek_general"},
{"greek"},
{"hebrew_general"},
{"hebrew"},
{"latin1_danish"},
{"latin1_general"},
{"latin1_german1"},
{"latin1_spanish"},
{"latin1_swedish"},
{"latin1"},
{"latin2_croatian"},
{"latin2_general"},
{"latin2_hungarian"},
{"latin2"},
{"latin5_turkish"},
{"latin5"},
{"macce_general"},
{"macce"},
{"sjis_japanese"},
{"sjis"},
{"tis620_thai"},
{"tis620"},
{"ucs2_czech"},
{"ucs2_danish"},
{"ucs2_esperanto"},
{"ucs2_estonian"},
{"ucs2_general"},
{"ucs2_hungarian"},
{"ucs2_icelandic"},
{"ucs2_latvian"},
{"ucs2_lithuanian"},
{"ucs2_persian"},
{"ucs2_polish"},
{"ucs2_romanian"},
{"ucs2_slovak"},
{"ucs2_slovenian"},
{"ucs2_spanish"},
{"ucs2_swedish"},
{"ucs2_turkish"},
{"ucs2_unicode"},
{"ucs2"},
{"ujis_japanese"},
{"ujis"},
{"utf8_czech"},
{"utf8_danish"},
{"utf8_esperanto"},
{"utf8_estonian"},
{"utf8_general"},
{"utf8_hungarian"},
{"utf8_icelandic"},
{"utf8_latvian"},
{"utf8_lithuanian"},
{"utf8_persian"},
{"utf8_polish"},
{"utf8_romanian"},
{"utf8_slovak"},
{"utf8_slovenian"},
{"utf8_spanish"},
{"utf8_swedish"},
{"utf8_turkish"},
{"utf8_unicode"},
{"utf8"}
};
static const char* mySqlSortSequence[MAX_COLLATION] =
{
{"QALA101F4"},
{"QBLA101F4"},
{"QACHT04B0"},
{"QBCHT04B0"},
{"QALA20481"},
{"QCLA20481"},
{"QDLA20481"},
{"QELA20481"},
{"QACYR0401"},
{"QBCYR0401"},
{"QCCYR0401"},
{"QAARA01A4"},
{"QBARA01A4"},
{"QCLA101F4"},
{"QDLA101F4"},
{"QALA20366"},
{"QBLA20366"},
{"QAJPN04B0"},
{"QBJPN04B0"},
{"QAKOR04B0"},
{"QBKOR04B0"},
{"QACHS04B0"},
{"QBCHS04B0"},
{"QCCHS04B0"},
{"QDCHS04B0"},
{"QAELL036B"},
{"QBELL036B"},
{"QAHEB01A8"},
{"QBHEB01A8"},
{"QALA1047C"},
{"QBLA1047C"},
{"QCLA1047C"},
{"QDLA1047C"},
{"QELA1047C"},
{"QFLA1047C"},
{"QCLA20366"},
{"QELA20366"},
{"QFLA20366"},
{"QGLA20366"},
{"QATRK0402"},
{"QBTRK0402"},
{"QHLA20366"},
{"QILA20366"},
{"QCJPN04B0"},
{"QDJPN04B0"},
{"QATHA0346"},
{"QBTHA0346"},
{"ACS_CZ"},
{"ADA_DK"},
{"AEO"},
{"AET"},
{"QAUCS04B0"},
{"AHU"},
{"AIS"},
{"ALV"},
{"ALT"},
{"AFA"},
{"APL"},
{"ARO"},
{"ASK"},
{"ASL"},
{"AES"},
{"ASW"},
{"ATR"},
{"AEN"},
{"*HEX"},
{"QEJPN04B0"},
{"QFJPN04B0"},
{"ACS_CZ"},
{"ADA_DK"},
{"AEO"},
{"AET"},
{"QAUCS04B0"},
{"AHU"},
{"AIS"},
{"ALV"},
{"ALT"},
{"AFA"},
{"APL"},
{"ARO"},
{"ASK"},
{"ASL"},
{"AES"},
{"ASW"},
{"ATR"},
{"AEN"},
{"*HEX"}
};
/**
Get the IBM i sort sequence that corresponds to the given MySQL collation.
@param fieldCharSet The collated character set
@param[out] rtnSortSequence The corresponding sort sequence
@return 0 if successful. Failure otherwise
*/
static int32 getAssociatedSortSequence(const CHARSET_INFO *fieldCharSet, const char** rtnSortSequence)
{
DBUG_ENTER("ha_ibmdb2i::getAssociatedSortSequence");
if (strcmp(fieldCharSet->csname,"binary") != 0)
{
int collationSearchLen = strlen(fieldCharSet->name);
if (fieldCharSet->state & MY_CS_BINSORT)
collationSearchLen -= 4;
else
collationSearchLen -= 3;
uint16 loopCnt = 0;
for (loopCnt; loopCnt < MAX_COLLATION; ++loopCnt)
{
if ((strlen(mySQLCollation[loopCnt]) == collationSearchLen) &&
(strncmp((char*)mySQLCollation[loopCnt], fieldCharSet->name, collationSearchLen) == 0))
break;
}
if (loopCnt == MAX_COLLATION) // Did not find associated sort sequence
{
getErrTxt(DB2I_ERR_SRTSEQ);
DBUG_RETURN(DB2I_ERR_SRTSEQ);
}
*rtnSortSequence = mySqlSortSequence[loopCnt];
}
DBUG_RETURN(0);
}
/**
Update sort sequence information for a key.
This function accumulates information about a key as it is called for each
field composing the key. The caller should invoke the function for each field
and (with the exception of the charset parm) preserve the values for the
parms across invocations, until a particular key has been evaluated. Once
the last field in the key has been evaluated, the fileSortSequence and
fileSortSequenceLibrary parms will contain the correct information for
creating the corresponding DB2 key.
@param charset The character set under consideration
@param[in, out] fileSortSequenceType The type of the current key's sort seq
@param[in, out] fileSortSequence The IBM i identifier for the DB2 sort sequence
that corresponds
@return 0 if successful. Failure otherwise
*/
int32 updateAssociatedSortSequence(const CHARSET_INFO* charset,
char* fileSortSequenceType,
char* fileSortSequence,
char* fileSortSequenceLibrary)
{
DBUG_ENTER("ha_ibmdb2i::updateAssociatedSortSequence");
DBUG_ASSERT(charset);
if (strcmp(charset->csname,"binary") != 0)
{
char newSortSequence[11] = "";
char newSortSequenceType = ' ';
const char* foundSortSequence;
int rc = getAssociatedSortSequence(charset, &foundSortSequence);
if (rc) DBUG_RETURN (rc);
switch(foundSortSequence[0])
{
case '*': // Binary
strcat(newSortSequence,foundSortSequence);
newSortSequenceType = 'B';
break;
case 'Q': // Non-ICU sort sequence
strcat(newSortSequence,foundSortSequence);
if ((charset->state & MY_CS_BINSORT) != 0)
{
strcat(newSortSequence,"U");
}
else if ((charset->state & MY_CS_CSSORT) != 0)
{
strcat(newSortSequence,"U");
}
else
{
strcat(newSortSequence,"S");
}
newSortSequenceType = 'N';
break;
default: // ICU sort sequence
{
if ((charset->state & MY_CS_CSSORT) == 0)
{
if (osVersion.v >= 6)
strcat(newSortSequence,"I34"); // ICU 3.4
else
strcat(newSortSequence,"I26"); // ICU 2.6.1
}
strcat(newSortSequence,foundSortSequence);
newSortSequenceType = 'I';
}
break;
}
if (*fileSortSequenceType == ' ') // If no sort sequence has been set yet
{
// Set associated sort sequence
strcpy(fileSortSequence,newSortSequence);
strcpy(fileSortSequenceLibrary,"QSYS");
*fileSortSequenceType = newSortSequenceType;
}
else if (strcmp(fileSortSequence,newSortSequence) != 0)
{
// Only one sort sequence/collation is supported for each DB2 index.
getErrTxt(DB2I_ERR_MIXED_COLLATIONS);
DBUG_RETURN(DB2I_ERR_MIXED_COLLATIONS);
}
}
DBUG_RETURN(0);
}
/*
Licensed Materials - Property of IBM
DB2 Storage Engine Enablement
Copyright IBM Corporation 2007,2008
All rights reserved
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
(a) Redistributions of source code must retain this list of conditions, the
copyright notice in section {d} below, and the disclaimer following this
list of conditions.
(b) Redistributions in binary form must reproduce this list of conditions, the
copyright notice in section (d) below, and the disclaimer following this
list of conditions, in the documentation and/or other materials provided
with the distribution.
(c) The name of IBM may not be used to endorse or promote products derived from
this software without specific prior written permission.
(d) The text of the required copyright notice is:
Licensed Materials - Property of IBM
DB2 Storage Engine Enablement
Copyright IBM Corporation 2007,2008
All rights reserved
THIS SOFTWARE IS PROVIDED BY IBM CORPORATION "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
SHALL IBM CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
#ifndef DB2I_COLLATIONSUPPORT_H
#define DB2I_COLLATIONSUPPORT_H
#include "db2i_global.h"
#include "mysql_priv.h"
int32 updateAssociatedSortSequence(const CHARSET_INFO* charset,
char* fileSortSequenceType,
char* fileSortSequence,
char* fileSortSequenceLibrary);
#endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*
Licensed Materials - Property of IBM
DB2 Storage Engine Enablement
Copyright IBM Corporation 2007,2008
All rights reserved
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
(a) Redistributions of source code must retain this list of conditions, the
copyright notice in section {d} below, and the disclaimer following this
list of conditions.
(b) Redistributions in binary form must reproduce this list of conditions, the
copyright notice in section (d) below, and the disclaimer following this
list of conditions, in the documentation and/or other materials provided
with the distribution.
(c) The name of IBM may not be used to endorse or promote products derived from
this software without specific prior written permission.
(d) The text of the required copyright notice is:
Licensed Materials - Property of IBM
DB2 Storage Engine Enablement
Copyright IBM Corporation 2007,2008
All rights reserved
THIS SOFTWARE IS PROVIDED BY IBM CORPORATION "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
SHALL IBM CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
#ifndef DB2I_ERRORS_H
#define DB2I_ERRORS_H
#include "qmyse.h"
class THD;
/**
@enum DB2I_errors
@brief These are the errors that can be returned by the storage engine proper
and that are specific to the engine. Refer to db2i_errors.cc for text
descriptions of the errors.
*/
enum DB2I_errors
{
DB2I_FIRST_ERR = 2500,
DB2I_ERR_ICONV_OPEN,
DB2I_ERR_INVALID_NAME,
DB2I_ERR_RENAME_MOVE,
DB2I_ERR_UNSUPP_CHARSET,
DB2I_ERR_PART_AUTOINC,
DB2I_ERR_UNKNOWN_ENCODING,
DB2I_ERR_RESERVED,
DB2I_ERR_TABLE_NOT_FOUND,
DB2I_ERR_RESOLVE_OBJ,
DB2I_ERR_PGMCALL,
DB2I_ERR_ILECALL,
DB2I_ERR_ICONV,
DB2I_ERR_QTQGESP,
DB2I_ERR_QTQGRDC,
DB2I_ERR_INVALID_COL_VALUE,
DB2I_ERR_TOO_LONG_SCHEMA,
DB2I_ERR_MIXED_COLLATIONS,
DB2I_ERR_SRTSEQ,
DB2I_ERR_SUB_CHARS,
DB2I_ERR_PRECISION,
DB2I_ERR_INVALID_DATA,
DB2I_ERR_RESERVED2,
DB2I_ERR_ILL_CHAR,
DB2I_ERR_BAD_RDB_NAME,
DB2I_ERR_UNKNOWN_IDX,
DB2I_ERR_DISCOVERY_MISMATCH,
DB2I_ERR_WARN_CREATE_DISCOVER,
DB2I_ERR_WARN_COL_ATTRS,
DB2I_LAST_ERR = DB2I_ERR_WARN_COL_ATTRS
};
void getErrTxt(int errcode, ...);
void reportSystemAPIError(int errCode, const Qmy_Error_output *errInfo);
void warning(THD *thd, int errCode, ...);
const char* DB2I_SQL0350 = "\xE2\xD8\xD3\xF0\xF3\xF5\xF0"; // SQL0350 in EBCDIC
const char* DB2I_CPF503A = "\xC3\xD7\xC6\xF5\xF0\xF3\xC1"; // CPF503A in EBCDIC
const char* DB2I_SQL0538 = "\xE2\xD8\xD3\xF0\xF5\xF3\xF8"; // SQL0538 in EBCDIC
#endif
This diff is collapsed.
This diff is collapsed.
/*
Licensed Materials - Property of IBM
DB2 Storage Engine Enablement
Copyright IBM Corporation 2007,2008
All rights reserved
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
(a) Redistributions of source code must retain this list of conditions, the
copyright notice in section {d} below, and the disclaimer following this
list of conditions.
(b) Redistributions in binary form must reproduce this list of conditions, the
copyright notice in section (d) below, and the disclaimer following this
list of conditions, in the documentation and/or other materials provided
with the distribution.
(c) The name of IBM may not be used to endorse or promote products derived from
this software without specific prior written permission.
(d) The text of the required copyright notice is:
Licensed Materials - Property of IBM
DB2 Storage Engine Enablement
Copyright IBM Corporation 2007,2008
All rights reserved
THIS SOFTWARE IS PROVIDED BY IBM CORPORATION "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
SHALL IBM CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
#ifndef DB2I_GLOBAL_H
#define DB2I_GLOBAL_H
#define MYSQL_SERVER 1
#include "my_global.h"
#include "my_sys.h"
const uint MAX_DB2_KEY_PARTS=120;
const int MAX_DB2_V5R4_LIBNAME_LENGTH = 10;
const int MAX_DB2_V6R1_LIBNAME_LENGTH = 30;
const int MAX_DB2_SCHEMANAME_LENGTH=258;
const int MAX_DB2_FILENAME_LENGTH=258;
const int MAX_DB2_COLNAME_LENGTH=128;
const int MAX_DB2_SAVEPOINTNAME_LENGTH=128;
const int MAX_DB2_QUALIFIEDNAME_LENGTH=MAX_DB2_V6R1_LIBNAME_LENGTH + 1 + MAX_DB2_FILENAME_LENGTH;
const uint32 MAX_CHAR_LENGTH = 32765;
const uint32 MAX_VARCHAR_LENGTH = 32739;
const uint32 MAX_DEC_PRECISION = 63;
const uint32 MAX_BLOB_LENGTH = 2147483646;
const uint32 MAX_BINARY_LENGTH = MAX_CHAR_LENGTH;
const uint32 MAX_VARBINARY_LENGTH = MAX_VARCHAR_LENGTH;
const uint32 MAX_FULL_ALLOCATE_BLOB_LENGTH = 65536;
const uint32 MAX_FOREIGN_LEN = 64000;
const char* DB2I_TEMP_TABLE_SCHEMA = "QTEMP";
const char DB2I_ADDL_INDEX_NAME_DELIMITER[5] = {'_','_','_','_','_'};
const char DB2I_DEFAULT_INDEX_NAME_DELIMITER[3] = {'_','_','_'};
const int DB2I_INDEX_NAME_LENGTH_TO_PRESERVE = 110;
enum enum_DB2I_INDEX_TYPE
{
typeNone = 0,
typeDefault = 'D',
typeHex = 'H',
typeAscii = 'A'
};
void* roundToQuadWordBdy(void* ptr)
{
return (void*)(((uint64)(ptr)+0xf) & ~0xf);
}
typedef uint64_t ILEMemHandle;
struct OSVersion
{
uint8 v;
uint8 r;
};
extern OSVersion osVersion;
/**
Allocate 16-byte aligned space using the MySQL heap allocator
@details Many of the spaces used by the QMY_* APIS are required to be
aligned on 16 byte boundaries. The standard system malloc will do this
alignment by default. However, in order to use the heap debug and tracking
features of the mysql allocator, we chose to implement an aligning wrapper
around my_malloc. Essentially, we overallocate the storage space, find the
first aligned address in the space, store a pointer to the true malloc
allocation in the bytes immediately preceding the aligned address, and return
the aligned address to the caller.
@parm size The size of heap storage needed
@return A 16-byte aligned pointer to the storage requested.
*/
void* malloc_aligned(size_t size)
{
char* p;
char* base;
base = (char*)my_malloc(size + sizeof(void*) + 15, MYF(MY_WME));
if (likely(base))
{
p = (char*)roundToQuadWordBdy(base + sizeof(void*));
char** p2 = (char**)(p - sizeof(void*));
*p2 = base;
}
else
p = NULL;
return p;
}
/**
Free a 16-byte aligned space alloced by malloc_aligned
@details We know that a pointer to the true malloced storage immediately
precedes the aligned address, so we pull that out and call my_free().
@parm p A 16-byte aligned pointer generated by malloc_aligned
*/
void free_aligned(void* p)
{
if (likely(p))
{
my_free(*(char**)((char*)p-sizeof(void*)));
}
}
#endif
/*
Licensed Materials - Property of IBM
DB2 Storage Engine Enablement
Copyright IBM Corporation 2007,2008
All rights reserved
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
(a) Redistributions of source code must retain this list of conditions, the
copyright notice in section {d} below, and the disclaimer following this
list of conditions.
(b) Redistributions in binary form must reproduce this list of conditions, the
copyright notice in section (d) below, and the disclaimer following this
list of conditions, in the documentation and/or other materials provided
with the distribution.
(c) The name of IBM may not be used to endorse or promote products derived from
this software without specific prior written permission.
(d) The text of the required copyright notice is:
Licensed Materials - Property of IBM
DB2 Storage Engine Enablement
Copyright IBM Corporation 2007,2008
All rights reserved
THIS SOFTWARE IS PROVIDED BY IBM CORPORATION "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
SHALL IBM CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
/**
@file
@brief Used to redefine iconv symbols to the optimized "myconv" ones
*/
#ifndef DB2I_ICONV_H
#define DB2I_ICONV_H
#include "db2i_myconv.h"
#define iconv_open(A, B) myconv_open(A, B, CONVERTER_DMAP)
#define iconv_close myconv_close
#define iconv myconv_dmap
#define iconv_t myconv_t
#endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment