[ 
https://jira.duraspace.org/browse/DS-680?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=21015#action_21015
 ] 

Scott Phillips commented on DS-680:
-----------------------------------


I came across this bug in on of our pre-production dspace instances and I was 
not able to reproduce the error on any of our other instances. I eventually 
tracked the problem down, it is caused by a blank metadata entry in 
dc.date.accessioned. 

The SQL blows up with the exception while trying to cast that blank value into 
a date timestamp. I played around with various ways to fix this and came up 
with a relatively simple fix for postgres that adds another clause to check if 
the field looks remotely like a date.

        // Verifies that the metadata contains a valid date, otherwise the
        // postgres queries blow up when doing the ::timestamp cast.
        if (!oracle && startDate != null || endDate != null) {
                dateQuery.append(" AND text_value LIKE '____-__-__T__:__:__Z' 
");
        }

Here is the bit in the Postgres manual that discuss the "::" cast operator, 
http://www.postgresql.org/docs/current/static/sql-expressions.html#SQL-SYNTAX-TYPE-CASTS

> invalid input syntax for type timestamp in db query for stat-initial utility
> ----------------------------------------------------------------------------
>
>                 Key: DS-680
>                 URL: https://jira.duraspace.org/browse/DS-680
>             Project: DSpace
>          Issue Type: Bug
>    Affects Versions: 1.6.2
>         Environment: DSpace 1.6.2; Java JDK 1.6.0 (Sun); Apache Ant 1.8.1; 
> JUnit 4.8.2; Apache Maven 2.2.1; Apache Tomcat 6.0.26; Apache Httpd 2.2.15; 
> Tomcat Connector 1.2.30 (for mod_jk); PostgreSQL 8.4.4
>            Reporter: Royal Roads University
>            Assignee: Mark H. Wood
>
> DSpace 1.6.2 >> Command [dspace]/bin/stat-initial generates an Exception: 
> ERROR: invalid input syntax for type timestamp
> Traced issue to extraneous content in db query in WHERE clause( e.g. AND 
> text_value::timestamp > ...)
> Traced to:
> /dspace-1.6.2-src-release/dspace-api/src/main/java/org/dspace/app/statistics/LogAnalyser.java
> CHANGED FROM:
> Line 1240:
> dateQuery.append(" AND text_value::timestamp > '" +
> unParseDate(startDate) + "'::timestamp ");
> Line 1255:
> dateQuery.append(" AND text_value::timestamp > '" +
> unParseDate(startDate) + "'::timestamp ");
> CHANGED TO:
> Line 1240:
> dateQuery.append(" AND text_value > '" +
> unParseDate(startDate) + "' ");
> Line 1255:
> dateQuery.append(" AND text_value > '" +
> unParseDate(startDate) + "' ");

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
https://jira.duraspace.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security 
threats, fraudulent activity, and more. Splunk takes this data and makes 
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
_______________________________________________
Dspace-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dspace-devel

Reply via email to