Repository navigation
Conversation
Since JSQLParser#2700, every PostgreSQL ALTER DATABASE fails to parse, while 5.4 returned an UnsupportedStatement. Model RENAME TO, OWNER TO, SET TABLESPACE, REFRESH COLLATION VERSION, the [WITH] options and SET/RESET of configuration parameters. Outside the MySQL dialect, other ALTER DATABASE forms are unsupported statements again, and ALTER SCHEMA with MySQL options no longer requires that dialect. Extract the SET/RESET state of AlterRole into ConfigurationParameterChange, which ALTER DATABASE shares; AlterRole keeps its accessors. Type each PostgreSQL CREATE DATABASE option, accept the CHAR SET and CHARSET spellings, keep CreateDatabase options in one list and drop the empty raw option that added a trailing space. Signed-off-by: minleejae <mmj9808@gmail.com>
…outine definers Model PostgreSQL ALTER FUNCTION/PROCEDURE/ROUTINE and MySQL ALTER FUNCTION/PROCEDURE as AlterRoutine with typed RoutineCharacteristic items shared by both dialects; SET/RESET reuse ConfigurationParameterChange and the MySQL COMMENT keeps its literal as a StringValue. Add PostgreSQL ALTER TRIGGER as AlterTrigger. Unmodelled forms remain unsupported statements. Keep the MySQL DEFINER of CREATE FUNCTION/PROCEDURE, accept CREATE TRIGGER IF NOT EXISTS, keep MariaDB's OR REPLACE, and capture procedural trigger bodies with the routine body boundary so the next statement is split correctly. Signed-off-by: minleejae <mmj9808@gmail.com>
With the MySQL or MariaDB dialect, parse the characteristics between the routine header and its body (COMMENT, LANGUAGE SQL, [NOT] DETERMINISTIC, the SQL data access and SQL SECURITY) into RoutineCharacteristic items with the production that ALTER FUNCTION/PROCEDURE uses. The declaration tokens are still captured and render the statement unchanged; getCharacteristics() is a read-only view of them, and the COMMENT literal is a StringValue. CHARACTER SET in a return type no longer starts the routine body. 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 #2812, which builds on #2811. Please review those first; this PR is the third commit on top of them.
Purpose
Expose the characteristics of MySQL
CREATE FUNCTIONandCREATE PROCEDURE, such asCOMMENT 'proc comment',DETERMINISTIC,READS SQL DATAorSQL SECURITY INVOKER. Today they are only loose tokens infunctionDeclarationParts:COMMENT ON FUNCTION, has to find the token and decode the MySQL escapes itself.DETERMINISTICmeans matching keywords among the routine's tokens.ALTER FUNCTION/ALTER PROCEDURE.Current design (As-is)
CreateFunctionStatement()captures everything afterFUNCTION/PROCEDUREwithcaptureFunctionBody(), a token loop thatRoutineBodyBoundarystops at the end of the routine. The tokens becomefunctionDeclarationPartsand render the statement.COMMENTliteral is kept only as written, for example'it\'s'.RoutineBodyBoundarytreats theSETof aCHARACTER SETreturn type as the start of the body.Target design (To-be)
Dialect.MYSQLorDialect.MARIADB, the capture parses the characteristics between the routine header (name, parameters andRETURNStype) and the body with Parse ALTER FUNCTION, PROCEDURE and TRIGGER actions and MySQL routine definers #2812'sMySqlRoutineCharacteristicproduction. The production now takes[NOT] DETERMINISTIC, which MySQL allows only inCREATE, soALTER FUNCTION f DETERMINISTICremains unsupported.RoutineCharacteristic.Kindvalues:DETERMINISTICandNOT_DETERMINISTIC.COMMENTis aStringValueread with the dialect's escaping (Parse ALTER FUNCTION, PROCEDURE and TRIGGER actions and MySQL routine definers #2812), sogetNotExcapedValue()is the text MySQL stores.CreateFunctionalStatement.getCharacteristics()returns them in source order. It is empty without a MySQL dialect, so PostgreSQL'sLANGUAGE sqland other dialects' options are not read as MySQL characteristics.functionDeclarationPartsis still fully populated, including the characteristic tokens:setFunctionDeclarationParts(parts)clears it; the newsetFunctionDeclarationParts(parts, characteristics)sets both; appending tokens keeps it.RoutineBodyBoundary.isBeforeBody()tells the capture where characteristics can appear.CHARACTER SETandCHAR SETin a return type no longer start the body. The routine still ends at the same token.Validation
CREATE PROCEDURE cp1() COMMENT 'proc comment' SELECT 1,CREATE FUNCTION cf1() RETURNS INT DETERMINISTIC COMMENT 'fn' RETURN 1,COMMENT 'c' LANGUAGE SQL SQL SECURITY INVOKER, andCHARSET,CHARACTER SET,COLLATEandSET(...)return types;Dialect.MYSQLandDialect.MARIADB: the characteristic kinds, the samefunctionDeclarationPartsand SQL as without a dialect, deparse, reparse and statement boundaries;COMMENTliterals ('it\'s','it''s',"dq",'a\\b', Korean text and emoji) against the text MySQL stores;ALTER ... DETERMINISTICstill unsupported.spotlessApply check: 10,575 tests, 10,550 passed, 25 skipped, zero failures/errors. The grammar choice conflict check passes.master(bdf8ac31) on the survey corpora of MySQL 8.4 and PostgreSQL 18 DDL/DCL: no regressions, and the parse results are those of Parse ALTER FUNCTION, PROCEDURE and TRIGGER actions and MySQL routine definers #2812.DETERMINISTICandNO SQLin the routine corpus, and theCOMMENT,DETERMINISTIC,LANGUAGE SQLandSQL SECURITYcomment-corpus cases.toString()on a second, identical server, in the same order. All 211 MySQL and 338 PostgreSQL statements give the same result (success, or the same error).CREATE PROCEDURE … COMMENT …andCREATE FUNCTION … DETERMINISTIC COMMENT …. Afterwards, every stored comment (MySQL table, column, index, partition, routine and event comments; PostgreSQLpg_description) is byte-identical on both servers.Integration validation
Applied this PR together with the other comment PRs (#2820, #2821, #2822, #2824), the DDL/DCL PRs #2806–#2819 and #2778 on
master(bdf8ac31), with the stacked PRs on top of their bases (#2814 → #2821, #2816 → #2822, #2806 → #2824 and #2811 → #2812 → #2823).master. Between the branches, conflicts are limited to adjacent additions (README/index rows, usage sections, imports, test methods, visitor and feature lists, an enum line and an alias guard).spotlessApply check: 11,877 tests, 11,852 passed, 25 skipped, zero failures/errors. The grammar choice conflict check passes.master: 206) and 363 of 364 PostgreSQL statements (master: 328), the same as Share MySQL account names across CREATE USER and DEFINER #2806–Render single spaces in ALTER visibility, FORCE and row level security actions #2819 together. There are no regressions.master: 67) and for 118 of 119 PostgreSQL statements (master: 76). The exception is aCREATE AGGREGATEsetup statement. Every table, column, index, partition, routine, event, user andCOMMENT ONcomment literal is aStringValue, exceptCOMMENT = _utf8mb4'x', which MySQL rejects.