ALTER TABLE {blocks} ADD types text

thest - April 27, 2005 - 08:05

And I've got the following problem when upgrading from 4.5.0 to 4.6.0. Update.php reported the problem:

user error: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'types text' at line 1
query: ALTER TABLE blocks ADD types text in /usr/local/www/data/ranat_tmp/includes/database.mysql.inc on line 66.
ALTER TABLE {blocks} ADD types text
FAILED

After that drupal seemed to be working. But when I entered Block menu I got errors like:

user error: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'types) VALUES ('archive', '0', 0, 0, 0, 0, '', 0, 0, '')' at li
query: INSERT INTO blocks (module, delta, status, weight, region, visibility, pages, custom, throttle, types) VALUES ('archive', '0', 0, 0, 0, 0, '', 0, 0, '') in /usr/local/www/data/ranat_tmp/includes/database.mysql.inc on line 66.

and all the block disappeared from the site. No administration menu, no menus at all. (I had backups of course). Errors apear because 'types' field was not created by update.php. I tried to add the field manualy with phpmyadmin - all the same.

So why did update.php failed to alter 'blocks' table?

Still remains

thest - April 28, 2005 - 05:15

I made a clean installation of 4.5.2 and tried to update to 4.6.0 - the same problem:

ALTER TABLE {blocks} ADD types text
FAILED

solution?

thest - April 28, 2005 - 05:34

I've fixed the problem but I'm not sure it's all right. What I did:
As update.php can't add "types" field to "blocks" table I added it manually with phpmyadmin.
When entering blocks panel I get errors for query:
INSERT INTO blocks (module, delta, status, weight, region, visibility, pages, custom, throttle, types) VALUES ('archive', '0', 0, 0, 0, 0, '', 0, 0, '')
It's because mysql considers word "types" being a special keyword. So quoted this word in /modules/block.module line 163:
INSERT INTO blocks (module, delta, status, weight, region, visibility, pages, custom, throttle, `types`) VALUES ('archive', '0', 0, 0, 0, 0, '', 0, 0, '')
And now it's working! But I'm not sure I fixed it correctly so I'm not upgradint my working site now. Have anyone seen the same?
My MySQL is 4.1.1
My PHP is 4.3.11

MySQL 4.1

clydefrog - April 28, 2005 - 05:53

This is a known issue that only affects users with MySQL versions 4.1.0 and 4.1.1 (apparently). A quick solution is to quote the field name in backquotes, as thest has done.

Thanks

thest - April 28, 2005 - 06:05

But now I see that there are a lot of other queries where "types" is not quoted. I can't be sure I fixed them all. Are developers going to fix it?

Thanks

thest - April 29, 2005 - 03:43

I can see, that the solution is to quote all "types" manualy or to upgrade MySql. I'd better prefer waiting for next Drupal release. Hope it will be soon and the problem will be fixed.

still need help...

flntobi - May 1, 2005 - 12:00

I guess I have the same problem. All my blocks are gone and my mysql table "blocks" is empty. What ist supposed to be in there? Can i fill it up manualy?

I made my Last backup before the upgrade and I don't want to upgrade again...

Thanks

To fix manually:

thest - May 3, 2005 - 05:31

1. You should add the field "types" manualy to "blocks" table. The SQL is:
ALTER TABLE `blocks` ADD `types` text;
2. Everywhere in the source where "types" field is present in SQL queries you should quote it like this: `types`. For example in /modules/block.module line 163:
INSERT INTO blocks (module, delta, status, weight, region, visibility, pages, custom, throttle, types) VALUES ('archive', '0', 0, 0, 0, 0, '', 0, 0, '')
should be:
INSERT INTO blocks (module, delta, status, weight, region, visibility, pages, custom, throttle, `types`) VALUES ('archive', '0', 0, 0, 0, 0, '', 0, 0, '')
Also in line 265
types = '%s'
replace with
`types` = '%s'
and in line 274
custom, types FROM
replace with
custom, `types` FROM
Should work now. Go to Blocks menu and turn your blocks on.
But maybe you'll have to quote "types" somewhere else.

how do i do that?

Robaco - May 22, 2005 - 03:26

how do i do that?

Changed Table

serg80 - May 4, 2005 - 23:17

I found that even after I backtic'ed all of the types fields, I continued to recieve errors. I found that I was missing a `visibility` tinyint(1) column in the database, and that the `path` column has been renamed to `pages` - I manually changed these in the database and it worked.

how you did theses changes?

Robaco - May 22, 2005 - 03:07

how you did theses changes? what files did you change? i´m freaking out

Thanks for sharing theses

jackiboa - October 17, 2009 - 03:21

Thanks for sharing
theses

 
 

Drupal is a registered trademark of Dries Buytaert.