First there is no database that is accessible to law enforcement of people who voluntarily go to rehab. You may remember (or may not because you were stoned) reading HIPAA Rights notifications when you checked in. That federal law would make such a database illegal.

Second, unless the gunshop where you purchased your gun has closed the ATF does NOT have you in a database of gun owners. The 4473 is sitting in the files of the dealer that sold you the gun.

Finally, lots of people do drugs and own guns and never have the guns anywhere near the drugs.