Bug 421

Summary: mythfilldatabase fails with SQL error
Product: Fedora Reporter: Rodd Clarkson <rodd>
Component: mythtvAssignee: Jarod Wilson <jarod>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P5    
Version: 14   
Hardware: All   
OS: GNU/Linux   
namespace:

Description Rodd Clarkson 2009-03-08 05:23:18 CET
running mythfilldatabase results in the following output.

I've even tried dropping the database and recreating it with:

create database mythconverg default character set utf8;

but it still tries running the alter statement below which fails.

I'm all up to date with both rawhide and rpmfusion, but here's some mythtv and mysql versions.

bash-4.0$ rpm -qa mythtv\*
mythtv-backend-0.22-0.1.svn.r19722.fc11.i386
mythtv-setup-0.22-0.1.svn.r19722.fc11.i386
mythtv-common-0.22-0.1.svn.r19722.fc11.i386
mythtv-base-themes-0.22-0.1.svn.r19722.fc11.i386
mythtv-frontend-0.22-0.1.svn.r19722.fc11.i386
bash-4.0$ rpm -qa mysql\*
mysql-libs-5.1.32-1.fc11.i586
mysql-5.1.32-1.fc11.i586
mysql-server-5.1.32-1.fc11.i586


bash-4.0$ mythfilldatabase 
2009-03-07 18:28:02.498 Using runtime prefix = /usr
2009-03-07 18:28:02.498 Unable to read configuration file mysql.txt
2009-03-07 18:28:02.498 Empty LocalHostName.
2009-03-07 18:28:02.499 Using localhost value of mythtv.localdomain
2009-03-07 18:28:02.505 New DB connection, total: 1
2009-03-07 18:28:02.508 Connected to database 'mythconverg' at host: localhost
2009-03-07 18:28:02.508 Closing DB connection named 'DBManager0'
2009-03-07 18:28:02.509 Connected to database 'mythconverg' at host: localhost
2009-03-07 18:28:02.510 DataDirectProcessor::FixProgramIDs() -- begin
2009-03-07 18:28:02.511 New DB DataDirect connection
2009-03-07 18:28:02.512 Connected to database 'mythconverg' at host: localhost
2009-03-07 18:28:02.513 DataDirectProcessor::FixProgramIDs() -- end
2009-03-07 18:28:02.514 No current database version?
2009-03-07 18:28:02.515 Database appears to be empty/new!
2009-03-07 18:28:02.515 Database schema is old. Waiting to see if DB is being upgraded.
2009-03-07 18:28:03.515 New DB connection, total: 2
2009-03-07 18:28:03.516 Connected to database 'mythconverg' at host: localhost
2009-03-07 18:28:03.532 No current database version?
2009-03-07 18:28:03.533 Database appears to be empty/new!
2009-03-07 18:28:04.536 No current database version?
2009-03-07 18:28:04.536 Database appears to be empty/new!
2009-03-07 18:28:05.539 No current database version?
2009-03-07 18:28:05.540 Database appears to be empty/new!
2009-03-07 18:28:06.542 No current database version?
2009-03-07 18:28:06.543 Database appears to be empty/new!
2009-03-07 18:28:07.545 No current database version?
2009-03-07 18:28:07.546 Database appears to be empty/new!
2009-03-07 18:28:07.546 Timed out waiting.
2009-03-07 18:28:07.546 The database seems to be empty - not attempting a backup
2009-03-07 18:28:07.567 Newest Schema Version : 1228
2009-03-07 18:28:07.569 Inserting MythTV initial database information.
2009-03-07 18:28:07.569 New DB connection, total: 3
2009-03-07 18:28:07.570 Connected to database 'mythconverg' at host: localhost
2009-03-07 18:28:07.570 Upgrading to schema version 1226
2009-03-07 18:28:07.571 DB Error (Performing database upgrade): 
Query was: ALTER DATABASE mythconverg DEFAULT CHARACTER SET utf8; 
Error was: Driver error was [2/1295]:
QMYSQL3: Unable to prepare statement
Database error was:
This command is not supported in the prepared statement protocol yet
 
new version: 1226
2009-03-07 18:28:07.571 Database Schema upgrade FAILED, unlocking.
2009-03-07 18:28:07.571 Incorrect database schema
2009-03-07 18:28:07.572 DataDirect: Deleting temporary files
bash-4.0$
Comment 1 Jarod Wilson 2009-03-08 05:30:54 CET
Yeah, just hit this one myself Thursday or Friday, looking into it...
Comment 2 Rodd Clarkson 2009-03-10 07:27:10 CET
I did a little more digging and it's apparently a combination of creating a new database (it won't happen if you already have a database), mysql-5.1.x, qt-4.4.x and mythtv-0.22.x.

The key is this part:

> Database error was:
> This command is not supported in the prepared statement protocol yet

Apparently, mythtv never uses prepared statements (although is does ask for the ALTER DATABASE, but not in any 'prepared statement' sense) and something (probably qt, but not confirmed) is middle managing the sql requests and trying to use a prepared statement instead.

j-rod (maybe j-rod and jarod have something in common) at mythtv is apparently trying to figure this out.

We should keep this bug open until it's been fixed up stream, and it may be that there's a bug to track upstream, but I'm not sure what, and whether bugzilla can do that.
Comment 3 Jarod Wilson 2009-03-10 17:44:17 CET
(In reply to comment #2)
> I did a little more digging and it's apparently a combination of creating a new
> database (it won't happen if you already have a database), mysql-5.1.x,
> qt-4.4.x and mythtv-0.22.x.
> 
> The key is this part:
> 
> > Database error was:
> > This command is not supported in the prepared statement protocol yet

Yep, I know. :)

> j-rod (maybe j-rod and jarod have something in common) at mythtv is apparently
> trying to figure this out.

He is I and I am him.

> We should keep this bug open until it's been fixed up stream, and it may be
> that there's a bug to track upstream, but I'm not sure what, and whether
> bugzilla can do that.

Yeah, I'm working on it w/some other mythtv folks, we'll track down who the bug actually belongs to and get it fixed for everyone.
Comment 4 Rodd Clarkson 2009-03-11 10:50:11 CET
jarod (errr, j-rod), it's nice to know someone is looking into this and I wish you all the best.

Is there anyway I can get a skeleton database to use so that I (and others) can work around this until it's resolved?
Comment 5 Jarod Wilson 2009-03-11 15:29:05 CET
(In reply to comment #4)
> jarod (errr, j-rod), it's nice to know someone is looking into this and I wish
> you all the best.

We're onto something -- it seems its actually a bug in qt 4.5.0, not in mythtv. qt's mysql bindings in 4.5.0 are trying to run every single query as a prepared statement when many are destined to fail, per http://dev.mysql.com/doc/refman/5.1/en/c-api-prepared-statements.html, which lists what types of queries are actually supported as prepared statements (note the lack of 'alter database ...'). Mike Dean has a patch for qt that would sort of brute-force around it, but is going to file a ticket upstream, where they might hopefully come up with a better patch.

> Is there anyway I can get a skeleton database to use so that I (and others) can
> work around this until it's resolved?

Yeah, there are a few ways you could go about getting a db... Could maybe take an F10 install and do the initial database population there, then move it to rawhide, or comb through mythtv/libs/libmythtv/dbcheck.cpp, scraping out all the sql statements, dropping them into a .sql file and importing them that way. Both would likely require some slight munging to get variable parts of the data correct (which mythtv normally does for you). With luck, we'll have a fix sooner than later though.
Comment 6 Jarod Wilson 2009-03-12 16:43:08 CET
Upstream bug filed here:
http://www.qtsoftware.com/developer/task-tracker/index_html?method=entry&id=248078

However, a work-around has also been committed to mythtv. I'll try to get a new build together later today...
Comment 7 Jarod Wilson 2009-03-12 20:15:05 CET
New build w/the work-around in-progress:

http://buildsys.rpmfusion.org/build-status/job.psp?uid=3008
Comment 8 Jarod Wilson 2009-03-12 21:26:11 CET
Nggh. Build failed for reasons that are non-reproduceable building locally on an x86_64 rawhide box (at least outside of mock, still need to try inside mock).
Comment 9 Rodd Clarkson 2009-03-26 06:51:51 CET
Any luck with the build.  I'm guessing no at this stage, but I thought I'd check in since it's been a while.
Comment 10 Jarod Wilson 2009-03-31 23:57:59 CEST
Finally had a build actually finish today, woo!
Comment 11 Jarod Wilson 2009-04-13 22:24:24 CEST
This works for me now, clean rawhide install + mythtv-0.22-0.2.svn.r20293.fc11