copy code from mysqltcl-3.052