PostgreSQL for WordPress (or PG4WP) is a plugin to install and use WordPress with a PostgreSQL database.
Cuurent development is done with WordPress version 3.2.1 but it may work with other versions too (2.9.2 was tested ok recently).
The original code was inspired by usleepless’ script « mysql2pgsql.php » and has evolved to become compatible with newer versions of WordPress and PostgreSQL.
PG4WP rewrites the SQL code on the fly and makes the call to the native function adequately in place of the « mysql_*() » initial call.
The plugin is based on a wpdb class identical to the WordPress’ one, except that all calls to « mysql_*() » are renamed « wpsql_*() », and the « converter » defines these « wpsql_*() » functions.
You don’t need to disable MySQL support in PHP to use a « converter » for a particular database and MySQL support is still available (the MySQL « converter » is included).
The WordPress core works, but there was very little testing.
If you test it (successfully or not) , I’d like to be informed of the results.
Plugins using WordPress’ wpdb with standard SQL should work without modification.
If you use a plugin successfully (or not) , please leave a comment.
If a plugin you wish to use doesn’t work and you think PG4WP is the cause, please leave a comment and I’ll try fix the problem.
You can download the latest version of PG4WP from the plugin directory
Thanks! My school linux server only uses postgres so this is a huge help and seems to be working perfectly!!!
Although its a tad slow :-/ Probly just a server issue.
Nice to hear it helped you.
Maybe you could give me some informations about your setup (WordPress version, PostgreSQL version, maybe Web server version and PHP version, …).
v1.0 was intended to « just work », I know there are some bottlenecks in the code and the next step will be to optimize almost everything.
I have some ideas, such as separating « setup » code from « daily usage » code.
This would mainly reduce memory footprint but may also give a little speed boost.
I’ll make some code profiling in the next few days so that I can determine which part of my own code is the slowest, and try to make it a little faster.
Hey Hawk,
thanks for your huge effort on this!
I just stumbled upon those news items:
http://www.h-online.com/open/news/item/Oracle-adds-commercial-extensions-to-MySQL-1344611.html
(was linked from here: http://monty-says.blogspot.com/2011/09/oracle-adding-close-source-extensions.html)
My conclusion: that’s going to drive development further from mysql more towards true open source projects – like postgresql.
Since WP-Core still doesn’t allow other dbms than mysql (https://codex.wordpress.org/Using_Alternative_Databases) your project/plugin seems the closest wordpress gets to postgresql.
I guess that your target audience is going to grow in the future and wish you all the best!
Thanks again for your work on this wonderful plugin!
Cheers,
C
Hey Hawk,
thanks for your huge effort on this!
I just stumbled upon those news items:
http://www.h-online.com/open/news/item/Oracle-adds-commercial-extensions-to-MySQL-1344611.html
(was linked from here: http://monty-says.blogspot.com/2011/09/oracle-adding-close-source-extensions.html)
My conclusion: that’s going to drive development further from mysql more towards true open source projects – like postgresql.
Since WP-Core still doesn’t allow other dbms than mysql (https://codex.wordpress.org/Using_Alternative_Databases) your project/plugin seems the closest wordpress gets to postgresql.
I guess that your target audience is going to grow in the future and wish you all the best!
Thanks again for your work on this wonderful plugin!
Cheers,
C
+1
Hi,
I’ve found a bug in this code, in this line:
$sql = preg_replace( ‘/COUNT(.+)ORDER BY.+/’, ‘COUNT$1′, $sql);
Specifically, the « dot » character in a PCRE does *NOT* match a newline by default, which means in an SQL query in which COUNT and ORDER BY are on different lines, the ORDER BY clause will not be deleted. WordPress seems to generate such queries, which then blew up in my installation. I fixed it by changing like so:
$sql = preg_replace( ‘/COUNT(.+)ORDER BY.+/s’, ‘COUNT$1′, $sql);
The « s » modifier makes dots include newlines.