We need to key off prefixes, since I assume difference prefixes signal different schema.
For sanity I think we want separate validation procedures for each prefix, including the no-prefix case. We also want an option to skip validation for maintenance and highest performance purposes.
Do we want to store the code in the database?
I don't think that'll be complicated or difficult, but executing code from an outside source is dangerous if the source is not properly protected, if so, warnings must be put in the SRFI(s). But such "stored procedures" would make the validation ironclad, which is how the higher end RDBMS inspiration for this works, and would make it much simpler for non-Data Base Administrators (DBAs), all they'd need to know is that they might get validation errors, and how to skip validation. This being Scheme, I don't think we need to make validation required and locked down except for DBAs.
If stored, we'll need to define a reserved prefix to store it under, like "VALIDATE_XYZZY_" or something even more random.
Or more general, this should also allow for the generic stored procedure concept where behavior is delegated to "the database". We always need to be careful about being too prescriptive in use cases, users will find unanticipated ways to use functionality, and this is a particularly obvious example. At some sites, DBA maintained stored procedures are the only way to access the database.
That also strongly suggests adding an "execute stored procedure" procedure to the SRFI-167 API.
Ah, one wrinkle in storing is Scheme implementations that require a C compilation step for highest performance, when it's not possible to store and then load upon okvs-open object code. But the code could also be stored in an object file to be linked by everybody for the final binary, the API will need to be conceptually general to accommodate a variety of implementation methods.
Anyway, those are my half-awake thoughts as of now.
- Harold