<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://g1r-mp.com/wiki/index.php?action=history&amp;feed=atom&amp;title=DbGetConnectionState</id>
	<title>DbGetConnectionState - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://g1r-mp.com/wiki/index.php?action=history&amp;feed=atom&amp;title=DbGetConnectionState"/>
	<link rel="alternate" type="text/html" href="https://g1r-mp.com/wiki/index.php?title=DbGetConnectionState&amp;action=history"/>
	<updated>2026-09-19T13:10:25Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.46.0</generator>
	<entry>
		<id>https://g1r-mp.com/wiki/index.php?title=DbGetConnectionState&amp;diff=891&amp;oldid=prev</id>
		<title>QCherry: Document upcoming 0.1.4 database recovery; organize wiki navigation</title>
		<link rel="alternate" type="text/html" href="https://g1r-mp.com/wiki/index.php?title=DbGetConnectionState&amp;diff=891&amp;oldid=prev"/>
		<updated>2026-09-19T10:51:44Z</updated>

		<summary type="html">&lt;p&gt;Document upcoming 0.1.4 database recovery; organize wiki navigation&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= dbGetConnectionState =&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Available since 0.1.4 (in development; not present in public 0.1.3). Server-side only.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
== Syntax ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
table|false dbGetConnectionState(DatabaseConnection connection)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Returns false for an unknown or foreign handle; otherwise returns a snapshot:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Field !! Meaning&lt;br /&gt;
|-&lt;br /&gt;
| state || connected, reconnecting, disconnected, transaction_lost, or closing while shutdown is pending.&lt;br /&gt;
|-&lt;br /&gt;
| generation || Starts at 1 after initial connection; increments after each successful replacement session.&lt;br /&gt;
|-&lt;br /&gt;
| errorCode || Last state error code, or 0 after successful connection.&lt;br /&gt;
|-&lt;br /&gt;
| errorMessage || Last state error description, or an empty string after successful connection.&lt;br /&gt;
|-&lt;br /&gt;
| autoreconnect || Whether automatic recovery was enabled in dbConnect.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This is a cached worker-observed state, not a blocking ping. It may still say connected until the next query or idle health check observes a failure. transaction_lost also covers conservative session-loss fencing after a failed control/unknown statement; do not infer that COMMIT rolled back.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local status = dbGetConnectionState(db)&lt;br /&gt;
if status then&lt;br /&gt;
    outputDebugString(status.state .. &amp;quot; / generation &amp;quot; .. status.generation)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
See [[MySQL connection recovery]], [[dbReconnect]] and [[onDatabaseConnectionStateChange]].&lt;br /&gt;
[[Category:Lua Functions]]&lt;br /&gt;
[[Category:Server Functions]]&lt;br /&gt;
[[Category:Database Functions]]&lt;/div&gt;</summary>
		<author><name>QCherry</name></author>
	</entry>
</feed>