Using diagserver after upgrade

[Bug #241131] If you use diagserver after upgrading to Adaptive Server version 12.5, there may be assertion failures from the statistics code when you access sysusers, sysalternates, or syslogins. The assertion errors may also be present when you re-run installmaster as a part of the upgrade process for some of the system procedures.

If you use the dataserver binary, you might see some system stored procedures such as sp_adduser, sp_addlogin, sp_addalias, and sp_dropuser run slowly due to incorrect statistical information stored in sysstatistics on these catalogs.

Incorrect statistics are gathered on these catalogs due to the assertion failures. If you run optdiag against these catalogs after upgrade to 12.5, an error is returned:

Internal error: data length mismatch in ct_fetch().
CTLIB Message: - L4/O2/S6/N36/6/0:
ct_send(): protocol specific layer: internal Client Library 
error: There is a tds state machine error. An illegal tds token sequence was received. 
Optdiag failed. Check for error messages above.

The incorrect histogram information was saved in sysstatistics on these catalogs.

Workaround: Running update statistics does not fix this problem; use the following commands.

On the master database:

delete statistics master.dbo.syslogins
update statistics master.dbo.sysloginsdelete statistics master.dbo.sysusers
update statistics master.dbo.sysusersdelete statistics master.dbo.sysalternates
update statistics master.dbo.sysalternates

On all user databases:

delete statistics dbname.dbo.sysalternates
update statistics dbname.dbo.sysalternatesdelete statistics dbname.dbo.sysuser
update statistics dbname.dbo.sysuser