1 #ifndef BZS_DB_PROTOCOL_TDAP_TDAPSCHEMA_H
2 #define BZS_DB_PROTOCOL_TDAP_TDAPSCHEMA_H
22 #include <bzs/db/protocol/tdap/tdapcapi.h>
26 #include <bzs/env/compiler.h>
27 #include <bzs/env/crosscompile.h>
28 #include <bzs/db/protocol/tdap/mysql/characterset.h>
29 #include <bzs/db/blobStructs.h>
61 unsigned short bit0 : 1;
62 unsigned short bit1 : 1;
63 unsigned short bit2 : 1;
64 unsigned short bit3 : 1;
65 unsigned short bit4 : 1;
66 unsigned short bit5 : 1;
67 unsigned short bit6 : 1;
68 unsigned short bit7 : 1;
69 unsigned short bit8 : 1;
70 unsigned short bit9 : 1;
71 unsigned short bitA : 1;
72 unsigned short bitB : 1;
73 unsigned short bitC : 1;
74 unsigned short bitD : 1;
75 unsigned short bitE : 1;
76 unsigned short bitF : 1;
145 #define MAX_KEY_SEGMENT 8
154 static const int MYSQL_FDNAME_SIZE = 64;
155 static const int MYSQL_TBNAME_SIZE = 64;
156 static const int PERVASIVE_FDNAME_SIZE = 20;
157 static const int FIELD_NAME_SIZE = MYSQL_FDNAME_SIZE;
158 static const int TABLE_NAME_SIZE = 32;
159 static const int FILE_NAME_SIZE = 266;
161 #if (defined(__x86_32__) || __APPLE_32__)
162 static const int TABLEDEF_FILLER_SIZE = 21;
164 static const int TABLEDEF_FILLER_SIZE = 9;
167 #ifndef MYSQL_DYNAMIC_PLUGIN
180 lenByCharnum(uchar_td type, uchar_td charsetIndex, ushort_td charnum);
182 #endif // MYSQL_DYNAMIC_PLUGIN
198 case ft_mywvarbinary:
218 #define PAD_CHAR_OPTION_SAVED 1
219 #define USE_PAD_CHAR 2
220 #define TRIM_PAD_CHAR 4
303 const wchar_t* name()
const;
304 const wchar_t* name(
wchar_t* buf)
const;
305 const wchar_t* chainChar()
const;
306 void setName(
const wchar_t* s);
307 void setChainChar(
const wchar_t* s);
308 #else // NOT _UNICODE
310 #ifdef MYSQL_DYNAMIC_PLUGIN
312 inline const char* name()
const {
return m_name; };
314 inline const char* chainChar()
const {
return m_chainChar; };
316 inline void setName(
const char* s)
318 strncpy_s(m_name, FIELD_NAME_SIZE, s,
sizeof(m_name) - 1);
321 inline void setChainChar(
const char* s)
323 strncpy_s(m_chainChar, 2, s,
sizeof(m_chainChar) - 1);
326 #else // NOT MYSQL_DYNAMIC_PLUGIN
327 const char* name()
const;
328 const char* name(
char* buf)
const;
329 const char* chainChar()
const;
330 void setName(
const char* s);
331 void setChainChar(
const char* s);
332 #endif // NOT MYSQL_DYNAMIC_PLUGIN
333 #endif // NOT _UNICODE
335 inline const char*
nameA()
const {
return m_name; };
339 strncpy_s(m_name, FIELD_NAME_SIZE, s,
sizeof(m_name) - 1);
341 #ifndef MYSQL_DYNAMIC_PLUGIN
352 #endif // MYSQL_DYNAMIC_PLUGIN
357 inline bool isKeyVarType()
const
359 return (((type >= ft_myvarchar) && (type <= ft_mywvarbinary)) ||
360 (type == ft_myblob) || (type == ft_mytext));
365 inline ushort_td maxKeylen()
const {
return keylen ? keylen : len; };
370 return mysql::codePage((
unsigned short)m_charsetIndex);
379 return ((type == ft_integer) || (type == ft_decimal) ||
380 (type == ft_money) || (type == ft_logical) ||
381 (type == ft_numeric) || (type == ft_bfloat) ||
382 (type == ft_uinteger) || (type == ft_autoinc) ||
383 (type == ft_bit) || (type == ft_numericsts) ||
384 (type == ft_numericsa) || (type == ft_autoIncUnsigned));
389 unsigned int charNum()
const;
393 m_charsetIndex = index;
394 if ((type == ft_wstring) || (type == ft_wzstring) ||
395 (type == ft_mywvarchar) || (type == ft_mywvarbinary) ||
396 (type == ft_mywchar))
397 m_charsetIndex = CHARSET_UTF16LE;
406 if (((type >= ft_myvarchar) && (type <= ft_mywvarbinary)) ||
408 return len < 256 ? 1 : 2;
409 else if (type == ft_lvar)
416 if ((type == ft_myblob) || (type == ft_mytext))
423 return (type == ft_myblob) || (type == ft_mytext);
428 if (((type >= ft_myvarchar) && (type <= ft_mywvarbinary)) ||
430 return (len < 256) ? len - 1 : len - 2;
431 else if (type == ft_lvar)
433 else if ((type == ft_myblob) || (type == ft_mytext))
453 inline uint_td
dataLen(
const uchar_td* ptr)
const
455 int blen = varLenBytes();
459 return *((
unsigned char*)ptr);
460 return *((
unsigned short*)ptr);
465 int blen = blobLenBytes();
469 memcpy(&v, ptr, blen);
476 inline const uchar_td*
keyData(
const uchar_td* ptr)
const
478 if ((type == ft_myblob) || (type == ft_mytext))
479 return blobDataPtr(ptr);
480 int sizeByte = varLenBytes();
481 return ptr + sizeByte;
486 if ((type == ft_myblob) || (type == ft_mytext))
487 return blobDataLen(ptr);
493 m_padCharOptions = 0;
494 m_padCharOptions |= PAD_CHAR_OPTION_SAVED;
495 if ((type == ft_mychar) || (type == ft_mywchar))
497 m_padCharOptions |= USE_PAD_CHAR;
499 m_padCharOptions |= TRIM_PAD_CHAR;
501 else if ((type == ft_string) || (type == ft_wstring))
504 m_padCharOptions |= USE_PAD_CHAR;
506 m_padCharOptions |= TRIM_PAD_CHAR;
511 bool usePadChar()
const {
return (m_padCharOptions & USE_PAD_CHAR) == USE_PAD_CHAR;}
515 bool trimPadChar()
const {
return (m_padCharOptions & TRIM_PAD_CHAR) == TRIM_PAD_CHAR;}
524 inline uchar_td* keyCopy(uchar_td* to,
const uchar_td* from, ushort_td datalen=0xff)
527 ushort_td kl = maxKeylen();
528 memset(to, 0x00, kl);
529 ushort_td keyVarlen =
531 ushort_td copylen = std::min<ushort_td>(kl, datalen);
535 copylen = (ushort_td)std::min<uint_td>((uint_td)copylen,
538 memcpy(to, ©len, 2);
541 from = keyData(from);
543 memcpy(to, from, copylen);
544 return to + kl - keyVarlen;
548 inline const uchar_td* blobDataPtr(
const uchar_td* ptr)
const
550 int blen = blobLenBytes();
553 const uchar_td** p = (
const uchar_td**)(ptr + blen);
557 inline uint_td unPackCopy(uchar_td* dest,
const uchar_td* src)
const
559 int clen = varLenBytes();
563 clen += *((
unsigned char*)src);
565 clen += *((
unsigned short*)src);
566 memcpy(dest, src, clen);
570 inline ushort_td varLenByteForKey()
const
572 if (((type >= ft_myvarchar) && (type <= ft_mywvarbinary)) ||
573 (type == ft_lstring))
574 return len < 256 ? 1 : 2;
575 else if ((type == ft_myblob) || (type == ft_mytext))
583 inline const uchar_td* getKeyValueFromKeybuf(
const uchar_td* from,
584 const uchar_td** data,
587 ushort_td keyVarlen =
591 size = *((ushort_td*)from);
608 inline unsigned char* setBlobFieldPointer(uchar_td* dest,
const blobHeader* hd,
609 unsigned char* blobBlock,
int fieldNum)
const
611 assert(hd->curRow < hd->rows);
612 const blobField* f = hd->nextField;
613 int sizeByte = blobLenBytes();
614 unsigned int size = f->size;
616 memcpy(dest, &size, sizeByte);
618 memcpy(blobBlock, f->data(), size);
620 memcpy(dest + sizeByte, &blobBlock,
sizeof(
char*));
621 hd->nextField = (blobField*)f->next();
622 if (fieldNum == hd->fieldCount - 1)
624 return blobBlock + size;
627 inline void setPadCharDefaultSettings()
629 if (!padCharOptionSaved())
632 if ((type == ft_string) || (type == ft_wstring) ||
633 (type == ft_mychar) || (type == ft_mywchar))
635 m_padCharOptions |= USE_PAD_CHAR;
636 m_padCharOptions |= TRIM_PAD_CHAR;
639 else if ((type == ft_mychar) || (type == ft_mywchar))
640 m_padCharOptions |= USE_PAD_CHAR;
645 bool padCharOptionSaved()
const
647 return (m_padCharOptions & PAD_CHAR_OPTION_SAVED) == PAD_CHAR_OPTION_SAVED;
677 const wchar_t* fileName()
const;
678 const wchar_t* tableName()
const;
679 void setFileName(
const wchar_t* s);
680 void setTableName(
const wchar_t* s);
681 const char* toChar(
char* buf,
const wchar_t* s,
int size);
684 #ifdef MYSQL_DYNAMIC_PLUGIN
686 const char* fileName()
const {
return m_fileName; };
688 const char* tableName()
const {
return m_tableName; };
690 inline void setFileName(
const char* s) { setFileNameA(s); };
692 inline void setTableName(
const char* s) { setTableNameA(s); };
694 inline const char* toChar(
char* buf,
const char* s,
int size)
696 strncpy_s(buf, size, s, size - 1);
700 const char* fileName()
const;
701 const char* tableName()
const;
702 void setFileName(
const char* s);
703 void setTableName(
const char* s);
704 const char* toChar(
char* buf,
const char* s,
int size);
705 #endif // MYSQL_DYNAMIC_PLUGIN
714 strncpy_s(m_fileName, FILE_NAME_SIZE, s, FILE_NAME_SIZE - 1);
719 strncpy_s(m_tableName, TABLE_NAME_SIZE, s,
sizeof(m_tableName) - 1);
722 uint_td unPack(
char* ptr,
size_t size)
const;
723 uint_td pack(
char* ptr,
size_t size)
const;
747 char m_fileName[FILE_NAME_SIZE];
748 char m_tableName[TABLE_NAME_SIZE];
753 uchar_td filler0[17];
775 uchar_td reserved[TABLEDEF_FILLER_SIZE];
802 const _TCHAR* moduleVersionShortString(_TCHAR* buf);
803 const _TCHAR* moduleTypeString();
842 #endif // BZS_DB_PROTOCOL_TDAP_TDAPSCHEMA_H
ushort_td preAlloc
Definition: tdapSchema.h:131
uchar_td iconIndex
Definition: tdapSchema.h:762
uchar_td replicaKeyNum
Definition: tdapSchema.h:757
ushort_td filterId
Definition: tdapSchema.h:250
void setFileNameA(const char *s)
Definition: tdapSchema.h:712
bool isBlob() const
Definition: tdapSchema.h:421
Definition: tdapSchema.h:818
ushort_td keylen
Definition: tdapSchema.h:260
const _TCHAR * protocol(const _TCHAR *uri)
Definition: uri.h:42
ushort_td minorVersion
Definition: tdapSchema.h:799
ushort_td fixedRecordLen
Definition: tdapSchema.h:764
uchar_td lookTable
Definition: tdapSchema.h:239
フィールド定義構造体
Definition: tdapSchema.h:225
ushort_td ddfid
Definition: tdapSchema.h:249
ushort_td len
Definition: tdapSchema.h:232
サーバーおよびクライアントモジュールのバージョン構造体
Definition: tdapSchema.h:796
int autoIncExSpace
Definition: tdapSchema.h:765
combineType
Definition: tdapSchema.h:815
FLAGS fileFlag
Definition: tdapSchema.h:129
void setPadCharSettings(bool set, bool trim)
Definition: tdapSchema.h:491
uchar_td parentKeyNum
Definition: tdapSchema.h:756
unsigned short bitC
Definition: tdapSchema.h:98
pragma_pop
Definition: btrDate.h:106
uchar_td decimals
Definition: tdapSchema.h:233
ushort_td viewWidth
Definition: tdapSchema.h:235
unsigned short bitB
Definition: tdapSchema.h:97
ushort_td recLen
Definition: tdapSchema.h:125
ushort_td varSize
Definition: tdapSchema.h:738
uchar_td m_charsetIndex
Definition: tdapSchema.h:263
uchar_td reserve1[2]
Definition: tdapSchema.h:130
char m_name[N]
Definition: tdapSchema.h:228
uchar_td reserve2[2]
Definition: tdapSchema.h:116
Definition: tdapSchema.h:831
int varLenBytes() const
Definition: tdapSchema.h:404
unsigned int codePage() const
Definition: tdapSchema.h:368
bool isStringType(uchar_td type)
Definition: tdapSchema.h:204
ushort_td preAlloc
Definition: tdapSchema.h:742
uint_td blobDataLen(const uchar_td *ptr) const
Definition: tdapSchema.h:463
const char * nameA() const
Definition: tdapSchema.h:335
uchar_td acsNo
Definition: tdapSchema.h:118
keydef * keyDefs
Definition: tdapSchema.h:778
Definition: tdapSchema.h:828
uchar_td iconIndex3
Definition: tdapSchema.h:767
Definition: tdapSchema.h:827
ushort_td id
Definition: tdapSchema.h:725
int maxVarDatalen() const
Definition: tdapSchema.h:426
キーセグメント定義構造体
Definition: tdapSchema.h:137
const char * fileNameA() const
Definition: tdapSchema.h:708
PACKAGE const _TCHAR * getTypeName(short type)
void setNameA(const char *s)
Definition: tdapSchema.h:337
bool trimPadChar() const
Definition: tdapSchema.h:515
フィールド定義構造体
Definition: tdapSchema.h:300
Definition: tdapSchema.h:817
ビットフィールド共用体
Definition: tdapSchema.h:80
uint_td keyDataLen(const uchar_td *ptr) const
Definition: tdapSchema.h:484
fielddef_t< MYSQL_FDNAME_SIZE > fielddef_t_my
Definition: tdapSchema.h:293
unsigned short all
Definition: tdapSchema.h:82
char m_chainChar[2]
Definition: tdapSchema.h:246
bool usePadChar() const
Definition: tdapSchema.h:511
Definition: tdapSchema.h:830
ushort_td m_padCharOptions
Definition: tdapSchema.h:265
uint_td keyCount
Definition: tdapSchema.h:113
Definition: tdapSchema.h:832
バージョン配列構造体
Definition: tdapSchema.h:806
FLAGS enableFlags
Definition: tdapSchema.h:267
ushort_td defViewWidth
Definition: tdapSchema.h:243
PACKAGE ushort_td lenByCharnum(uchar_td type, uchar_td charsetIndex, ushort_td charnum)
uchar_td treeIndex
Definition: tdapSchema.h:761
Definition: tdapSchema.h:825
const char * tableNameA() const
Definition: tdapSchema.h:710
テーブルスキーマ管理クラス (nocopyable noncreatable)
Definition: dbDef.h:46
unsigned short bit8
Definition: tdapSchema.h:94
uchar_td keyCount
Definition: tdapSchema.h:744
ushort_td majorVersion
Definition: tdapSchema.h:798
ushort_td userOption
Definition: tdapSchema.h:253
unsigned short bit7
Definition: tdapSchema.h:93
uint_td schemaCodePage
Definition: tdapSchema.h:768
FLAGS keyFlag
Definition: tdapSchema.h:112
eCompType
Definition: tdapSchema.h:823
FLAGS flags
Definition: tdapSchema.h:140
uchar_td type
Definition: tdapSchema.h:231
uchar_td charsetIndex() const
Definition: tdapSchema.h:400
キー定義構造体
Definition: tdapSchema.h:147
uint_td recCount
Definition: tdapSchema.h:128
uchar_td keyType
Definition: tdapSchema.h:114
uchar_td nullValue
Definition: tdapSchema.h:115
unsigned short bitE
Definition: tdapSchema.h:100
double min
Definition: tdapSchema.h:237
ushort_td fieldCount
Definition: tdapSchema.h:743
uint_td blobLenBytes() const
Definition: tdapSchema.h:414
FLAGS optionFlags
Definition: tdapSchema.h:758
FLAGS flags
Definition: tdapSchema.h:754
create tableで使用するキーセグメント定義構造体
Definition: tdapSchema.h:108
uchar_td lookFields[3]
Definition: tdapSchema.h:241
tabledef()
Definition: tdapSchema.h:664
ushort_td ddfid
Definition: tdapSchema.h:763
ushort_td pos
Definition: tdapSchema.h:242
unsigned short bitD
Definition: tdapSchema.h:99
keySegment segments[MAX_KEY_SEGMENT]
Definition: tdapSchema.h:150
unsigned short bitF
Definition: tdapSchema.h:101
unsigned short bitA
Definition: tdapSchema.h:96
short version
Definition: tdapSchema.h:751
unsigned short bit9
Definition: tdapSchema.h:95
uchar_td fieldNum
Definition: tdapSchema.h:139
ushort_td pageSize
Definition: tdapSchema.h:737
ushort_td keyPos
Definition: tdapSchema.h:110
uchar_td keyNumber
Definition: tdapSchema.h:151
uchar_td iconIndex2
Definition: tdapSchema.h:766
ushort_td keyLen
Definition: tdapSchema.h:111
uchar_td primaryKeyNum
Definition: tdapSchema.h:755
uchar_td segmentCount
Definition: tdapSchema.h:149
void setLenByCharnum(ushort_td charnum)
Definition: tdapSchema.h:347
pragma_pack1
Definition: btrDate.h:35
bool isNumericType() const
Definition: tdapSchema.h:377
unsigned short bit1
Definition: tdapSchema.h:87
fielddef_t< PERVASIVE_FDNAME_SIZE > fielddef_t_pv
Definition: tdapSchema.h:294
unsigned short bit3
Definition: tdapSchema.h:89
Definition: tdapSchema.h:826
unsigned short bit5
Definition: tdapSchema.h:91
unsigned short bit6
Definition: tdapSchema.h:92
void setCharsetIndex(uchar_td index)
Definition: tdapSchema.h:391
uchar_td filterKeynum
Definition: tdapSchema.h:251
uchar_td lookDBNum
Definition: tdapSchema.h:254
uchar_td lookField
Definition: tdapSchema.h:240
uchar_td nullValue
Definition: tdapSchema.h:252
unsigned short bit0
Definition: tdapSchema.h:86
ushort_td maxRecordLen
Definition: tdapSchema.h:760
fielddef * fieldDefs
Definition: tdapSchema.h:777
double defValue
Definition: tdapSchema.h:238
unsigned short bit2
Definition: tdapSchema.h:88
Definition: tdapSchema.h:819
ushort_td convertFileNum
Definition: tdapSchema.h:759
client::dbdef * parent
Definition: tdapSchema.h:774
void cleanup()
Definition: tdapSchema.h:666
int align() const
Definition: tdapSchema.h:345
uint_td dataLen(const uchar_td *ptr) const
Definition: tdapSchema.h:453
char viewNum
Definition: tdapSchema.h:234
ushort_td m_schemaCodePage
Definition: tdapSchema.h:264
PACKAGE uchar_td getFilterLogicTypeCode(const _TCHAR *cmpstr)
bool isStringTypeForIndex(uchar_td type)
Definition: tdapSchema.h:185
unsigned char type
Definition: tdapSchema.h:800
PACKAGE int getTypeAlign(short type)
uchar_td charsetIndex
Definition: tdapSchema.h:752
uchar_td keyNo
Definition: tdapSchema.h:117
Definition: tdapSchema.h:829
create tableで使用するファイル定義構造体
Definition: tdapSchema.h:123
テーブル定義構造体
Definition: tdapSchema.h:660
keySpec keySpecs[1]
Definition: tdapSchema.h:132
ushort_td pageSize
Definition: tdapSchema.h:126
double max
Definition: tdapSchema.h:236
const _TCHAR * typeName() const
Definition: tdapSchema.h:343
unsigned short bit4
Definition: tdapSchema.h:90
ushort_td indexCount
Definition: tdapSchema.h:127
const uchar_td * keyData(const uchar_td *ptr) const
Definition: tdapSchema.h:476
void setTableNameA(const char *s)
Definition: tdapSchema.h:717