Upgrading the Views module to version 6.x-2.3 for Drupal using a PostgreSQL database gave the following warnings:

warning: pg_query() [function.pg-query]: Query failed: ERROR: column "data" is of type text but expression is of type bytea HINT: You will need to rewrite or cast the expression. in D:\Project\krw-portaal\includes\database.pgsql.inc on line 139.
user warning: query: UPDATE views_object_cache SET data = data_old in D:\Project\krw-portaal\includes\database.pgsql.inc on line 915.

views module
Update #6002
ALTER TABLE {views_object_cache} RENAME data TO data_old
ALTER TABLE {views_object_cache} ADD COLUMN data text
Failed: UPDATE {views_object_cache} SET data = data_old
ALTER TABLE {views_object_cache} DROP COLUMN data_old

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Josh Waihi’s picture

subscribing to this. Query needs to be something like UPDATE {views_object_cache} SET data = CAST(data_old AS TEXT)

Josh Waihi’s picture

Josh Waihi’s picture

Project: Views (for Drupal 7) » Drupal core
Version: 6.x-2.3 » 6.x-dev
Component: Code » postgresql database
Assigned: Unassigned » Josh Waihi
Status: Active » Reviewed & tested by the community
FileSize
878 bytes

I've tested and confirmed that this patch fixes the issue above. However this is a Core issue and not a view issue.

sammys’s picture

There is a duplicate issue post over at http://drupal.org/node/370957

sriddering’s picture

I'm glad that you have found the problem and fixed it for future generations,, but exactly how would someone fix the error if they run into it now and it is causing their site to malfunction?

brianV’s picture

@sriddering,

Open includes/database.pgsql.inc, and find this around line 915:
$ret[] = update_sql("UPDATE {". $table ."} SET $field_new = ". $field ."_old");

and replace it with:

$map =  db_type_map();
$typecast = $map[$spec['type'] . ':' . $spec['size']];
$ret[] = update_sql('UPDATE {' . $table . '} SET ' . $field_new . ' = CAST(' . $field . '_old AS ' . $typecast . ')');

Make sure you back up the file before editing just in case you make a mistake and break your site.

Josh Waihi’s picture

@sriddering: untill this patch gets commited, people that use db_change_column (i think thats what its called) in such a way will lose the old data unfortunately since this isn't done in a transaction. no way to get it back :( fortunately for this context, the data isn't that important and views will still be ok nevertheless

merlinofchaos’s picture

Priority: Normal » Critical

Since this breaks the 2.2 to 2.3 upgrade for pgsql users I'm upping this to critical.

Josh Waihi’s picture

@merlinofchaos: that may explain the lack of interest :D

merlinofchaos’s picture

It may be that we need to have ti fixed for D7 and then backported, except I have no idea how different db_change_column even is in D7.

Josh Waihi’s picture

FileSize
903 bytes
merlinofchaos’s picture

Version: 6.x-dev » 7.x-dev
Josh Waihi’s picture

hmm, this maybe problematic for situations, for example, converting INT to CHAR:

psql> select CAST(57 AS CHAR);
 bpchar 
--------
 5
(1 row)

however it is how PostgreSQL deals with such a situation. I'm sure we can be any more accurate without a whole bunch of logic that says IF casting from type x to type y do this ELSE IF and so on.

webchick’s picture

Status: Reviewed & tested by the community » Needs review

Josh informed me that he hasn't run the pgsql tests to make sure this doesn't break them. Marking this down to code needs review until that happens.

Josh Waihi’s picture

FileSize
1.45 KB
Josh Waihi’s picture

better. fixed stuff. message I wrote did post before :(

webchick’s picture

Version: 7.x-dev » 6.x-dev
Status: Needs review » Patch (to be ported)

Ok, committed to HEAD. Needs porting to 6.x.

Josh Waihi’s picture

FileSize
1.13 KB
Josh Waihi’s picture

Status: Patch (to be ported) » Reviewed & tested by the community

somethings up with commenting and posting patches at the same time :(

Gábor Hojtsy’s picture

Status: Reviewed & tested by the community » Needs work

Let's not loose the code comment in Drupal 6!

Josh Waihi’s picture

@Gabor Hojtsy you mean you want comments to describe whats happening?

Gábor Hojtsy’s picture

Why is the code comment in the Drupal 7 patch would not be applicable to Drupal 6? How can you make be applicable?

Josh Waihi’s picture

Status: Needs work » Needs review
FileSize
1.39 KB

+comments

Josh Waihi’s picture

Status: Needs review » Reviewed & tested by the community
Gábor Hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

Fixed code style according to D6 standards (whitespace around concatenation), and committed this one: http://drupal.org/cvs?commit=222930 Thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.