]> git.ipfire.org Git - thirdparty/asterisk.git/commit
res_config_odbc: Prevent Realtime fallback on record-not-found (SQL_NO_DATA)
authorAlexei Gradinari <alex2grad@gmail.com>
Tue, 15 Jul 2025 21:56:39 +0000 (17:56 -0400)
committerGeorge Joseph <gjoseph@sangoma.com>
Wed, 17 Sep 2025 17:40:37 +0000 (11:40 -0600)
commit5bdc661745c20b045903e1fc56acd37c5277e760
treea55919edf606adae42409da8f1fca28726a86bca
parent21881d576dd668aeaa7e8950f70f4b9a1c44482c
res_config_odbc: Prevent Realtime fallback on record-not-found (SQL_NO_DATA)

This patch fixes an issue in the ODBC Realtime engine where Asterisk incorrectly
falls back to the next configured backend when the current one returns
SQL_NO_DATA (i.e., no record found).
This is a logical error and performance risk in multi-backend configurations.

Solution:
Introduced CONFIG_RT_NOT_FOUND ((void *)-1) as a special return marker.
ODBC Realtime backend now return CONFIG_RT_NOT_FOUND when no data is found.
Core engine stops iterating on this marker, avoiding unnecessary fallback.

Notes:
Other Realtime backends (PostgreSQL, LDAP, etc.) can be updated similarly.
This patch only covers ODBC.

Fixes: #1305
(cherry picked from commit dfe25fbc8a11c99980bdaf8d9a3960643fad7768)
include/asterisk/config.h
main/config.c
res/res_config_odbc.c