Commit d05ccc23 authored by Olivier Bertrand's avatar Olivier Bertrand

- Add extra column info in discovery

modified:
  storage/connect/ha_connect.cc
  storage/connect/myconn.cpp
  storage/connect/odbconn.cpp
  storage/connect/plgdbsem.h
parent d253599b
...@@ -3555,7 +3555,7 @@ static bool add_fields(PGLOBAL g, ...@@ -3555,7 +3555,7 @@ static bool add_fields(PGLOBAL g,
#else // !NEW_WAY #else // !NEW_WAY
static bool add_field(String *sql, const char *field_name, int typ, static bool add_field(String *sql, const char *field_name, int typ,
int len, int dec, uint tm, const char *rem, int len, int dec, uint tm, const char *rem,
char *dft, int flag, bool dbf, char v) char *dft, char *xtra, int flag, bool dbf, char v)
{ {
char var = (len > 255) ? 'V' : v; char var = (len > 255) ? 'V' : v;
bool error= false; bool error= false;
...@@ -3597,6 +3597,11 @@ static bool add_field(String *sql, const char *field_name, int typ, ...@@ -3597,6 +3597,11 @@ static bool add_field(String *sql, const char *field_name, int typ,
} else } else
error|= sql->append(dft); error|= sql->append(dft);
} // endif dft
if (xtra && *xtra) {
error|= sql->append(" ");
error|= sql->append(xtra);
} // endif rem } // endif rem
if (rem && *rem) { if (rem && *rem) {
...@@ -4106,7 +4111,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, ...@@ -4106,7 +4111,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
} // endif src } // endif src
if (ok) { if (ok) {
char *cnm, *rem, *dft; char *cnm, *rem, *dft, *xtra;
int i, len, prec, dec, typ, flg; int i, len, prec, dec, typ, flg;
PDBUSER dup= PlgGetUser(g); PDBUSER dup= PlgGetUser(g);
PCATLG cat= (dup) ? dup->Catalog : NULL; PCATLG cat= (dup) ? dup->Catalog : NULL;
...@@ -4217,7 +4222,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, ...@@ -4217,7 +4222,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
#else // !NEW_WAY #else // !NEW_WAY
// Now add the field // Now add the field
if (add_field(&sql, cnm, typ, len, dec, NOT_NULL_FLAG, if (add_field(&sql, cnm, typ, len, dec, NOT_NULL_FLAG,
0, NULL, flg, dbf, 0)) NULL, NULL, NULL, flg, dbf, 0))
rc= HA_ERR_OUT_OF_MEM; rc= HA_ERR_OUT_OF_MEM;
#endif // !NEW_WAY #endif // !NEW_WAY
} // endfor crp } // endfor crp
...@@ -4227,7 +4232,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, ...@@ -4227,7 +4232,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
typ= len= prec= dec= 0; typ= len= prec= dec= 0;
tm= NOT_NULL_FLAG; tm= NOT_NULL_FLAG;
cnm= (char*)"noname"; cnm= (char*)"noname";
dft= NULL; dft= xtra= NULL;
#if defined(NEW_WAY) #if defined(NEW_WAY)
rem= ""; rem= "";
// cs= NULL; // cs= NULL;
...@@ -4271,6 +4276,9 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, ...@@ -4271,6 +4276,9 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
case FLD_DEFAULT: case FLD_DEFAULT:
dft= crp->Kdata->GetCharValue(i); dft= crp->Kdata->GetCharValue(i);
break; break;
case FLD_EXTRA:
xtra= crp->Kdata->GetCharValue(i);
break;
default: default:
break; // Ignore break; // Ignore
} // endswitch Fld } // endswitch Fld
...@@ -4307,7 +4315,8 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, ...@@ -4307,7 +4315,8 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
rc= add_fields(g, thd, &alter_info, cnm, typ, prec, dec, rc= add_fields(g, thd, &alter_info, cnm, typ, prec, dec,
tm, rem, 0, dbf, v); tm, rem, 0, dbf, v);
#else // !NEW_WAY #else // !NEW_WAY
if (add_field(&sql, cnm, typ, prec, dec, tm, rem, dft, 0, dbf, v)) if (add_field(&sql, cnm, typ, prec, dec, tm, rem, dft, xtra,
0, dbf, v))
rc= HA_ERR_OUT_OF_MEM; rc= HA_ERR_OUT_OF_MEM;
#endif // !NEW_WAY #endif // !NEW_WAY
} // endfor i } // endfor i
......
...@@ -65,13 +65,15 @@ PQRYRES MyColumns(PGLOBAL g, const char *host, const char *db, ...@@ -65,13 +65,15 @@ PQRYRES MyColumns(PGLOBAL g, const char *host, const char *db,
const char *table, const char *colpat, const char *table, const char *colpat,
int port, bool info) int port, bool info)
{ {
static int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING, TYPE_INT, int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING, TYPE_INT,
TYPE_STRING, TYPE_SHORT, TYPE_SHORT, TYPE_SHORT, TYPE_STRING, TYPE_SHORT, TYPE_SHORT, TYPE_SHORT,
TYPE_STRING, TYPE_STRING, TYPE_STRING, TYPE_STRING}; TYPE_STRING, TYPE_STRING, TYPE_STRING, TYPE_STRING,
static XFLD fldtyp[] = {FLD_NAME, FLD_TYPE, FLD_TYPENAME, FLD_PREC, TYPE_STRING};
FLD_KEY, FLD_SCALE, FLD_RADIX, FLD_NULL, XFLD fldtyp[] = {FLD_NAME, FLD_TYPE, FLD_TYPENAME, FLD_PREC,
FLD_REM, FLD_NO, FLD_DEFAULT, FLD_CHARSET}; FLD_KEY, FLD_SCALE, FLD_RADIX, FLD_NULL,
static unsigned int length[] = {0, 4, 16, 4, 4, 4, 4, 4, 0, 32, 0, 32}; FLD_REM, FLD_NO, FLD_DEFAULT, FLD_EXTRA,
FLD_CHARSET};
unsigned int length[] = {0, 4, 16, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0};
char *fld, *fmt, v, cmd[128], uns[16], zero[16]; char *fld, *fmt, v, cmd[128], uns[16], zero[16];
int i, n, nf, ncol = sizeof(buftyp) / sizeof(int); int i, n, nf, ncol = sizeof(buftyp) / sizeof(int);
int len, type, prec, rc, k = 0; int len, type, prec, rc, k = 0;
...@@ -110,7 +112,7 @@ PQRYRES MyColumns(PGLOBAL g, const char *host, const char *db, ...@@ -110,7 +112,7 @@ PQRYRES MyColumns(PGLOBAL g, const char *host, const char *db,
/* Get the size of the name and default columns. */ /* Get the size of the name and default columns. */
/********************************************************************/ /********************************************************************/
length[0] = myc.GetFieldLength(0); length[0] = myc.GetFieldLength(0);
length[10] = myc.GetFieldLength(5); // length[10] = myc.GetFieldLength(5);
} else { } else {
n = 0; n = 0;
length[0] = 128; length[0] = 128;
...@@ -130,7 +132,9 @@ PQRYRES MyColumns(PGLOBAL g, const char *host, const char *db, ...@@ -130,7 +132,9 @@ PQRYRES MyColumns(PGLOBAL g, const char *host, const char *db,
case 4: crp->Name = "Length"; break; case 4: crp->Name = "Length"; break;
case 5: crp->Name = "Key"; break; case 5: crp->Name = "Key"; break;
case 10: crp->Name = "Date_fmt"; break; case 10: crp->Name = "Date_fmt"; break;
case 11: crp->Name = "Collation"; break; case 11: crp->Name = "Default"; break;
case 12: crp->Name = "Extra"; break;
case 13: crp->Name = "Collation"; break;
} // endswitch i } // endswitch i
if (info) if (info)
...@@ -224,12 +228,17 @@ PQRYRES MyColumns(PGLOBAL g, const char *host, const char *db, ...@@ -224,12 +228,17 @@ PQRYRES MyColumns(PGLOBAL g, const char *host, const char *db,
crp->Kdata->SetValue(fld, i); crp->Kdata->SetValue(fld, i);
crp = crp->Next; // Date format crp = crp->Next; // Date format
crp->Kdata->SetValue((fmt) ? fmt : (char*) "", i); // crp->Kdata->SetValue((fmt) ? fmt : (char*) "", i);
crp->Kdata->SetValue(fmt, i);
crp = crp->Next; // New (default) crp = crp->Next; // New (default)
fld = myc.GetCharField(5); fld = myc.GetCharField(5);
crp->Kdata->SetValue(fld, i); crp->Kdata->SetValue(fld, i);
crp = crp->Next; // New (extra)
fld = myc.GetCharField(6);
crp->Kdata->SetValue(fld, i);
crp = crp->Next; // New (charset) crp = crp->Next; // New (charset)
fld = myc.GetCharField(2); fld = myc.GetCharField(2);
crp->Kdata->SetValue(fld, i); crp->Kdata->SetValue(fld, i);
......
...@@ -287,9 +287,9 @@ PQRYRES ODBCColumns(PGLOBAL g, char *dsn, char *db, char *table, ...@@ -287,9 +287,9 @@ PQRYRES ODBCColumns(PGLOBAL g, char *dsn, char *db, char *table,
int buftyp[] = {TYPE_STRING, TYPE_STRING, TYPE_STRING, TYPE_STRING, int buftyp[] = {TYPE_STRING, TYPE_STRING, TYPE_STRING, TYPE_STRING,
TYPE_SHORT, TYPE_STRING, TYPE_INT, TYPE_INT, TYPE_SHORT, TYPE_STRING, TYPE_INT, TYPE_INT,
TYPE_SHORT, TYPE_SHORT, TYPE_SHORT, TYPE_STRING}; TYPE_SHORT, TYPE_SHORT, TYPE_SHORT, TYPE_STRING};
XFLD fldtyp[] = {FLD_QUALIF, FLD_OWNER, FLD_TABNAME, FLD_NAME, XFLD fldtyp[] = {FLD_CAT, FLD_SCHEM, FLD_TABNAME, FLD_NAME,
FLD_TYPE, FLD_TYPENAME, FLD_PREC, FLD_LENGTH, FLD_TYPE, FLD_TYPENAME, FLD_PREC, FLD_LENGTH,
FLD_SCALE, FLD_RADIX, FLD_NULL, FLD_REM}; FLD_SCALE, FLD_RADIX, FLD_NULL, FLD_REM};
unsigned int length[] = {0, 0, 0, 0, 6, 0, 10, 10, 6, 6, 6, 0}; unsigned int length[] = {0, 0, 0, 0, 6, 0, 10, 10, 6, 6, 6, 0};
int n, ncol = 12; int n, ncol = 12;
PQRYRES qrp; PQRYRES qrp;
...@@ -565,8 +565,8 @@ PQRYRES ODBCTables(PGLOBAL g, char *dsn, char *db, char *tabpat, ...@@ -565,8 +565,8 @@ PQRYRES ODBCTables(PGLOBAL g, char *dsn, char *db, char *tabpat,
{ {
int buftyp[] = {TYPE_STRING, TYPE_STRING, TYPE_STRING, int buftyp[] = {TYPE_STRING, TYPE_STRING, TYPE_STRING,
TYPE_STRING, TYPE_STRING}; TYPE_STRING, TYPE_STRING};
XFLD fldtyp[] = {FLD_QUALIF, FLD_OWNER, FLD_NAME, XFLD fldtyp[] = {FLD_CAT, FLD_SCHEM, FLD_NAME,
FLD_TYPE, FLD_REM}; FLD_TYPE, FLD_REM};
unsigned int length[] = {0, 0, 0, 16, 0}; unsigned int length[] = {0, 0, 0, 16, 0};
int n, ncol = 5; int n, ncol = 5;
PQRYRES qrp; PQRYRES qrp;
......
...@@ -496,11 +496,12 @@ enum XFLD {FLD_NO = 0, /* Not a field definition item */ ...@@ -496,11 +496,12 @@ enum XFLD {FLD_NO = 0, /* Not a field definition item */
FLD_CHARSET = 10, /* Field collation */ FLD_CHARSET = 10, /* Field collation */
FLD_KEY = 11, /* Field key property */ FLD_KEY = 11, /* Field key property */
FLD_DEFAULT = 12, /* Field default value */ FLD_DEFAULT = 12, /* Field default value */
FLD_PRIV = 13, /* Field priviledges */ FLD_EXTRA = 13, /* Field extra info */
FLD_DATEFMT = 14, /* Field date format */ FLD_PRIV = 14, /* Field priviledges */
FLD_QUALIF = 15, /* Table qualifier */ FLD_DATEFMT = 15, /* Field date format */
FLD_OWNER = 16, /* Table owner */ FLD_CAT = 16, /* Table catalog */
FLD_TABNAME = 17}; /* Column Table name */ FLD_SCHEM = 17, /* Table schema */
FLD_TABNAME = 18}; /* Column Table name */
/***********************************************************************/ /***********************************************************************/
/* Result of last SQL noconv query. */ /* Result of last SQL noconv query. */
......
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