1. added content type - let's say 'foo'
2. installed IMCE, CCK: content, IMCE image
3. tried to add field called 'image' for that type

RESULT:

* warning: pg_query() [function.pg-query]: Query failed: ERROR: adding columns with defaults is not implemented HINT: Add the column, then use ALTER TABLE SET DEFAULT. in /home/maho/workspace/top2005/includes/database.pgsql.inc on line 138.
* user warning: query: ALTER TABLE content_type_okladka ADD COLUMN field_image_imceimage_path character(255) default '' in /home/maho/workspace/top2005/includes/database.pgsql.inc on line 684.
* warning: pg_query() [function.pg-query]: Query failed: ERROR: adding columns with defaults is not implemented HINT: Add the column, then use ALTER TABLE SET DEFAULT. in /home/maho/workspace/top2005/includes/database.pgsql.inc on line 138.
* user warning: query: ALTER TABLE content_type_okladka ADD COLUMN field_image_imceimage_width int NOT NULL default '0' in /home/maho/workspace/top2005/includes/database.pgsql.inc on line 684.
* warning: pg_query() [function.pg-query]: Query failed: ERROR: adding columns with defaults is not implemented HINT: Add the column, then use ALTER TABLE SET DEFAULT. in /home/maho/workspace/top2005/includes/database.pgsql.inc on line 138.
* user warning: query: ALTER TABLE content_type_okladka ADD COLUMN field_image_imceimage_height int NOT NULL default '0' in /home/maho/workspace/top2005/includes/database.pgsql.inc on line 684.

Comments

panis’s picture

Project: Imce CCK Image » Content Construction Kit (CCK)
Component: Code » content.module

is this a CCK bug - I would think this should be handled by CCK unless there is documentation that I have not found yet disallowing use of the hook_field_settings as below. The imceimage CCK returns the following in hook_field_settings()

   case 'database columns':
                       $columns = array(
                              'imceimage_path' => array('type' => 'char', 'length' =>255, 'not null' => FALSE, 'default' => ""),
                              'imceimage_width' => array('type' => 'int', 'not null' => TRUE, 'default' => "0"),
                              'imceimage_height' => array('type' => 'int', 'not null' => TRUE, 'default' => "0"),
                              'imceimage_alt' => array('type' => 'text'));
               return $columns;
   
karens’s picture

Project: Content Construction Kit (CCK) » Imce CCK Image
Component: content.module » Code

This is not a CCK problem. IMCE Image either has not been ported to D6 or it has not been done completely yet. We now use no default values, CCK fields must allow NULL values so we can use NULL for empty values, and we use the Schema API format for column definition which does not put quotes around numbers even if they were to be used as default values, so these column definitions are not correct for the way D6 CCK works.

panis’s picture

KarenS - If this is still in your radar - are there differences in mysql and pgsql implementations somewhere that would make this code work fine on mysql but have this error in pgsql?

also notice that all the error messages suggest that pgsql does not allow adding columns with default values - and does not complain about the 'not null' specifier:

adding columns with defaults is not implemented HINT: Add the column, then use ALTER TABLE SET DEFAULT. 

thanks

crumpeta’s picture

I was having similar problems with IMCE cck on mysql. I changed hook_field_settings, 'database columns' to return:

			$columns = array(
			    'imceimage_path' => array('type' => 'char', 'length' => 255, 'not null' => FALSE),
			    'imceimage_width' => array('type' => 'int', 'not null' => FALSE),
			    'imceimage_height' => array('type' => 'int', 'not null' => FALSE),
			    'imceimage_alt' => array('type' => 'text')
			);

and this worked for me. Hope it helps someone else.

yang_yi_cn’s picture

has anybody tested the change? should I commit that code?

the_g_bomb’s picture

surely type = INT means that the default should be 0 not "0"? FALSE might also throw errors with type = INT, haven't tested but just a thought.