Skip to content
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
29 changes: 29 additions & 0 deletions api/src/org/labkey/api/data/SQLParameterException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright (c) 2011 LabKey Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.labkey.api.data;

import org.labkey.api.util.SkipMothershipLogging;

/**
* Signals there was a problem with a SQL parameter, such as a conversion problem.
*/
public class SQLParameterException extends SQLGenerationException implements SkipMothershipLogging
{
public SQLParameterException(String message)
{
super(message);
}
}
4 changes: 3 additions & 1 deletion api/src/org/labkey/api/data/SqlExecutingSelector.java
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,9 @@ public void handleSqlException(SQLException e, @Nullable Connection conn)
if (null != _sql)
ExceptionUtil.decorateException(e, ExceptionUtil.ExceptionInfo.DialectSQL, _sql.toDebugString(), false);

throw getExceptionFramework().translate(getScope(), "ExecutingSelector", e);
RuntimeException translated = getExceptionFramework().translate(getScope(), "ExecutingSelector", e);
ExceptionUtil.copyDecorations(e, translated);
throw translated;
}
}
}
10 changes: 6 additions & 4 deletions api/src/org/labkey/api/data/Table.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Strings;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -50,6 +51,7 @@
import org.labkey.api.query.RuntimeValidationException;
import org.labkey.api.security.User;
import org.labkey.api.util.BaseScanner;
import org.labkey.api.util.ExceptionUtil;
import org.labkey.api.util.GUID;
import org.labkey.api.util.JunitUtil;
import org.labkey.api.util.MemTracker;
Expand Down Expand Up @@ -571,7 +573,7 @@ Object getObject(ResultSet rs) throws SQLException
// Standard SQLException catch block: log exception, query SQL, and params
static void logException(@Nullable SQLFragment sql, @Nullable Connection conn, SQLException e, Level logLevel)
{
if (SqlDialect.isCancelException(e))
if (SqlDialect.isCancelException(e) || ExceptionUtil.isIgnorable(e))
{
return;
}
Expand All @@ -585,7 +587,7 @@ static void logException(@Nullable SQLFragment sql, @Nullable Connection conn, S
String trim = sql.getSQL().trim();

// Treat a ConstraintException during INSERT/UPDATE as a WARNING. Treat all other SQLExceptions as an ERROR.
if (RuntimeSQLException.isConstraintException(e) && (StringUtils.startsWithIgnoreCase(trim, "INSERT") || StringUtils.startsWithIgnoreCase(trim, "UPDATE")))
if (RuntimeSQLException.isConstraintException(e) && (Strings.CI.startsWith(trim, "INSERT") || Strings.CI.startsWith(trim, "UPDATE")))
{
// Log this ConstraintException if log Level is WARN (the default) or lower. Skip logging for callers that request just ERRORs.
if (Level.WARN.isMoreSpecificThan(logLevel))
Expand Down Expand Up @@ -1409,7 +1411,7 @@ public void testSelect() throws SQLException
//noinspection EmptyTryBlock,UnusedDeclaration
try (ResultSet rs = new TableSelector(tinfo).getResultSet()){}

Map[] maps = new TableSelector(tinfo).getMapArray();
Map<?, ?>[] maps = new TableSelector(tinfo).getMapArray();
assertNotNull(maps);

Principal[] principals = new TableSelector(tinfo).getArray(Principal.class);
Expand Down Expand Up @@ -1739,7 +1741,7 @@ public static ParameterMapStatement deleteStatement(Connection conn, TableInfo t
//

Domain domain = tableDelete.getDomain();
DomainKind domainKind = tableDelete.getDomainKind();
DomainKind<?> domainKind = tableDelete.getDomainKind();
if (null != domain && null != domainKind && StringUtils.isEmpty(domainKind.getStorageSchemaName()))
{
if (!d.isPostgreSQL() && !d.isSqlServer())
Expand Down
2 changes: 1 addition & 1 deletion api/src/org/labkey/api/data/TableSelector.java
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ public Results getResultsAsync(final boolean cache, final boolean scrollable, Ht
}

/**
* Setting this options asks the TableSelector to add additional display columns to the generated SQL, as well
* Setting this option asks the TableSelector to add additional display columns to the generated SQL, as well

* as forcing the results to be sorted.
* @return this
Expand Down
8 changes: 8 additions & 0 deletions api/src/org/labkey/api/util/ExceptionUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,14 @@ public class ExceptionUtil
*/
private static final Map<String, ExceptionTally> EXCEPTION_TALLIES = Collections.synchronizedMap(new HashMap<>());

public static void copyDecorations(Throwable source, Throwable target)
{
for (Map.Entry<Enum<?>, String> entry : getExceptionDecorations(source).entrySet())
{
decorateException(target, entry.getKey(), entry.getValue(), false);
}
}

private static class ExceptionTally
{
/** Total number of times the exception has happened */
Expand Down
10 changes: 3 additions & 7 deletions api/src/org/labkey/api/util/SkipMothershipLogging.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,9 @@

package org.labkey.api.util;

/*
* User: adam
* Date: Aug 10, 2009
* Time: 2:03:50 PM
*/

// Exceptions implement this interface to tell mothership not to log them
/**
* Exceptions implement this interface as a tag to tell mothership not to log them
*/
public interface SkipMothershipLogging
{
}
1 change: 0 additions & 1 deletion core/src/org/labkey/core/dialect/PostgreSql92Dialect.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
abstract class PostgreSql92Dialect extends BasePostgreSqlDialect
{
public static final String PRODUCT_NAME = "PostgreSQL";
public static final String RECOMMENDED = PRODUCT_NAME + " 17.x is the recommended version.";

// This has been the standard PostgreSQL identifier max byte length for many years. However, this could change in
// the future plus servers can be compiled with a different limit, so we query this setting on first connection to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ else if (psv.isDeprecated())

public static String getStandardWarningMessage(String warning, String databaseProductVersion)
{
return "LabKey Server " + warning + " " + PostgreSql92Dialect.PRODUCT_NAME + " version " + databaseProductVersion + ". " + PostgreSql92Dialect.RECOMMENDED;
return "LabKey Server " + warning + " " + PostgreSql92Dialect.PRODUCT_NAME + " version " + databaseProductVersion + ". " + PostgreSqlVersion.RECOMMENDED;
}

@Override
Expand Down
8 changes: 6 additions & 2 deletions core/src/org/labkey/core/dialect/PostgreSqlVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,24 @@
import java.util.function.Supplier;
import java.util.stream.Collectors;

import static org.labkey.core.dialect.PostgreSql92Dialect.PRODUCT_NAME;

/**
* Enum that specifies the versions of PostgreSQL that LabKey supports plus their properties
*/
public enum PostgreSqlVersion
{
POSTGRESQL_UNSUPPORTED(-1, true, false, null),
POSTGRESQL_13(130, false, true, PostgreSql_13_Dialect::new),
POSTGRESQL_13(130, true, true, PostgreSql_13_Dialect::new),
POSTGRESQL_14(140, false, true, PostgreSql_14_Dialect::new),
POSTGRESQL_15(150, false, true, PostgreSql_15_Dialect::new),
POSTGRESQL_16(160, false, true, PostgreSql_16_Dialect::new),
POSTGRESQL_17(170, false, true, PostgreSql_17_Dialect::new),
POSTGRESQL_18(180, false, false, PostgreSql_18_Dialect::new),
POSTGRESQL_18(180, false, true, PostgreSql_18_Dialect::new),
POSTGRESQL_FUTURE(Integer.MAX_VALUE, true, false, PostgreSql_18_Dialect::new);

public static final String RECOMMENDED = PRODUCT_NAME + " 18.x is the recommended version.";

private final int _version;
private final boolean _deprecated;
private final boolean _tested;
Expand Down
10 changes: 7 additions & 3 deletions query/src/org/labkey/query/QueryServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.apache.commons.collections4.MultiValuedMap;
import org.apache.commons.collections4.SetValuedMap;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Strings;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.xmlbeans.XmlError;
Expand Down Expand Up @@ -65,7 +66,7 @@
import org.labkey.api.data.ResultsImpl;
import org.labkey.api.data.RuntimeSQLException;
import org.labkey.api.data.SQLFragment;
import org.labkey.api.data.SQLGenerationException;
import org.labkey.api.data.SQLParameterException;
import org.labkey.api.data.SimpleFilter;
import org.labkey.api.data.Sort;
import org.labkey.api.data.SqlSelector;
Expand Down Expand Up @@ -120,6 +121,7 @@
import org.labkey.api.util.CSRFUtil;
import org.labkey.api.util.ConfigurationException;
import org.labkey.api.util.ContainerContext;
import org.labkey.api.util.ExceptionUtil;
import org.labkey.api.util.GUID;
import org.labkey.api.util.JunitUtil;
import org.labkey.api.util.Pair;
Expand Down Expand Up @@ -1360,7 +1362,7 @@ public MultiValuedMap<Path, ModuleCustomViewDef> load(Stream<? extends Resource>
{
// Note: Can't use standard filter (getFilter(suffix)) below since we must allow ".qview.xml"
return unmodifiable(resources
.filter(resource -> StringUtils.endsWithIgnoreCase(resource.getName(), CustomViewXmlReader.XML_FILE_EXTENSION))
.filter(resource -> Strings.CI.endsWith(resource.getName(), CustomViewXmlReader.XML_FILE_EXTENSION))
.map(ModuleCustomViewDef::new)
.collect(LabKeyCollectors.toMultiValuedMap(def -> def.getPath().getParent(), def -> def)));
}
Expand Down Expand Up @@ -2683,7 +2685,9 @@ public void bindNamedParameters(SQLFragment frag, @Nullable Map<String, Object>
}
catch (ConversionException e)
{
throw new RuntimeSQLException(new SQLGenerationException(ConvertHelper.getStandardConversionErrorMessage(value, p.getName(), p.getJdbcType().getJavaClass())));
SQLParameterException paramException = new SQLParameterException(ConvertHelper.getStandardConversionErrorMessage(value, p.getName(), p.getJdbcType().getJavaClass()));
ExceptionUtil.decorateException(paramException, ExceptionUtil.ExceptionInfo.SkipMothershipLogging, "true", true);
throw new RuntimeSQLException(paramException);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE study.uploadlog DROP CONSTRAINT UQ_UploadLog_FilePath;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE study.uploadlog DROP CONSTRAINT UQ_UploadLog_FilePath;
6 changes: 1 addition & 5 deletions study/src/org/labkey/study/StudyModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@
import org.labkey.api.exp.PropertyType;
import org.labkey.api.exp.api.ExperimentService;
import org.labkey.api.exp.property.PropertyService;
import org.labkey.api.files.FileContentService;
import org.labkey.api.files.TableUpdaterFileListener;
import org.labkey.api.message.digest.ReportAndDatasetChangeDigestProvider;
import org.labkey.api.migration.DatabaseMigrationService;
import org.labkey.api.migration.DefaultMigrationSchemaHandler;
Expand Down Expand Up @@ -228,7 +226,7 @@ public String getName()
@Override
public Double getSchemaVersion()
{
return 25.003;
return 25.005;
}

@Override
Expand Down Expand Up @@ -391,8 +389,6 @@ protected void startupAfterSpringConfig(ModuleContext moduleContext)
folderRegistry.addFactories(new StudyWriterFactory(), new StudyImporterFactory());
}

FileContentService.get().addFileListener(new TableUpdaterFileListener(StudySchema.getInstance().getTableInfoUploadLog(), "FilePath", TableUpdaterFileListener.Type.filePath, "RowId"));

DatasetDefinition.cleanupOrphanedDatasetDomains();

OptionalFeatureService.get().addExperimentalFeatureFlag(StudyQuerySchema.EXPERIMENTAL_STUDY_SUBSCHEMAS, "Use sub-schemas in Study",
Expand Down
Loading