Skip to content

Conversation

@carlopires
Copy link

Also includes:

  • Fixes to postgresql sql script
  • Fixes to database adapters

Gabriele,

First, thanks for your hard work on make joomla run with postgresql. I'm using it right now.

I had to make some changes to make my components install with postgresql_v2 branch. I'm pulling to you to see if these fixes are useful to you.

Fixes to postgresql sql script
Fixes to database adapters
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is JDatabase::insertObject, base class for all drivers, so this is common for all driver while "RETURNING" clause works only on PostgreSQL and maybe on Oracle, but surely it doesn't work on MySQL .
This change, and the following on this file, can be useful for JDatabasePostgresql::insertObject, or change this to use implementation merged inside platform .
Anyway, thank you to submit this change I think I'll push inside platform's driver.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah... I think this code must go to platform's driver. The current code did not work to me (postgresql 9.1)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does not work because there's no JDatabasePostgresqlQuery for that INSERT INTO statement, so "insertid" will crash.
If you change this code with that already present inside platform it will work.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting change, could be better implemented without same code replication, maybe doing what you've proposed for database.php

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The real effort of this block is replacement of "insertid" with "returning" JDatabasePostgresqlQuery element.
I'm thinking a better solution than existing and than this change.

Ps
platform code has to pass some code style check, this change will not pass them.

…abaseQuery

Revert installer adapters to use JDatabase::insertid and avoid break of compatibility with others drivers
@carlopires
Copy link
Author

Gabriele,

I changed JDatabase::insertObject and JDatabase::updateObject like you suggested and could revert the changes about insertid on installer adapters.

I was wondering if JDatabasePostgreSQL::inserid could just be just:

return $this->loadResult()

As JDatabasePostgreSQL::insertObject are using RETURNING clause.

The problem is that JDatabasePostgreSQL::insertObject can be called null key parameter and this could crash insertid in some point. I decided to keep the current code and now everything is working fine. The final diffs are now much less impactive.

Thanks a lot for you help.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm reading pg_num_rows doc, it accepts only resources so casting null to integer doesn't seem to be a resource.
I think it's better something like ( !isnull($cur) ? $cur : $this->cursor) , don't you?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$cur parameter comes with boolean value (false) and is causing php to issue warnings... What about this:

return pg_num_rows( is_numeric($cur) ? (int)$cur : $this->cursor);

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the error is $cur value set to false, it has to be a resource link .

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so, but to fix this I will need to revisit all getNumRows calls and this is out of my possibilities, now.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes are what I wanted to do after merging this pull, thank you.
+1

@gpongelli
Copy link
Owner

Really good job, thank you very much of this pull!
I'll do same change inside platform code to keep them.

Eng. Gabriele Pongelli.

gpongelli added a commit that referenced this pull request Apr 7, 2012
Fixes for insertid issues with postgresql driver
@gpongelli gpongelli merged commit 8e5b5eb into gpongelli:postgresql_v2 Apr 7, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants