Repository navigation
Conversation
CREATE USER and DEFINER read user@host with their own copies of the same rule. Neither accepted app@'%' or 'app'@localhost, because the lexer reads app@ and @localhost as single tokens. Without a dialect a double-quoted part also lost its quotes, so CREATE USER "app"@"%" rendered as app@%. Add one MySqlAccountName() production that splits those tokens, keep the quote character of double-quoted and backquoted parts apart from their value, and use it for CREATE USER and DEFINER. Signed-off-by: minleejae <mmj9808@gmail.com>
DROP PROCEDURE p(int) lost its signature, DROP FUNCTION accepted only one signature, and owner tables, CASCADE/RESTRICT and the roles of DROP OWNED BY were kept as raw parameter tokens. Model routine targets as RoutineReference, role and account targets as UserAccount read with MySqlAccountName(), the ON table of DROP TRIGGER/RULE in the existing owner field and CASCADE/RESTRICT as CascadeBehavior. Keep getNames(), getTypeToParameters(), getParamsByType() and getParameters() as derived values. Parse DROP TYPE, DOMAIN, EVENT, EVENT TRIGGER, [UNDO] TABLESPACE ... ENGINE, USER, GROUP, MySQL account names in DROP USER/ROLE, DROP DATABASE ... WITH (FORCE) and PostgreSQL REASSIGN OWNED. Signed-off-by: minleejae <mmj9808@gmail.com>
This was referenced Oct 14, 2026
This branch has not been deployed
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.
Builds on #2806, which shares MySQL account-name parsing (
MySqlAccountName()); please review that first.Purpose
Keep every part of a DROP statement in the AST and in the rendered SQL. Today
DROP PROCEDURE p(int)silently loses(int)in both, so overloaded PostgreSQL procedures cannot be told apart, and several common DROP forms fail to parse:DROP FUNCTION f(int), g(text),DROP TYPE,DROP DOMAIN,DROP EVENT TRIGGER,DROP TABLESPACE,DROP USER,DROP GROUP,DROP DATABASE … WITH (FORCE)andREASSIGN OWNED.DROP EVENT,DROP [UNDO] TABLESPACE … [ENGINE [=] e],DROP USER 'app'@'%'andDROP ROLE 'r'@'h'.Current design (As-is)
DROP FUNCTIONkeeps a signature: one list of argument strings ingetTypeToParameters(), written after the last name. Other routine kinds parse the argument list and discard it.getParameters(), except the owner table ofDROP INDEX … ON t:DROP TRIGGER trg ON users CASCADEgives[ON, users, CASCADE];DROP OWNED BY old_role CASCADEgives the nameBYand the parameters[old_role, CASCADE].'r'@'h'cannot be parsed.Target design (To-be)
RoutineReferenceitems ingetRoutines(), the model that GRANT and COMMENT use. The grammar reuses the sharedRoutineReference()production:VARIADIC, array and multi-word types;*andORDER BYare kept;DROP AGGREGATErequires a signature;FuncArgsListproductions are removed.DROP OWNED BYareUserAccountitems ingetAccounts():MySqlAccountName()from Share MySQL account names across CREATE USER and DEFINER #2806, so DROP accepts the same MySQL spellings as CREATE USER, such asapp@'%'and'app'@localhost;"Admin"round-trips, withAdminingetValue()and"ingetQuoteStr().DROP TRIGGER t ON tblandDROP RULE r ON tblstoretblin the existinggetTable()owner field, likeDROP INDEX … ON. Table discovery reports it. SQL Server'sON DATABASEandON ALL SERVERtrigger scopes stay parameters.CascadeBehavior(Consolidate CASCADE/RESTRICT enums (breaking API change) #2745) ingetBehavior(). It is accepted once, as the last clause.DROP TYPE,DOMAIN,EVENT,EVENT TRIGGER,TABLESPACE,USERandGROUPare accepted.ObjectTypegainsAGGREGATE,DOMAIN,EVENT_TRIGGER,GROUP,OWNED,ROLE,ROUTINE,RULE,TYPEandUSER.DROP UNDO TABLESPACEandENGINE [=] name:isUndo(),getEngine()andisEngineUseEquals();DROP DATABASE … [WITH] (FORCE):isForce(). The optional WITH is always rendered.REASSIGN OWNED BY r [, …] TO ris a newReassignOwnedstatement:UserAccountproduction asDROP OWNED BY;REASSIGNis a new non-reserved token, since a statement that starts with a plain identifier creates choice conflicts;StatementDeParser,TablesNamesFinder,StatementVisitorAdapterand statement features (MODIFIES_SCHEMA);Feature.reassignOwned, enabled for PostgreSQL.getName()andgetNames()return read-only snapshots of routine and account names;getTypeToParameters()andgetParamsByType()return a read-only map with the last routine's argument declarations, where the legacy single-signature form kept them. The map now also covers PROCEDURE, ROUTINE and AGGREGATE, and lower-casedrop functionno longer loses its arguments;getParameters()is a snapshot that includes ON with the owner table and the CASCADE/RESTRICT keyword;setParameters()replaces the whole clause with raw tokens and clears both;addParameters()keeps them. Raw tokens are never parsed;setTypeToParameters()first convert routine and account targets to the legacy names and single signature. For example,setName()onDROP FUNCTION f(int)still rendersDROP FUNCTION g(int).getTypeToParameters()of a parsed routine DROP now throwsUnsupportedOperationException.addParameters("CASCADE")render the same SQL, but their object tree differs from a parsed statement. Two existingDropTestcomparisons now usewithBehavior().DROP TABLE t(int)) and tokens after CASCADE/RESTRICT are rejected. Before, they were silently dropped or kept as raw tokens.usage.rstdocuments the model and migration. README and index listDROP OWNED/REASSIGN OWNED.DROP INDEX … ALGORITHM/LOCKhandling is unchanged.Validation
DropRoutineSignatureTest,DropObjectTypeTest,DropRoleTestandDropValidatorTestcover:StatementDeParseroutput withDialect.MYSQL/POSTGRESQL;spotlessApply check: 10,457 tests, 10,432 passed, 25 skipped, zero failures/errors. Grammar, Checkstyle, PMD, SpotBugs and coverage checks pass.master(bdf8ac31) on a corpus of 635 MySQL 8.4 and PostgreSQL 18 DDL/DCL statements, each accepted by the server, plus variants:DROP TRIGGER … ON users CASCADEandDROP RULE r1 ON v(owner table), and twoDROP OWNED BYforms (roles instead of the nameBY).DROP PROCEDURE p1(int)renders its signature again.routines,accounts,table,behaviorandobjectTypefields.toString()on a second, identical server, in the same order. All 209 MySQL and 336 PostgreSQL statements give the same result (success, or the same error).Integration validation
Applied #2806–#2819 together on
master(bdf8ac31), with the stacked PRs on top of their bases (#2806 → #2807 → #2808, #2806 → #2809 → #2810 and #2811 → #2812).master. Between the branches, conflicts are limited to adjacent additions (README/index rows, usage sections, imports, visitor and feature lists, one enum line and one alias guard).spotlessApply check: 11,494 tests, 11,469 passed, 25 skipped, zero failures/errors. The grammar choice conflict check passes.master: 206) and 363 of 364 PostgreSQL statements (master: 328). Every MySQL 8.4 non-reserved word and PostgreSQL 18 unreserved or column-name keyword parses as a column and table name.