/**
 * 
 */
package testsuite.simple;

import testsuite.BaseTestCase;

/**
 * @author Tonci
 * 
 * VARBINARY <> VAR_STRING + BINARY much like c/NET error in Bug#25605
 *
 *	java.vm.version         : 1.5.0_11-b03
	java.vm.vendor          : Sun Microsystems Inc.
	java.runtime.version    : 1.5.0_11-b03
	os.name                 : Windows XP
	os.version              : 5.1
	sun.management.compiler : HotSpot Client Compiler
	5.0.48-pb1038-log
	MySQL data type: 253(FIELD_TYPE_VAR_STRING)
	
	Thus the result:
	.Loading JDBC driver 'com.mysql.jdbc.Driver'
	Done.

	Done.

	Connected to 5.0.48-pb1038-log
	1 id java.lang.Integer INTEGER 11
	2 value java.lang.String VARCHAR 10

 */
public class TestIssue18970 extends BaseTestCase {

	/**
	 * @param name
	 */
	public TestIssue18970(String name) {
		super(name);
		// TODO Auto-generated constructor stub
	}

	public void testissue18970() throws Exception {

		createTable("i18970_1", "(id int)");
		createTable("i18970_2", "(id int, binaryvalue varbinary(10))");
		
			try {
				this.stmt.executeUpdate("insert into i18970_1 value (1),(2),(3)");
				this.stmt.executeUpdate("insert into i18970_2 value (1,'¢‚¤'),(2,'‚¢‚¤'),(3,' ‚¢¤')");
	    		this.rs = this.stmt.executeQuery("select i18970_1.id, (select i18970_2.binaryvalue from i18970_2 where i18970_2.id=i18970_1.id) as value from i18970_1");
	    		java.sql.ResultSetMetaData tblMD = this.rs.getMetaData();
	    	
	    		for (int i=1; i<tblMD.getColumnCount()+1; i++)
	    		{	
	    			System.out.println(i + " " + tblMD.getColumnName(i) + " " +
	    					tblMD.getColumnClassName(i) + " " + tblMD.getColumnTypeName(i) + " " +
	    					new Integer(tblMD.getColumnDisplaySize(i)));
	    			switch (i) {
	    			case 1: 
	    				assertEquals(tblMD.getColumnTypeName(i).toUpperCase(),"INTEGER");
	    				break;
	    			case 2: 
	    				assertEquals(tblMD.getColumnTypeName(i).toUpperCase(),"VARBINARY");
	    				break;
	    			}
	    		}    		
				
			} finally {
				closeMemberJDBCResources();
			}
		}	
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		junit.textui.TestRunner.run(TestIssue18970.class);
	}

}
