2
Licensed Materials - Property of IBM
3
DB2 Storage Engine Enablement
4
Copyright IBM Corporation 2007,2008
7
Redistribution and use in source and binary forms, with or without modification,
8
are permitted provided that the following conditions are met:
9
(a) Redistributions of source code must retain this list of conditions, the
10
copyright notice in section {d} below, and the disclaimer following this
12
(b) Redistributions in binary form must reproduce this list of conditions, the
13
copyright notice in section (d) below, and the disclaimer following this
14
list of conditions, in the documentation and/or other materials provided
15
with the distribution.
16
(c) The name of IBM may not be used to endorse or promote products derived from
17
this software without specific prior written permission.
18
(d) The text of the required copyright notice is:
19
Licensed Materials - Property of IBM
20
DB2 Storage Engine Enablement
21
Copyright IBM Corporation 2007,2008
24
THIS SOFTWARE IS PROVIDED BY IBM CORPORATION "AS IS" AND ANY EXPRESS OR IMPLIED
25
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
26
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
27
SHALL IBM CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
29
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31
CONTRACT, STRICT LIABILITY, OR TORT INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
32
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
40
Undelimit quote-delimited DB2 names in-place
42
void stripExtraQuotes(char* name, uint maxLen)
44
char* oldName = (char*)sql_strdup(name);
50
if (oldName[i] == '"' && oldName[i+1] == '"')
52
} while (++j < maxLen && oldName[++i]);
60
Convert a MySQL identifier name into a DB2 compatible format
62
@parm input The MySQL name
63
@parm output The DB2 name
64
@parm outlen The amount of space allocated for output
65
@parm delimit Should delimiting quotes be placed around the converted name?
66
@parm delimitQuotes Should quotes in the MySQL be delimited with additional quotes?
68
@return FALSE if output was too small and name was truncated; TRUE otherwise
70
bool convertMySQLNameToDB2Name(const char* input,
74
bool delimitQuotes = true)
84
if (delimitQuotes && input[i] == '"')
86
} while (++o < outlen-2 && input[++i]);
90
output[min(o, outlen-1)] = 0; // This isn't the most user-friendly way to handle overflows,
91
// but at least its safe.
92
return (o <= outlen-1);
95
bool isOrdinaryIdentifier(const char* s)
99
if (my_isupper(system_charset_info, *s) ||
100
my_isdigit(system_charset_info, *s) ||
114
Fill memory with a 16-bit word.
116
@param p Pointer to space to fill.
117
@param v Value to fill
118
@param l Length of space (in 16-bit words)
120
void memset16(void* p, uint16 v, size_t l)
122
uint16* p2=(uint16*)p;