FEAT: Adding getDecimalSeperator and setDecimalSeperator as global functions by jahnvi480 · Pull Request #188 · microsoft/mssql-python

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Global state in multi-threaded environment

The current implementation uses global state (g_decimalSeparator) without considering thread safety. Given that this library is likely to be used in multi-threaded applications (web servers, concurrent data processing), this could lead to:

Data corruption: Concurrent string operations on g_decimalSeparator
Inconsistent behavior: Different threads seeing different separator values
Race conditions: Database operations using incorrect separators
Suggested Solutions:

Use std::atomicstd::string for the global variable
Add mutex protection around read/write operations
Consider thread-local storage for separator configuration
Encapsulate separator in a thread-safe configuration object/context