-
Notifications
You must be signed in to change notification settings - Fork 390
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
Execute script #3837
Execute script #3837
Conversation
321ef01
to
310ef16
Compare
c0f7fa7
to
59f5a08
Compare
92d414b
to
7523d4c
Compare
f62aa94
to
95bbe94
Compare
Also rename IoFormat to OutputFormat
Also rename SCRIPT to NULL
This partially reverts commit fe43b9f.
This partially reverts commit bb8dd54
4f99867
to
b0000b4
Compare
This partially reverts commit 32c0d63.
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.
No obvious issues jumped out at me, so let's merge this and do post-merge review and testing.
edb/server/compiler/compiler.py
Outdated
protocol_version=ctx.protocol_version, | ||
) | ||
else: | ||
# Legacy protocol support |
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.
Drop this? We shouldn't be supporting 0.11 and below anymore.
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.
I think this is for restoring pre-0.12 dumps - I'll complete the comment here.
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.
Let's merge this.
Co-authored-by: Elvis Pranskevichus <elvis@edgedb.com>
The reason it was kept is explained in #3120, mitigated in #3814 #3837. But the core issue that compiler assumes mutation of transaction state for any compilation even by Parse message still exists. We can drop the `_last_anon_compiled` because the client bindings are no longer sending Parse + Execute for `commit` or `rollback` commands (which triggered two server compilation of the same command) like edgedb/edgedb-python#337. However, we still need to double check all bindings to make sure the transaction control commands are using only one `Execute` message.
Depends on #3814, edgedb/edgedb-python#310
stmt_mode = "all"
inEdgeConnection._compile()
and check inserver.compiler
Sample scenarios of EdgeDB
Execute
generating Postgres messages using pseudo-code:Single-command EdgeQL
EdgeDB Protocol:
Generated Postgres messages:
On protocol-level, transaction control commands like
START TRANSACTION
,COMMIT
,ROLLBACK [...]
are allowed.Multi-command EdgeQL
EdgeDB Protocol:
Generated Postgres messages:
There is only one
Sync
per EdgeDBExecute
, so it is either an atomic implicit transaction in Postgres, or a part of the outer existing transaction.On protocol-level, transaction control commands are NOT allowed.
Flush
messages may be added ifSET GLOBAL
is in the script, but that won't affect the atomicity. Only the values generated from the last command will be returned.Migration Commands
START MIGRATION ...
,COMMIT MIGRATION
andABORT MIGRATION
are allowed in scripts, but only if allSTART MIGRATION ...
have a matchingCOMMIT MIGRATION
orABORT MIGRATION
. Implementation-wise, migration commands in scripts will never open or close a database transaction or savepoint, they are always a part of the outer implicit or explicit transaction.In addition, there will be a new capability
MIGRATION_TX
, gating the ability of the migration commands to actually open or close a database transaction. The client bindings should always turn this capability off, so that the following practice is forbidden:Instead, the client could either run migration in a script:
Or use an explicit transaction to wrap the separate migration commands:
Client Bindings
Both
query()
andexecute()
will use the sameParse
/Execute
EdgeDB protocol messages, both accepting single-command and multi-command EdgeQL. The difference is,execute()
will generateParse
/Execute
messages withoutput_format=NULL
(previously known asio_format
), whilequery()
will useoutput_format=BINARY
(orJSON
for thequery_*_json()
family).Rejected Ideas
Transactional Script
EdgeDB Protocol:
Generated Postgres messages:
Returning values is NOT allowed.
Illegal Transactional Script
Statements outside transactions are not allowed:
Mismatching transaction boundaries are not allowed: