From 66c6c0d5a5e517d6a8e777d6b4c6961845c0bde2 Mon Sep 17 00:00:00 2001 From: Anastasiya <45152336+LonwoLonwo@users.noreply.github.com> Date: Sat, 3 Dec 2022 03:56:04 +0300 Subject: [PATCH] #550 fix the special case for procedure parameters reading (#1130) * #550 fix the special case for procedure parameters reading - then catalog or schema are quoted * #550 formatting fix * #550 add nullability check to the condition --- .../client/jdbc/SnowflakeDatabaseMetaData.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/snowflake/client/jdbc/SnowflakeDatabaseMetaData.java b/src/main/java/net/snowflake/client/jdbc/SnowflakeDatabaseMetaData.java index b80a5a5f4..39ad726d8 100644 --- a/src/main/java/net/snowflake/client/jdbc/SnowflakeDatabaseMetaData.java +++ b/src/main/java/net/snowflake/client/jdbc/SnowflakeDatabaseMetaData.java @@ -1140,17 +1140,29 @@ public ResultSet getProcedureColumns( String procedureNameUnparsed = resultSetStepOne.getString("arguments").trim(); String procedureNameNoArgs = resultSetStepOne.getString("name"); String schemaName = resultSetStepOne.getString("schema_name"); + // Check that schema name match the original input + // And check special case - schema with special name in quotes + boolean isSchemaNameMatch = + compiledSchemaPattern != null + && (compiledSchemaPattern.matcher(schemaName).matches() + || (schemaName.startsWith("\"") + && schemaName.endsWith("\"") + && compiledSchemaPattern + .matcher(schemaName) + .region(1, schemaName.length() - 1) + .matches())); + // Check that procedure name and schema name match the original input in case wildcards have // been used. // Procedure name column check must occur later when columns are parsed. if ((compiledProcedurePattern != null && !compiledProcedurePattern.matcher(procedureNameNoArgs).matches()) - || (compiledSchemaPattern != null - && !compiledSchemaPattern.matcher(schemaName).matches())) { + || (compiledSchemaPattern != null && !isSchemaNameMatch)) { continue; } + String catalogName = resultSetStepOne.getString("catalog_name"); String showProcedureColCommand = - getSecondResultSetCommand(catalog, schemaName, procedureNameUnparsed, "procedure"); + getSecondResultSetCommand(catalogName, schemaName, procedureNameUnparsed, "procedure"); ResultSet resultSetStepTwo = executeAndReturnEmptyResultIfNotFound(