Cannot update temporary tables
Moderators: gto, cipto_kh, EgonHugeist
still buggy...
Thanks a lot for trying to debug to all guys! But sorry I have to disappoint some of you. I have applied the hack from mdaems and get another errormessage when opening a simple resultset with a ZQuery, TDataSource and a TDBGrid :
What I found curious is this:
There is a function in the ZdbResultSetMetadata which should deliver the tablename, but it doesn't.
In my case, the result of the first function is always a empty string so that I get the SCanNotUpdateThisQueryType exception . The first func calls the second one "GetTableName" and even here the property TableName of TZColumnInfo is empty. So far, so frustrating... Maybe more tomorrow evening.
hmmmm.... maybe this could have something to do with the mysql-version (5.0.18-log) as I saw a db called "INFORMATION_SCHEMA" on my localhost? I will update the mysql-server and let you know...
Maybe I'm still doing something wrong, but I don't believe so. I have tried some debugging in the ZDbcGenericResolver.pas and in ZDbcResultSetMetadata.pas but with no effort. I finally had to make a diff of the original 6.5.1 sources with those I tried to debug in order to get the originals back.SQL Error: Unknown table 'channels' in information_schema.
What I found curious is this:
There is a function in the ZdbResultSetMetadata which should deliver the tablename, but it doesn't.
Code: Select all
// In ZdbcGenericResolver (Line 253):
function TZGenericCachedResolver.DefineTableName: string;
var
I: Integer;
Temp: string;
begin
Result := '';
for I := 1 to Metadata.GetColumnCount do
begin
Temp := ComposeFullTableName(Metadata.GetCatalogName(I),
Metadata.GetSchemaName(I), Metadata.GetTableName(I));
if (Result = '') and (Temp <> '') then
Result := Temp
else if (Result <> '') and (Temp <> '') and (Temp <> Result) then
raise EZSQLException.Create(SCanNotUpdateComplexQuery);
end;
if Result = '' then
raise EZSQLException.Create(SCanNotUpdateThisQueryType);
end;
Code: Select all
// In ZDbcResultSetMetadata (Line 419):
function TZAbstractResultSetMetadata.GetTableName(Column: Integer): string;
begin
if not Loaded then LoadColumns;
Result := TZColumnInfo(FResultSet.ColumnsInfo[Column - 1]).TableName;
end;
hmmmm.... maybe this could have something to do with the mysql-version (5.0.18-log) as I saw a db called "INFORMATION_SCHEMA" on my localhost? I will update the mysql-server and let you know...
Last edited by anse123 on 03.04.2006, 22:07, edited 1 time in total.
I just found this in my mysql-query.log:
I just discovered that Zeos always uses the first database which is present for all formed updates, deletes and so on. Although the ZConnection.Database is set to the correct dbname, all queries are fired with "insert into firstdbname.correcttablename ...". strange... why does Zeos use a DBname in its statements at all? It could also rely on the ZConnection.Database property? Now I have patched the TZGenericCachedResolver.ComposeFullTableName to never use a DBname. Just commented the 4 lines 242 to 245 out.
These queries are fired by ZDbcMysqlMetadata funcs "GetTables" and "GetColumns" and I think "GetKeys". Looks like the current database was set to "information_schema", which is not what I did and this db doesn't have the table called "channels"...query.log wrote:...
78 Query SHOW TABLES FROM information_schema LIKE 'channels'
78 Query SHOW COLUMNS FROM information_schema.channels LIKE '%'
I just discovered that Zeos always uses the first database which is present for all formed updates, deletes and so on. Although the ZConnection.Database is set to the correct dbname, all queries are fired with "insert into firstdbname.correcttablename ...". strange... why does Zeos use a DBname in its statements at all? It could also rely on the ZConnection.Database property? Now I have patched the TZGenericCachedResolver.ComposeFullTableName to never use a DBname. Just commented the 4 lines 242 to 245 out.
- mdaems
- Zeos Project Manager
- Posts: 2766
- Joined: 20.09.2005, 15:28
- Location: Brussels, Belgium
- Contact:
Hi Anse,
Maybe you should check where he's changing the current database to Information_schema. Quick scanning, the code information_schema is only used in PostGresSql.My patch concerns mysql only.
If you find the solution, please send a patch to the testing SVN branch for zeoslib. So we can integrate it.
Mark
Maybe you should check where he's changing the current database to Information_schema. Quick scanning, the code information_schema is only used in PostGresSql.My patch concerns mysql only.
If you find the solution, please send a patch to the testing SVN branch for zeoslib. So we can integrate it.
Mark
ok... ist seems more simple than I thought
- My ZConnection initially has the database-property set to "Information_schema" (this is the first database on the server)
- then a ZQuery executes ('USE ' + secondDBname)
- then another ZQuery executes ('SELECT * FROM ' + tableFromSecondDB)
- here I always got the exception because Zeos always does additional queries when I execute a simple query like "select * from table". For example it wants to fetch the fieldnames and keys from the table ("show keys from db.table"). But this "db" is still set to "Information_schema".
I assume this is a bug in ZeosLib - it should recognize which DB is currently used. But I don't know if my suggestions for not using a dbname at all for the internal queries has no negative side-effects... So should I check this into CVS?
BTW: I don't see a SVN repository, only CVS .
http://sourceforge.net/svn/?group_id=35994 says: "This Project Has Turned Off SVN"
Regards,
Anse
- My ZConnection initially has the database-property set to "Information_schema" (this is the first database on the server)
- then a ZQuery executes ('USE ' + secondDBname)
- then another ZQuery executes ('SELECT * FROM ' + tableFromSecondDB)
- here I always got the exception because Zeos always does additional queries when I execute a simple query like "select * from table". For example it wants to fetch the fieldnames and keys from the table ("show keys from db.table"). But this "db" is still set to "Information_schema".
I assume this is a bug in ZeosLib - it should recognize which DB is currently used. But I don't know if my suggestions for not using a dbname at all for the internal queries has no negative side-effects... So should I check this into CVS?
BTW: I don't see a SVN repository, only CVS .
http://sourceforge.net/svn/?group_id=35994 says: "This Project Has Turned Off SVN"
Regards,
Anse
- mdaems
- Zeos Project Manager
- Posts: 2766
- Joined: 20.09.2005, 15:28
- Location: Brussels, Belgium
- Contact:
Hi Anse,
The Sourceforge CVS is not longer in use for development. For the moment we use a SVN repository (svn://www.firmos.at/zeos/).
Most recent patches can be found in the 'testing' branch. (Read more about his in other threads)
Concerning your problem : Probably it's a bug, but why don't you use the database property of the connection component? Also, did you try putting the database name in front of the table name to avoid the prefixing with the wrong database name.
Mark
The Sourceforge CVS is not longer in use for development. For the moment we use a SVN repository (svn://www.firmos.at/zeos/).
Most recent patches can be found in the 'testing' branch. (Read more about his in other threads)
Concerning your problem : Probably it's a bug, but why don't you use the database property of the connection component? Also, did you try putting the database name in front of the table name to avoid the prefixing with the wrong database name.
Mark
thanks for the reply, mdaems.
I am setting the database property before I execute the "select ...", but it doesn't seem to effect something. For the moment I have fixed the problem by commenting the 4 lines out and removing database from the internal queries (as described above).
By the way... I just released a first "HeidiSQL" version 3.0 BETA. HeidiSQL ist based on the old MySQL-Front 2.5, which is now using ZeosLib as connector! Have a look here : http://www.heidisql.com/
Regards,
Anse
I am setting the database property before I execute the "select ...", but it doesn't seem to effect something. For the moment I have fixed the problem by commenting the 4 lines out and removing database from the internal queries (as described above).
By the way... I just released a first "HeidiSQL" version 3.0 BETA. HeidiSQL ist based on the old MySQL-Front 2.5, which is now using ZeosLib as connector! Have a look here : http://www.heidisql.com/
Regards,
Anse
Yes, I am using the alpha 6.5.1 for HeidiSQL
I noticed the ZConnection-property "Catalog". What does it stand for? Is it probably the represention of the current database, which I can set and get rid of all problems I had ? I always thought I have to set the "Database"-property but now I'm not sure.
Anse
I noticed the ZConnection-property "Catalog". What does it stand for? Is it probably the represention of the current database, which I can set and get rid of all problems I had ? I always thought I have to set the "Database"-property but now I'm not sure.
Anse