Commit 7e8504b5 authored by Olivier Bertrand's avatar Olivier Bertrand

- Add longjmp initialization in PlgAllocResult

modified:
  storage/connect/plgdbutl.cpp

- Update type translation to take care of type_modifiers

modified:
  storage/connect/ha_connect.cc
  storage/connect/myutil.cpp
  storage/connect/myutil.h
  storage/connect/odbconn.cpp
parent 3a7f4f24
......@@ -3488,25 +3488,45 @@ static bool add_fields(PGLOBAL g,
// void *vcolinfo,
// engine_option_value *create_options,
int flg,
bool dbf)
bool dbf,
char v)
{
register Create_field *new_field;
char *length, *decimals;
enum_field_types type= PLGtoMYSQL(typ, dbf);
char *length, *decimals= NULL;
enum_field_types type;
//Virtual_column_info *vcol_info= (Virtual_column_info *)vcolinfo;
engine_option_value *crop;
LEX_STRING *comment= thd->make_lex_string(rem, strlen(rem));
LEX_STRING *field_name= thd->make_lex_string(name, strlen(name));
LEX_STRING *comment;
LEX_STRING *field_name;
DBUG_ENTER("ha_connect::add_fields");
if (len) {
if (!v && typ == TYPE_STRING && len > 255)
v= 'V'; // Change CHAR to VARCHAR
length= (char*)PlugSubAlloc(g, NULL, 8);
sprintf(length, "%d", len);
if (dec) {
if (typ == TYPE_FLOAT) {
decimals= (char*)PlugSubAlloc(g, NULL, 8);
sprintf(decimals, "%d", dec);
sprintf(decimals, "%d", min(dec, (min(len, 31) - 1)));
} // endif dec
} else
decimals= NULL;
length= NULL;
if (!rem)
rem= "";
type= PLGtoMYSQL(typ, dbf, v);
comment= thd->make_lex_string(rem, strlen(rem));
field_name= thd->make_lex_string(name, strlen(name));
switch (v) {
case 'Z': type_modifier|= ZEROFILL_FLAG;
case 'U': type_modifier|= UNSIGNED_FLAG; break;
} // endswitch v
if (flg) {
engine_option_value *start= NULL, *end= NULL;
......@@ -3552,8 +3572,8 @@ static bool add_field(String *sql, const char *field_name, int typ,
if (!strcmp(type, "DOUBLE")) {
error|= sql->append(',');
// dec must be <= len and <= 31
error|= sql->append_ulonglong(min(dec, (len - 1)));
// dec must be < len and < 31
error|= sql->append_ulonglong(min(dec, (min(len, 31) - 1)));
} // endif dec
error|= sql->append(')');
......@@ -3849,7 +3869,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
TABLE_SHARE *table_s,
HA_CREATE_INFO *create_info)
{
char spc= ',', qch= 0;
char v, spc= ',', qch= 0;
const char *fncn= "?";
const char *user, *fn, *db, *host, *pwd, *sep, *tbl, *src;
const char *col, *ocl, *rnk, *pic, *fcl;
......@@ -3871,7 +3891,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
//CHARSET_INFO *cs;
Alter_info alter_info;
#else // !NEW_WAY
char v, buf[1024];
char buf[1024];
String sql(buf, sizeof(buf), system_charset_info);
sql.copy(STRING_WITH_LEN("CREATE TABLE whatever ("), system_charset_info);
......@@ -3965,7 +3985,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
tab= table_s->table_name.str; // Default value
#if defined(NEW_WAY)
add_option(thd, create_info, "tabname", tab);
// add_option(thd, create_info, "tabname", tab);
#endif // NEW_WAY
} // endif tab
......@@ -4192,10 +4212,11 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
#if defined(NEW_WAY)
// Now add the field
rc= add_fields(g, thd, &alter_info, cnm, typ, len, dec,
NOT_NULL_FLAG, "", flg, dbf);
NOT_NULL_FLAG, "", flg, dbf, 0);
#else // !NEW_WAY
// Now add the field
if (add_field(&sql, cnm, typ, len, dec, NOT_NULL_FLAG, 0, NULL, flg, dbf, 0))
if (add_field(&sql, cnm, typ, len, dec, NOT_NULL_FLAG,
0, NULL, flg, dbf, 0))
rc= HA_ERR_OUT_OF_MEM;
#endif // !NEW_WAY
} // endfor crp
......@@ -4282,8 +4303,8 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
// Now add the field
#if defined(NEW_WAY)
rc= add_fields(g, thd, &alter_info, cnm, typ, len, dec,
tm, rem, 0, true);
rc= add_fields(g, thd, &alter_info, cnm, typ, prec, dec,
tm, rem, 0, dbf, v);
#else // !NEW_WAY
if (add_field(&sql, cnm, typ, prec, dec, tm, rem, dft, 0, dbf, v))
rc= HA_ERR_OUT_OF_MEM;
......
......@@ -84,7 +84,7 @@ int MYSQLtoPLG(char *typname, char *var)
/************************************************************************/
/* Convert from PlugDB type to MySQL type number */
/************************************************************************/
enum enum_field_types PLGtoMYSQL(int type, bool dbf)
enum enum_field_types PLGtoMYSQL(int type, bool dbf, char v)
{
enum enum_field_types mytype;
......@@ -99,10 +99,14 @@ enum enum_field_types PLGtoMYSQL(int type, bool dbf)
mytype = MYSQL_TYPE_DOUBLE;
break;
case TYPE_DATE:
mytype = (dbf) ? MYSQL_TYPE_DATE : MYSQL_TYPE_DATETIME;
mytype = (dbf) ? MYSQL_TYPE_DATE :
(v == 'S') ? MYSQL_TYPE_TIMESTAMP :
(v == 'D') ? MYSQL_TYPE_NEWDATE :
(v == 'T') ? MYSQL_TYPE_TIME :
(v == 'Y') ? MYSQL_TYPE_YEAR : MYSQL_TYPE_DATETIME;
break;
case TYPE_STRING:
mytype = MYSQL_TYPE_VARCHAR;
mytype = (v) ? MYSQL_TYPE_VARCHAR : MYSQL_TYPE_STRING;
break;
case TYPE_BIGINT:
mytype = MYSQL_TYPE_LONGLONG;
......@@ -138,7 +142,7 @@ const char *PLGtoMYSQLtype(int type, bool dbf, char v)
} // endswitch mytype
return "CHAR(0)";
} // end of PLGtoMYSQL
} // end of PLGtoMYSQLtype
/************************************************************************/
/* Convert from MySQL type to PlugDB type number */
......
......@@ -4,8 +4,8 @@
#ifndef __MYUTIL__H
#define __MYUTIL__H
enum enum_field_types PLGtoMYSQL(int type, bool dbf);
const char *PLGtoMYSQLtype(int type, bool dbf, char var = NULL);
enum enum_field_types PLGtoMYSQL(int type, bool dbf, char var = 0);
const char *PLGtoMYSQLtype(int type, bool dbf, char var = 0);
int MYSQLtoPLG(char *typname, char *var = NULL);
int MYSQLtoPLG(int mytype, char *var = NULL);
char *MyDateFmt(int mytype);
......
......@@ -121,7 +121,7 @@ int TranslateSQLType(int stp, int prec, int& len, char& v)
case SQL_LONGVARCHAR: // (-1)
v = 'V';
type = TYPE_STRING;
len = min(abs(len), 255);
len = min(abs(len), 256);
break;
case SQL_NUMERIC: // 2
case SQL_DECIMAL: // 3
......
......@@ -278,6 +278,18 @@ PQRYRES PlgAllocResult(PGLOBAL g, int ncol, int maxres, int ids,
PCOLRES *pcrp, crp;
PQRYRES qrp;
// Save stack and allocation environment and prepare error return
if (g->jump_level == MAX_JUMP) {
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
return NULL;
} // endif jump_level
if (setjmp(g->jumper[++g->jump_level]) != 0) {
printf("%s\n", g->Message);
qrp = NULL;
goto fin;
} // endif rc
/************************************************************************/
/* Allocate the structure used to contain the result set. */
/************************************************************************/
......@@ -342,6 +354,8 @@ PQRYRES PlgAllocResult(PGLOBAL g, int ncol, int maxres, int ids,
*pcrp = NULL;
fin:
g->jump_level--;
return qrp;
} // end of PlgAllocResult
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment