You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ma...@apache.org on 2007/07/31 22:29:12 UTC
svn commit: r561494 - in /db/derby/code/trunk/java/engine/org/apache/derby:
iapi/types/DataTypeDescriptor.java
impl/sql/compile/LikeEscapeOperatorNode.java
Author: mamta
Date: Tue Jul 31 13:29:11 2007
New Revision: 561494
URL: http://svn.apache.org/viewvc?view=rev&rev=561494
Log:
DERBY-2793
Collation comparison algorithm for LIKE is incorrect. Rather than duplicating the code in 2 places, I am including a genric method in DataTypeDescriptor which can be called whenever needed.
Modified:
db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataTypeDescriptor.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LikeEscapeOperatorNode.java
Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataTypeDescriptor.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataTypeDescriptor.java?view=diff&rev=561494&r1=561493&r2=561494
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataTypeDescriptor.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataTypeDescriptor.java Tue Jul 31 13:29:11 2007
@@ -40,7 +40,7 @@
import org.apache.derby.iapi.services.sanity.SanityManager;
import org.apache.derby.iapi.sql.conn.ConnectionUtil;
-/**
+/**
* DataTypeDescriptor describes a runtime SQL type.
*/
@@ -1090,17 +1090,7 @@
//If both the types are string types, then we need to make sure
//they have the same collation set on them
if (compareWithTypeID.isStringTypeId() && typeId.isStringTypeId()) {
- //both the operands can not have the collation derivation of
- //NONE. This is because in that case, we do not know what kind
- //of collation to use for comparison.
- if (getCollationDerivation() == compareWithDTD.getCollationDerivation() &&
- getCollationDerivation() == StringDataValue.COLLATION_DERIVATION_NONE)
- return false;
- if (getCollationDerivation() == compareWithDTD.getCollationDerivation() &&
- getCollationType() == compareWithDTD.getCollationType())
- return true;//collation matches
- else
- return false;//collation does not match
+ return compareCollationInfo(compareWithDTD);
} else
return false;//can't be compared
}
@@ -1165,7 +1155,20 @@
return false;
}
-
+ public boolean compareCollationInfo(DataTypeDescriptor compareWithDTD){
+ //both the operands can not have the collation derivation of
+ //NONE. This is because in that case, we do not know what kind
+ //of collation to use for comparison.
+ if (getCollationDerivation() == compareWithDTD.getCollationDerivation() &&
+ getCollationDerivation() == StringDataValue.COLLATION_DERIVATION_NONE)
+ return false;
+ if (getCollationDerivation() == compareWithDTD.getCollationDerivation() &&
+ getCollationType() == compareWithDTD.getCollationType())
+ return true;//collation matches
+ else
+ return false;//collation does not match
+ }
+
/**
* Converts this data type descriptor (including length/precision)
* to a string. E.g.
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LikeEscapeOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LikeEscapeOperatorNode.java?view=diff&rev=561494&r1=561493&r2=561494
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LikeEscapeOperatorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LikeEscapeOperatorNode.java Tue Jul 31 13:29:11 2007
@@ -53,7 +53,7 @@
import java.util.Vector;
-
+
/**
This node represents a like comparison operator (no escape)
@@ -339,11 +339,8 @@
// The left and the pattern of the LIKE must be same collation type
// and derivation.
- if (receiver.getTypeServices().getCollationType() !=
- leftOperand.getTypeServices().getCollationType() ||
- receiver.getTypeServices().getCollationDerivation() !=
- leftOperand.getTypeServices().getCollationDerivation()
- )
+ if (!receiver.getTypeServices().compareCollationInfo(
+ leftOperand.getTypeServices()))
{
// throw error.
throw StandardException.newException(
Re: svn commit: r561494 - in /db/derby/code/trunk/java/engine/org/apache/derby: iapi/types/DataTypeDescriptor.java impl/sql/compile/LikeEscapeOperatorNode.java
Posted by Mamta Satoor <ms...@gmail.com>.
I will add a comment to the method (I thought I did, but looks like not:(
Mamta
On 7/31/07, Daniel John Debrunner <dj...@apache.org> wrote:
>
> mamta@apache.org wrote:
> > Author: mamta
> > Date: Tue Jul 31 13:29:11 2007
> > New Revision: 561494
> >
> > URL: http://svn.apache.org/viewvc?view=rev&rev=561494
> > Log:
> > DERBY-2793
> >
> > Collation comparison algorithm for LIKE is incorrect. Rather than
> duplicating the code in 2 places, I am including a genric method in
> DataTypeDescriptor which can be called whenever needed.
> >
> >
> > Modified:
> >
> db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataTypeDescriptor.java
> >
> db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LikeEscapeOperatorNode.java
> >
> > Modified:
> db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataTypeDescriptor.java
> > URL:
> http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataTypeDescriptor.java?view=diff&rev=561494&r1=561493&r2=561494
> >
> ==============================================================================
> > ---
> db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataTypeDescriptor.java
> (original)
> > +++
> db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataTypeDescriptor.java
> Tue Jul 31 13:29:11 2007
>
>
>
> Does this method have any javadoc comments with it? Would be useful to
> indicate what exactly its purpose is, as it still doesn't seem to be
> implementing the required collation determination from 9.13.
>
>
> >
> > -
> > + public boolean compareCollationInfo(DataTypeDescriptor
> compareWithDTD){
> > + //both the operands can not have the collation derivation
> of
> > + //NONE. This is because in that case, we do not know what
> kind
> > + //of collation to use for comparison.
> > + if (getCollationDerivation() ==
> compareWithDTD.getCollationDerivation() &&
> > + getCollationDerivation() ==
> StringDataValue.COLLATION_DERIVATION_NONE)
> > + return false;
> > + if (getCollationDerivation() ==
> compareWithDTD.getCollationDerivation() &&
> > + getCollationType() ==
> compareWithDTD.getCollationType())
> > + return true;//collation matches
> > + else
> > + return false;//collation does not match
> > + }
> > +
>
> >
>
>
Re: svn commit: r561494 - in /db/derby/code/trunk/java/engine/org/apache/derby:
iapi/types/DataTypeDescriptor.java impl/sql/compile/LikeEscapeOperatorNode.java
Posted by Daniel John Debrunner <dj...@apache.org>.
mamta@apache.org wrote:
> Author: mamta
> Date: Tue Jul 31 13:29:11 2007
> New Revision: 561494
>
> URL: http://svn.apache.org/viewvc?view=rev&rev=561494
> Log:
> DERBY-2793
>
> Collation comparison algorithm for LIKE is incorrect. Rather than duplicating the code in 2 places, I am including a genric method in DataTypeDescriptor which can be called whenever needed.
>
>
> Modified:
> db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataTypeDescriptor.java
> db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LikeEscapeOperatorNode.java
>
> Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataTypeDescriptor.java
> URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataTypeDescriptor.java?view=diff&rev=561494&r1=561493&r2=561494
> ==============================================================================
> --- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataTypeDescriptor.java (original)
> +++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataTypeDescriptor.java Tue Jul 31 13:29:11 2007
Does this method have any javadoc comments with it? Would be useful to
indicate what exactly its purpose is, as it still doesn't seem to be
implementing the required collation determination from 9.13.
>
> -
> + public boolean compareCollationInfo(DataTypeDescriptor compareWithDTD){
> + //both the operands can not have the collation derivation of
> + //NONE. This is because in that case, we do not know what kind
> + //of collation to use for comparison.
> + if (getCollationDerivation() == compareWithDTD.getCollationDerivation() &&
> + getCollationDerivation() == StringDataValue.COLLATION_DERIVATION_NONE)
> + return false;
> + if (getCollationDerivation() == compareWithDTD.getCollationDerivation() &&
> + getCollationType() == compareWithDTD.getCollationType())
> + return true;//collation matches
> + else
> + return false;//collation does not match
> + }
> +
>