Hi there,
In some situations it would come in handy if there was also a numeric error code from the DB layer.
What I mean is an additional property of Exception_frame like .err, .errno or alike, which receives the numeric error code from the driver API in case of an exception.
For example a in my code I'm using:
// If there are many asynchronous inserts, we might hit a deadlock if (retries < 2 && strncmp(Exception_frame.message, "Deadlock found when trying to get lock; try restarting transaction", 67) == 0) { retries++; _usleep(100000); goto redo; }
This is kind of ugly...
It would be better to do something like
if (retries < 2 && Exception_frame.errno == ER_LOCK_DEADLOCK) { ... }
Cheers, Till
Not a bad idea. This should be fairly easy to do as we already keep track of the lastError (status) of every statement executed against the database. Instead of inventing new generic error codes, I will just use the one by the database itself. E.g. SQLITE_LOCKED, CR_CONNECTION_ERROR (MySQL), PGRES_BAD_RESPONSE (PostgreSQL), OCI_ERROR (Oracle) etc. All these database error codes are integers. I’ll put it on my TODO list.
Best regards
On 22 Jul 2025, at 17:39, g4-lisz@tonarchiv.ch wrote:
Hi there,
In some situations it would come in handy if there was also a numeric error code from the DB layer.
What I mean is an additional property of Exception_frame like .err, .errno or alike, which receives the numeric error code from the driver API in case of an exception.
For example a in my code I'm using:
// If there are many asynchronous inserts, we might hit a deadlock if (retries < 2 && strncmp(Exception_frame.message, "Deadlock found when trying to get lock; try restarting transaction", 67) == 0) { retries++; _usleep(100000); goto redo; }
This is kind of ugly...
It would be better to do something like
if (retries < 2 && Exception_frame.errno == ER_LOCK_DEADLOCK) { ... }
Cheers, Till
Hi Jan-Henrik
Glad you like the plan idea!
Cheers, Till
July 24, 2025 4:04 AM, "Jan-Henrik Haukeland" hauk@tildeslash.com wrote:
Not a bad idea. This should be fairly easy to do as we already keep track of the lastError (status) of every statement executed against the database. Instead of inventing new generic error codes, I will just use the one by the database itself. E.g. SQLITE_LOCKED, CR_CONNECTION_ERROR (MySQL), PGRES_BAD_RESPONSE (PostgreSQL), OCI_ERROR (Oracle) etc. All these database error codes are integers. I’ll put it on my TODO list.
Best regards
On 22 Jul 2025, at 17:39, g4-lisz@tonarchiv.ch wrote:
Hi there,
In some situations it would come in handy if there was also a numeric error code from the DB layer.
What I mean is an additional property of Exception_frame like .err, .errno or alike, which receives the numeric error code from the driver API in case of an exception.
For example a in my code I'm using:
// If there are many asynchronous inserts, we might hit a deadlock if (retries < 2 && strncmp(Exception_frame.message, "Deadlock found when trying to get lock; try restarting transaction", 67) == 0) { retries++; _usleep(100000); goto redo; }
This is kind of ugly...
It would be better to do something like
if (retries < 2 && Exception_frame.errno == ER_LOCK_DEADLOCK) { ... }
Cheers, Till