[odb-users] arbitrary query returning tuples
Патрушев Данил Андреевич
d.patrushev at prosoftsystems.ru
Wed Dec 13 03:55:09 EST 2023
Hello. The doc says:
To support these kinds of use cases, ODB allows us to specify the complete query for a native view at runtime rather than at the view definition.
To indicate that a native view has a runtime query, we can either specify the empty db query pragma or omit the pragma altogether. For example:
#pragma db view
struct sequence_value
{
unsigned long long value;
};
The library in question is libodb-pgqsl.
I used to leverage this feature for complex SELECT's that would otherwise be impossible to execute using "normal" odb mechanisms. I figured that
this kind of view allowed you to run arbitrary queries returning tuples, but it turns out I was wrong. I found out that it is impossible to run a query,
which, for example starts with "INSERT...". I spent some time digging in the sources and realized libodb-pgsql does some preprocessing even for
this kind of super low-level view, adding "WHERE" if the text of the query doesn't meet certain criteria, which results in invalid SQL. That was news to me. So, the question is: is that a feature?
If it is, is there still a way to execute an arbitrary query returning tuples (for any database backend, not just libodb-pgsql)?
More information about the odb-users
mailing list