PostgreSQL driver for Joomla! CMS. [v2] - [DEPRECATED] #166

wants to merge 44 commits into

5 participants


This driver implements inherited function from JDatabase class and add some other useful function to be able to use Joomla! on PostgreSQL database.
There is also a class that inherits from JDatabaseQuery to be able to create query object using PostgreSQL dialect.
Also added change item class for Postgresql under CMS libraries folder.
This pull include codes from platform 12.1 for JDatabaseQuery::charLength to address CMS' CASE WHEN
queries that has to be compared with 0 .

JDatabasePostgresql::getQuery has an optional second parameter to retrieve JDatabasePostgresqlQuery object, used inside JDatabasePostgresql::insertid call .

PostgreSQL's added functions:

  • getRandom, ge a random number
  • getStringPositionSQL, returns string's position inside another string
  • releaseTransactionSavepoint, release given savepoint during transaction
  • showTables, lists all table in database
  • transactionSavepoint, to create a savepoint

Overridden functions:

  • connected
  • dropTable
  • escape
  • explain
  • fetchArray
  • fetchAssoc
  • fetchObject
  • freeResult
  • getAffectedRows
  • getAlterDbCharacterSet
  • getCollation
  • getCreateDbQuery
  • getNumRows
  • getQuery
  • getTableColumns
  • getTableCreate
  • getTableKeys
  • getTableList
  • getVersion
  • hasUTF
  • insertid
  • insertObject
  • lockTable
  • query
  • queryBatch
  • renameTable
  • replacePrefix
  • select
  • setUTF
  • test
  • transactionCommit
  • transactionRollback
  • transactionStart
  • unlockTables
  • updateObject

PostgreSQL database query added functions:

  • limit, a possible replace for limit in setQuery
  • offset, a possible replace for limit in setQuery
  • forShare, lock table/row during SELECT
  • forUpdate, lock table/row during SELECT
  • noWait, no wait a locked table
  • returning, an INSERT INTO optional clause to returns last insert id
gpongelli added some commits Mar 25, 2012
@gpongelli gpongelli Added PostgreSQL's sql files. ed00929
@gpongelli gpongelli Added PostgreSQL as supported database. cd388bf
@gpongelli gpongelli Fixed an issue on new article, publish_down field was not a timestamp
but an empty string.
@gpongelli gpongelli Removed old commented code block.
Replaced an INSERT IGNORE INTO query to be PostgreSQL compatible.
@gpongelli gpongelli Updated charLength to 12.1 platform's version to address CMS' CASE WHEN
@gpongelli gpongelli Added quoteName call to columns' name that have capital letter. b7942fc
@gpongelli gpongelli Query fix. 28d0e82
@gpongelli gpongelli Fixed CASE WHEN query, it must evaluate boolean. fa4e3ad
@gpongelli gpongelli Fixed CASE WHEN comparison with null date. 58a4575
@gpongelli gpongelli Fixed CASE WHEN comparison with null date. 06ffece
@gpongelli gpongelli Query fix. 24fd93c
@gpongelli gpongelli Fixed SELECT query using quoteName with array parameter. 567d7ef
@gpongelli gpongelli Query fix. bb626ed
@gpongelli gpongelli Escaping chr(0) chars from the session.
Thanks to elkuku.
@gpongelli gpongelli Query fix. 2ce3dc1
@gpongelli gpongelli Added Postgresql entry. fc78d37
@gpongelli gpongelli Various changes to make Joomla! installable on PostgreSQL.
Added handle section for "CREATE OR REPLACE FUNCTION", used in
PostgreSQL to create a replacement for SOUNDEX function.
@gpongelli gpongelli Fix: Table key must not "0" but "null" for insert statements.
Thanks to elkuku.
@gpongelli gpongelli Update PostgreSQL changes. 6e5b461
@gpongelli gpongelli Added a kind of filter to load only requested files, depending on
database subfolder, and not all present under sql/update folder.
@gpongelli gpongelli Added Postgresql driver, query class, change item class and sql files. c202cab

See #84 .

gpongelli and others added some commits Mar 25, 2012
@gpongelli gpongelli Changed getQuery to return a JDatabasePostgresqlQuery object inside
JDatabasePostgresql::insertid call.
@gpongelli gpongelli Replaced "left" call with "substr", supported in PostgreSQL database
older than 9.1 .
@carlopires carlopires Fixes for insertid issues with postgresql driver
Fixes to postgresql sql script
Fixes to database adapters
@carlopires carlopires Fix template adapters to work with postgresql 31f0952
@carlopires carlopires Fixed JDatabase::insertObject and JDatabase::updateObject to use JDat…

Revert installer adapters to use JDatabase::insertid and avoid break of compatibility with others drivers
@carlopires carlopires Fixed joomla users creation 9881248
@carlopires carlopires Finished users management fixes with PostgreSQL bd747b5
@carlopires carlopires Removed insertid calls from installer adapters to avoid pitfalls rela…
…ted to JTable::store
@carlopires carlopires Fixed menu edition with PostgreSQL 559c69e
@carlopires carlopires Better fix to JDatabasePostgreSQL::getNumRows 8d6e9e1
@carlopires carlopires Joomla coding style applied to JDatabasePostgreSQL::insertObject a4aa9f7
@gpongelli gpongelli Merge pull request #2 from carlopires/postgresql_v2
Fixes for insertid issues with postgresql driver
@gpongelli gpongelli Changed explicit primary key name with more general $key to let code
be independent of future primary key's change.
@gpongelli gpongelli Fixed charLength use to work with PostgreSQL. a4f5418
@gpongelli gpongelli Added fix for older PostgreSQL version. 27d6303
@gpongelli gpongelli Added three check before value storing to prevent query error. a7e43b2
@gpongelli gpongelli Overloaded store function to avoid NOT NULL constraint violation. c38403f
@gpongelli gpongelli Added checks on timestamp empty fields. b58f7a2
@gpongelli gpongelli Removed doubled $sqlFolder . ba231c8
@gpongelli gpongelli Added a comment for deprecated "imagepos" field. 49c9464
@gpongelli gpongelli Changed "imagepos" lenght to avoid PostgreSQL error on not used field. 08ba302

Hello gpongelli,
i'm thinking in using Joomla! on PostegreSQL in my organization. And i need it because i want to use the spatial component PostGIS. Could you please tell me if the support for PostgreSQL of Joomla! is in a stable release? Or what release can i use for this matter? Otherwise I'm considering using Drupal. Could you help me on this?
Thanks in advanced,
Rui Sabino


Hello gpongelli,

Really nice work.
Postgres support is very important to easily integrate Joomla with other applications that are using postgres DB.

Thank you very much for you work and hope this pull request will be included in next Joomla release.



I'm using your version for about two months and only recently found a bug :)

When I try to process multiple articles, for example when copying multiple articles from one category to another changing their language, I receive the following error (translated from portuguese):

The batch process failed with the following message: Failed to archive JTableAsset ::
JLIB_DATABASE_QUERY_FAILED ERROR: null value in the "rules" violates the constraint not null SQL = INSERT INTO "minonl_assets" ("name", "title" , "parent_id", "level", "lft", "RGT") VALUES ('com_content.article.98', 'Software and Human Resources Management in the Cloud', 207,4,323,324) RETURNING id

The result of this operation, is that only one article is copied and mantains de original language.

In the screencast bellow you can see it happening.

It's not a serious error so I can continue working with no problem, I just want to let you now ;)


@mbabker mbabker closed this Dec 28, 2012
@gpongelli gpongelli referenced this pull request in joomla/joomla-platform Mar 16, 2013

Improvement for PostgreSQL database. #1460

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment