This one is easy: don't do it! If you're talking to a database, you should be using a powerful and declarative language for building your queries.
>Global state
This is a solved problem from a computer science perspective. The rest of the work is getting programmers to understand how and change their habits accordingly.
>Raising exceptions vs returning error codes
Option/Either types are a very strong middle ground. They don't require the boilerplate of checking error codes and they don't have the unpredictability of exceptions (particularly in the case of asynchronous code).
>Very often, one new solution pretends it will get rid of complexity, but the actual complexity is just moved a bit further behind the carpet.
I know what you mean. A lot of solutions end up "punting" the complexity to some other structure. The real answer (if there can be one) is to find ways to eliminate this complexity altogether. One major way to do that is to work with values and compose pure functions to build them. Pure functions dramatically improve one's ability to reason about their properties in isolation.