00001 /* Copyright (C) 2010 PrimeBase Technologies GmbH 00002 * All rights reserved. 00003 * 00004 * Redistribution and use in source and binary forms, with or without 00005 * modification, are permitted provided that the following conditions are met: 00006 * 00007 * * Redistributions of source code must retain the above copyright notice, 00008 * this list of conditions and the following disclaimer. 00009 * * Redistributions in binary form must reproduce the above copyright notice, 00010 * this list of conditions and the following disclaimer in the documentation 00011 * and/or other materials provided with the distribution. 00012 * * Neither the name of the "PrimeBase Technologies GmbH" nor the names of its 00013 * contributors may be used to endorse or promote products derived from this 00014 * software without specific prior written permission. 00015 * 00016 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 00017 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00018 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 00019 * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 00020 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 00021 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00022 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 00023 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00024 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00025 * POSSIBILITY OF SUCH DAMAGE. 00026 * 00027 * 00028 * PrimeBase Media Stream for MySQL/Drizzle 00029 * 00030 * Barry Leslie 00031 * 00032 * 2009-07-16 00033 * 00034 * H&G2JCtL 00035 * 00036 * PBMS interface used to enable engines for use with the PBMS daemon. 00037 * 00038 * For an example on how to build this into an engine have a look at the PBXT engine 00039 * in file ha_pbxt.cc. Search for 'PBMS_ENABLED'. 00040 * 00041 */ 00042 00043 00044 #pragma once 00045 #ifndef __PBMS_ENABLED_H__ 00046 #define __PBMS_ENABLED_H__ 00047 00048 #include "pbms.h" 00049 00050 #ifdef DRIZZLED 00051 #include <drizzled/common.h> 00052 #define TABLE Table 00053 #define uchar unsigned char 00054 #else 00055 #include <mysql_priv.h> 00056 #endif 00057 00058 class Field; 00059 typedef bool (*IsPBMSFilterFunc)(Field *field); 00060 00061 /* 00062 * pbms_initialize() should be called from the engines plugIn's 'init()' function. 00063 * The engine_name is the name of your engine, "PBXT" or "InnoDB" for example. 00064 * 00065 * The isServer flag indicates if this entire server is being enabled. This is only 00066 * true if this is being built into the server's handler code above the engine level 00067 * calls. 00068 */ 00069 extern bool pbms_initialize(const char *engine_name, bool isServer, bool isTransactional, PBMSResultPtr result, IsPBMSFilterFunc is_pbms_blob); 00070 00071 /* 00072 * pbms_finalize() should be called from the engines plugIn's 'deinit()' function. 00073 */ 00074 extern void pbms_finalize(const char *engine_name); 00075 00076 /* 00077 * pbms_write_row_blobs() should be called from the engine's 'write_row' function. 00078 * It can alter the row data so it must be called before any other function using the row data. 00079 * 00080 * pbms_completed() must be called after calling pbms_write_row_blobs() and just before 00081 * returning from write_row() to indicate if the operation completed successfully. 00082 */ 00083 extern int pbms_write_row_blobs(const TABLE *table, unsigned char *buf, PBMSResultPtr result); 00084 00085 /* 00086 * pbms_update_row_blobs() should be called from the engine's 'update_row' function. 00087 * It can alter the row data so it must be called before any other function using the row data. 00088 * 00089 * pbms_completed() must be called after calling pbms_write_row_blobs() and just before 00090 * returning from write_row() to indicate if the operation completed successfully. 00091 */ 00092 extern int pbms_update_row_blobs(const TABLE *table, const unsigned char *old_row, unsigned char *new_row, PBMSResultPtr result); 00093 00094 /* 00095 * pbms_delete_row_blobs() should be called from the engine's 'delete_row' function. 00096 * 00097 * pbms_completed() must be called after calling pbms_delete_row_blobs() and just before 00098 * returning from delete_row() to indicate if the operation completed successfully. 00099 */ 00100 extern int pbms_delete_row_blobs(const TABLE *table, const unsigned char *buf, PBMSResultPtr result); 00101 00102 /* 00103 * pbms_rename_table_with_blobs() should be called from the engine's 'rename_table' function. 00104 * 00105 * NOTE: Renaming tables across databases is not supported. 00106 * 00107 * pbms_completed() must be called after calling pbms_rename_table_with_blobs() and just before 00108 * returning from rename_table() to indicate if the operation completed successfully. 00109 */ 00110 extern int pbms_rename_table_with_blobs(const char *old_table_path, const char *new_table_path, PBMSResultPtr result); 00111 00112 /* 00113 * pbms_delete_table_with_blobs() should be called from the engine's 'delete_table' function. 00114 * 00115 * NOTE: Currently pbms_delete_table_with_blobs() cannot be undone so it should only 00116 * be called after the host engine has performed successfully drop it's table. 00117 * 00118 * pbms_completed() must be called after calling pbms_delete_table_with_blobs() and just before 00119 * returning from delete_table() to indicate if the operation completed successfully. 00120 */ 00121 extern int pbms_delete_table_with_blobs(const char *table_path, PBMSResultPtr result); 00122 00123 /* 00124 * pbms_completed() must be called to indicate success or failure of a an operation after having 00125 * called pbms_write_row_blobs(), pbms_delete_row_blobs(), pbms_rename_table_with_blobs(), or 00126 * pbms_delete_table_with_blobs(). 00127 * 00128 * pbms_completed() has the effect of committing or rolling back the changes made if the session 00129 * is in 'autocommit' mode. 00130 */ 00131 extern void pbms_completed(const TABLE *table, bool ok); 00132 00133 #endif