After adding a new block and saving, going back to configure the block results in an empty form.

pg_query(): Query failed: ERROR: column reference "title" is ambiguous in /var/www/drupal/drupal-5.0-rc2/includes/database.pgsql.inc on line 125.

query: SELECT bx.*, title FROM boxes bx INNER JOIN blocks bl ON bx.bid = bl.delta WHERE module = 'block' AND bid = 5 in /var/www/drupal/drupal-5.0-rc2/includes/database.pgsql.inc on line 144.

Adding bl reference to "title" column in block_box_get() fixes this on my install.

# diff block.module.orig block.module
362c362
<   return db_fetch_array(db_query("SELECT bx.*, title FROM {boxes} bx INNER JOIN {blocks} bl ON bx.bid = bl.delta WHERE module = 'block' AND bid = %d", $bid));
---
>   return db_fetch_array(db_query("SELECT bx.*, bl.title FROM {boxes} bx INNER JOIN {blocks} bl ON bx.bid = bl.delta WHERE module = 'block' AND bid = %d", $bid));

Server
OS: Debian 3.1 (Sarge)
Web Server: Apache 2.0.54
PHP: 4.3.10
DB: Postgres 7.4.7
Drupal: 5.0rc2

Comments

ulyses’s picture

The problem seems to still exist in Drupal 5.0 Release.

Server
OS: Windows XP SP2
Web Server: Apache 2.2.4
PHP: 5.2.0
DB: Postgres 8.2
Drupal: 5.0

Best regards,
John

mdixoncm’s picture

Version: 5.0-rc2 » 5.1

We have just experienced this problem.

The issue can be resolved by changing line 362 to

  return db_fetch_array(db_query("SELECT bx.*, bx.title FROM {boxes} bx INNER JOIN {blocks} bl ON bx.bid = bl.delta WHERE module = 'block' AND bid = %d", $bid));

I'll add this to a patch in a minute.

mdixoncm’s picture

Status: Active » Needs review
StatusFileSize
new0 bytes

Patch implemented ready for review

mdixoncm’s picture

StatusFileSize
new730 bytes

That last file didn't upload correctly ... this one should be ok

rdibble’s picture

I had get the same messages in drupal 5.1 on the site I'm working on....
* warning: pg_query() [function.pg-query]: Query failed: ERROR: column reference "title" is ambiguous LINE 1: SELECT bx.*, title FROM boxes bx INNER JOIN blocks bl ON bx.... ^ in /var/www/virtual-drake/drake-prod/includes/database.pgsql.inc on line 125.
* user warning: query: SELECT bx.*, title FROM boxes bx INNER JOIN blocks bl ON bx.bid = bl.delta WHERE module = 'block' AND bid = 1 in /var/www/virtual-drake/drake-prod/includes/database.pgsql.inc on line 144.

Thanks for the info on how to patch.

jpolt’s picture

The same patch fixed it for me

Drupal 5.1
PostgreSQL 8.2

Zen’s picture

Version: 5.1 » 6.x-dev
StatusFileSize
new748 bytes

That should be bl.title not bx.title. It is the blocks table that has the title field and not the boxes table. Attached patch also adds missing aliases in other parts of the query.

Please review and set to "Ready to be committed" if the attached patch works for you. I'm not sure how adding bx.title worked for anybody as that should have spat out an unknown field error.

FYI: I've tested this only on MySQL.

Thanks,
-K

Zen’s picture

P.S. The above patch applies on both 6 and 5 with offsets.

stormsweeper’s picture

The cause here may be the drop column query in system.install isn't being executed in system_update_1006(). That was the case for me, although the rest of that update did go through (dropping the constraint, etc).

dries’s picture

Ah, can you guys look at the drop-query too? Let's make sure we're fixing the problem at the right level, eh. :)

Zen’s picture

Status: Needs review » Reviewed & tested by the community

@Dries: The pgSQL query in question appears to be OK. However, there were other inconsistencies with the syntax and I've created an issue for it: http://drupal.org/node/138556

http://drupal.org/node/132775 (a dupe) also has the same fix. Marking this RTBC.

-K

drewish’s picture

I'm getting the same error on MySQL and this patch corrects it.

drewish’s picture

Just for future searchers, I'm getting this error as a side effect of the query:

PHP Fatal error:  Unsupported operand types in D:\drupal\drupalhead\modules\block\block.module on line 592
dries’s picture

Version: 6.x-dev » 5.x-dev

Committed to CVS HEAD. I think this needs to go into Drupal 5 too.

drumm’s picture

Committed to 5.

drumm’s picture

Status: Reviewed & tested by the community » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)