-
Notifications
You must be signed in to change notification settings - Fork 407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove multiplicity from QueryUnit.sql
#7985
Conversation
Currently, `QueryUnit.sql` is a tuple representing, possibly, multiple SQL statements corresponding to the original EdgeQL statement. This introduces significant complexity to consumers of `QueryUnit`, which are mostly unprepared to handle more than one SQL statement anyway. Originally the SQL tuple was used to represent multiple EdgeQL statements, a task which is now handled by the `QueryUnitGroup` stuff. Another use case are the non-transactional commands (`CREATE BRANCH` and friends). Finally, since this facility was available, more uses of it were added without actually _needing_ be executed as multiple SQL statements with no other recourse: those are mostly maintenance commands and the DDL type_id readback. I think the above uses are no longer a sufficient reason to keep the tuple complexity and so I'm ripping it out here, making `QueryUnit.sql` a `bytes` property with the invariant of _always_ containing exactly one SQL statement and thus not needing any special handling. The users are fixed up as follows: - Non-transactional branch units encode the extra SQL needed to represent them in the new `QueryUnit.db_op_trailer` property which is a tuple of SQL. Branch commands have special handling for them already, so this is not a nuisance. - The newly-added type id mappings produced by DDL commands are now communicated via the new "indirect return" mechanism, whereby a DDL PLBlock can communicate a return value via a specially-formatted `NoticeResponse` message. - All other unwitting users of multi-statement `QueryUnit` are converted to use a single statement instead (primarily by converting them to use a `DO` block).
ebfb72a
to
c6a7040
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a little unclear to me that this is actually simpler, since pulling results out via NOTICE feels wildly janky. I guess it won't feel as janky the next time we have to do it, for better or worse.
"statements": [{"text": stmt} for stmt in self.statements], | ||
"confidence": self.confidence, | ||
"prompt": self.prompt, | ||
"prompt_id": self.prompt_id, | ||
"data_safe": self.data_safe, | ||
"required_user_input": list(self.required_user_input), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's probably not worth undoing but all these automated changes make this diff pointlessly noisy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how this happened, I don't have format-on-save enabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You clearly have something enabled, plenty of changes here just change '
to "
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Must have pressed a "format file" shortcut or something. It's just this file.
Yeah, it does seem like it at first, but the mechanism is reliable. There are more cleanups to be realized from the single-statement invariant of |
Currently,
QueryUnit.sql
is a tuple representing, possibly, multipleSQL statements corresponding to the original EdgeQL statement. This
introduces significant complexity to consumers of
QueryUnit
, which aremostly unprepared to handle more than one SQL statement anyway.
Originally the SQL tuple was used to represent multiple EdgeQL statements,
a task which is now handled by the
QueryUnitGroup
stuff. Another usecase are the non-transactional commands (
CREATE BRANCH
and friends).Finally, since this facility was available, more uses of it were added
without actually needing be executed as multiple SQL statements
with no other recourse: those are mostly maintenance commands and the
DDL type_id readback.
I think the above uses are no longer a sufficient reason to keep the
tuple complexity and so I'm ripping it out here, making
QueryUnit.sql
a
bytes
property with the invariant of always containing exactly oneSQL statement and thus not needing any special handling. The users are
fixed up as follows:
Non-transactional branch units encode the extra SQL needed to
represent them in the new
QueryUnit.db_op_trailer
property which isa tuple of SQL. Branch commands have special handling for them
already, so this is not a nuisance.
The newly-added type id mappings produced by DDL commands are now
communicated via the new "indirect return" mechanism, whereby a DDL
PLBlock can communicate a return value via a specially-formatted
NoticeResponse
message.All other unwitting users of multi-statement
QueryUnit
are convertedto use a single statement instead (primarily by converting them to use a
DO
block).