Skip to content
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

Support for Babelfish v.4.4.0 #135

Merged
merged 5 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified BabelfishCompass_UserGuide.docx
Binary file not shown.
Binary file modified BabelfishCompass_UserGuide.pdf
Binary file not shown.
16 changes: 11 additions & 5 deletions BabelfishFeatures.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
# this must always be the first section:
[Babelfish for T-SQL]
# only Babelfish version numbers listed here can be referenced the rules below:
valid_versions=1.0.0, 1.1.0, 1.2.0, 1.3.0, 1.4.0, 1.5.0, 1.6.0, 2.1.0, 2.2.0, 2.3.0, 2.4.0, 2.5.0, 3.1.0, 3.2.0, 3.3.0, 3.4.0, 3.5.0, 4.0.0, 4.1.0, 4.2.0, 4.3.0
valid_versions=1.0.0, 1.1.0, 1.2.0, 1.3.0, 1.4.0, 1.5.0, 1.6.0, 2.1.0, 2.2.0, 2.3.0, 2.4.0, 2.5.0, 3.1.0, 3.2.0, 3.3.0, 3.4.0, 3.5.0, 4.0.0, 4.1.0, 4.2.0, 4.3.0, 4.4.0
# x.y.1/2/3 etc are bugfix releases for x.y.0 (no new T-SQL features supported), and are typically based on a newer PG release
file_format=2 # version number for format of this .cfg file. This is not expected to change much
file_timestamp=Nov-2024 # identifies the version of this file, together with the latest Babelfish version supported
file_timestamp=Dec-2024 # identifies the version of this file, together with the latest Babelfish version supported
# format: dd-MON-yyyy or MON-yyyy

# Basic principle:
Expand Down Expand Up @@ -198,6 +198,7 @@ rule=xml_value_call,xml_query_call,xml_exist_call,xml_modify_call,xml_nodes_meth
list=EXIST,MODIFY,VALUE,QUERY,NODES,SELECT FOR XML AUTO,SELECT FOR XML AUTO ELEMENTS,SELECT FOR XML EXPLICIT,SELECT FOR XML PATH,SELECT FOR XML PATH ELEMENTS,SELECT FOR XML RAW,SELECT FOR XML RAW ELEMENTS,XML SCHEMA COLLECTION,XML TYPE DEFINITION,XML INDEX,SELECTIVE XML INDEX,WITH XMLNAMESPACES,XML COLUMN_SET FOR ALL_SPARSE_COLUMNS
report_group=XML
supported-1.0.0=SELECT FOR XML PATH,SELECT FOR XML RAW
supported-4.4.0=EXIST
complexity_score=HIGH
complexity_score-MEDIUM=EXIST,VALUE,QUERY,NODES

Expand Down Expand Up @@ -616,6 +617,7 @@ complexity_score=HIGH

[ALTER FUNCTION]
rule=create_or_alter_function
supported-4.4.0=*
report_group=Functions
complexity_score=HIGH

Expand Down Expand Up @@ -775,11 +777,12 @@ report_group=Procedures

[CREATE DATABASE options]
rule=create_database
list=COLLATE,COLLATE SQL_LATIN1_GENERAL_CP1_CI_AS,COLLATE ANY,CATALOG_COLLATION,CATALOG_COLLATION DATABASE_DEFAULT,ALLOW_SNAPSHOT_ISOLATION,ANSI_NULLS,ANSI_NULL_DEFAULT,ANSI_PADDING,ANSI_WARNINGS,ARITHABORT,AUTO_CLOSE,AUTO_SHRINK,AUTO_UPDATE_STATISTICS,AUTO_UPDATE_STATISTICS_ASYNC,DB_CHAINING,COMPATIBILITY_LEVEL,CONCAT_NULL_YIELDS_NULL,CONTAINMENT=PARTIAL,CONTAINMENT=NONE,CURSOR_CLOSE_ON_COMMIT,CURSOR_DEFAULT,DATE_CORRELATION_OPTIMIZATION,DELAYED_DURABILITY,DISABLE_BROKER,FILESTREAM,HONOR_BROKER_PRIORITY,MULTI_USER,NUMERIC_ROUNDABORT,PAGE_VERIFY,PARAMETERIZATION,QUERY_STORE,QUOTED_IDENTIFIER,READ_COMMITTED_SNAPSHOT,RECOVERY,RECURSIVE_TRIGGERS,TARGET_RECOVERY_TIME,TRUSTWORTHY
list=COLLATE,COLLATE SQL_LATIN1_GENERAL_CP1_CI_AS,COLLATE BBF_UNICODE_CP1250_CI_AI,COLLATE BBF_UNICODE_CP1250_CI_AS,COLLATE POLISH_CI_AI,COLLATE POLISH_CI_AS,COLLATE BBF_UNICODE_BIN2,COLLATE BBF_UNICODE_CP1_CI_AI,COLLATE BBF_UNICODE_CP1_CI_AS,COLLATE FINNISH_SWEDISH_CI_AI,COLLATE FINNISH_SWEDISH_CI_AS,COLLATE FRENCH_CI_AI,COLLATE FRENCH_CI_AS,COLLATE MODERN_SPANISH_CI_AI,COLLATE MODERN_SPANISH_CI_AS,COLLATE TRADITIONAL_SPANISH_CI_AI,COLLATE TRADITIONAL_SPANISH_CI_AS,COLLATE BBF_UNICODE_CP1257_CI_AI,COLLATE BBF_UNICODE_CP1257_CI_AS,COLLATE ESTONIAN_CI_AI,COLLATE ESTONIAN_CI_AS,COLLATE LATIN1_GENERAL_100_BIN2,COLLATE LATIN1_GENERAL_140_BIN2,COLLATE LATIN1_GENERAL_90_BIN2,COLLATE LATIN1_GENERAL_BIN2,COLLATE SQL_LATIN1_GENERAL_CP1250_CI_AS,COLLATE LATIN1_GENERAL_CI_AI,COLLATE SQL_LATIN1_GENERAL_CP1_CI_AI,COLLATE LATIN1_GENERAL_CI_AS,COLLATE SQL_LATIN1_GENERAL_CP1251_CI_AS,COLLATE SQL_LATIN1_GENERAL_CP1257_CI_AS,CATALOG_COLLATION,CATALOG_COLLATION DATABASE_DEFAULT,ALLOW_SNAPSHOT_ISOLATION,ANSI_NULLS,ANSI_NULL_DEFAULT,ANSI_PADDING,ANSI_WARNINGS,ARITHABORT,AUTO_CLOSE,AUTO_SHRINK,AUTO_UPDATE_STATISTICS,AUTO_UPDATE_STATISTICS_ASYNC,DB_CHAINING,COMPATIBILITY_LEVEL,CONCAT_NULL_YIELDS_NULL,CONTAINMENT=PARTIAL,CONTAINMENT=NONE,CURSOR_CLOSE_ON_COMMIT,CURSOR_DEFAULT,DATE_CORRELATION_OPTIMIZATION,DELAYED_DURABILITY,DISABLE_BROKER,FILESTREAM,HONOR_BROKER_PRIORITY,MULTI_USER,NUMERIC_ROUNDABORT,PAGE_VERIFY,PARAMETERIZATION,QUERY_STORE,QUOTED_IDENTIFIER,READ_COMMITTED_SNAPSHOT,RECOVERY,RECURSIVE_TRIGGERS,TARGET_RECOVERY_TIME,TRUSTWORTHY
supported-1.0.0=CONTAINMENT=NONE
ignored-2.4.0=CATALOG_COLLATION DATABASE_DEFAULT
ignored-2.4.0=COLLATE
supported-3.1.0=COLLATE SQL_LATIN1_GENERAL_CP1_CI_AS
supported-4.4.0=COLLATE BBF_UNICODE_CP1250_CI_AI,COLLATE BBF_UNICODE_CP1250_CI_AS,COLLATE POLISH_CI_AI,COLLATE POLISH_CI_AS,COLLATE BBF_UNICODE_BIN2,COLLATE BBF_UNICODE_CP1_CI_AI,COLLATE BBF_UNICODE_CP1_CI_AS,COLLATE FINNISH_SWEDISH_CI_AI,COLLATE FINNISH_SWEDISH_CI_AS,COLLATE FRENCH_CI_AI,COLLATE FRENCH_CI_AS,COLLATE MODERN_SPANISH_CI_AI,COLLATE MODERN_SPANISH_CI_AS,COLLATE TRADITIONAL_SPANISH_CI_AI,COLLATE TRADITIONAL_SPANISH_CI_AS,COLLATE BBF_UNICODE_CP1257_CI_AI,COLLATE BBF_UNICODE_CP1257_CI_AS,COLLATE ESTONIAN_CI_AI,COLLATE ESTONIAN_CI_AS,COLLATE LATIN1_GENERAL_100_BIN2,COLLATE LATIN1_GENERAL_140_BIN2,COLLATE LATIN1_GENERAL_90_BIN2,COLLATE LATIN1_GENERAL_BIN2,COLLATE SQL_LATIN1_GENERAL_CP1250_CI_AS,COLLATE LATIN1_GENERAL_CI_AI,COLLATE SQL_LATIN1_GENERAL_CP1_CI_AI,COLLATE LATIN1_GENERAL_CI_AS,COLLATE SQL_LATIN1_GENERAL_CP1251_CI_AS,COLLATE SQL_LATIN1_GENERAL_CP1257_CI_AS
report_group=Databases

[ALTER DATABASE]
Expand Down Expand Up @@ -884,7 +887,7 @@ report_group=DML

[Cross-database reference]
rule=full_object_name
list=SELECT,INSERT,UPDATE,DELETE,MERGE,SELECT..INTO,EXECUTE,TRUNCATE TABLE,CREATE INDEX,DROP INDEX,UPDATE STATISTICS,CREATE TABLE,ALTER TABLE,SET IDENTITY_INSERT
list=SELECT,INSERT,UPDATE,DELETE,MERGE,SELECT..INTO,EXECUTE,TRUNCATE TABLE,CREATE INDEX,DROP INDEX,UPDATE STATISTICS,CREATE TABLE,ALTER TABLE,SET IDENTITY_INSERT,CREATE SYNONYM
supported-2.1.0=SELECT,INSERT,UPDATE,DELETE,SELECT..INTO
supported-2.2.0=EXECUTE
report_group=Identifiers
Expand Down Expand Up @@ -1052,6 +1055,7 @@ supported-3.5.0-3.*=availability_groups,availability_replicas
supported-4.1.0=availability_groups,availability_replicas
supported-4.2.0=login_token,user_token
supported-4.3.0=sequences,partition_functions,partition_schemes,partition_parameters,partition_range_values,destination_data_spaces
supported-4.4.0=dm_os_sys_info

[INFORMATION_SCHEMA]
rule=full_object_name
Expand Down Expand Up @@ -1081,6 +1085,7 @@ supported-3.4.0=sp_who,sp_changedbowner
supported-3.5.0-3.*=sp_procedure_params_100_managed
supported-4.1.0=sp_procedure_params_100_managed
supported-4.2.0=sp_renamedb
supported-4.4.0=sp_reset_connection
default_classification-ReviewManually=sp_db_vardecimal_storage_format,sp_fulltext_database
report_group-XML=sp_xml_preparedocument,sp_xml_removedocument,sp_xml_schema_rowset,sp_xml_schema_rowset2
report_group-Distributed Transactions(XA)=sp_sqljdbc_xa_install,sp_sqljdbc_xa_uninstall,sp_sqljdbc_xa_internal_remove,sp_xa_commit,sp_xa_end,sp_xa_forget,sp_xa_forget_ex,sp_xa_init,sp_xa_init_ex,sp_xa_prepare,sp_xa_prepare_ex,sp_xa_recover,sp_xa_rollback,sp_xa_rollback_ex,sp_xa_start,xp_sqljdbc_xa_commit,xp_sqljdbc_xa_end,xp_sqljdbc_xa_forget,xp_sqljdbc_xa_forget_ex,xp_sqljdbc_xa_init,xp_sqljdbc_xa_init_ex,xp_sqljdbc_xa_prepare,xp_sqljdbc_xa_prepare_ex,xp_sqljdbc_xa_recover,xp_sqljdbc_xa_rollback,xp_sqljdbc_xa_rollback_ex,xp_sqljdbc_xa_start
Expand Down Expand Up @@ -1166,6 +1171,7 @@ rule=pivot_clause
list=PIVOT,VIEW,CTE,JOIN
supported-3.4.0=PIVOT
supported-4.2.0=CTE,JOIN
supported-4.4.0=VIEW
report_group=DML

[SELECT..UNPIVOT]
Expand Down Expand Up @@ -1661,5 +1667,5 @@ list=FORMSOF,ISABOUT,NEAR,INFLECTIONAL,THESAURUS
complexity_score=HIGH

#-----------------------------------------------------------------------------------
#file checksum=17a3941b
#file checksum=72d4288c
#--- end ---------------------------------------------------------------------------
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# 2024-12
- Added support for Babelfish v.4.4.0.
- Detect object type argument to sp_rename.
- Detect cross-database references by SET IDENTITY_INSERT.
- Added -nopopupwindow flag to suppress automatically opening the report in the browser.
- Automatic DDL generation (with -sqlendpoint) for multiple databases continues when a database does not exist or is not accessible.
- Include Compass User Guide in distro .zip file.

# 2024-10b
- Detect and rewrite redundant unary '+' operators for strings.

Expand Down
81 changes: 42 additions & 39 deletions src/main/java/compass/CompassAnalyze.java
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public class CompassAnalyze {
static final String OpenKeyStmt = "OPEN KEY";
static final String CloseKeyStmt = "CLOSE KEY";
static final String Collations = "Collations";
static final String CaseSensitiveCollation = "Case-sensitive collation";
static final String CaseSensitiveCollation= "Case-sensitive collation";
static final String DBAStmts = "DBA statements";
static final String MiscObjects = "Miscellaneous objects";
static final String MoneyLiteral = "MONEY literal";
Expand Down Expand Up @@ -8011,6 +8011,7 @@ else if (hasParent(ctx.parent,"alter_database")) {

String status = featureSupportedInVersion(Collations,collationName);
String CSmsg = "";

if (collationName.toUpperCase().contains("_CS_")) {
if (status.equals(u.Supported)) {
String CSstatus = featureSupportedInVersion(CaseSensitiveCollation,contextCS);
Expand All @@ -8031,33 +8032,25 @@ else if (hasParent(ctx.parent,"alter_database")) {
String statusCrdbV24 = "";
if (statusCrdb.equals(u.NotSupported)) {
msg = "CREATE DATABASE...COLLATE";
status = statusCrdb;
}
status = statusCrdb;
}
else {
status = statusCrdbV24 = statusCrdb; // CREATE DATABASE...COLLATE is IGNORED

statusCrdb= featureSupportedInVersion(CreateDatabaseOptions, "COLLATE ANY");
statusCrdb = featureSupportedInVersion(CreateDatabaseOptions, "COLLATE " + collationName);
String statusv31 = featureSupportedInVersion(CreateDatabaseOptions,"COLLATE SQL_LATIN1_GENERAL_CP1_CI_AS");
if (statusCrdb.equals(u.Supported)) {
msg = CSmsg+collationName+", "+context;
status = statusCrdb;
status = statusCrdb;
}
else {
statusCrdb = featureSupportedInVersion(CreateDatabaseOptions, "COLLATE " + collationName);
String statusv31 = featureSupportedInVersion(CreateDatabaseOptions,"COLLATE SQL_LATIN1_GENERAL_CP1_CI_AS");
if (statusCrdb.equals(u.Supported)) {
msg = CSmsg+collationName+", "+context;
status = statusCrdb;
}
if (statusv31.equals(u.Supported)) {
status = u.NotSupported;
}
else {
if (statusv31.equals(u.Supported)) {
status = u.NotSupported;
}
else {
status = statusCrdbV24;
}
}
}

status = statusCrdbV24;
}
}
}
}

Expand Down Expand Up @@ -8661,29 +8654,39 @@ public void CaptureIdentifier(String objNameRaw, String objName, String stmt, in
}
if (objName.contains(".")) {
List<String> parts = new ArrayList<String>(Arrays.asList(objName.split("\\.")));

boolean ObjTypeSupported = true;
if (stmt.equals("CREATE SYNONYM")) {
String statusObj = featureSupportedInVersion(MiscObjects, "SYNONYM");
if (!statusObj.equals(u.Supported)) ObjTypeSupported = false;
}

if (parts.size() == 3) {
String dbName = u.getDBNameFromID(objName);
String status = "";
String ownDB = "";
if (dbName.equalsIgnoreCase(u.currentDatabase)) {
status = u.Supported;
ownDB = " (in current database)";
}
else {
String stmtTest = stmt;
stmtTest = u.applyPatternFirst(stmtTest, "\\(target\\)$", "");
stmtTest = u.applyPatternFirst(stmtTest, "^EXECUTE procedure$", "EXECUTE");
//u.appOutput(u.thisProc()+"stmt=["+stmt+"] stmtTest=["+stmtTest+"] ");
status = featureSupportedInVersion(CrossDbReference,stmtTest);
if (ObjTypeSupported) {
if (parts.size() == 3) {
String dbName = u.getDBNameFromID(objName);
String status = "";
String ownDB = "";
if (dbName.equalsIgnoreCase(u.currentDatabase)) {
status = u.Supported;
ownDB = " (in current database)";
}
else {
String stmtTest = stmt;
stmtTest = u.applyPatternFirst(stmtTest, "\\(target\\)$", "");
stmtTest = u.applyPatternFirst(stmtTest, "^EXECUTE procedure$", "EXECUTE");
//u.appOutput(u.thisProc()+"stmt=["+stmt+"] stmtTest=["+stmtTest+"] ");
status = featureSupportedInVersion(CrossDbReference,stmtTest);
}
captureItem(CrossDbReference+" by "+stmt+ownDB, objName.toUpperCase(), CrossDbReference, stmt, status, lineNr);
}
captureItem(CrossDbReference+" by "+stmt+ownDB, objName.toUpperCase(), CrossDbReference, stmt, status, lineNr);
}

if (parts.size() == 4) {
String serverName = u.getServerNameFromID(objName);
String status = featureSupportedInVersion(RemoteObjectReference, stmt);
captureItem(RemoteObjectReference+" by "+stmt, objName.toUpperCase()+fmt, RemoteObjectReference, stmt, status, lineNr);
if (ObjTypeSupported) {
if (parts.size() == 4) {
String serverName = u.getServerNameFromID(objName);
String status = featureSupportedInVersion(RemoteObjectReference, stmt);
captureItem(RemoteObjectReference+" by "+stmt, objName.toUpperCase()+fmt, RemoteObjectReference, stmt, status, lineNr);
}
}
}

Expand Down
23 changes: 19 additions & 4 deletions src/main/java/compass/CompassUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public class CompassUtilities {
public static boolean onLinux = false;
public static String onPlatform = uninitialized;

public static final String thisProgVersion = "2024-11";
public static final String thisProgVersionDate = "November 2024";
public static final String thisProgVersion = "2024-12";
public static final String thisProgVersionDate = "December 2024";
public static final String thisProgName = "Babelfish Compass";
public static final String thisProgNameLong = "Compatibility assessment tool for Babelfish for PostgreSQL";
public static final String thisProgNameExec = "Compass";
Expand Down Expand Up @@ -112,8 +112,8 @@ public class CompassUtilities {
public String targetBabelfishVersionReportLine = "Target Babelfish version : v."; // line in report listing the target version
public boolean stdReport = false; // development only

public static List<String> BabelfishVersionList = Arrays.asList("1.0.0", "1.1.0", "1.2.0", "1.3.0", "1.4.0", "1.5.0", "2.1.0", "2.2.0", "2.3.0", "2.4.0", "3.1.0", "3.2.0", "3.3.0", "3.4.0", "3.5.0", "4.0.0", "4.1.0", "4.2.0", "4.3.0");
public static List<String> BabelfishPGVersionList = Arrays.asList("13.4", "13.5", "13.6", "13.7", "13.8", "13.9", "14.3/4", "14.5", "14.6", "14.7", "15.2", "15.3", "15.4", "15.5", "15.6", "16.1", "16.2", "16.3", "16.4");
public static List<String> BabelfishVersionList = Arrays.asList("1.0.0", "1.1.0", "1.2.0", "1.3.0", "1.4.0", "1.5.0", "2.1.0", "2.2.0", "2.3.0", "2.4.0", "3.1.0", "3.2.0", "3.3.0", "3.4.0", "3.5.0", "4.0.0", "4.1.0", "4.2.0", "4.3.0", "4.4.0");
public static List<String> BabelfishPGVersionList = Arrays.asList("13.4", "13.5", "13.6", "13.7", "13.8", "13.9", "14.3/4", "14.5", "14.6", "14.7", "15.2", "15.3", "15.4", "15.5", "15.6", "16.1", "16.2", "16.3", "16.4", "16.6");

// minimum Babelfish version; this is fixed
public static final String baseBabelfishVersion = "1.0.0";
Expand Down Expand Up @@ -6035,6 +6035,14 @@ private String formatComplexityList(List<Integer> cnt) {
}

public String formatPGversion(String bbfVersion) {
// we forgot to update the BBF version list or PG version list
if (BabelfishVersionList.size() != BabelfishPGVersionList.size()) {
if (devOptions) {
appOutput(thisProc()+"Internal error: BabelfishVersionList does not match BabelfishPGVersionList");
errorExitStackTrace();
}
}

String s = "";
for (int i = 0; i < BabelfishVersionList.size(); i++) {
String v1 = BabelfishVersionList.get(i);
Expand All @@ -6046,6 +6054,13 @@ public String formatPGversion(String bbfVersion) {
if (!s.isEmpty()) {
s = " (PG "+s+")";
}
else {
// we forgot to update the BBF version list or PG version list
if (devOptions) {
appOutput(thisProc()+"Internal error: BabelfishVersionList/BabelfishPGVersionList not updated for '"+bbfVersion+"'");
errorExitStackTrace();
}
}
return s;
}

Expand Down
Loading