Issue Details (XML | Word | Printable)

Key: DERBY-2591
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Bernt M. Johnsen
Reporter: Bernt M. Johnsen
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Derby

DataDictionaryImpl.getSystemSQLName() may generate duplicates

Created: 25/Apr/07 01:39 PM   Updated: 27/Apr/07 02:10 PM
Return to search
Component/s: SQL
Affects Version/s: None
Fix Version/s: 10.3.1.4

Time Tracking:
Not Specified

File Attachments:
  Size
File DERBY-2591.diff 2007-04-25 01:42 PM Bernt M. Johnsen 1 kB

Resolution Date: 26/Apr/07 12:23 PM


 Description  « Hide
DataDictionaryImpl.getSystemSQLName() may generates names on the form SQLYYMMDDHHMMSSmmN where mm is in 10 milliseconds and N is number to avoid collisions with 10 milliseconds. The name was probably generated this way to fit into the 18 caharcter limit of constraint names in older derby versions. However, if a getSystemSQLName() is called 12 hours after a call on the same date (e.g at 01:00:00 and 13:00:00), which is unlikely but not very unlikely, a duplicate name is generated, since the HH-part is filled by the call
generatedSystemSQLName.append(twoDigits(calendarForLastSystemSQLName.get(Calendar.HOUR)));
and Calendar.HOUR implementes the pretty stupid idea that there are only 12 hours. It was definitely Calendar.HOUR_OF_DAY which gives you the hour for a 24-hour clock that should have been used.



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Bernt M. Johnsen added a comment - 25/Apr/07 01:42 PM
Attatched a patch. Is a review really needed for this fix?????? ;-)

Bernt M. Johnsen added a comment - 25/Apr/07 02:15 PM
BTW: Since only two digits is used for YY, there is also a risk for collisions in a 100-year cycle (remember Y2K anyone?). This is not fixed by the attached patch.

Bernt M. Johnsen added a comment - 26/Apr/07 12:23 PM
Committed revision 532723.