Commit ece56ac5 authored by Sergei Golubchik's avatar Sergei Golubchik

merge 10.0-connect

parents a6e5ac22 ec906f92
......@@ -228,7 +228,7 @@ PQRYRES DBFColumns(PGLOBAL g, const char *fn, BOOL info)
qrp = PlgAllocResult(g, ncol, fields, IDS_COLUMNS + 3,
buftyp, fldtyp, length, true, false);
if (info)
if (info || !qrp)
return qrp;
if (trace) {
......
......@@ -165,7 +165,7 @@ extern "C" char nmfile[];
extern "C" char pdebug[];
extern "C" {
char version[]= "Version 1.01.0010 November 30, 2013";
char version[]= "Version 1.01.0011 December 15, 2013";
#if defined(XMSG)
char msglang[]; // Default message language
......@@ -3555,7 +3555,7 @@ static bool add_fields(PGLOBAL g,
#else // !NEW_WAY
static bool add_field(String *sql, const char *field_name, int typ,
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;
bool error= false;
......@@ -3597,6 +3597,11 @@ static bool add_field(String *sql, const char *field_name, int typ,
} else
error|= sql->append(dft);
} // endif dft
if (xtra && *xtra) {
error|= sql->append(" ");
error|= sql->append(xtra);
} // endif rem
if (rem && *rem) {
......@@ -3873,11 +3878,11 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
const char *fncn= "?";
const char *user, *fn, *db, *host, *pwd, *sep, *tbl, *src;
const char *col, *ocl, *rnk, *pic, *fcl;
char *tab, *dsn;
char *tab, *dsn, *shm;
#if defined(WIN32)
char *nsp= NULL, *cls= NULL;
#endif // WIN32
int port= 0, hdr= 0, mxr= 0, rc= 0;
int port= 0, hdr= 0, mxr= 0, mxe= 0, rc= 0;
int cop __attribute__((unused)) = 0;
uint tm, fnc= FNC_NO, supfnc= (FNC_NO | FNC_COL);
bool bif, ok= false, dbf= false;
......@@ -3933,7 +3938,8 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
cls= GetListOption(g, "class", topt->oplist);
#endif // WIN32
port= atoi(GetListOption(g, "port", topt->oplist, "0"));
mxr= atoi(GetListOption(g,"maxerr", topt->oplist, "0"));
mxr= atoi(GetListOption(g,"maxres", topt->oplist, "0"));
mxe= atoi(GetListOption(g,"maxerr", topt->oplist, "0"));
#if defined(PROMPT_OK)
cop= atoi(GetListOption(g, "checkdsn", topt->oplist, "0"));
#endif // PROMPT_OK
......@@ -3942,7 +3948,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
user= "root";
} // endif option_list
if (!db)
if (!(shm= (char*)db))
db= table_s->db.str; // Default value
// Check table type
......@@ -4105,7 +4111,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
} // endif src
if (ok) {
char *cnm, *rem, *dft;
char *cnm, *rem, *dft, *xtra;
int i, len, prec, dec, typ, flg;
PDBUSER dup= PlgGetUser(g);
PCATLG cat= (dup) ? dup->Catalog : NULL;
......@@ -4137,17 +4143,17 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
qrp= ODBCSrcCols(g, dsn, (char*)src);
src= NULL; // for next tests
} else
qrp= ODBCColumns(g, dsn, (char *) tab, NULL, fnc == FNC_COL);
qrp= ODBCColumns(g, dsn, shm, tab, NULL, mxr, fnc == FNC_COL);
break;
case FNC_TABLE:
qrp= ODBCTables(g, dsn, (char *) tab, true);
qrp= ODBCTables(g, dsn, shm, tab, mxr, true);
break;
case FNC_DSN:
qrp= ODBCDataSources(g, true);
qrp= ODBCDataSources(g, mxr, true);
break;
case FNC_DRIVER:
qrp= ODBCDrivers(g, true);
qrp= ODBCDrivers(g, mxr, true);
break;
default:
sprintf(g->Message, "invalid catfunc %s", fncn);
......@@ -4163,7 +4169,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
break;
#endif // MYSQL_SUPPORT
case TAB_CSV:
qrp= CSVColumns(g, fn, spc, qch, hdr, mxr, fnc == FNC_COL);
qrp= CSVColumns(g, fn, spc, qch, hdr, mxe, fnc == FNC_COL);
break;
#if defined(WIN32)
case TAB_WMI:
......@@ -4216,7 +4222,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
#else // !NEW_WAY
// Now add the field
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;
#endif // !NEW_WAY
} // endfor crp
......@@ -4226,7 +4232,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
typ= len= prec= dec= 0;
tm= NOT_NULL_FLAG;
cnm= (char*)"noname";
dft= NULL;
dft= xtra= NULL;
#if defined(NEW_WAY)
rem= "";
// cs= NULL;
......@@ -4270,6 +4276,9 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
case FLD_DEFAULT:
dft= crp->Kdata->GetCharValue(i);
break;
case FLD_EXTRA:
xtra= crp->Kdata->GetCharValue(i);
break;
default:
break; // Ignore
} // endswitch Fld
......@@ -4306,7 +4315,8 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
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))
if (add_field(&sql, cnm, typ, prec, dec, tm, rem, dft, xtra,
0, dbf, v))
rc= HA_ERR_OUT_OF_MEM;
#endif // !NEW_WAY
} // endfor i
......@@ -4813,7 +4823,7 @@ maria_declare_plugin(connect)
&connect_storage_engine,
"CONNECT",
"Olivier Bertrand",
"Direct access to external data, including many file formats",
"Management of External Data (SQL/MED), including many file formats",
PLUGIN_LICENSE_GPL,
connect_init_func, /* Plugin Init */
connect_done_func, /* Plugin Deinit */
......@@ -4821,6 +4831,6 @@ maria_declare_plugin(connect)
NULL, /* status variables */
NULL, /* system variables */
"0.1", /* string version */
MariaDB_PLUGIN_MATURITY_ALPHA /* maturity */
MariaDB_PLUGIN_MATURITY_BETA /* maturity */
}
maria_declare_plugin_end;
......@@ -65,13 +65,15 @@ PQRYRES MyColumns(PGLOBAL g, const char *host, const char *db,
const char *table, const char *colpat,
int port, bool info)
{
static int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING, TYPE_INT,
TYPE_STRING, TYPE_SHORT, TYPE_SHORT, TYPE_SHORT,
TYPE_STRING, TYPE_STRING, TYPE_STRING, TYPE_STRING};
static XFLD fldtyp[] = {FLD_NAME, FLD_TYPE, FLD_TYPENAME, FLD_PREC,
FLD_KEY, FLD_SCALE, FLD_RADIX, FLD_NULL,
FLD_REM, FLD_NO, FLD_DEFAULT, FLD_CHARSET};
static unsigned int length[] = {0, 4, 16, 4, 4, 4, 4, 4, 0, 32, 0, 32};
int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING, TYPE_INT,
TYPE_STRING, TYPE_SHORT, TYPE_SHORT, TYPE_SHORT,
TYPE_STRING, TYPE_STRING, TYPE_STRING, TYPE_STRING,
TYPE_STRING};
XFLD fldtyp[] = {FLD_NAME, FLD_TYPE, FLD_TYPENAME, FLD_PREC,
FLD_KEY, FLD_SCALE, FLD_RADIX, FLD_NULL,
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];
int i, n, nf, ncol = sizeof(buftyp) / sizeof(int);
int len, type, prec, rc, k = 0;
......@@ -110,7 +112,7 @@ PQRYRES MyColumns(PGLOBAL g, const char *host, const char *db,
/* Get the size of the name and default columns. */
/********************************************************************/
length[0] = myc.GetFieldLength(0);
length[10] = myc.GetFieldLength(5);
// length[10] = myc.GetFieldLength(5);
} else {
n = 0;
length[0] = 128;
......@@ -119,8 +121,9 @@ PQRYRES MyColumns(PGLOBAL g, const char *host, const char *db,
/**********************************************************************/
/* Allocate the structures used to refer to the result set. */
/**********************************************************************/
qrp = PlgAllocResult(g, ncol, n, IDS_COLUMNS + 3,
buftyp, fldtyp, length, false, true);
if (!(qrp = PlgAllocResult(g, ncol, n, IDS_COLUMNS + 3,
buftyp, fldtyp, length, false, true)))
return NULL;
// Some columns must be renamed
for (i = 0, crp = qrp->Colresp; crp; crp = crp->Next)
......@@ -129,7 +132,9 @@ PQRYRES MyColumns(PGLOBAL g, const char *host, const char *db,
case 4: crp->Name = "Length"; break;
case 5: crp->Name = "Key"; 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
if (info)
......@@ -223,12 +228,17 @@ PQRYRES MyColumns(PGLOBAL g, const char *host, const char *db,
crp->Kdata->SetValue(fld, i);
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)
fld = myc.GetCharField(5);
crp->Kdata->SetValue(fld, i);
crp = crp->Next; // New (extra)
fld = myc.GetCharField(6);
crp->Kdata->SetValue(fld, i);
crp = crp->Next; // New (charset)
fld = myc.GetCharField(2);
crp->Kdata->SetValue(fld, i);
......
......@@ -20,28 +20,28 @@ CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CATFUNC=Tables CONNECTION='Not im
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`Table_Qualifier` char(128) NOT NULL,
`Table_Owner` char(128) NOT NULL,
`Table_Cat` char(128) NOT NULL,
`Table_Schema` char(128) NOT NULL,
`Table_Name` char(128) NOT NULL,
`Table_Type` char(16) NOT NULL,
`Remark` char(128) NOT NULL
`Remark` char(255) NOT NULL
) ENGINE=CONNECT DEFAULT CHARSET=latin1 CONNECTION='Not important' `TABLE_TYPE`='ODBC' `CATFUNC`='Tables'
DROP TABLE t1;
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CATFUNC=Columns CONNECTION='Not important';
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`Table_Qualif` char(128) NOT NULL,
`Table_Owner` char(128) NOT NULL,
`Table_Cat` char(128) NOT NULL,
`Table_Schema` char(128) NOT NULL,
`Table_Name` char(128) NOT NULL,
`Column_Name` char(128) NOT NULL,
`Data_Type` smallint(6) NOT NULL,
`Type_Name` char(20) NOT NULL,
`Precision` int(10) NOT NULL,
`Length` int(10) NOT NULL,
`Scale` smallint(6) NOT NULL,
`Type_Name` char(30) NOT NULL,
`Column_Size` int(10) NOT NULL,
`Buffer_Length` int(10) NOT NULL,
`Decimal_Digits` smallint(6) NOT NULL,
`Radix` smallint(6) NOT NULL,
`Nullable` smallint(6) NOT NULL,
`Remarks` char(128) NOT NULL
`Remarks` char(255) NOT NULL
) ENGINE=CONNECT DEFAULT CHARSET=latin1 CONNECTION='Not important' `TABLE_TYPE`='ODBC' `CATFUNC`='Columns'
DROP TABLE t1;
......@@ -10,8 +10,8 @@ SET NAMES utf8;
# All tables in all schemas
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' CATFUNC=Tables;
SELECT * FROM t1 ORDER BY Table_Owner, Table_Name;
Table_Qualifier Table_Owner Table_Name Table_Type Remark
SELECT * FROM t1 ORDER BY Table_Schema, Table_Name;
Table_Cat Table_Schema Table_Name Table_Type Remark
mtr public t1 TABLE
mtr public t2 TABLE
mtr public v1 VIEW
......@@ -21,8 +21,8 @@ mtr schema1 v1 VIEW
DROP TABLE t1;
# All tables in all schemas
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' CATFUNC=Tables TABNAME='%.%.%';
SELECT * FROM t1 ORDER BY Table_Owner, Table_Name;
Table_Qualifier Table_Owner Table_Name Table_Type Remark
SELECT * FROM t1 ORDER BY Table_Schema, Table_Name;
Table_Cat Table_Schema Table_Name Table_Type Remark
mtr public t1 TABLE
mtr public t2 TABLE
mtr public v1 VIEW
......@@ -32,8 +32,8 @@ mtr schema1 v1 VIEW
DROP TABLE t1;
# All tables in all schemas
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' CATFUNC=Tables TABNAME='%.%';
SELECT * FROM t1 ORDER BY Table_Owner, Table_Name;
Table_Qualifier Table_Owner Table_Name Table_Type Remark
SELECT * FROM t1 ORDER BY Table_Schema, Table_Name;
Table_Cat Table_Schema Table_Name Table_Type Remark
mtr public t1 TABLE
mtr public t2 TABLE
mtr public v1 VIEW
......@@ -43,48 +43,48 @@ mtr schema1 v1 VIEW
DROP TABLE t1;
# All tables in the default schema ("public")
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' CATFUNC=Tables TABNAME='%';
SELECT * FROM t1 ORDER BY Table_Owner, Table_Name;
Table_Qualifier Table_Owner Table_Name Table_Type Remark
SELECT * FROM t1 ORDER BY Table_Schema, Table_Name;
Table_Cat Table_Schema Table_Name Table_Type Remark
mtr public t1 TABLE
mtr public t2 TABLE
mtr public v1 VIEW
DROP TABLE t1;
# All tables "t1" in all schemas
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' CATFUNC=Tables TABNAME='%.%.t1';
SELECT * FROM t1 ORDER BY Table_Owner, Table_Name;
Table_Qualifier Table_Owner Table_Name Table_Type Remark
SELECT * FROM t1 ORDER BY Table_Schema, Table_Name;
Table_Cat Table_Schema Table_Name Table_Type Remark
mtr public t1 TABLE
mtr schema1 t1 TABLE
DROP TABLE t1;
# All tables "t1" in all schemas
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' CATFUNC=Tables TABNAME='%.t1';
SELECT * FROM t1 ORDER BY Table_Owner, Table_Name;
Table_Qualifier Table_Owner Table_Name Table_Type Remark
SELECT * FROM t1 ORDER BY Table_Schema, Table_Name;
Table_Cat Table_Schema Table_Name Table_Type Remark
mtr public t1 TABLE
mtr schema1 t1 TABLE
DROP TABLE t1;
# Table "t1" in the default schema ("public")
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' CATFUNC=Tables TABNAME='t1';
SELECT * FROM t1 ORDER BY Table_Owner, Table_Name;
Table_Qualifier Table_Owner Table_Name Table_Type Remark
SELECT * FROM t1 ORDER BY Table_Schema, Table_Name;
Table_Cat Table_Schema Table_Name Table_Type Remark
mtr public t1 TABLE
DROP TABLE t1;
# Table "t1" in the schema "public"
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' CATFUNC=Tables TABNAME='%.public.t1';
SELECT * FROM t1 ORDER BY Table_Owner, Table_Name;
Table_Qualifier Table_Owner Table_Name Table_Type Remark
SELECT * FROM t1 ORDER BY Table_Schema, Table_Name;
Table_Cat Table_Schema Table_Name Table_Type Remark
mtr public t1 TABLE
DROP TABLE t1;
# Table "t1" in the schema "schema1"
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' CATFUNC=Tables TABNAME='%.schema1.t1';
SELECT * FROM t1 ORDER BY Table_Owner, Table_Name;
Table_Qualifier Table_Owner Table_Name Table_Type Remark
SELECT * FROM t1 ORDER BY Table_Schema, Table_Name;
Table_Cat Table_Schema Table_Name Table_Type Remark
mtr schema1 t1 TABLE
DROP TABLE t1;
# All tables "t1" in all schemas (Catalog name is ignored by PostgreSQL)
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' CATFUNC=Tables TABNAME='xxx.%.t1';
SELECT * FROM t1 ORDER BY Table_Owner, Table_Name;
Table_Qualifier Table_Owner Table_Name Table_Type Remark
SELECT * FROM t1 ORDER BY Table_Schema, Table_Name;
Table_Cat Table_Schema Table_Name Table_Type Remark
mtr public t1 TABLE
mtr schema1 t1 TABLE
DROP TABLE t1;
......@@ -94,8 +94,8 @@ DROP TABLE t1;
# All columns in the schemas "public" and "schema1"
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' CATFUNC=Columns;
SELECT * FROM t1 WHERE Table_Owner IN ('public','schema1') ORDER BY Table_Owner, Table_Name;
Table_Qualif Table_Owner Table_Name Column_Name Data_Type Type_Name Precision Length Scale Radix Nullable Remarks
SELECT * FROM t1 WHERE Table_Schema IN ('public','schema1') ORDER BY Table_Schema, Table_Name;
Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Buffer_Length Decimal_Digits Radix Nullable Remarks
mtr public t1 a 4 int4 10 4 0 10 0
mtr public t2 a 4 int4 10 4 0 10 0
mtr public v1 a 4 int4 10 4 0 10 1
......@@ -105,8 +105,8 @@ mtr schema1 v1 a 1 bpchar 10 60 0 0 1
DROP TABLE t1;
# All columns in the schemas "public" and "schema1"
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' CATFUNC=Columns TABNAME='%.%.%';
SELECT * FROM t1 WHERE Table_Owner IN ('public','schema1') ORDER BY Table_Owner, Table_Name;
Table_Qualif Table_Owner Table_Name Column_Name Data_Type Type_Name Precision Length Scale Radix Nullable Remarks
SELECT * FROM t1 WHERE Table_Schema IN ('public','schema1') ORDER BY Table_Schema, Table_Name;
Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Buffer_Length Decimal_Digits Radix Nullable Remarks
mtr public t1 a 4 int4 10 4 0 10 0
mtr public t2 a 4 int4 10 4 0 10 0
mtr public v1 a 4 int4 10 4 0 10 1
......@@ -116,27 +116,27 @@ mtr schema1 v1 a 1 bpchar 10 60 0 0 1
DROP TABLE t1;
# All tables "t1" in all schemas
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' CATFUNC=Columns TABNAME='%.%.t1';
SELECT * FROM t1 ORDER BY Table_Owner, Table_Name;
Table_Qualif Table_Owner Table_Name Column_Name Data_Type Type_Name Precision Length Scale Radix Nullable Remarks
SELECT * FROM t1 ORDER BY Table_Schema, Table_Name;
Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Buffer_Length Decimal_Digits Radix Nullable Remarks
mtr public t1 a 4 int4 10 4 0 10 0
mtr schema1 t1 a 1 bpchar 10 60 0 0 0
DROP TABLE t1;
# Table "t1" in the schema "public"
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' CATFUNC=Columns TABNAME='%.public.t1';
SELECT * FROM t1 ORDER BY Table_Owner, Table_Name;
Table_Qualif Table_Owner Table_Name Column_Name Data_Type Type_Name Precision Length Scale Radix Nullable Remarks
SELECT * FROM t1 ORDER BY Table_Schema, Table_Name;
Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Buffer_Length Decimal_Digits Radix Nullable Remarks
mtr public t1 a 4 int4 10 4 0 10 0
DROP TABLE t1;
# Table "t1" in the schema "schema1"
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' CATFUNC=Columns TABNAME='%.schema1.t1';
SELECT * FROM t1 ORDER BY Table_Owner, Table_Name;
Table_Qualif Table_Owner Table_Name Column_Name Data_Type Type_Name Precision Length Scale Radix Nullable Remarks
SELECT * FROM t1 ORDER BY Table_Schema, Table_Name;
Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Buffer_Length Decimal_Digits Radix Nullable Remarks
mtr schema1 t1 a 1 bpchar 10 60 0 0 0
DROP TABLE t1;
# All tables "t1" in all schemas (Catalog name is ignored by PostgreSQL)
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' CATFUNC=Columns TABNAME='xxx.%.t1';
SELECT * FROM t1 ORDER BY Table_Owner, Table_Name;
Table_Qualif Table_Owner Table_Name Column_Name Data_Type Type_Name Precision Length Scale Radix Nullable Remarks
SELECT * FROM t1 ORDER BY Table_Schema, Table_Name;
Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Buffer_Length Decimal_Digits Radix Nullable Remarks
mtr public t1 a 4 int4 10 4 0 10 0
mtr schema1 t1 a 1 bpchar 10 60 0 0 0
DROP TABLE t1;
......
......@@ -43,17 +43,17 @@ DROP VIEW v1;
DROP TABLE t1;
CREATE TABLE t1 ENGINE=CONNECT CATFUNC=Columns TABNAME='t1' TABLE_TYPE=ODBC CONNECTION='Driver=SQLite3 ODBC Driver;Database=MTR_SUITE_DIR/std_data/test.sqlite3;NoWCHAR=yes' CHARSET=utf8 DATA_CHARSET=utf8;
SELECT * FROM t1;
Table_Qualif Table_Owner Table_Name Column_Name Data_Type Type_Name Precision Length Scale Radix Nullable Remarks
Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Buffer_Length Decimal_Digits Radix Nullable Remarks
t1 a 12 varchar(64) 64 64 10 0 1
DROP TABLE t1;
CREATE TABLE t1 ENGINE=CONNECT CATFUNC=Tables TABNAME='t1' TABLE_TYPE=ODBC CONNECTION='Driver=SQLite3 ODBC Driver;Database=MTR_SUITE_DIR/std_data/test.sqlite3;NoWCHAR=yes' CHARSET=utf8 DATA_CHARSET=utf8;
SELECT * FROM t1;
Table_Qualifier Table_Owner Table_Name Table_Type Remark
Table_Cat Table_Schema Table_Name Table_Type Remark
t1 TABLE
DROP TABLE t1;
CREATE TABLE t1 ENGINE=CONNECT CATFUNC=Columns TABLE_TYPE=ODBC CONNECTION='Driver=SQLite3 ODBC Driver;Database=MTR_SUITE_DIR/std_data/test.sqlite3;NoWCHAR=yes' CHARSET=utf8 DATA_CHARSET=utf8;
SELECT * FROM t1 ORDER BY Table_name;
Table_Qualif Table_Owner Table_Name Column_Name Data_Type Type_Name Precision Length Scale Radix Nullable Remarks
Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Buffer_Length Decimal_Digits Radix Nullable Remarks
t000 a 4 INT 9 10 10 0 1
t000 b 4 INT 9 10 10 0 1
t000 c 4 INT 9 10 10 0 1
......@@ -2058,7 +2058,7 @@ Table_Qualif Table_Owner Table_Name Column_Name Data_Type Type_Name Precision Le
DROP TABLE t1;
CREATE TABLE t1 ENGINE=CONNECT CATFUNC=Tables TABLE_TYPE=ODBC CONNECTION='Driver=SQLite3 ODBC Driver;Database=MTR_SUITE_DIR/std_data/test.sqlite3;NoWCHAR=yes' CHARSET=utf8 DATA_CHARSET=utf8;
SELECT * FROM t1 ORDER BY Table_name;
Table_Qualifier Table_Owner Table_Name Table_Type Remark
Table_Cat Table_Schema Table_Name Table_Type Remark
t000 TABLE
t001 TABLE
t002 TABLE
......
......@@ -15,12 +15,12 @@ Menseau Eric NULL
DROP TABLE contact;
CREATE TABLE t1 ENGINE=CONNECT CATFUNC=Tables TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineXLS;DBQ=DATADIR/test/contacts.xls' CHARSET=utf8 DATA_CHARSET=latin1;;
SELECT * FROM t1 WHERE Table_name='CONTACT';
Table_Qualifier Table_Owner Table_Name Table_Type Remark
Table_Cat Table_Schema Table_Name Table_Type Remark
DATADIR/test/contacts CONTACT TABLE
DROP TABLE t1;
CREATE TABLE t1 ENGINE=CONNECT CATFUNC=Columns TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEngineXLS;DBQ=DATADIR/test/contacts.xls' CHARSET=utf8 DATA_CHARSET=latin1;;
SELECT * FROM t1 WHERE Table_name='CONTACT' AND Column_name IN ('Nom','Fonction');
Table_Qualif Table_Owner Table_Name Column_Name Data_Type Type_Name Precision Length Scale Radix Nullable Remarks
Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Buffer_Length Decimal_Digits Radix Nullable Remarks
DATADIR/test/contacts CONTACT Nom 12 VARCHAR 255 510 0 0 1
DATADIR/test/contacts CONTACT Fonction 12 VARCHAR 255 510 0 0 1
DROP TABLE t1;
......@@ -413,7 +413,7 @@ DROP TABLE t1;
SET @a=LOAD_FILE('MYSQLD_DATADIR/test/t1.xml');
SELECT CAST(@a AS CHAR CHARACTER SET latin1);
CAST(@a AS CHAR CHARACTER SET latin1) <?xml version="1.0" encoding="iso-8859-1"?>
<!-- Created by CONNECT Version 1.01.0010 November 30, 2013 -->
<!-- Created by CONNECT Version 1.01.0011 December 15, 2013 -->
<t1>
<line>
<node>ÀÁÂÃ</node>
......
......@@ -22,7 +22,7 @@
#
#[ConnectEnginePostgresql]
#Description=PostgreSQL DSN for ConnectSE
#Driver=PostgreSQL
#Driver=PostgreSQL (should the path to the driver so file)
#Database=mtr
#Servername=localhost
#Port=5432
......@@ -36,52 +36,52 @@ SET NAMES utf8;
--echo
--echo # All tables in all schemas
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' CATFUNC=Tables;
SELECT * FROM t1 ORDER BY Table_Owner, Table_Name;
SELECT * FROM t1 ORDER BY Table_Schema, Table_Name;
DROP TABLE t1;
--echo # All tables in all schemas
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' CATFUNC=Tables TABNAME='%.%.%';
SELECT * FROM t1 ORDER BY Table_Owner, Table_Name;
SELECT * FROM t1 ORDER BY Table_Schema, Table_Name;
DROP TABLE t1;
--echo # All tables in all schemas
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' CATFUNC=Tables TABNAME='%.%';
SELECT * FROM t1 ORDER BY Table_Owner, Table_Name;
SELECT * FROM t1 ORDER BY Table_Schema, Table_Name;
DROP TABLE t1;
--echo # All tables in the default schema ("public")
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' CATFUNC=Tables TABNAME='%';
SELECT * FROM t1 ORDER BY Table_Owner, Table_Name;
SELECT * FROM t1 ORDER BY Table_Schema, Table_Name;
DROP TABLE t1;
--echo # All tables "t1" in all schemas
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' CATFUNC=Tables TABNAME='%.%.t1';
SELECT * FROM t1 ORDER BY Table_Owner, Table_Name;
SELECT * FROM t1 ORDER BY Table_Schema, Table_Name;
DROP TABLE t1;
--echo # All tables "t1" in all schemas
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' CATFUNC=Tables TABNAME='%.t1';
SELECT * FROM t1 ORDER BY Table_Owner, Table_Name;
SELECT * FROM t1 ORDER BY Table_Schema, Table_Name;
DROP TABLE t1;
--echo # Table "t1" in the default schema ("public")
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' CATFUNC=Tables TABNAME='t1';
SELECT * FROM t1 ORDER BY Table_Owner, Table_Name;
SELECT * FROM t1 ORDER BY Table_Schema, Table_Name;
DROP TABLE t1;
--echo # Table "t1" in the schema "public"
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' CATFUNC=Tables TABNAME='%.public.t1';
SELECT * FROM t1 ORDER BY Table_Owner, Table_Name;
SELECT * FROM t1 ORDER BY Table_Schema, Table_Name;
DROP TABLE t1;
--echo # Table "t1" in the schema "schema1"
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' CATFUNC=Tables TABNAME='%.schema1.t1';
SELECT * FROM t1 ORDER BY Table_Owner, Table_Name;
SELECT * FROM t1 ORDER BY Table_Schema, Table_Name;
DROP TABLE t1;
--echo # All tables "t1" in all schemas (Catalog name is ignored by PostgreSQL)
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' CATFUNC=Tables TABNAME='xxx.%.t1';
SELECT * FROM t1 ORDER BY Table_Owner, Table_Name;
SELECT * FROM t1 ORDER BY Table_Schema, Table_Name;
DROP TABLE t1;
--echo #
......@@ -92,37 +92,37 @@ DROP TABLE t1;
#
# For some reasons SQLColumn (unlike SQLTables) include columns of system
# tables from the schemas like "information_schema", "pg_catalog", "pg_toast".
# So we add the "Table_Owner IN ('public','schema1')" clause into some queries.
# So we add the "Table_Schema IN ('public','schema1')" clause into some queries.
#
--echo # All columns in the schemas "public" and "schema1"
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' CATFUNC=Columns;
SELECT * FROM t1 WHERE Table_Owner IN ('public','schema1') ORDER BY Table_Owner, Table_Name;
SELECT * FROM t1 WHERE Table_Schema IN ('public','schema1') ORDER BY Table_Schema, Table_Name;
DROP TABLE t1;
--echo # All columns in the schemas "public" and "schema1"
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' CATFUNC=Columns TABNAME='%.%.%';
SELECT * FROM t1 WHERE Table_Owner IN ('public','schema1') ORDER BY Table_Owner, Table_Name;
SELECT * FROM t1 WHERE Table_Schema IN ('public','schema1') ORDER BY Table_Schema, Table_Name;
DROP TABLE t1;
--echo # All tables "t1" in all schemas
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' CATFUNC=Columns TABNAME='%.%.t1';
SELECT * FROM t1 ORDER BY Table_Owner, Table_Name;
SELECT * FROM t1 ORDER BY Table_Schema, Table_Name;
DROP TABLE t1;
--echo # Table "t1" in the schema "public"
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' CATFUNC=Columns TABNAME='%.public.t1';
SELECT * FROM t1 ORDER BY Table_Owner, Table_Name;
SELECT * FROM t1 ORDER BY Table_Schema, Table_Name;
DROP TABLE t1;
--echo # Table "t1" in the schema "schema1"
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' CATFUNC=Columns TABNAME='%.schema1.t1';
SELECT * FROM t1 ORDER BY Table_Owner, Table_Name;
SELECT * FROM t1 ORDER BY Table_Schema, Table_Name;
DROP TABLE t1;
--echo # All tables "t1" in all schemas (Catalog name is ignored by PostgreSQL)
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' CATFUNC=Columns TABNAME='xxx.%.t1';
SELECT * FROM t1 ORDER BY Table_Owner, Table_Name;
SELECT * FROM t1 ORDER BY Table_Schema, Table_Name;
DROP TABLE t1;
......
......@@ -4,9 +4,10 @@
#if defined(PROMPT_OK)
char *ODBCCheckConnection(PGLOBAL g, char *dsn, int cop);
#endif // PROMPT_OK
PQRYRES ODBCDataSources(PGLOBAL g, bool info);
PQRYRES ODBCColumns(PGLOBAL g, char *dsn, char *table,
char *colpat, bool info);
PQRYRES ODBCDataSources(PGLOBAL g, int maxres, bool info);
PQRYRES ODBCColumns(PGLOBAL g, char *dsn, char *db, char *table,
char *colpat, int maxres, bool info);
PQRYRES ODBCSrcCols(PGLOBAL g, char *dsn, char *src);
PQRYRES ODBCTables(PGLOBAL g, char *dsn, char *tabpat, bool info);
PQRYRES ODBCDrivers(PGLOBAL g, bool info);
PQRYRES ODBCTables(PGLOBAL g, char *dsn, char *db, char *tabpat,
int maxres, bool info);
PQRYRES ODBCDrivers(PGLOBAL g, int maxres, bool info);
This diff is collapsed.
......@@ -58,12 +58,13 @@ enum CATINFO {CAT_TAB = 1, /* SQLTables */
typedef struct tagCATPARM {
CATINFO Id; // Id to indicate function
PQRYRES Qrp; // Result set pointer
PUCHAR Tab; // Table name or pattern
PUCHAR Pat; // Table type or column pattern
PUCHAR DB; // Database (Schema)
PUCHAR Tab; // Table name or pattern
PUCHAR Pat; // Table type or column pattern
SQLLEN* *Vlen; // To array of indicator values
UWORD *Status; // To status block
// For SQLStatistics
UWORD Unique; // Index type
UWORD Unique; // Index type
UWORD Accuracy; // For Cardinality and Pages
// For SQLSpecialColumns
UWORD ColType;
......
......@@ -496,11 +496,12 @@ enum XFLD {FLD_NO = 0, /* Not a field definition item */
FLD_CHARSET = 10, /* Field collation */
FLD_KEY = 11, /* Field key property */
FLD_DEFAULT = 12, /* Field default value */
FLD_PRIV = 13, /* Field priviledges */
FLD_DATEFMT = 14, /* Field date format */
FLD_QUALIF = 15, /* Table qualifier */
FLD_OWNER = 16, /* Table owner */
FLD_TABNAME = 17}; /* Column Table name */
FLD_EXTRA = 13, /* Field extra info */
FLD_PRIV = 14, /* Field priviledges */
FLD_DATEFMT = 15, /* Field date format */
FLD_CAT = 16, /* Table catalog */
FLD_SCHEM = 17, /* Table schema */
FLD_TABNAME = 18}; /* Column Table name */
/***********************************************************************/
/* Result of last SQL noconv query. */
......@@ -574,6 +575,7 @@ DllExport PDBUSER PlgGetUser(PGLOBAL g);
DllExport PCATLG PlgGetCatalog(PGLOBAL g, bool jump = true);
DllExport bool PlgSetXdbPath(PGLOBAL g, PSZ, PSZ, char *, int, char *, int);
DllExport void PlgDBfree(MBLOCK&);
DllExport void *PlgDBSubAlloc(PGLOBAL g, void *memp, size_t size);
//lExport PSZ GetIniString(PGLOBAL, void *, LPCSTR, LPCSTR, LPCSTR, LPCSTR);
//lExport int GetIniSize(char *, char *, char *, char *);
//lExport bool WritePrivateProfileInt(LPCSTR, LPCSTR, int, LPCSTR);
......
......@@ -1446,7 +1446,6 @@ void PlgDBfree(MBLOCK& mp)
mp.Size = 0;
} // end of PlgDBfree
#if 0 // Not used yet
/***********************************************************************/
/* Program for sub-allocating one item in a storage area. */
/* Note: This function is equivalent to PlugSubAlloc except that in */
......@@ -1463,8 +1462,8 @@ void *PlgDBSubAlloc(PGLOBAL g, void *memp, size_t size)
/*******************************************************************/
memp = g->Sarea;
size = ((size + 3) / 4) * 4; /* Round up size to multiple of 4 */
//size = ((size + 7) / 8) * 8; /* Round up size to multiple of 8 */
//size = ((size + 3) / 4) * 4; /* Round up size to multiple of 4 */
size = ((size + 7) / 8) * 8; /* Round up size to multiple of 8 */
pph = (PPOOLHEADER)memp;
#if defined(DEBTRACE)
......@@ -1473,34 +1472,9 @@ void *PlgDBSubAlloc(PGLOBAL g, void *memp, size_t size)
#endif
if ((uint)size > pph->FreeBlk) { /* Not enough memory left in pool */
char *pname = NULL;
PACTIVITY ap;
if (memp == g->Sarea)
pname = "Work";
else if ((ap = g->Activityp)) {
if (memp == ap->LangRulep)
pname = "Rule";
else if (memp == ap->Nodep[0])
pname = "Dictionary";
else if (memp == ap->Nodep[1])
pname = "Vartok";
else if (memp == ap->Nodep[2])
pname = "Lexicon";
else if (memp == ap->User_Dictp)
pname = "User dictionary";
else if (ap->Aptr)
pname = "Application";
} // endif memp
if (pname)
sprintf(g->Message,
"Not enough memory in %s area for request of %d (used=%d free=%d)",
pname, size, pph->To_Free, pph->FreeBlk);
else
sprintf(g->Message, MSG(SUBALLOC_ERROR),
memp, size, pph->To_Free, pph->FreeBlk);
sprintf(g->Message,
"Not enough memory in Work area for request of %d (used=%d free=%d)",
(int) size, pph->To_Free, pph->FreeBlk);
#if defined(DEBTRACE)
htrc("%s\n", g->Message);
......@@ -1521,7 +1495,6 @@ void *PlgDBSubAlloc(PGLOBAL g, void *memp, size_t size)
#endif
return (memp);
} // end of PlgDBSubAlloc
#endif // 0 Not used yet
/***********************************************************************/
/* PUTOUT: Plug DB object typing routine. */
......
......@@ -130,20 +130,20 @@ char *GetMsgid(int id)
case IDS_13: p = "%s: invalid connection key value %d"; break;
case IDS_14: p = "SafeDB: %s rc=%d"; break;
case IDS_15: p = "Wrong communication Dll called for engine %s"; break;
case IDS_TAB_01: p = "Table_Qualifier"; break;
case IDS_TAB_02: p = "Table_Owner"; break;
case IDS_TAB_01: p = "Table_Cat"; break;
case IDS_TAB_02: p = "Table_Schema"; break;
case IDS_TAB_03: p = "Table_Name"; break;
case IDS_TAB_04: p = "Table_Type"; break;
case IDS_TAB_05: p = "Remark"; break;
case IDS_COL_01: p = "Table_Qualif"; break;
case IDS_COL_02: p = "Table_Owner"; break;
case IDS_COL_01: p = "Table_Cat"; break;
case IDS_COL_02: p = "Table_Schema"; break;
case IDS_COL_03: p = "Table_Name"; break;
case IDS_COL_04: p = "Column_Name"; break;
case IDS_COL_05: p = "Data_Type"; break;
case IDS_COL_06: p = "Type_Name"; break;
case IDS_COL_07: p = "Precision"; break;
case IDS_COL_08: p = "Length"; break;
case IDS_COL_09: p = "Scale"; break;
case IDS_COL_07: p = "Column_Size"; break;
case IDS_COL_08: p = "Buffer_Length"; break;
case IDS_COL_09: p = "Decimal_Digits"; break;
case IDS_COL_10: p = "Radix"; break;
case IDS_COL_11: p = "Nullable"; break;
case IDS_COL_12: p = "Remarks"; break;
......
......@@ -340,11 +340,11 @@ PQRYRES CSVColumns(PGLOBAL g, const char *fn, char sep, char q,
/*********************************************************************/
qrp = PlgAllocResult(g, ncol, imax, IDS_COLUMNS + 3,
buftyp, fldtyp, length, false, false);
qrp->Nblin = imax;
if (info)
if (info || !qrp)
return qrp;
qrp->Nblin = imax;
/*********************************************************************/
/* Now get the results into blocks. */
/*********************************************************************/
......
......@@ -478,6 +478,16 @@ bool TDBCAT::Initialize(PGLOBAL g)
if (!(Qrp = GetResult(g)))
return true;
if (Qrp->Truncated) {
sprintf(g->Message, "Result limited to %d lines", Qrp->Maxres);
PushWarning(g, this);
} // endif Truncated
if (Qrp->BadLines) {
sprintf(g->Message, "%d bad lines in result", Qrp->BadLines);
PushWarning(g, this);
} // endif Badlines
Init = true;
return false;
} // end of Initialize
......@@ -488,10 +498,11 @@ bool TDBCAT::Initialize(PGLOBAL g)
int TDBCAT::GetMaxSize(PGLOBAL g)
{
if (MaxSize < 0) {
if (Initialize(g))
return -1;
// if (Initialize(g))
// return -1;
MaxSize = Qrp->Nblin;
// MaxSize = Qrp->Nblin;
MaxSize = 10; // To make MariaDB happy
} // endif MaxSize
return MaxSize;
......
/************* Tabodbc C++ Program Source Code File (.CPP) *************/
/* PROGRAM NAME: TABODBC */
/* ------------- */
/* Version 2.6 */
/* Version 2.7 */
/* */
/* COPYRIGHT: */
/* ---------- */
......@@ -90,8 +90,8 @@ extern int num_read, num_there, num_eq[2]; // Statistics
/***********************************************************************/
ODBCDEF::ODBCDEF(void)
{
Connect = Tabname = Tabowner = Tabqual = Srcdef = Qrystr = NULL;
Catver = Options = Quoted = 0;
Connect = Tabname = Tabowner = Tabqual = Srcdef = Qchar = Qrystr = NULL;
Catver = Options = Quoted = Maxerr = Maxres = 0;
Xsrc = false;
} // end of ODBCDEF constructor
......@@ -104,13 +104,15 @@ bool ODBCDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
Tabname = Cat->GetStringCatInfo(g, "Name",
(Catfunc & (FNC_TABLE | FNC_COL)) ? NULL : Name);
Tabname = Cat->GetStringCatInfo(g, "Tabname", Tabname);
Tabowner = Cat->GetStringCatInfo(g, "Owner", "");
Tabqual = Cat->GetStringCatInfo(g, "Qualifier", "");
//Tabowner = Cat->GetStringCatInfo(g, "Owner", NULL);
Tabowner = Cat->GetStringCatInfo(g, "Dbname", NULL);
Tabqual = Cat->GetStringCatInfo(g, "Qualifier", NULL);
Srcdef = Cat->GetStringCatInfo(g, "Srcdef", NULL);
Qrystr = Cat->GetStringCatInfo(g, "Query_String", "?");
Catver = Cat->GetIntCatInfo("Catver", 2);
Xsrc = Cat->GetBoolCatInfo("Execsrc", FALSE);
Mxr = Cat->GetIntCatInfo("Maxerr", 0);
Maxerr = Cat->GetIntCatInfo("Maxerr", 0);
Maxres = Cat->GetIntCatInfo("Maxres", 0);
Quoted = Cat->GetIntCatInfo("Quoted", 0);
Options = ODBConn::noOdbcDialog;
Pseudo = 2; // FILID is Ok but not ROWID
......@@ -1152,7 +1154,7 @@ TDBXDBC::TDBXDBC(PODEF tdp) : TDBODBC(tdp)
{
Cmdlist = NULL;
Cmdcol = NULL;
Mxr = tdp->Mxr;
Mxr = tdp->Maxerr;
Nerr = 0;
} // end of TDBXDBC constructor
......@@ -1385,24 +1387,24 @@ void XSRCCOL::WriteColumn(PGLOBAL g)
// Should never be called
} // end of WriteColumn
/* ---------------------------TDBSRC class --------------------------- */
/* ---------------------------TDBDRV class --------------------------- */
/***********************************************************************/
/* GetResult: Get the list of ODBC data sources. */
/* GetResult: Get the list of ODBC drivers. */
/***********************************************************************/
PQRYRES TDBSRC::GetResult(PGLOBAL g)
PQRYRES TDBDRV::GetResult(PGLOBAL g)
{
return ODBCDataSources(g, false);
return ODBCDrivers(g, Maxres, false);
} // end of GetResult
/* ---------------------------TDBDRV class --------------------------- */
/* ---------------------------TDBSRC class --------------------------- */
/***********************************************************************/
/* GetResult: Get the list of ODBC drivers. */
/* GetResult: Get the list of ODBC data sources. */
/***********************************************************************/
PQRYRES TDBDRV::GetResult(PGLOBAL g)
PQRYRES TDBSRC::GetResult(PGLOBAL g)
{
return ODBCDrivers(g, false);
return ODBCDataSources(g, Maxres, false);
} // end of GetResult
/* ---------------------------TDBOTB class --------------------------- */
......@@ -1410,9 +1412,10 @@ PQRYRES TDBDRV::GetResult(PGLOBAL g)
/***********************************************************************/
/* TDBOTB class constructor. */
/***********************************************************************/
TDBOTB::TDBOTB(PODEF tdp) : TDBCAT(tdp)
TDBOTB::TDBOTB(PODEF tdp) : TDBDRV(tdp)
{
Dsn = tdp->GetConnect();
Dsn = tdp->GetConnect();
Schema = tdp->GetTabowner();
Tab = tdp->GetTabname();
} // end of TDBOTB constructor
......@@ -1421,7 +1424,7 @@ TDBOTB::TDBOTB(PODEF tdp) : TDBCAT(tdp)
/***********************************************************************/
PQRYRES TDBOTB::GetResult(PGLOBAL g)
{
return ODBCTables(g, Dsn, Tab, false);
return ODBCTables(g, Dsn, Schema, Tab, Maxres, false);
} // end of GetResult
/* ---------------------------TDBOCL class --------------------------- */
......@@ -1431,7 +1434,7 @@ PQRYRES TDBOTB::GetResult(PGLOBAL g)
/***********************************************************************/
PQRYRES TDBOCL::GetResult(PGLOBAL g)
{
return ODBCColumns(g, Dsn, Tab, NULL, false);
return ODBCColumns(g, Dsn, Schema, Tab, NULL, Maxres, false);
} // end of GetResult
/* ------------------------ End of Tabodbc --------------------------- */
......@@ -23,6 +23,7 @@ typedef class TDBSRC *PTDBSRC;
class DllExport ODBCDEF : public TABDEF { /* Logical table description */
friend class TDBODBC;
friend class TDBXDBC;
friend class TDBDRV;
public:
// Constructor
ODBCDEF(void);
......@@ -54,7 +55,8 @@ class DllExport ODBCDEF : public TABDEF { /* Logical table description */
int Catver; /* ODBC version for catalog functions */
int Options; /* Open connection options */
int Quoted; /* Identifier quoting level */
int Mxr; /* Maxerr for an Exec table */
int Maxerr; /* Maxerr for an Exec table */
int Maxres; /* Maxres for a catalog table */
bool Xsrc; /* Execution type */
}; // end of ODBCDEF
......@@ -250,37 +252,40 @@ class XSRCCOL : public ODBCCOL {
}; // end of class XSRCCOL
/***********************************************************************/
/* This is the class declaration for the Data Sources catalog table. */
/* This is the class declaration for the Drivers catalog table. */
/***********************************************************************/
class TDBSRC : public TDBCAT {
class TDBDRV : public TDBCAT {
public:
// Constructor
TDBSRC(PODEF tdp) : TDBCAT(tdp) {}
TDBDRV(PODEF tdp) : TDBCAT(tdp) {Maxres = tdp->Maxres;}
protected:
// Specific routines
virtual PQRYRES GetResult(PGLOBAL g);
}; // end of class TDBSRC
// Members
int Maxres; // Returned lines limit
}; // end of class TDBDRV
/***********************************************************************/
/* This is the class declaration for the Drivers catalog table. */
/* This is the class declaration for the Data Sources catalog table. */
/***********************************************************************/
class TDBDRV : public TDBCAT {
class TDBSRC : public TDBDRV {
public:
// Constructor
TDBDRV(PODEF tdp) : TDBCAT(tdp) {}
TDBSRC(PODEF tdp) : TDBDRV(tdp) {}
protected:
// Specific routines
virtual PQRYRES GetResult(PGLOBAL g);
}; // end of class TDBDRV
// No additional Members
}; // end of class TDBSRC
/***********************************************************************/
/* This is the class declaration for the tables catalog table. */
/***********************************************************************/
class TDBOTB : public TDBCAT {
class TDBOTB : public TDBDRV {
public:
// Constructor
TDBOTB(PODEF tdp);
......@@ -291,6 +296,7 @@ class TDBOTB : public TDBCAT {
// Members
char *Dsn; // Points to connection string
char *Schema; // Points to schema name or NULL
char *Tab; // Points to ODBC table name or pattern
}; // end of class TDBOTB
......@@ -306,7 +312,7 @@ class TDBOCL : public TDBOTB {
// Specific routines
virtual PQRYRES GetResult(PGLOBAL g);
// Members
// No additional Members
}; // end of class TDBOCL
#endif // !NODBC
......@@ -158,8 +158,9 @@ PQRYRES TabColumns(PGLOBAL g, THD *thd, const char *db,
/**********************************************************************/
/* Allocate the structures used to refer to the result set. */
/**********************************************************************/
qrp = PlgAllocResult(g, ncol, n, IDS_COLUMNS + 3,
buftyp, fldtyp, length, false, true);
if (!(qrp = PlgAllocResult(g, ncol, n, IDS_COLUMNS + 3,
buftyp, fldtyp, length, false, true)))
return NULL;
// Some columns must be renamed
for (i = 0, crp = qrp->Colresp; crp; crp = crp->Next)
......
......@@ -213,7 +213,7 @@ PQRYRES WMIColumns(PGLOBAL g, char *nsp, char *cls, bool info)
qrp = PlgAllocResult(g, ncol, n, IDS_COLUMNS + 3,
buftyp, fldtyp, length, false, true);
if (info)
if (info || !qrp)
return qrp;
/*********************************************************************/
......
......@@ -95,8 +95,8 @@ bool user_connect::user_init()
PDBUSER dup= NULL;
// Areasize= 64M because of VEC tables. Should be parameterisable
//g= PlugInit(NULL, 67108864);
g= PlugInit(NULL, 134217728); // 128M because of embedded tests (???)
g= PlugInit(NULL, 67108864);
//g= PlugInit(NULL, 134217728); // 128M was because of old embedded tests
// Check whether the initialization is complete
if (!g || !g->Sarea || PlugSubSet(g, g->Sarea, g->Sarea_Size)
......
......@@ -246,12 +246,12 @@ void TYPBLK<TYPE>::SetValue(PVAL valp, int n)
ChkIndx(n);
ChkTyp(valp);
if (!(b = valp->IsNull() && Nullable))
if (!(b = valp->IsNull()))
Typp[n] = GetTypedValue(valp);
else
Reset(n);
SetNull(n, b);
SetNull(n, b && Nullable);
} // end of SetValue
template <>
......@@ -671,12 +671,12 @@ void CHRBLK::SetValue(PVAL valp, int n)
ChkIndx(n);
ChkTyp(valp);
if (!(b = valp->IsNull() && Nullable))
if (!(b = valp->IsNull()))
SetValue((PSZ)valp->GetCharValue(), n);
else
Reset(n);
SetNull(n, b);
SetNull(n, b && Nullable);
} // end of SetValue
/***********************************************************************/
......@@ -887,6 +887,7 @@ STRBLK::STRBLK(PGLOBAL g, void *mp, int nval)
{
Global = g;
Nullable = true;
Sorted = false;
} // end of STRBLK constructor
/***********************************************************************/
......@@ -1026,8 +1027,12 @@ void STRBLK::SetValue(PVAL valp, int n)
void STRBLK::SetValue(PSZ p, int n)
{
if (p) {
Strp[n] = (PSZ)PlugSubAlloc(Global, NULL, strlen(p) + 1);
strcpy(Strp[n], p);
if (!Sorted || !n || !Strp[n-1] || strcmp(p, Strp[n-1])) {
Strp[n] = (PSZ)PlugSubAlloc(Global, NULL, strlen(p) + 1);
strcpy(Strp[n], p);
} else
Strp[n] = Strp[n-1];
} else
Strp[n] = NULL;
......@@ -1041,9 +1046,14 @@ void STRBLK::SetValue(char *sp, uint len, int n)
PSZ p;
if (sp) {
p = (PSZ)PlugSubAlloc(Global, NULL, len + 1);
memcpy(p, sp, len);
p[len] = 0;
if (!Sorted || !n || !Strp[n-1] || strlen(Strp[n-1]) != len ||
strncmp(sp, Strp[n-1], len)) {
p = (PSZ)PlugSubAlloc(Global, NULL, len + 1);
memcpy(p, sp, len);
p[len] = 0;
} else
p = Strp[n-1];
} else
p = NULL;
......
......@@ -268,9 +268,13 @@ class STRBLK : public VALBLK {
virtual int Find(PVAL vp);
virtual int GetMaxLength(void);
// Specific
void SetSorted(bool b) {Sorted = b;}
protected:
// Members
PSZ* const &Strp; // Pointer to PSZ buffer
bool Sorted; // Values are (semi?) sorted
}; // end of class STRBLK
/***********************************************************************/
......
......@@ -1129,7 +1129,8 @@ void TYPVAL<PSZ>::SetValue_psz(PSZ s)
/***********************************************************************/
void TYPVAL<PSZ>::SetValue_pvblk(PVBLK blk, int n)
{
strncpy(Strp, blk->GetCharValue(n), Len);
// STRBLK's can return a NULL pointer
SetValue_psz(blk->GetCharValue(n));
} // end of SetValue_pvblk
/***********************************************************************/
......
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