Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 347164

Summary: Ingres's implementation of SQLDevToolsConfiguration.recognize() method uses indexOf() instead of string compare.
Product: [Tools] Data Tools Reporter: Barry LaFond <blafond>
Component: EnablementAssignee: Brian Fitzpatrick <bfitzpat>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 1.7.2   
Target Milestone: 1.9   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Patch of Ingres DB config none

Description Barry LaFond CLA 2011-05-25 10:37:02 EDT
Build Identifier: 1.7.2.v20100914-1028

JBoss's Teiid Designer extends SQLDevToolsConfiguration and implements it's own recognize() method.

However the ID = "Teiid" will return TRUE for Ingres's recognize() method because they have a PRODUCT ID containing "II" and their recognize() method uses an indexOf() call instead of a pure string compare. 

Reproducible: Always

Steps to Reproduce:
Requires running full runtime version of Teiid Designer

See http://www.jboss.org/teiiddesigner
Comment 1 Brian Fitzpatrick CLA 2011-05-25 10:39:45 EDT
I'll take a look at this...
Comment 2 Brian Fitzpatrick CLA 2011-05-25 12:05:18 EDT
Barry, I'm looking at the code here:

	private static final String[] PRODUCTS = { "Ingres", "II" };

        ...

	public boolean recognize(String product, String version) {
		// TODO extract version from supplied string
		// example product="INGRES" and version="0.1.0.w32/115)"
		if (product != null) {
			String formattedProduct = format(product);
			for (int i = 0; i < PRODUCTS.length; i++) {
				if (formattedProduct.indexOf(format(PRODUCTS[i])) > -1) {
					return true;
				}
			}
		}
		return false;
	}

Obviously indexOf isn't the right approach since it's lowercasing the string and then looking for "ii". I don't have Ingres installed. Can you tell me what the actual product strings are that get returned and processed by this method? Specifically one with "Ingres" in it and another with "II" in it vs. what you get back from Teiid...
Comment 3 Barry LaFond CLA 2011-05-25 14:44:00 EDT
Teiid's recognize() method values:

product = "Teiid Server"
version = "x"

IngresDBConfiguration.recognize() is returning TRUE for that product/version also.


** additional concern **
Seems like SQLToolsFacade.getDeclaredDatabaseVendorDefinitionId() is finding 2 ids and the if( ids.size() > 0 ) then it ends up returning the first one if other compares fail. (line 364 in my code)

That logic seems a little strange too.
Comment 4 Brian Fitzpatrick CLA 2011-05-26 11:30:35 EDT
Created attachment 196673 [details]
Patch of Ingres DB config

This patch changes the Ingres IngresDBConfiguration class a bit to resolve the issue. It should work to support both Ingres and Teiid.
Comment 5 Brian Fitzpatrick CLA 2011-05-26 14:16:05 EDT
Committed change minus the last comparison in the patch. If this causes issues for Ingres with the "II" version, we can resolve in the dot release in November, but it seemed to work on our end. I was unable to get in touch with any of my previous contacts at Ingres to confirm, so please let us know if there are issues.

Tagged in HEAD in org.eclipse.datatools.enablement.ingres.ui as v201105270214