Skip to content

Add BACKUP/RESTORE key statement parsing support#50

Merged
kyleconroy merged 25 commits intomainfrom
claude/fix-tests-iteratively-mPPkb
Dec 31, 2025
Merged

Add BACKUP/RESTORE key statement parsing support#50
kyleconroy merged 25 commits intomainfrom
claude/fix-tests-iteratively-mPPkb

Conversation

@kyleconroy
Copy link
Copy Markdown
Collaborator

No description provided.

- Add BackupTransactionLogStatement AST type
- Update parseBackupStatement to handle both BACKUP DATABASE and BACKUP LOG
- Fix DeviceInfo.PhysicalDevice to be ScalarExpression instead of IdentifierOrValueExpression
- Update parseRestoreStatement to make FROM clause optional
- Change RESTORE LOG kind from "Log" to "TransactionLog" to match expected output
- Add JSON marshaling for BackupTransactionLogStatement
- Add CreateTypeUddtStatement for CREATE TYPE ... FROM syntax
- Add CreateTypeUdtStatement for CREATE TYPE ... EXTERNAL NAME syntax
- Update parseCreateTypeStatement to handle both variants
- Add JSON marshaling for new statement types
- Add TriggerOptionType interface for different trigger option types
- Add ExecuteAsClause and ExecuteAsTriggerOption types
- Add BeginEndAtomicBlockStatement and atomic block option types
- Update CREATE TRIGGER parsing to handle WITH clause (NATIVE_COMPILATION, SCHEMABINDING, EXECUTE AS)
- Add parsing for BEGIN ATOMIC blocks with options
- Add JSON marshaling for new types
- Fix CREATE TYPE parsing to handle incomplete statements gracefully
- Add BackupServiceMasterKeyStatement AST type
- Add RestoreServiceMasterKeyStatement AST type
- Add RestoreMasterKeyStatement AST type
- Add parsing for BACKUP SERVICE MASTER KEY
- Add parsing for RESTORE SERVICE MASTER KEY
- Add parsing for RESTORE MASTER KEY
- Add JSON marshaling for new statement types
Fix MaxLiteral.Value to preserve the original casing from the SQL token
literal instead of hardcoding lowercase. This allows the parser to
correctly handle both "MAX" and "max" variants in data type parameters.
…tring value fixes

- Add support for TokenStar (asterisk) as a wildcard ColumnReferenceExpression
  in parsePrimaryExpression, fixing count(*) parsing in function calls
- Fix LiteralAtomicBlockOption value parsing to strip N prefix and quotes
  from national strings in BEGIN ATOMIC block options
- Add CastCall, ConvertCall, TryCastCall, TryConvertCall AST types
- Implement special parsing for CAST/CONVERT syntax in expressions
- Add VECTOR to known SQL data types
- Fix CreateFunctionStatement JSON marshaling to include Parameters
- Enable 6 previously failing tests:
  - Baselines160_CreateFunctionStatementTests160
  - CreateFunctionStatementTests160
  - Baselines160_ExpressionTests160
  - ExpressionTests160
  - Baselines160_VectorFunctionTests160
  - VectorFunctionTests160
- Add AST types for server audit statements in ast/server_audit_statement.go
- Implement parseCreateServerAuditStatement and parseAlterServerAuditStatement
- Add JSON marshaling for all server audit types
- Handle SourceDeclaration and EventSessionObjectName for predicate expressions
- Enable ServerAuditStatementTests110 and Baselines110_ServerAuditStatementTests110
…able-valued functions

- Add default value parsing for function parameters (= value)
- Support RETURNS TABLE for inline table-valued functions
- Parse WITH SCHEMABINDING and other function options
- Add SelectStatement field to SelectFunctionReturnType
- Add Parameters and Options to alterFunctionStatementToJSON
- Add functionOptionToJSON helper function
- Enable BaselinesCommon_AlterFunctionStatementTests
- Add CreateFullTextCatalogStatement AST type
- Implement full parsing for ON FILEGROUP, IN PATH, WITH options, AS DEFAULT, AUTHORIZATION clauses
- Add JSON marshaling for CreateFullTextCatalogStatement
- Enable Baselines90_CreateFulltextCatalogStatementTests
- Mark PhaseOne_CreateFulltextCatalog as todo (outdated format)
- Add handling for TokenOrder and TokenGroup in parseOptimizerHint
- Properly parse two-word hints like ORDER GROUP, HASH GROUP, LOOP JOIN
- Enable BaselinesCommon_DeleteStatementTests, BaselinesCommon_UpdateStatementTests,
  DeleteStatementTests, and UpdateStatementTests
- Add readDoubleQuotedIdentifier for handling "name" style identifiers
- Fix readBracketedIdentifier to handle escaped brackets (]])
- Update parseIdentifier to unescape ]] to ] and "" to "
- Add isIdentifierChar and advanceIdentifierChar methods for Unicode support
- Enable BaselinesCommon_IdentifierTests
- Add CompressionDelayIndexOption and OrderIndexOption AST types
- Change FilterClause from ScalarExpression to BooleanExpression
- Parse WHERE clause for filtered columnstore indexes
- Parse WITH clause with COMPRESSION_DELAY, SORT_IN_TEMPDB, ORDER options
- Parse ORDER clause for Azure Synapse/DW syntax (directly after ON table)
- Add JSON marshaling for columnstore index options
- Enable Baselines130_CreateColumnStoreIndexTests130 and CreateColumnStoreIndexTests130
- Parse SET (...) clause with index options
- Add OPTIMIZE_FOR_SEQUENTIAL_KEY to index option map
- Enable Baselines150_AlterIndexStatementTests150 and AlterIndexStatementTests150
- Add TopRowFilter, OutputClause, OutputIntoClause fields to InsertSpecification
- Add OutputClause and OutputIntoClause AST types
- Parse TOP clause before the target in INSERT statements
- Handle subqueries in TOP clause (TOP (SELECT ...))
- Wrap non-subquery TOP expressions in ParenthesisExpression
- Parse OUTPUT and OUTPUT INTO clauses after column list
- Add outputClauseToJSON and outputIntoClauseToJSON marshalers
- Enable Baselines90_InsertStatementTests90 and InsertStatementTests90
Implement full parsing for ALTER EXTERNAL LIBRARY including:
- AUTHORIZATION clause for owner specification
- SET clause with CONTENT option for library file paths
- WITH clause with LANGUAGE option

Also enables CreateIndexStatementTests130 tests that now pass due to
previous index parsing improvements.
Use parseDataTypeReference instead of parseDataType for the AS clause
to preserve UserDataTypeReference when the type is a user-defined alias
(like INTALIAS) rather than a built-in type (like INT).
- Add TableHintType interface for polymorphic table hints
- Add IndexTableHint struct for INDEX hints with values
- Add TableHintsOptimizerHint for OPTION (TABLE HINT(name, hints))
- Parse table hints in WITH clause for NamedTableReference
- Handle TABLE keyword token in optimizer hint parsing
- Enable Baselines120_FromClauseTests120 test
- Add MaxSizeDatabaseOption and LiteralDatabaseOption AST types
- Add CopyOf field to CreateDatabaseStatement for AS COPY OF syntax
- Parse parenthesized Azure options (maxsize, edition)
- Parse AS COPY OF syntax for database cloning
- Handle ALTER DATABASE MODIFY with Azure options
- Enable CreateAlterDatabaseStatementTestsAzure110 and Baselines110 tests
- Add DropAsymmetricKeyStatement with REMOVE PROVIDER KEY option
- Extend CreateAsymmetricKeyStatement with KeySource, EncryptionAlgorithm, Password
- Add ProviderEncryptionSource and KeyOption types (Algorithm, ProviderKeyName, CreationDisposition)
- Enable AsymmetricKeyStatementTests100 and Baselines100_AsymmetricKeyStatementTests100
- Parse AUTHORIZATION, FROM (CONTENT=...), WITH (LANGUAGE=...)
- Add ExternalLibraryFiles and Language fields to CreateExternalLibraryStatement
- Enable CreateExternalLibrary140 and Baselines140_CreateExternalLibrary140
- Parse REMOVE PRIVATE KEY, REMOVE ATTESTED OPTION
- Parse ATTESTED BY 'value'
- Parse WITH PRIVATE KEY (ENCRYPTION BY PASSWORD, DECRYPTION BY PASSWORD)
- Add Kind, AttestedBy, EncryptionPassword, DecryptionPassword fields
- Enable Baselines90_AlterAsymmetricKeyStatementTests
- Add Platform field to ExternalLibraryFileOption
- Parse PLATFORM = identifier in FROM clause
- Enable CreateExternalLibrary150 and Baselines150 tests
- Add CreateTypeTableStatement for CREATE TYPE ... AS TABLE statements
- Add ComputedColumnExpression field to ColumnDefinition
- Parse READONLY modifier in CREATE FUNCTION parameters
- Use parseDataTypeReference for user-defined types in CREATE FUNCTION
- Parse column list for UNIQUE table constraints
- Only output Clustered field when explicitly specified in constraints

Enables tests: Baselines100_TableParametersTests, TableParametersTests
- Add On field to SelectStatement for filegroup specification
- Parse ON clause after INTO in SELECT statements
- Update parseQueryExpressionWithInto and related functions

Enables tests: SelectStatementTests140, Baselines140_SelectStatementTests140
@kyleconroy kyleconroy merged commit 4e4bc70 into main Dec 31, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants