fix(plugins): address routines and triggers the way the engine spells them, and copy a table's sequences - #2568
Merged
Conversation
… them, and copy a table's sequences
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #2567. Two defects the copy feature exposed, both of which also affect released features.
A routine and a trigger are not addressed by name alone
SourceObjectSyncBuilderwrote every drop asDROP <keyword> schema.name. That is wrong on two counts, and both reach Compare & Sync, not just Copy To:f(integer)andf(text)in one schema, soDROP FUNCTION public.fis ambiguous and the server refuses it.DROP TRIGGER name ON table. Without theON, every trigger drop failed.MySQL is the opposite on both: it rejects the argument list and takes no
ON. Only the driver knows which, sogenerateDropRoutineSQL(name:signature:schema:isFunction:)joins the existinggenerateDropTriggerSQLinPluginDatabaseDriver, with anildefault meaning "the caller's own qualified name is right for this engine". PostgreSQL implements it; every other driver inherits the old behaviour unchanged.ObjectCopyPlanneralso had to pass the trigger's owning table through, which it now does in the signature slottriggerReadsalready uses.A copied table's default names a sequence that was never copied
PostgreSQL reports a
SERIALcolumn asinteger ... DEFAULT nextval('orders_id_seq'::regclass)and the driver keeps that text verbatim, so a copied table'sCREATEeither fails outright or, where the source's own sequence happens to be reachable, succeeds and leaves the copy handing out the original's keys.fetchDependentSequencesalready existed and nothing called it.ObjectCopyPlannernow reads it for every table whose structure it writes and puts the result in a newObjectCopyTableStep.sequenceStatements, which runs after the drop and before the create. A sequence several tables default from is created once, under the first of them in dependency order.The driver's own DDL had a bug of its own here: the
setvalline spelled the schema it was read from while theCREATE SEQUENCEbeside it was schema-relative. Run against another schema it repositioned the original sequence; against another database it named one that was not there. It is now unqualified, so the pair agrees. That fixes SQL export and the structure editor's DDL tab as well.Verification
verify.sh buildPASS,verify.sh testPASS (23 cases across the three suites),verify.sh lint0 violationsverify.sh abi origin/main: two added lines, no removals, and the new requirement carries a default. Additive, so nocurrentPluginKitVersionbump and no plugin re-release.verify.sh build PostgreSQLDriverPASS.verify.sh pluginsfails locally on the oracle-nio fork's@TaskLocalmacro, which is a known local-toolchain failure unrelated to this branch; CI compiles the aggregate.New tests:
SourceObjectSyncBuilderTestscovers both dialect drops and the unchanged fallback for an engine that implements neither, andObjectCopySequenceStatementTestscovers the split, the termination and the ordering against the create.