// TestCase14165.cpp : Defines the entry point for the console application.
//

#include <stdio.h>

#include <my_global.h>
#include <mysql.h>


int main(int argc, char* argv[])
{
	MYSQL *mysql;

	char* server_options[] = {
		"mysql-test",
		"--datadir=C:\\Projekte\\jose\\mysql-je\\data",
		"--basedir=C:\\Projekte\\mysql-5.0.16",
		"--skip-bdb",
		"--skip-innodb",
		"--skip-grant-tables",
		"--skip-name-resolve",
		"--skip-external-locking",
		"--skip-locking",
		"--default-character-set=utf8",
		"--default-collation=utf8_general_ci",
	};

   mysql_server_init(11, server_options, NULL);
   mysql = mysql_init(NULL);
   mysql_options(mysql, MYSQL_READ_DEFAULT_GROUP, "libmysqld_client");
   mysql_options(mysql, MYSQL_OPT_USE_EMBEDDED_CONNECTION, NULL);

   mysql_real_connect(mysql, NULL,NULL,NULL, "Test", 0,NULL,0);

   printf("%s \n", mysql_get_server_info(mysql));

   mysql_query(mysql, "DROP FUNCTION IF EXISTS simplepi");
   mysql_query(mysql, "CREATE FUNCTION simplepi() RETURNS DOUBLE RETURN 3.141");

   int eno = mysql_errno(mysql);
   const char* error = mysql_error(mysql);
   const char* sqlstate = mysql_sqlstate(mysql);
	
   printf("%i: %s (%s)\n", eno, error, sqlstate);

   mysql_close(mysql);
   mysql_server_end();

   return 0;
}

