Monday, October 20, 2008
Using config.status to build outside the tree
Tuesday, October 14, 2008
Ideas for BLOB streaming
- File Storage: This storage engine would just store the blobs in individual files. It may be of interest to applications where they want to be able to directly grab the data such a web application where the data is directly read by the web server.
- Amazon S3 Storage: This storage engine would store the BLOBs in Amazon S3 buckets. This BLOB storage engine would be of interest to applications that deal with massive amounts of data and need a highly scalable storage solution.
- Mirrored Storage: This storage engine would replicate the BLOBs to multiple geographical locations so that requests for the data could be directed to the closest mirrored site.
- Load Balancing Storage: This storage engine would have the ability to move the BLOB data around to from one storage location to another to try to optimize it's access time or more evenly distribute the storage load on different servers.
- Wally Storage: This engine wouldn't actually store anything and would reply to any request for data that it will have it for them by Wednesday. This would be of interest to applications that are forced to store data that they know nobody will ever actually want.
Alpha release v05.06 of the BLOB streaming engine
What's new in 5.06:
- The BLOB streaming engine can now be used with MyISAM tables as well as tables created by any other MySQL storage engine.
- The name of the PrimeBase BLOB streaming engine has been changed from MyBS to PBMS which stands for "PrimeBase Media Streaming".
- streaming-enabled table: This is any table created by a streaming-enabled engine such as PBXT, or has triggers defined on blob referencing columns that notify the PBMS engine when BLOB references are inserted, updated, and deleted.
- BLOB reference column: This is a column in a stream-enabled table that contains PBMS BLOB references and notifies the PBMS engine when data is inserted, updated, or deleted from the column.
Create table x.foo(c1 integer, c2 longblob) ENGINE = MYISAM;
create trigger x.foo_insert_trig BEFORE INSERT on x.foo for each row BEGIN set NEW.c2 = pbms_insert_blob_trig("x", "foo", 2, NEW.c2); END
create trigger x.foo_update_trig BEFORE UPDATE on x.foo for each row BEGIN set NEW.c2 = pbms_update_blob_trig("x", "foo", 2, OLD.c2, NEW.c2); END
create trigger x.foo_delete_trig BEFORE UPDATE on x.foo for each row BEGIN declare dummy integer; set dummy = pbms_delete_blob_trig("x", "foo", 2, OLD.c2); END
As a result of the name change you will see that any use of the letters 'mybs' has been changed to 'pbms' throughout the code and documentation.
Friday, October 10, 2008
PrimeBase PBMS does MYISAM
/* Functions used for non PBMS enabled tables. */
/*
* pbms_init_udfs()
* Declares the PBMS UDFs on the server if they do not already exist.
*
* Equivalent UFD: NONE
*/
pbms_bool pbms_init_udfs(MYSQL *mysql);
/*
* pbms_enabled()
* Returns 'true' if the 'engine' is PBMS enabled i.e. provides direct support for PBMS.
* So far the PBXT engine is the only PBMS enabled engine out there. Hopefully that will change.
*
* Equivalent UFD: pbms_enabled_engine(engine)
*/
pbms_bool pbms_enabled(MYSQL *mysql, const char *engine, pbms_bool *enabled);
/*
* pbms_init_table()
* Creates triggers on any 'longblob' columns in the table that will notify the PBMS engine when blob PBMS
* references are inserted, deleted, or updated. If 'no_blobs_ok' is 'false' then an error is reported if
* no 'longblob' columns are found. If 'no_blobs_ok' is 'true' and then no error is reported if no 'longblob'
* columns are found and no action is taken.
*
* Equivalent UFD: NONE
*/
pbms_bool pbms_init_table(struct st_mysql *mysql, const char *database, const char *table, pbms_bool no_blobs_ok);
/*
* pbms_reset_table_blobs()
* This is similar to pbms_init_table() except that it is meant to be called if an alter table has been done on
* a table that contains blobs being managed by PBMS and either a 'longblob' column has been added or dropped, or
* the ordinal position of a 'longblob' column has changed.
*
* Equivalent UFD: NONE
*/
pbms_bool pbms_reset_table_blobs(struct st_mysql *mysql, const char *database, const char *table);
/*
* pbms_drop_table_blobs()
* This function is called after a table has been dropped to notify PBMS to remove all blob references from that
* table.
*
* Equivalent UFD: pbms_delete_all_blobs_in_table(database);
*/
pbms_bool pbms_drop_table_blobs(struct st_mysql *mysql, const char *database, const char *table);
/*
* pbms_table_renamed()
* This function is called after a table containing blobs has been renamed.
*
* Equivalent UFD: pbms_rename_table_with_blobs(database);
*/
pbms_bool pbms_table_renamed(struct st_mysql *mysql, const char *database, const char *old_table, const char *new_table);
/*
* pbms_dropping_database()
* Call this function before dropping any database that contained tables containing blobs. This gives the PBMS
* engine a chance to remove it's files and sub directories from the database directory so that it can be
* deleted.
*
* Equivalent UFD: pbms_dropping_database(database);
*/
pbms_bool pbms_dropping_database(struct st_mysql *mysql, const char *database);
/*
User defined functions provided with the PBMS engine:
//UDFs used in triggers:
// 'col_position' is the ordinal of the longblob column starting at position 1.
pbms_insert_blob_trig(database, table col_position, blob_url);
pbms_update_blob_trig(database, table col_position, old_blob_url, new_blob_url);
pbms_delete_blob_trig(database, table col_position, blob_url);
// Example:
crete table x.foo(c1 int, c2 longblob);
create trigger x.foo_insert_trig BEFORE INSERT on x.foo for each row BEGIN set NEW.c2 = pbms_insert_blob_trig("x", "foo", 2, NEW.c2); END
create trigger x.foo_update_trig BEFORE UPDATE on x.foo for each row BEGIN set NEW.c2 = pbms_update_blob_trig("x", "foo", 2, OLD.c2, NEW.c2); END
create trigger x.foo_delete_trig BEFORE UPDATE on x.foo for each row BEGIN declare dummy integer; set dummy = pbms_delete_blob_trig("x", "foo", 2, OLD.c2); END
///////////
pbms_delete_all_blobs_in_table(database, table);
pbms_rename_table_with_blobs(database, old_table, new_table);
pbms_dropping_database(database);
pbms_enabled_engine(engine);
NOTE: pbms_enabled_engine() returns -1 on error.
CREATE FUNCTION pbms_insert_blob_trig RETURNS STRING SONAME "libpbms.so";
CREATE FUNCTION pbms_update_blob_trig RETURNS STRING SONAME "libpbms.so";
CREATE FUNCTION pbms_delete_blob_trig RETURNS INTEGER SONAME "libpbms.so";
CREATE FUNCTION pbms_delete_all_blobs_in_table RETURNS INTEGER SONAME "libpbms.so";
CREATE FUNCTION pbms_rename_table_with_blobs RETURNS INTEGER SONAME "libpbms.so";
CREATE FUNCTION pbms_dropping_database RETURNS INTEGER SONAME "libpbms.so";
CREATE FUNCTION pbms_enabled_engine RETURNS INTEGER SONAME "libpbms.so";
*/
Use of PBMS with non PBMS enabled engines is not yet transactionally safe. This means that if you use it on an INODB table while say doing some inserts in a transaction and then rollback the transaction the blob references will remain. Of course PBMS enabled engines such as PBXT do not have this problem. Making PBMS transactionally safe with non PBMS enabled engines is on my to-do list.
The test shell 'pbmstest' included with the PBMS source uses the new API functions and by default performs it's tests using a MYISAM table.
Barry