Thank for the reminder. I did notice your patch. I would review it when I get a chance.
Thomas -----Original Message----- >From: Matthew Baird [mailto:[EMAIL PROTECTED]] >Sent: Tuesday, December 18, 2001 1:53 PM >To: [EMAIL PROTECTED] >Subject: Re: [castor-dev] patch: oracle and buildTableAlias > >REPOST > >-----Original Message----- >From: Matthew Baird [mailto:[EMAIL PROTECTED]] >Sent: Monday, December 10, 2001 2:33 PM >To: [EMAIL PROTECTED] >Subject: [castor-dev] patch: oracle and buildTableAlias > > >Hi, I reported a bug a while ago that affected Oracle users when their >table >lengths got close to 30 (limit in oracle). The buildTableAlias routine >in >parsetreewalker would append an underscore and a number (dependant on >how >many tables in your query). This had a chance of making your table alias >name longer than 30 characters which would cause failures in Oracle. > >I played around with making this an 'if-oracle do this' type patch, but >no >luck. Maybe in the future. For now, this patch does the following: > >- check the name + the _ + the index is not longer than 30 >- if so, truncate the tableName by the approprite number of characters >- add the _ and the number to the end of the truncated table name. > >this should work in all cases, and only has the side effect that if you >have >a set of long table names that only differ in the characters AFTER the >~28 >characters, you will lose that data (only affects read-ability of query, >query will still execute correctly). > >We've been using this patch in production (with both SQL Server and >Oracle >and 300+ tables.) for 2 months with no problems. > >following is the diff -u just the way Thomas likes it. > >thanks, >Matthew > > >--- ParseTreeWalker.java.orig Mon Dec 10 06:16:00 2001 >+++ ParseTreeWalker.java Mon Dec 10 06:16:00 2001 >@@ -101,6 +101,7 @@ > public static final int DEPENDANT_OBJECT_VALUE = 5; > public static final int DEPENDANT_VALUE = 6; > >+ public static final int MAX_TABLE_LENGTH = 30; > > /** > * Creates a new parse tree walker. Which checks the tree for >errors, >and >@@ -873,6 +874,20 @@ > } else { > index = i.intValue(); > } >+ // fix for oracle support. If we have a 30 character table >name, >adding >+ // anything to it (_#) will cause it to be too long and will >make >oracle >+ // barf. the length we are trying to evaluate is: >+ // length of the table name + the length of the index number >we >are using >+ // + the _ character. >+ String stringIndex = String.valueOf(index); >+ if(tableAlias.length() + stringIndex.length() + 1 > >MAX_TABLE_LENGTH) { >+ // use a substring of the original table name, rather >than >the table alias >+ // because if we truncate the table alias it could become >"ununique" >+ // (by truncating the _# we add) by truncating the table >name >+ // beforehand we are guaranteed uniqueness as long as the >index is >+ // not reused. >+ tableAlias = tableAlias.substring(MAX_TABLE_LENGTH - >(stringIndex.length() + 1)); >+ } > // If table name contains '.', it should be replaced, since >such >names aren't allowed for aliases > tableAlias = tableAlias.replace('.', '_') + "_" + index; > } >@@ -941,7 +956,7 @@ > if ( i > 1 ) { > manyTableAlias = buildTableAlias( manyTableAlias, >path, >i - 1 ); > sourceTableAlias = buildTableAlias( >sourceTableAlias, >path, i - 1 ); >- } >+ } > > _queryExpr.addInnerJoin( sourceClass.getTableName(), > identity.getSQLName(), > >-- > >----------------------------------------------------------- >If you wish to unsubscribe from this mailing, send mail to >[EMAIL PROTECTED] with a subject of: > unsubscribe castor-dev > >----------------------------------------------------------- >If you wish to unsubscribe from this mailing, send mail to >[EMAIL PROTECTED] with a subject of: > unsubscribe castor-dev > ----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to [EMAIL PROTECTED] with a subject of: unsubscribe castor-dev
