6.0.0-beta1
7/13/25

[#12498] SQL Syntax error or access violation updating Horde_History DB schema
Summary SQL Syntax error or access violation updating Horde_History DB schema
Queue Horde Framework Packages
Queue Version Git master
Type Bug
State Resolved
Priority 2. Medium
Owners
Requester lp.allard.1 (at) gmail (dot) com
Created 07/25/2013 (4371 days ago)
Due
Updated 01/02/2024 (558 days ago)
Assigned 07/25/2013 (4371 days ago)
Resolved 08/02/2013 (4363 days ago)
Github Issue Link
Github Pull Request
Milestone
Patch No

History
01/02/2024 12:50:44 PM unihb (at) uni-bremen (dot) de Comment #17 Reply to this comment
Is my database structure ok?
Can someone give me the right sql command to fix the upgrade?
Moin!
I use this:

/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `horde_histories` (
   `history_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
   `object_uid` varchar(255) NOT NULL,
   `history_action` varchar(32) NOT NULL,
   `history_ts` bigint(20) NOT NULL,
   `history_desc` text DEFAULT NULL,
   `history_who` varchar(255) DEFAULT NULL,
   `history_extra` text DEFAULT NULL,
   `history_modseq` int(11) NOT NULL DEFAULT 0,
   PRIMARY KEY (`history_id`),
   KEY `history_action_idx` (`history_action`),
   KEY `history_ts_idx` (`history_ts`),
   KEY `history_uid_idx` (`object_uid`),
   KEY `index_horde_histories_on_history_modseq` (`history_modseq`),
   KEY `index_horde_histories_on_object_uid` (`object_uid`),
   KEY `history_modseq_idx` (`history_modseq`)
) ENGINE=MyISAM AUTO_INCREMENT=14715533 DEFAULT CHARSET=utf8mb3 
COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

:-)
Arnold

12/30/2023 09:37:01 PM tester (at) gmail (dot) com Comment #16
New Attachment: profile.html.html Download
Reply to this comment

[Show Quoted Text - 23 lines]
08/02/2013 09:07:04 PM Michael Rubinsky Comment #15
State ⇒ Resolved
Reply to this comment
Hopefully the last of the issues surrounding the latest History updates.
08/02/2013 09:03:54 PM Git Commit Comment #14 Reply to this comment
Changes have been made in Git (master):

commit 0e4a486e140a43a63adc9b9357b0f0c0a7d80283
Author: Michael J Rubinsky <mrubinsk@horde.org>
Date:   Fri Aug 2 17:02:31 2013 -0400

     Only remove index if we have the current index name.

     Bug: 12498

  .../History/4_horde_history_add_compositeindex.php |   14 +++++++++++-
  .../5_horde_history_remove_compositeindex.php      |   14 +++++++++++-
  .../History/6_horde_history_fix_botchedindexes.php |   21 +++++++++++++++++--
  3 files changed, 42 insertions(+), 7 deletions(-)

http://git.horde.org/horde-git/-/commit/0e4a486e140a43a63adc9b9357b0f0c0a7d80283
07/27/2013 07:06:14 PM samuel (dot) wolf (at) wolf-maschinenbau (dot) de Comment #13 Reply to this comment
Deleted I guess...
In this case you need the backup of your database.
  When you said "I use phpmyadmin to delete all indexes in the horde_histories
table except the "PRIMARY key"  this is what I did, I deleted all 
columns except the primary key.
Yes I said delete indexes *not* columns.
I do not know what is to do now.
07/27/2013 04:57:07 PM lp (dot) allard (dot) 1 (at) gmail (dot) com Comment #12 Reply to this comment
I am not sure exactly how to execute these SQL commands ..  I tried
in phpmyadmin, going into the horde_db then navigting in
horde_histories table then clicking on the SQL (Run SQL Query) and
copy paste the commands you provided, I get
Where are all your columns gone?
Deleted I guess...
  When you said "I use phpmyadmin to delete all indexes in the horde_histories
table except the "PRIMARY key"  this is what I did, I deleted all 
columns except the primary key.

I guess I confused indexes and columns...

Can I just recreate the columns and then run your commands? I am 
afraid to keep screwing around with that, since I dont know what Im 
doing...
07/27/2013 02:50:19 PM samuel (dot) wolf (at) wolf-maschinenbau (dot) de Comment #11 Reply to this comment
I am not sure exactly how to execute these SQL commands ..  I tried 
in phpmyadmin, going into the horde_db then navigting in 
horde_histories table then clicking on the SQL (Run SQL Query) and 
copy paste the commands you provided, I get
Where are all your columns gone?
07/27/2013 02:38:34 PM lp (dot) allard (dot) 1 (at) gmail (dot) com Comment #10
New Attachment: ISS8.jpeg Download
Reply to this comment

[Show Quoted Text - 24 lines]
OK Half of your procedure worked, the SQL part didnt.

I am not sure exactly how to execute these SQL commands ..  I tried in 
phpmyadmin, going into the horde_db then navigting in horde_histories 
table then clicking on the SQL (Run SQL Query) and copy paste the 
commands you provided, I get

#1064 - 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 'ALTER TABLE `hordedb`.`horde_histories` ADD INDEX 
`index_horde_histories_on_hist' at line 2

I tried one by one thinking SQL didnt like the back-to-back with 
multiple commands in the same query (I know it can do many commands in 
one query but...)

and I got:

#1072 - Key column 'history_ts' doesn't exist in table

Not sure how to push these commands in SQL.  Can you help ?
Very aprpeciated!
07/27/2013 07:41:13 AM samuel (dot) wolf (at) wolf-maschinenbau (dot) de Comment #9 Reply to this comment
OK so I am not a MySQL Guru, can someone recommend a MySQL command 
to try to fix this?
I fixed it with the following steps:
* horde-db-migrate show Horde_History schema version: 4 and the SQL error.
* comment out the up function in the following files 
(/usr/share/php/data/Horde_History/migration):
   5_horde_history_remove_compositeindex.php
   6_horde_history_fix_botchedindexes.php
* run horde-db-migrate to update to Horde_History schema version: 6
* I use phpmyadmin to delete all indexes in the horde_histories table 
except the "PRIMARY key
* at last add the indexes with the following commands
ALTER TABLE `HORDE_DB_NAME`.`horde_histories` ADD INDEX 
`index_horde_histories_on_history_action` ( `history_action` )
ALTER TABLE `HORDE_DB_NAME`.`horde_histories` ADD INDEX 
`index_horde_histories_on_history_ts` ( `history_ts` )
ALTER TABLE `HORDE_DB_NAME`.`horde_histories` ADD INDEX 
`index_horde_histories_on_history_modseq` ( `history_modseq` )
ALTER TABLE `HORDE_DB_NAME`.`horde_histories` ADD INDEX 
`index_horde_histories_on_object_uid` ( `object_uid` )

I hope this helps.

07/26/2013 08:20:19 PM lp (dot) allard (dot) 1 (at) gmail (dot) com Comment #8 Reply to this comment
I'm beginning to think that the way indexes are named has changed at 
some point in the past so that when we generate the name of the 
index to drop, it doesn't match the name it was created with in the 
past.

We probably need to catch the error and try to remove the old name 
explicitly when this happens.
OK so I am not a MySQL Guru, can someone recommend a MySQL command to 
try to fix this?

07/26/2013 04:38:59 PM Michael Rubinsky Comment #7 Reply to this comment
I'm beginning to think that the way indexes are named has changed at 
some point in the past so that when we generate the name of the index 
to drop, it doesn't match the name it was created with in the past.

We probably need to catch the error and try to remove the old name 
explicitly when this happens.
07/26/2013 03:36:23 PM samuel (dot) wolf (at) wolf-maschinenbau (dot) de Comment #6 Reply to this comment
Is my database structure ok?
Can someone give me the right sql command to fix the upgrade?

--
-- Tabellenstruktur für Tabelle `horde_histories`
--

CREATE TABLE IF NOT EXISTS `horde_histories` (
   `history_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
   `object_uid` varchar(255) NOT NULL,
   `history_action` varchar(32) NOT NULL,
   `history_ts` int(11) NOT NULL,
   `history_desc` longtext,
   `history_who` varchar(255) DEFAULT NULL,
   `history_extra` longtext,
   `history_modseq` int(11) NOT NULL DEFAULT '0',
   PRIMARY KEY (`history_id`),
   KEY `history_action_idx` (`history_action`),
   KEY `history_ts_idx` (`history_ts`),
   KEY `history_uid_idx` (`object_uid`),
   KEY `index_horde_histories_on_history_modseq_and_object_uid` 
(`history_modseq`,`object_uid`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=74754 ;
07/26/2013 02:48:39 PM samuel (dot) wolf (at) wolf-maschinenbau (dot) de Comment #5 Reply to this comment
Wher can i find the migration files? With the today update of 
Horde_History from 2.1.1 to 2.1.5 we have the very same error.
Or can i simply create a index with this name and let the schema 
upgrade remove it?
Same problem here:
Migrating to HordeHistoryRemoveCompositeIndex (5)
== 5 HordeHistoryRemoveCompositeIndex: migrating 
==============================
-- removeIndex('horde_histories', 'history_modseq')
QUERY FAILED: Can't DROP 'index_horde_histories_on_history_modseq'; 
check that column/key exists

DROP INDEX `index_horde_histories_on_history_modseq` ON `horde_histories`

07/26/2013 01:23:52 PM Michael Rubinsky Comment #4 Reply to this comment

[Show Quoted Text - 13 lines]
Sure, that's another (probably simpler) way to go.
07/26/2013 10:38:27 AM lst_hoe02 (at) kwsoft (dot) de Comment #3 Reply to this comment
My guess is that because of the confusion we created surrounding the 
upgrade of the History package you ran the migration before the 
final correct fix was in place. The migration might have succeeded 
enough to remove the index but no update the schema version.

Try migrating to version 4 and then back up to 6. If that fails, you 
can edit the migration files and comment out the 
$this->removeIndex() line in the 6 migration.
Wher can i find the migration files? With the today update of 
Horde_History from 2.1.1 to 2.1.5 we have the very same error.
Or can i simply create a index with this name and let the schema 
upgrade remove it?


07/25/2013 03:19:07 AM Michael Rubinsky Comment #2
State ⇒ Feedback
Reply to this comment
My guess is that because of the confusion we created surrounding the 
upgrade of the History package you ran the migration before the final 
correct fix was in place. The migration might have succeeded enough to 
remove the index but no update the schema version.

Try migrating to version 4 and then back up to 6. If that fails, you 
can edit the migration files and comment out the $this->removeIndex() 
line in the 6 migration.
07/25/2013 12:31:34 AM lp (dot) allard (dot) 1 (at) gmail (dot) com Comment #1
Priority ⇒ 2. Medium
State ⇒ Unconfirmed
Patch ⇒ No
Milestone ⇒
Summary ⇒ SQL Syntax error or access violation updating Horde_History DB schema
Type ⇒ Bug
Queue ⇒ Horde Framework Packages
Reply to this comment
Trying to update the Horde_History database schema after pear package 
update, the configuration page displays that the DB schema as outdated 
for Horde_History but displays the following message when trying to 
update its schema:

SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP 
'index_horde_histories_on_history_modseq'; check that column/key exists

Horde database created by H4 about a year ago, reused by H5.1.1 now.

Saved Queries