Apples and Oranges, Part II: A Linux DBMS Comparison
Bringing the Client to Life on mSQL

Matthias Warkus
Thursday, November 18, 1999 01:25:46 PM
The differences between mSQL's and MySQL's C API are very, very small. Thus,
there is even an automatic converter. The principal differences are:
- mSQL does not store a connection data block, only a number (
int
bookstore)
- some mSQL functions don't take the connection as an argument
- mSQL function names are Pascalish (they use StudlyCaps instead of
underscores)
The handy MONEY data type is a fixed-precision decimal fraction
type with two decimals. To make mSQL correctly store integer numbers of cents
in MONEY columns, I needed to convert them, casting them into
floats, dividing them and formatting them in the
sprintf statement of the add_new_book() function.
This is list_books(), ported to mSQL:
void
list_books(void)
{
int count;
m_result *result;
msqlQuery(bookstore, "SELECT ARTICLE_NO, AUTHOR_FIRST_NAMES,\
AUTHOR_LAST_NAMES, TITLE, ISBN, WHOLESALE_PRICE, RETAIL_PRICE,\
COPIES_AVAILABLE FROM BOOK");
result = msqlStoreResult();
for(count = msqlNumRows(result); count > 0; count--)
{
m_row record;
record = msqlFetchRow(result);
printf("\nArticle no. %s\n", record[0]);
printf("%s, %s:\n", record[2], record[1]);
printf(" %s (%s)\n", record[3], record[4]);
printf("Bought at %s; selling at %s; %s copies available\n\n",
record[5], record[6], record[7]);
};
msqlFreeResult(result);
}
Documentation for mSQL's C API can be found in the mSQL manual that ships
with mSQL as PostScript and as a large HTML file.
Next: Some Early Conclusions »