diff options
author | unknown <mikron@c-1e0be253.1238-1-64736c10.cust.bredbandsbolaget.se> | 2006-01-17 09:25:12 +0100 |
---|---|---|
committer | unknown <mikron@c-1e0be253.1238-1-64736c10.cust.bredbandsbolaget.se> | 2006-01-17 09:25:12 +0100 |
commit | 6f83ed91f3225c4ef22f41ad1dc2a573c1e9211b (patch) | |
tree | 16a1fdeaf02c8df59ebd4d39c7759f337db248f3 /mysys/my_compress.c | |
parent | 19bbb7cc8588e65526cb7087c7809719802d00b7 (diff) | |
download | mariadb-git-6f83ed91f3225c4ef22f41ad1dc2a573c1e9211b.tar.gz |
WL #2747: Fix such that backup and restore works for user defined
partitioned tables in NDB
include/my_sys.h:
Move packfrm and unpackfrm to mysys
mysql-test/r/ndb_restore.result:
New test cases
mysql-test/t/ndb_restore.test:
New test cases
mysys/my_compress.c:
Moved packfrm and unpackfrm to mysys
sql/ha_ndbcluster.cc:
Set value of partition function in hidden field for user defined
partitioning in NDB to handle restore and later on-line reorganize
of partitions
To save space value of those functions are limited to 32 bits
sql/ha_partition.cc:
Use new get_partition_id interface
sql/handler.h:
Use new get_partition_id interface
sql/mysql_priv.h:
Moved to mysys
sql/mysqld.cc:
Minor
sql/opt_range.cc:
New get_partition_id interface
sql/sql_partition.cc:
New get_partition_id interface
Fix error checks of specification of engines in ALTER TABLE
Moved packfrm and unpackfrm to mysys
sql/sql_table.cc:
Fixed debug printouts
storage/ndb/include/kernel/ndb_limits.h:
New constant
storage/ndb/include/kernel/signaldata/DictTabInfo.hpp:
New table description item
storage/ndb/include/ndb_version.h.in:
New version specific constant
storage/ndb/include/ndbapi/NdbDictionary.hpp:
New item in table descriptions
storage/ndb/src/common/debugger/signaldata/DictTabInfo.cpp:
New item in table descriptions
storage/ndb/src/kernel/blocks/backup/Backup.cpp:
Write fragment id in backup's log entry
storage/ndb/src/kernel/blocks/backup/BackupFormat.hpp:
Write fragment id in backup's log entry
storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp:
New item in table description
storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp:
New item in table description
storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp:
Moved constant
storage/ndb/src/ndbapi/NdbDictionary.cpp:
New item in table description
storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp:
New item in table description
storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp:
New item in table description
storage/ndb/tools/Makefile.am:
Compress library needed for ndb_restore
storage/ndb/tools/restore/Restore.cpp:
Handle fragment id and also handle backups from older versions
storage/ndb/tools/restore/Restore.hpp:
Use fragment id
storage/ndb/tools/restore/consumer.hpp:
Use fragment id
storage/ndb/tools/restore/consumer_printer.cpp:
Use fragment id
storage/ndb/tools/restore/consumer_printer.hpp:
Use fragment id
storage/ndb/tools/restore/consumer_restore.cpp:
Code to map node groups if new cluster has different set of
node groups from original cluster
Very simple search and replace parser of partition syntax in frm file
Fix settings of partition id properly using fragment id and hidden
field in tables
storage/ndb/tools/restore/consumer_restore.hpp:
Changed function headers and new one for mapping node groups
storage/ndb/tools/restore/consumer_restorem.cpp:
Use fragment id
storage/ndb/tools/restore/restore_main.cpp:
New parameter to set node group map, parser for this parameter
Diffstat (limited to 'mysys/my_compress.c')
-rw-r--r-- | mysys/my_compress.c | 128 |
1 files changed, 128 insertions, 0 deletions
diff --git a/mysys/my_compress.c b/mysys/my_compress.c index 0e37d2fef9b..34f3d1c842a 100644 --- a/mysys/my_compress.c +++ b/mysys/my_compress.c @@ -95,4 +95,132 @@ my_bool my_uncompress (byte *packet, ulong *len, ulong *complen) } DBUG_RETURN(0); } + +/* + Internal representation of the frm blob +*/ + +struct frm_blob_header +{ + uint ver; /* Version of header */ + uint orglen; /* Original length of compressed data */ + uint complen; /* Compressed length of data, 0=uncompressed */ +}; + +struct frm_blob_struct +{ + struct frm_blob_header head; + char data[1]; +}; + +/* + packfrm is a method used to compress the frm file for storage in a + handler. This method was developed for the NDB handler and has been moved + here to serve also other uses. + + SYNOPSIS + packfrm() + data Data reference to frm file data + len Length of frm file data + out:pack_data Reference to the pointer to the packed frm data + out:pack_len Length of packed frm file data + + RETURN VALUES + 0 Success + >0 Failure +*/ + +int packfrm(const void *data, uint len, + const void **pack_data, uint *pack_len) +{ + int error; + ulong org_len, comp_len; + uint blob_len; + struct frm_blob_struct *blob; + DBUG_ENTER("packfrm"); + DBUG_PRINT("enter", ("data: %x, len: %d", data, len)); + + error= 1; + org_len= len; + if (my_compress((byte*)data, &org_len, &comp_len)) + goto err; + + DBUG_PRINT("info", ("org_len: %d, comp_len: %d", org_len, comp_len)); + DBUG_DUMP("compressed", (char*)data, org_len); + + error= 2; + blob_len= sizeof(struct frm_blob_header)+org_len; + if (!(blob= (struct frm_blob_struct*) my_malloc(blob_len,MYF(MY_WME)))) + goto err; + + // Store compressed blob in machine independent format + int4store((char*)(&blob->head.ver), 1); + int4store((char*)(&blob->head.orglen), comp_len); + int4store((char*)(&blob->head.complen), org_len); + + // Copy frm data into blob, already in machine independent format + memcpy(blob->data, data, org_len); + + *pack_data= blob; + *pack_len= blob_len; + error= 0; + + DBUG_PRINT("exit", ("pack_data: %x, pack_len: %d", *pack_data, *pack_len)); +err: + DBUG_RETURN(error); + +} + +/* + unpackfrm is a method used to decompress the frm file received from a + handler. This method was developed for the NDB handler and has been moved + here to serve also other uses for other clustered storage engines. + + SYNOPSIS + unpackfrm() + pack_data Data reference to packed frm file data + out:unpack_data Reference to the pointer to the unpacked frm data + out:unpack_len Length of unpacked frm file data + + RETURN VALUES¨ + 0 Success + >0 Failure +*/ + +int unpackfrm(const void **unpack_data, uint *unpack_len, + const void *pack_data) +{ + const struct frm_blob_struct *blob= (struct frm_blob_struct*)pack_data; + byte *data; + ulong complen, orglen, ver; + DBUG_ENTER("unpackfrm"); + DBUG_PRINT("enter", ("pack_data: %x", pack_data)); + + complen= uint4korr((char*)&blob->head.complen); + orglen= uint4korr((char*)&blob->head.orglen); + ver= uint4korr((char*)&blob->head.ver); + + DBUG_PRINT("blob",("ver: %d complen: %d orglen: %d", + ver,complen,orglen)); + DBUG_DUMP("blob->data", (char*) blob->data, complen); + + if (ver != 1) + DBUG_RETURN(1); + if (!(data= my_malloc(max(orglen, complen), MYF(MY_WME)))) + DBUG_RETURN(2); + memcpy(data, blob->data, complen); + + + if (my_uncompress(data, &complen, &orglen)) + { + my_free((char*)data, MYF(0)); + DBUG_RETURN(3); + } + + *unpack_data= data; + *unpack_len= complen; + + DBUG_PRINT("exit", ("frmdata: %x, len: %d", *unpack_data, *unpack_len)); + DBUG_RETURN(0); +} #endif /* HAVE_COMPRESS */ |