crashed when trying to display table contents from a SQL Server 2000 database

olliejones's profile image olliejones posted 9 years ago in General Permalink
HeidiSQL crashed when I tried to display contents from a table in a SQL Server 2000 database (yeah, I know! trying to move it into the 21st century!) and so I attach the bug report.

It's here: https://dl.dropboxusercontent.com/u/6625297/bugreport.txt

(The forum webapp refused to let me attach it, saying "Error: File #0: Invalid file format: text/x-pascal. Allowed types: jpg, png, gif, txt, html.")


Thanks for all you do!
ansgar's profile image ansgar posted 9 years ago Permalink
The relevant message from that callstack is:
Invalid object name 'sys.partitions'

The query which is not working correctly is this one:
SELECT SUM(rows) FROM sys.partitions
WHERE
index_id IN (0, 1)
AND object_id = object_id("yourdb"."yourschema"."yourtable")


I can add a version conditional for older MSSQL versions like 2000. But you will have to post a working example here, as I'm not very familiar with these old servers.
ansgar's profile image ansgar posted 9 years ago Permalink
Perhaps we can just use a
SELECT COUNT(*) FROM "yourtable"
if that's good and fast enough?
Code modification/commit from ansgarbecker, 9 years ago, revision 9.1.0.4941
Outsource RowCount into TDBObject which calls TDBConnection.GetRowCount with a server and version specific query. Introduce SELECT COUNT(*) for MSSQL 2000.
See
* http://www.heidisql.com/forum.php?t=18158
* http://www.heidisql.com/forum.php?t=15438
ansgar's profile image ansgar posted 9 years ago Permalink
Should be finally fixed in r4941, by falling back to SELECT COUNT(*) on MSSQL 2000.
olliejones's profile image olliejones posted 9 years ago Permalink
This is excellent, thanks.
[expired user #11385]'s profile image [expired user #11385] posted 6 years ago Permalink

Should be finally fixed in r4941, by falling back to SELECT COUNT(*) on MSSQL 2000.

Would it be possible to download this revision as of today?

The last available version is r5215

ansgar's profile image ansgar posted 6 years ago Permalink

Well, the code is still in the latest build, so you should be fine when using the latest update.

[expired user #11385]'s profile image [expired user #11385] posted 6 years ago Permalink

Yeah, I've tried but it doesn't work at all with SQL Server 2000.

Errors with sysobjects. I can't see the table data and schema. Queries run fine though.

[expired user #11385]'s profile image [expired user #11385] posted 6 years ago Permalink

Here is the error:

SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_CATALOG='mydb' AND TABLE_NAME='mytable';

SELECT c.name AS "column", prop.value AS "comment" FROM sys.extended_properties AS prop INNER JOIN sys.all_objects o ON prop.major_id = o.object_id INNER JOIN sys.schemas s ON o.schema_id = s.schema_id INNER JOIN sys.columns AS c ON prop.major_id = c.object_id AND prop.minor_id = c.column_id WHERE prop.name='MS_Description' AND s.name='' AND o.name='mytable';

/* SQL Error (208): Invalid object name 'sys.extended_properties'
Invalid object name 'sys.columns'. */
/* SQL Error (208): Invalid object name 'sys.extended_properties'
Invalid object name 'sys.columns'. */
ansgar's profile image ansgar posted 6 years ago Permalink

I can add a version conditional here, but I need to know the minimum version of MSSQL supporting that sys.extended_properties table. That query is used to retrieve column comments, which are not vital for the table editor - it also works without them.

ansgar's profile image ansgar posted 6 years ago Permalink

You should file an issue in the tracker.

[expired user #11385]'s profile image [expired user #11385] posted 6 years ago Permalink

I'll put it up on GitHub now.

Please login to leave a reply, or register at first.