An Interview with Joshua Drake: Coauthor of Practical PostgreSQLby Jonathan Gennick, O'Reilly editor
Recently, Jonathan Gennick sat down with the coauthor of Practical PostgreSQL to talk about the future of this open source database. In this in-depth interview, Joshua Drake, who is also the cofounder of Command Prompt, and a project leader for Mammoth PostgreSQL, touches on everything from a Mac OS X distribution of PostgreSQL to LXP, the XML application server that runs as an Apache module to XML support in PostgreSQL.
Gennick: How long have you been working with PostgreSQL, and what got you started with it?
Drake: This is an interesting question. In the early 1990s I actually worked with Ingres, with which PostgreSQL has some deep-rooted history. However, as far as what I would consider current PostgreSQL, I started in 1995 with Postgres95. I had been contracted to write a shopping cart for an ISP and needed a database. Incidentally, that is also the time that I was first introduced to PHP (PHP/FI back then).
Gennick: I hear you are working on a Mac OS X distribution of PostgreSQL. Is that true? What are your plans for that? Are others also working on the same thing?
Drake: Well, Mac OS X is only one of our four supported distributions. (By the way, we refer to our distributions as Mammoth PostgreSQL.) We support Red Hat Linux 6.x/7.x, Solaris 8, Mac OS X, and Win32. Our Win32 version is in Beta and will be released shortly. Our hope is to give the Win32 users incentives to test deployments before moving to one of our Unix-supported platforms.
The Mac OS X version has been well received and is actually our most demanded version at this time. The marketing that Apple is doing right now with the "Just Works" slogan is the same as our thought process with our Mac OS X version. We are providing a database with enterprise class features that the Apple heads won't have to worry about. They just install it, and run it. If they need help they can call us.
There are other PostgreSQL distributions for Mac OS X out there, but I only know of two that are actively supported, our's (Command Prompt) and DbExpert's.
Gennick: You have distributions for more than just the Mac; why?
Drake: Market. We could just support Mac OS X or Linux, but it really wouldn't do us or our customers a lot of good. By providing a well-rounded set of support and programming services, plus the multiplatform support for our products, customers are never caught locked into their operating system platform.
Gennick: In Chapter 13 of Practical PostgreSQL, you cover something called LXP. Just what is that? It's not part of the standard PostgreSQL distribution, is it?
Drake: LXP is a XML application server that runs as an Apache module. The two main benefits of LXP are true database persistence and rapid development time. Originally LXP was developed internally for our own use; we wanted something that was versatile but not as programmatic as something like PHP or Perl. In other words, we wanted a simple solution to a number of complex problems. OK, we were lazy and did not want to continue coding in languages that required a lot of extra syntax.
LXP currently supports a wide array of features, including:
- XML Parsing
- Delimited Parsing (any delimiter)
- Content Inclusion
- Logic Parsing (if/else/ifnot)
- Form Processing
- Database Persistence
- Ad hoc queries
- Universal Brokering
- Large Object Support
- Browser based upload support (to a large object)
As a simple example, here is some code to perform a query to a PostgreSQL database and display the results in tabular form (for example, in rows and columns):
<lxp> <!-- select all my employees and their phone numbers from our employee table --> <include sql="SELECT employee_firstname, employee_lastname, phone_number FROM employees"> <div align="bold_content"> First Name: </div> <field name="employee_firstname"> <div align="bold_content"> Last Name: </div> <field name="employee_lastname"> <div align="bold_content"> Phone Number: </div> <field name="phone_number"> </include> </lxp>
As you can see, you can incorporate HTML directly into the LXP code and the parser understands how to deal with it. It is very simple, but extremely powerful. The equivalent code in PHP or Perl would need to be quite a bit more lengthy. An additional feature, which customers have found useful, is the Universal Broker. The Universal Broker was created to allow people to use tools as they are appropriate. For example, PHP. PHP is a great language and we use it in a lot of our development. There are times, when you want LXP to do something that is just better served in PHP. If this is the case, all you have to do is the following:
<lxp> <include method="uri" src="my_form.php" /> </lxp>
This will process the PHP file directly through Apache and allow you to use PHP (or Perl, Python, Java, and so on) directly from LXP.
The key to LXP is that it doesn't look like a programming language, but it does give you all the benefits of one. Many of our customers are extremely bright and self motivated, but they are not programmers. If you give them a bunch of PHP code they say, "Great... now I have to learn Latin?", but when they see LXP they say, "Hey looks like HTML... no problem". That is a powerful argument for the small business looking to develop an application.
LXP is not currently distributed as part of the community PostgreSQL. However, it is part of Mammoth PostgreSQL.