New large data variable (BLOB) support and database schema renaming
Manuel Lemos, 2005-12-21 06:30:00 GMT
|A new version of Metastorage was
released featuring support for large data variables, also known as BLOBs -
Binary Large OBjects, and providing means to upgrade database schemas
without destroying previously stored objects when classes, variables or
collections are renamed.
- BLOBs - Large data variables
Text variables can store sequences of characters of limited length that in
some databases may not exceed 255 characters. To store longer texts, it is
necessary to use a special type of table fields, usually known as BLOBs.
The procedure to store and retrieve BLOBs is different than with small
length text fields. It requires the use of prepared queries that can
transfer the field data in streams, instead of storing or retrieving the
field data all at once. This makes possible to transfer arbitrarily large
amounts of data without exceeding the applications memory usage limits.
This release of Metastorage introduces a new variable type named
The generated code to persist objects was rewritten to use prepared
queries, so the large data variable information can be streamed to
database server. The prepared queries are cached by the factory class to
avoid query parsing overhead.
Large data variables are always lazy loaded. This means that such
variables are only stored or retrieved when explicitly requested by the
Two new types of functions were implemented to store and retrieve large
setlargedata can prepare an object to store a large data variable
from a text string parameter or from a given file. getlargedata
can the contents of a large data variable into a text string, into a file
or serve it directly as part of the current script output.
This way Metastorage greatly simplifies the manipulation of large data
variables. With a single call, developers can easily implement complex
operations that are common in Web applications, such as storing files
uploaded using Web forms in a database, or serving files for download
directly to the users browsers, in a way that it works in environments
with limited memory availability, or even with PHP running in safe
The Metastorage tutorial document was updated to demonstrate how to easily
retrieve large data
variables, with practical examples as explained above.
- Database schema tables and field renaming
When applications need to be upgraded, sometimes it is necessary to rename
the tables and fields that map the persistent object classes and
Metastorage generates code that uses the
Metabase API. Metabase supports schema
installation and upgrading operations that include table and field
renaming. However, until now it was not possible to hint the Metabase
database schema manager that a table or a field needs to be renamed.
This release introduces a new parameter named was
that should be used to specify what was the previous name of classes,
variables or collections being renamed.
This way Metastorage can generate a database schema description that tells
exactly how the Metabase schema manager should safely upgrade the database
schema renaming the intended tables and fields correctly.