Commit 67567f5c authored by Olivier Bertrand's avatar Olivier Bertrand

- Implement the CHECK TABLE statement and accept REPAIR and ANALYZE

  modified:   storage/connect/connect.cc
  modified:   storage/connect/ha_connect.cc
  modified:   storage/connect/ha_connect.h
  modified:   storage/connect/tabjdbc.cpp
  modified:   storage/connect/tabmysql.cpp
  modified:   storage/connect/tabodbc.cpp

- MDEV-17212: Test if NumResultCols is implemented by the data source
  modified:   storage/connect/odbconn.cpp

- Change error type in Optimize
  modified:   storage/connect/ha_connect.cc

- Update version date
  modified:   storage/connect/ha_connect.cc

- Fix truncating error messages on first unrecognized latin1 character
  modified:   storage/connect/ha_connect.cc

- Fix MDEV-17343
  Reject multi-table UPDATE/DELETE commands that crash on some systems
  modified:   storage/connect/ha_connect.cc
  modified:   storage/connect/tabext.cpp

- Try fix some failing tests
  modified:   storage/connect/mysql-test/connect/r/jdbc.result
  modified:   storage/connect/mysql-test/connect/r/jdbc_postgresql.result
  modified:   storage/connect/mysql-test/connect/r/mysql_exec.result
  modified:   storage/connect/mysql-test/connect/r/odbc_postgresql.result

- Typo
  modified:   storage/connect/global.h
parent dbf25197
...@@ -254,7 +254,7 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2, ...@@ -254,7 +254,7 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
try { try {
if (!c1) { if (!c1) {
if (mode == MODE_INSERT) // if (mode == MODE_INSERT) or CHECK TABLE
// Allocate all column blocks for that table // Allocate all column blocks for that table
tdbp->ColDB(g, NULL, 0); tdbp->ColDB(g, NULL, 0);
......
/***********************************************************************/ /***********************************************************************/
/* GLOBAL.H: Declaration file used by all CONNECT implementations. */ /* GLOBAL.H: Declaration file used by all CONNECT implementations. */
/* (C) Copyright MariaDB Corporation Ab */ /* (C) Copyright MariaDB Corporation Ab */
/* Author Olivier Bertrand 1993-2017 */ /* Author Olivier Bertrand 1993-2018 */
/***********************************************************************/ /***********************************************************************/
/***********************************************************************/ /***********************************************************************/
...@@ -192,7 +192,7 @@ typedef struct _global { /* Global structure */ ...@@ -192,7 +192,7 @@ typedef struct _global { /* Global structure */
PACTIVITY Activityp; PACTIVITY Activityp;
char Message[MAX_STR]; char Message[MAX_STR];
ulong More; /* Used by jsonudf */ ulong More; /* Used by jsonudf */
int Createas; /* To pass info to created table */ int Createas; /* To pass multi to ext tables */
void *Xchk; /* indexes in create/alter */ void *Xchk; /* indexes in create/alter */
short Alchecked; /* Checked for ALTER */ short Alchecked; /* Checked for ALTER */
short Mrr; /* True when doing mrr */ short Mrr; /* True when doing mrr */
......
...@@ -170,9 +170,9 @@ ...@@ -170,9 +170,9 @@
#define JSONMAX 10 // JSON Default max grp size #define JSONMAX 10 // JSON Default max grp size
extern "C" { extern "C" {
char version[]= "Version 1.06.0007 August 06, 2018"; char version[]= "Version 1.06.0008 October 06, 2018";
#if defined(__WIN__) #if defined(__WIN__)
char compver[]= "Version 1.06.0007 " __DATE__ " " __TIME__; char compver[]= "Version 1.06.0008 " __DATE__ " " __TIME__;
char slash= '\\'; char slash= '\\';
#else // !__WIN__ #else // !__WIN__
char slash= '/'; char slash= '/';
...@@ -3290,6 +3290,58 @@ ha_rows ha_connect::records() ...@@ -3290,6 +3290,58 @@ ha_rows ha_connect::records()
} // end of records } // end of records
int ha_connect::check(THD* thd, HA_CHECK_OPT* check_opt)
{
int rc = HA_ADMIN_OK;
PGLOBAL g = ((table && table->in_use) ? GetPlug(table->in_use, xp) :
(xp) ? xp->g : NULL);
DBUG_ENTER("ha_connect::check");
if (!g || !table || xmod != MODE_READ)
DBUG_RETURN(HA_ADMIN_INTERNAL_ERROR);
// Do not close the table if it was opened yet (possible?)
if (IsOpened()) {
if (IsPartitioned() && CheckColumnList(g)) // map can have been changed
rc = HA_ADMIN_CORRUPT;
else if (tdbp->OpenDB(g)) // Rewind table
rc = HA_ADMIN_CORRUPT;
} else if (xp->CheckQuery(valid_query_id)) {
tdbp = NULL; // Not valid anymore
if (OpenTable(g, false))
rc = HA_ADMIN_CORRUPT;
} else // possible?
DBUG_RETURN(HA_ADMIN_INTERNAL_ERROR);
if (rc == HA_ADMIN_OK) {
TABTYPE type = GetTypeID(GetStringOption("Type", "*"));
if (IsFileType(type)) {
if (check_opt->flags & T_MEDIUM) {
// TO DO
do {
if ((rc = CntReadNext(g, tdbp)) == RC_FX)
break;
} while (rc != RC_EF);
rc = (rc == RC_EF) ? HA_ADMIN_OK : HA_ADMIN_CORRUPT;
} else if (check_opt->flags & T_EXTEND) {
// TO DO
} // endif's flags
} // endif file type
} else
PushWarning(g, thd, 1);
DBUG_RETURN(rc);
} // end of check
/** /**
Return an error message specific to this handler. Return an error message specific to this handler.
...@@ -3309,7 +3361,8 @@ bool ha_connect::get_error_message(int error, String* buf) ...@@ -3309,7 +3361,8 @@ bool ha_connect::get_error_message(int error, String* buf)
if (trace(1)) if (trace(1))
htrc("GEM(%d): %s\n", error, g->Message); htrc("GEM(%d): %s\n", error, g->Message);
buf->append(g->Message); buf->append(ErrConvString(g->Message, strlen(g->Message),
&my_charset_latin1).ptr());
} else } else
buf->append("Cannot retrieve error message"); buf->append("Cannot retrieve error message");
...@@ -3424,7 +3477,7 @@ int ha_connect::optimize(THD* thd, HA_CHECK_OPT*) ...@@ -3424,7 +3477,7 @@ int ha_connect::optimize(THD* thd, HA_CHECK_OPT*)
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message); push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message);
rc = 0; rc = 0;
} else } else
rc = HA_ERR_INTERNAL_ERROR; rc = HA_ERR_CRASHED_ON_USAGE; // Table must be repaired
} // endif rc } // endif rc
...@@ -3440,6 +3493,9 @@ int ha_connect::optimize(THD* thd, HA_CHECK_OPT*) ...@@ -3440,6 +3493,9 @@ int ha_connect::optimize(THD* thd, HA_CHECK_OPT*)
rc = HA_ERR_INTERNAL_ERROR; rc = HA_ERR_INTERNAL_ERROR;
} // end catch } // end catch
if (rc)
my_message(ER_WARN_DATA_OUT_OF_RANGE, g->Message, MYF(0));
return rc; return rc;
} // end of optimize } // end of optimize
...@@ -4501,14 +4557,16 @@ MODE ha_connect::CheckMode(PGLOBAL g, THD *thd, ...@@ -4501,14 +4557,16 @@ MODE ha_connect::CheckMode(PGLOBAL g, THD *thd,
// case SQLCOM_REPLACE_SELECT: // case SQLCOM_REPLACE_SELECT:
// newmode= MODE_UPDATE; // To be checked // newmode= MODE_UPDATE; // To be checked
// break; // break;
case SQLCOM_DELETE: case SQLCOM_DELETE_MULTI:
case SQLCOM_DELETE_MULTI: *cras = true;
case SQLCOM_DELETE:
case SQLCOM_TRUNCATE: case SQLCOM_TRUNCATE:
newmode= MODE_DELETE; newmode= MODE_DELETE;
break; break;
case SQLCOM_UPDATE:
case SQLCOM_UPDATE_MULTI: case SQLCOM_UPDATE_MULTI:
newmode= MODE_UPDATE; *cras = true;
case SQLCOM_UPDATE:
newmode= MODE_UPDATE;
break; break;
case SQLCOM_SELECT: case SQLCOM_SELECT:
case SQLCOM_OPTIMIZE: case SQLCOM_OPTIMIZE:
...@@ -4533,8 +4591,10 @@ MODE ha_connect::CheckMode(PGLOBAL g, THD *thd, ...@@ -4533,8 +4591,10 @@ MODE ha_connect::CheckMode(PGLOBAL g, THD *thd,
newmode= MODE_ANY; newmode= MODE_ANY;
break; break;
// } // endif partitioned // } // endif partitioned
case SQLCOM_REPAIR: // TODO implement it
default: newmode = MODE_UPDATE;
break;
default:
htrc("Unsupported sql_command=%d\n", thd_sql_command(thd)); htrc("Unsupported sql_command=%d\n", thd_sql_command(thd));
strcpy(g->Message, "CONNECT Unsupported command"); strcpy(g->Message, "CONNECT Unsupported command");
my_message(ER_NOT_ALLOWED_COMMAND, g->Message, MYF(0)); my_message(ER_NOT_ALLOWED_COMMAND, g->Message, MYF(0));
...@@ -4546,17 +4606,18 @@ MODE ha_connect::CheckMode(PGLOBAL g, THD *thd, ...@@ -4546,17 +4606,18 @@ MODE ha_connect::CheckMode(PGLOBAL g, THD *thd,
switch (thd_sql_command(thd)) { switch (thd_sql_command(thd)) {
case SQLCOM_CREATE_TABLE: case SQLCOM_CREATE_TABLE:
*chk= true; *chk= true;
*cras= true; break;
case SQLCOM_UPDATE_MULTI:
case SQLCOM_DELETE_MULTI:
*cras= true;
case SQLCOM_INSERT: case SQLCOM_INSERT:
case SQLCOM_LOAD: case SQLCOM_LOAD:
case SQLCOM_INSERT_SELECT: case SQLCOM_INSERT_SELECT:
// case SQLCOM_REPLACE: // case SQLCOM_REPLACE:
// case SQLCOM_REPLACE_SELECT: // case SQLCOM_REPLACE_SELECT:
case SQLCOM_DELETE: case SQLCOM_DELETE:
case SQLCOM_DELETE_MULTI:
case SQLCOM_TRUNCATE: case SQLCOM_TRUNCATE:
case SQLCOM_UPDATE: case SQLCOM_UPDATE:
case SQLCOM_UPDATE_MULTI:
case SQLCOM_SELECT: case SQLCOM_SELECT:
case SQLCOM_OPTIMIZE: case SQLCOM_OPTIMIZE:
case SQLCOM_SET_OPTION: case SQLCOM_SET_OPTION:
...@@ -4584,8 +4645,9 @@ MODE ha_connect::CheckMode(PGLOBAL g, THD *thd, ...@@ -4584,8 +4645,9 @@ MODE ha_connect::CheckMode(PGLOBAL g, THD *thd,
break; break;
// } // endif partitioned // } // endif partitioned
case SQLCOM_CHECK: // TODO implement it case SQLCOM_CHECK: // TODO implement it
case SQLCOM_END: // Met in procedures: IF(EXISTS(SELECT... case SQLCOM_ANALYZE: // TODO implement it
case SQLCOM_END: // Met in procedures: IF(EXISTS(SELECT...
newmode= MODE_READ; newmode= MODE_READ;
break; break;
default: default:
...@@ -4867,7 +4929,7 @@ int ha_connect::external_lock(THD *thd, int lock_type) ...@@ -4867,7 +4929,7 @@ int ha_connect::external_lock(THD *thd, int lock_type)
#endif // 0 #endif // 0
if (cras) if (cras)
g->Createas= 1; // To tell created table to ignore FLAG g->Createas= 1; // To tell external tables of a multi-table command
if (trace(1)) { if (trace(1)) {
#if 0 #if 0
...@@ -7248,7 +7310,7 @@ maria_declare_plugin(connect) ...@@ -7248,7 +7310,7 @@ maria_declare_plugin(connect)
0x0107, /* version number (1.05) */ 0x0107, /* version number (1.05) */
NULL, /* status variables */ NULL, /* status variables */
connect_system_variables, /* system variables */ connect_system_variables, /* system variables */
"1.06.0007", /* string version */ "1.06.0008", /* string version */
MariaDB_PLUGIN_MATURITY_STABLE /* maturity */ MariaDB_PLUGIN_MATURITY_STABLE /* maturity */
} }
maria_declare_plugin_end; maria_declare_plugin_end;
...@@ -347,11 +347,7 @@ PFIL CondFilter(PGLOBAL g, Item *cond); ...@@ -347,11 +347,7 @@ PFIL CondFilter(PGLOBAL g, Item *cond);
//PFIL CheckFilter(PGLOBAL g); //PFIL CheckFilter(PGLOBAL g);
/** admin commands - called from mysql_admin_table */ /** admin commands - called from mysql_admin_table */
virtual int check(THD* thd, HA_CHECK_OPT* check_opt) virtual int check(THD* thd, HA_CHECK_OPT* check_opt);
{
// TODO: implement it
return HA_ADMIN_OK; // Just to avoid error message with checktables
} // end of check
/** /**
Number of rows in table. It will only be called if Number of rows in table. It will only be called if
......
...@@ -236,24 +236,37 @@ WHEELFOR SALESMAN 10030.00 ...@@ -236,24 +236,37 @@ WHEELFOR SALESMAN 10030.00
MARTIN ENGINEER 10000.00 MARTIN ENGINEER 10000.00
DROP TABLE t1, connect.emp; DROP TABLE t1, connect.emp;
CREATE TABLE t2 (command varchar(128) not null,number int(5) not null flag=1,message varchar(255) flag=2) ENGINE=CONNECT TABLE_TYPE=JDBC CONNECTION='jdbc:mariadb://localhost:PORT/connect' OPTION_LIST='User=root,Execsrc=1'; CREATE TABLE t2 (command varchar(128) not null,number int(5) not null flag=1,message varchar(255) flag=2) ENGINE=CONNECT TABLE_TYPE=JDBC CONNECTION='jdbc:mariadb://localhost:PORT/connect' OPTION_LIST='User=root,Execsrc=1';
SELECT * FROM t2 WHERE command='drop table tx1';
command number message command number message
drop table tx1 0 Execute: java.sql.SQLSyntaxErrorException: (conn:24) Unknown table 'connect.tx1' drop table tx1 0 Execute: java.sql.SQLSyntaxErrorException: (conn:24) Unknown table 'connect.tx1'
Warnings:
Warning 1105 Execute: java.sql.SQLSyntaxErrorException: (conn:24) Unknown table 'connect.tx1'
SELECT * FROM t2 WHERE command = 'create table tx1 (a int not null, b char(32), c double(8,2))'; SELECT * FROM t2 WHERE command = 'create table tx1 (a int not null, b char(32), c double(8,2))';
command number message command number message
create table tx1 (a int not null, b char(32), c double(8,2)) 0 Affected rows create table tx1 (a int not null, b char(32), c double(8,2)) 0 Affected rows
Warnings:
Warning 1105 Affected rows
SELECT * FROM t2 WHERE command in ('insert into tx1 values(1,''The number one'',456.12)',"insert into tx1(a,b) values(2,'The number two'),(3,'The number three')"); SELECT * FROM t2 WHERE command in ('insert into tx1 values(1,''The number one'',456.12)',"insert into tx1(a,b) values(2,'The number two'),(3,'The number three')");
command number message command number message
insert into tx1 values(1,'The number one',456.12) 1 Affected rows insert into tx1 values(1,'The number one',456.12) 1 Affected rows
insert into tx1(a,b) values(2,'The number two'),(3,'The number three') 2 Affected rows insert into tx1(a,b) values(2,'The number two'),(3,'The number three') 2 Affected rows
Warnings:
Warning 1105 Affected rows
SELECT * FROM t2 WHERE command='update tx1 set c = 3.1416 where a = 2'; SELECT * FROM t2 WHERE command='update tx1 set c = 3.1416 where a = 2';
command number message command number message
update tx1 set c = 3.1416 where a = 2 1 Affected rows update tx1 set c = 3.1416 where a = 2 1 Affected rows
Warnings:
Warning 1105 Affected rows
SELECT * FROM t2 WHERE command='select * from tx1'; SELECT * FROM t2 WHERE command='select * from tx1';
command number message command number message
select * from tx1 3 Result set column number select * from tx1 3 Result set column number
Warnings:
Warning 1105 Result set column number
SELECT * FROM t2 WHERE command='delete from tx1 where a = 2'; SELECT * FROM t2 WHERE command='delete from tx1 where a = 2';
command number message command number message
delete from tx1 where a = 2 1 Affected rows delete from tx1 where a = 2 1 Affected rows
Warnings:
Warning 1105 Affected rows
SELECT * FROM connect.tx1; SELECT * FROM connect.tx1;
a b c a b c
1 The number one 456.12 1 The number one 456.12
......
...@@ -9,12 +9,18 @@ OPTION_LIST='Execsrc=1'; ...@@ -9,12 +9,18 @@ OPTION_LIST='Execsrc=1';
SELECT * FROM t2 WHERE command='drop table employee'; SELECT * FROM t2 WHERE command='drop table employee';
command number message command number message
drop table employee 0 Execute: org.postgresql.util.PSQLException: ERREUR: la table « employee » n'existe pas drop table employee 0 Execute: org.postgresql.util.PSQLException: ERREUR: la table « employee » n'existe pas
Warnings:
Warning 1105 Execute: org.postgresql.util.PSQLException: ERREUR: la table employee n'existe pas
SELECT * FROM t2 WHERE command = 'create table employee (id int not null, name varchar(32), title char(16), salary decimal(8,2))'; SELECT * FROM t2 WHERE command = 'create table employee (id int not null, name varchar(32), title char(16), salary decimal(8,2))';
command number message command number message
create table employee (id int not null, name varchar(32), title char(16), salary decimal(8,2)) 0 Affected rows create table employee (id int not null, name varchar(32), title char(16), salary decimal(8,2)) 0 Affected rows
Warnings:
Warning 1105 Affected rows
SELECT * FROM t2 WHERE command = "insert into employee values(4567,'Johnson', 'Engineer', 12560.50)"; SELECT * FROM t2 WHERE command = "insert into employee values(4567,'Johnson', 'Engineer', 12560.50)";
command number message command number message
insert into employee values(4567,'Johnson', 'Engineer', 12560.50) 1 Affected rows insert into employee values(4567,'Johnson', 'Engineer', 12560.50) 1 Affected rows
Warnings:
Warning 1105 Affected rows
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC CATFUNC=tables CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC CATFUNC=tables
CONNECTION='jdbc:postgresql://localhost/test?user=postgres&password=tinono' CONNECTION='jdbc:postgresql://localhost/test?user=postgres&password=tinono'
OPTION_LIST='Tabtype=TABLE,Maxres=10'; OPTION_LIST='Tabtype=TABLE,Maxres=10';
...@@ -63,4 +69,6 @@ DROP SERVER 'postgresql'; ...@@ -63,4 +69,6 @@ DROP SERVER 'postgresql';
SELECT * FROM t2 WHERE command='drop table employee'; SELECT * FROM t2 WHERE command='drop table employee';
command number message command number message
drop table employee 0 Affected rows drop table employee 0 Affected rows
Warnings:
Warning 1105 Affected rows
DROP TABLE t2; DROP TABLE t2;
...@@ -35,6 +35,8 @@ insert ignore into t1(id) values(NULL) 1 1 Affected rows ...@@ -35,6 +35,8 @@ insert ignore into t1(id) values(NULL) 1 1 Affected rows
Warning 0 1364 Field 'msg' doesn't have a default value Warning 0 1364 Field 'msg' doesn't have a default value
update t1 set msg = 'Four' where id = 4 0 1 Affected rows update t1 set msg = 'Four' where id = 4 0 1 Affected rows
select * from t1 0 2 Result set columns select * from t1 0 2 Result set columns
Warnings:
Warning 1105 Result set columns
# #
# Checking Using Procedure # Checking Using Procedure
# #
...@@ -48,9 +50,13 @@ CALL p1('insert ignore into t1(id) values(NULL)'); ...@@ -48,9 +50,13 @@ CALL p1('insert ignore into t1(id) values(NULL)');
command warnings number message command warnings number message
insert ignore into t1(id) values(NULL) 1 1 Affected rows insert ignore into t1(id) values(NULL) 1 1 Affected rows
Warning 0 1364 Field 'msg' doesn't have a default value Warning 0 1364 Field 'msg' doesn't have a default value
Warnings:
Warning 1105 Affected rows
CALL p1('update t1 set msg = "Five" where id = 5'); CALL p1('update t1 set msg = "Five" where id = 5');
command warnings number message command warnings number message
update t1 set msg = "Five" where id = 5 0 1 Affected rows update t1 set msg = "Five" where id = 5 0 1 Affected rows
Warnings:
Warning 1105 Affected rows
DROP PROCEDURE p1; DROP PROCEDURE p1;
DROP TABLE t1; DROP TABLE t1;
connection slave; connection slave;
......
...@@ -99,9 +99,9 @@ Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Bu ...@@ -99,9 +99,9 @@ Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Bu
mtr public t1 a 4 int4 10 4 0 10 0 mtr public t1 a 4 int4 10 4 0 10 0
mtr public t2 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 mtr public v1 a 4 int4 10 4 0 10 1
mtr schema1 t1 a 1 bpchar 10 60 NULL NULL 0 mtr schema1 t1 a 1 bpchar 10 40 NULL NULL 0
mtr schema1 t2 a 1 bpchar 10 60 NULL NULL 0 mtr schema1 t2 a 1 bpchar 10 40 NULL NULL 0
mtr schema1 v1 a 1 bpchar 10 60 NULL NULL 1 mtr schema1 v1 a 1 bpchar 10 40 NULL NULL 1
DROP TABLE t1; DROP TABLE t1;
# All columns in the schemas "public" and "schema1" # 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='%.%.%'; CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' CATFUNC=Columns TABNAME='%.%.%';
...@@ -110,16 +110,16 @@ Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Bu ...@@ -110,16 +110,16 @@ Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Bu
mtr public t1 a 4 int4 10 4 0 10 0 mtr public t1 a 4 int4 10 4 0 10 0
mtr public t2 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 mtr public v1 a 4 int4 10 4 0 10 1
mtr schema1 t1 a 1 bpchar 10 60 NULL NULL 0 mtr schema1 t1 a 1 bpchar 10 40 NULL NULL 0
mtr schema1 t2 a 1 bpchar 10 60 NULL NULL 0 mtr schema1 t2 a 1 bpchar 10 40 NULL NULL 0
mtr schema1 v1 a 1 bpchar 10 60 NULL NULL 1 mtr schema1 v1 a 1 bpchar 10 40 NULL NULL 1
DROP TABLE t1; DROP TABLE t1;
# All tables "t1" in all schemas # 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'; 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_Schema, Table_Name; 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 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 t1 a 4 int4 10 4 0 10 0
mtr schema1 t1 a 1 bpchar 10 60 NULL NULL 0 mtr schema1 t1 a 1 bpchar 10 40 NULL NULL 0
DROP TABLE t1; DROP TABLE t1;
# Table "t1" in the schema "public" # 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'; CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' CATFUNC=Columns TABNAME='%.public.t1';
...@@ -131,14 +131,14 @@ DROP TABLE t1; ...@@ -131,14 +131,14 @@ DROP TABLE t1;
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' CATFUNC=Columns TABNAME='%.schema1.t1'; 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_Schema, Table_Name; 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 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 NULL NULL 0 mtr schema1 t1 a 1 bpchar 10 40 NULL NULL 0
DROP TABLE t1; DROP TABLE t1;
# All tables "t1" in all schemas (Catalog name is ignored by PostgreSQL) # 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'; 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_Schema, Table_Name; 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 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 t1 a 4 int4 10 4 0 10 0
mtr schema1 t1 a 1 bpchar 10 60 NULL NULL 0 mtr schema1 t1 a 1 bpchar 10 40 NULL NULL 0
DROP TABLE t1; DROP TABLE t1;
# #
# Checking tables # Checking tables
......
...@@ -2354,11 +2354,11 @@ int ODBConn::GetCatInfo(CATPARM *cap) ...@@ -2354,11 +2354,11 @@ int ODBConn::GetCatInfo(CATPARM *cap)
if (!Check(rc)) if (!Check(rc))
ThrowDBX(rc, fnc, hstmt); ThrowDBX(rc, fnc, hstmt);
rc = SQLNumResultCols(hstmt, &ncol); // Some data source do not implement SQLNumResultCols
if (Check(SQLNumResultCols(hstmt, &ncol)))
// n because we no more ignore the first column // n because we no more ignore the first column
if ((n = (UWORD)qrp->Nbcol) > (UWORD)ncol) if ((n = (UWORD)qrp->Nbcol) > (UWORD)ncol)
ThrowDBX(MSG(COL_NUM_MISM)); ThrowDBX(MSG(COL_NUM_MISM));
// Unconditional to handle STRBLK's // Unconditional to handle STRBLK's
pval = (PVAL *)PlugSubAlloc(g, NULL, n * sizeof(PVAL)); pval = (PVAL *)PlugSubAlloc(g, NULL, n * sizeof(PVAL));
......
...@@ -125,6 +125,12 @@ EXTDEF::EXTDEF(void) ...@@ -125,6 +125,12 @@ EXTDEF::EXTDEF(void)
/***********************************************************************/ /***********************************************************************/
bool EXTDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) bool EXTDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
{ {
if (g->Createas) {
strcpy(g->Message,
"Multiple-table UPDATE/DELETE commands are not supported");
return true;
} // endif multi
Desc = NULL; Desc = NULL;
Tabname = GetStringCatInfo(g, "Name", Tabname = GetStringCatInfo(g, "Name",
(Catfunc & (FNC_TABLE | FNC_COL)) ? NULL : Name); (Catfunc & (FNC_TABLE | FNC_COL)) ? NULL : Name);
......
...@@ -1157,8 +1157,9 @@ bool TDBXJDC::OpenDB(PGLOBAL g) ...@@ -1157,8 +1157,9 @@ bool TDBXJDC::OpenDB(PGLOBAL g)
/* Get the command to execute. */ /* Get the command to execute. */
/*********************************************************************/ /*********************************************************************/
if (!(Cmdlist = MakeCMD(g))) { if (!(Cmdlist = MakeCMD(g))) {
Jcp->Close(); // Next lines commented out because of CHECK TABLE
return true; //Jcp->Close();
//return true;
} // endif Query } // endif Query
Rows = 1; Rows = 1;
...@@ -1189,8 +1190,10 @@ int TDBXJDC::ReadDB(PGLOBAL g) ...@@ -1189,8 +1190,10 @@ int TDBXJDC::ReadDB(PGLOBAL g)
Fpos++; // Used for progress info Fpos++; // Used for progress info
Cmdlist = (Nerr > Mxr) ? NULL : Cmdlist->Next; Cmdlist = (Nerr > Mxr) ? NULL : Cmdlist->Next;
return RC_OK; return RC_OK;
} else } else {
PushWarning(g, this, 1);
return RC_EF; return RC_EF;
} // endif Cmdlist
} // end of ReadDB } // end of ReadDB
......
...@@ -1587,8 +1587,9 @@ bool TDBMYEXC::OpenDB(PGLOBAL g) ...@@ -1587,8 +1587,9 @@ bool TDBMYEXC::OpenDB(PGLOBAL g)
/* Get the command to execute. */ /* Get the command to execute. */
/*********************************************************************/ /*********************************************************************/
if (!(Cmdlist = MakeCMD(g))) { if (!(Cmdlist = MakeCMD(g))) {
Myc.Close(); // Next lines commented out because of CHECK TABLE
return true; //Myc.Close();
//return true;
} // endif Cmdlist } // endif Cmdlist
return false; return false;
...@@ -1647,8 +1648,10 @@ int TDBMYEXC::ReadDB(PGLOBAL g) ...@@ -1647,8 +1648,10 @@ int TDBMYEXC::ReadDB(PGLOBAL g)
++N; ++N;
return RC_OK; return RC_OK;
} else } else {
return RC_EF; PushWarning(g, this, 1);
return RC_EF;
} // endif Cmdlist
} // end of ReadDB } // end of ReadDB
......
...@@ -1249,9 +1249,10 @@ bool TDBXDBC::OpenDB(PGLOBAL g) ...@@ -1249,9 +1249,10 @@ bool TDBXDBC::OpenDB(PGLOBAL g)
/* Get the command to execute. */ /* Get the command to execute. */
/*********************************************************************/ /*********************************************************************/
if (!(Cmdlist = MakeCMD(g))) { if (!(Cmdlist = MakeCMD(g))) {
Ocp->Close(); // Next lines commented out because of CHECK TABLE
return true; //Ocp->Close();
} // endif Query //return true;
} // endif Cmdlist
Rows = 1; Rows = 1;
return false; return false;
...@@ -1274,8 +1275,10 @@ int TDBXDBC::ReadDB(PGLOBAL g) ...@@ -1274,8 +1275,10 @@ int TDBXDBC::ReadDB(PGLOBAL g)
Fpos++; // Used for progress info Fpos++; // Used for progress info
Cmdlist = (Nerr > Mxr) ? NULL : Cmdlist->Next; Cmdlist = (Nerr > Mxr) ? NULL : Cmdlist->Next;
return RC_OK; return RC_OK;
} else } else {
return RC_EF; PushWarning(g, this, 1);
return RC_EF;
} // endif Cmdlist
} // end of ReadDB } // end of ReadDB
......
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