According to documentation db_query() should return FALSE "if the query was not executed correctly". This function calls _db_query() which returns nothing in such cases (for example when the sql syntax is wrong).

Attached one-liner fixes this by adding return FALSE to _db_query(). It's from 4.6.1 but should apply to cvs without problems. Please apply this patch also to 4.6 branch.

But there seems to be a problem with db_error(). It calls mysql_errno() but it seems that errors are cleared after mysql_error() call. So db_error() does not indicate any errors even if they occur.

Comments

Cvbge’s picture

I have moved the db_error part to http://drupal.org/node/25673

Cvbge’s picture

I forgot to make a patch for database.pgsql, but the change is the same.

Cvbge’s picture

StatusFileSize
new1.01 KB

Patch against current cvs, have both mysql and postgresql db. Maybe now someone will take a look at it?

killes@www.drop.org’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new1.05 KB

The patch makes sense to me. It shoudl have been rolled from the Drupal base directory, which I did.

dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to HEAD. Thanks.

Cvbge’s picture

Version: » 4.6.2
Status: Fixed » Reviewed & tested by the community

Please also apply to 4.6, patch applies without problems.

dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to DRUPAL-4-6. Thanks.

ken123’s picture

Anonymous’s picture

Anonymous’s picture

Anonymous’s picture

Status: Fixed » Closed (fixed)