mirror of
https://github.com/MariaDB/server.git
synced 2025-12-24 11:21:21 +03:00
Merge 10.0 into 10.1
Significantly reduce the amount of InnoDB, XtraDB and Mariabackup code changes by defining pfs_os_file_t as something that is transparently compatible with os_file_t.
This commit is contained in:
@@ -450,7 +450,7 @@ datadir_iter_free(datadir_iter_t *it)
|
||||
/************************************************************************
|
||||
Holds the state needed to copy single data file. */
|
||||
struct datafile_cur_t {
|
||||
os_file_t file;
|
||||
pfs_os_file_t file;
|
||||
char rel_path[FN_REFLEN];
|
||||
char abs_path[FN_REFLEN];
|
||||
MY_STAT statinfo;
|
||||
|
||||
@@ -35,7 +35,7 @@ Remove these on the first opportunity, i.e. single-binary XtraBackup. */
|
||||
/** Single bitmap file information */
|
||||
struct log_online_bitmap_file_t {
|
||||
char name[FN_REFLEN]; /*!< Name with full path */
|
||||
os_file_t file; /*!< Handle to opened file */
|
||||
pfs_os_file_t file; /*!< Handle to opened file */
|
||||
ib_uint64_t size; /*!< Size of the file */
|
||||
ib_uint64_t offset; /*!< Offset of the next read,
|
||||
or count of already-read bytes
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
|
||||
*******************************************************/
|
||||
|
||||
#include "my_config.h"
|
||||
#include "crc_glue.h"
|
||||
#include "crc-intel-pclmul.h"
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -29,7 +29,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
#include "read_filt.h"
|
||||
|
||||
struct xb_fil_cur_t {
|
||||
os_file_t file; /*!< source file handle */
|
||||
pfs_os_file_t file; /*!< source file handle */
|
||||
fil_node_t* node; /*!< source tablespace node */
|
||||
char rel_path[FN_REFLEN];
|
||||
/*!< normalized file path */
|
||||
|
||||
@@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
|
||||
|
||||
extern void os_io_init_simple(void);
|
||||
extern os_file_t files[1000];
|
||||
extern pfs_os_file_t files[1000];
|
||||
extern const char *innodb_checksum_algorithm_names[];
|
||||
extern TYPELIB innodb_checksum_algorithm_typelib;
|
||||
extern dberr_t open_or_create_data_files(
|
||||
|
||||
@@ -2412,7 +2412,7 @@ check_if_skip_table(
|
||||
Reads the space flags from a given data file and returns the compressed
|
||||
page size, or 0 if the space is not compressed. */
|
||||
ulint
|
||||
xb_get_zip_size(os_file_t file)
|
||||
xb_get_zip_size(pfs_os_file_t file)
|
||||
{
|
||||
byte *buf;
|
||||
byte *page;
|
||||
@@ -4856,7 +4856,7 @@ end:
|
||||
static my_bool
|
||||
xtrabackup_init_temp_log(void)
|
||||
{
|
||||
os_file_t src_file = XB_FILE_UNDEFINED;
|
||||
pfs_os_file_t src_file;
|
||||
char src_path[FN_REFLEN];
|
||||
char dst_path[FN_REFLEN];
|
||||
ibool success;
|
||||
@@ -5183,7 +5183,7 @@ xb_space_create_file(
|
||||
ulint space_id, /*!<in: space id */
|
||||
ulint flags __attribute__((unused)),/*!<in: tablespace
|
||||
flags */
|
||||
os_file_t* file) /*!<out: file handle */
|
||||
pfs_os_file_t* file) /*!<out: file handle */
|
||||
{
|
||||
ibool ret;
|
||||
byte* buf;
|
||||
@@ -5262,7 +5262,7 @@ mismatching ID, renames it to xtrabackup_tmp_#ID.ibd. If there was no
|
||||
matching file, creates a new tablespace.
|
||||
@return file handle of matched or created file */
|
||||
static
|
||||
os_file_t
|
||||
pfs_os_file_t
|
||||
xb_delta_open_matching_space(
|
||||
const char* dbname, /* in: path to destination database dir */
|
||||
const char* name, /* in: name of delta file (without .delta) */
|
||||
@@ -5276,7 +5276,7 @@ xb_delta_open_matching_space(
|
||||
char dest_space_name[FN_REFLEN];
|
||||
ibool ok;
|
||||
fil_space_t* fil_space;
|
||||
os_file_t file = 0;
|
||||
pfs_os_file_t file;
|
||||
ulint tablespace_flags;
|
||||
xb_filter_entry_t* table;
|
||||
|
||||
@@ -5440,8 +5440,8 @@ xtrabackup_apply_delta(
|
||||
including the .delta extension */
|
||||
void* /*data*/)
|
||||
{
|
||||
os_file_t src_file = XB_FILE_UNDEFINED;
|
||||
os_file_t dst_file = XB_FILE_UNDEFINED;
|
||||
pfs_os_file_t src_file;
|
||||
pfs_os_file_t dst_file;
|
||||
char src_path[FN_REFLEN];
|
||||
char dst_path[FN_REFLEN];
|
||||
char meta_path[FN_REFLEN];
|
||||
@@ -5815,7 +5815,7 @@ xtrabackup_apply_deltas()
|
||||
static my_bool
|
||||
xtrabackup_close_temp_log(my_bool clear_flag)
|
||||
{
|
||||
os_file_t src_file = XB_FILE_UNDEFINED;
|
||||
pfs_os_file_t src_file;
|
||||
char src_path[FN_REFLEN];
|
||||
char dst_path[FN_REFLEN];
|
||||
ibool success;
|
||||
@@ -6597,7 +6597,7 @@ skip_check:
|
||||
|
||||
if (xtrabackup_export) {
|
||||
msg("xtrabackup: export option is specified.\n");
|
||||
os_file_t info_file = XB_FILE_UNDEFINED;
|
||||
pfs_os_file_t info_file;
|
||||
char info_file_path[FN_REFLEN];
|
||||
ibool success;
|
||||
char table_name[FN_REFLEN];
|
||||
|
||||
@@ -27,7 +27,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
#include "changed_page_bitmap.h"
|
||||
|
||||
#ifdef __WIN__
|
||||
#define XB_FILE_UNDEFINED NULL
|
||||
#define XB_FILE_UNDEFINED INVALID_HANDLE_VALUE
|
||||
#else
|
||||
#define XB_FILE_UNDEFINED (-1)
|
||||
#endif
|
||||
@@ -194,7 +194,7 @@ void xb_data_files_close(void);
|
||||
/***********************************************************************
|
||||
Reads the space flags from a given data file and returns the compressed
|
||||
page size, or 0 if the space is not compressed. */
|
||||
ulint xb_get_zip_size(os_file_t file);
|
||||
ulint xb_get_zip_size(pfs_os_file_t file);
|
||||
|
||||
/************************************************************************
|
||||
Checks if a table specified as a name in the form "database/name" (InnoDB 5.6)
|
||||
|
||||
@@ -2590,5 +2590,43 @@ Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 27
|
||||
deallocate prepare stmt1;
|
||||
drop table t1,t2;
|
||||
#
|
||||
# Bug mdev-12670: mergeable derived / view with subqueries
|
||||
# subject to semi-join optimizations
|
||||
# (actually this is a 5.3 bug.)
|
||||
#
|
||||
create table t1 (a int) engine=myisam;
|
||||
insert into t1 values (5),(3),(2),(7),(2),(5),(1);
|
||||
create table t2 (b int, index idx(b)) engine=myisam;
|
||||
insert into t2 values (2),(3),(2),(1),(3),(4);
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
analyze table t1,t2;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
test.t2 analyze status OK
|
||||
explain select a from t1 where a in (select b from t2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 7 Using where
|
||||
1 PRIMARY t2 ref idx idx 5 test.t1.a 140 Using index; FirstMatch(t1)
|
||||
explain select * from (select a from t1 where a in (select b from t2)) t;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 7 Using where
|
||||
1 PRIMARY t2 ref idx idx 5 test.t1.a 140 Using index; FirstMatch(t1)
|
||||
create view v1 as select a from t1 where a in (select b from t2);
|
||||
explain select * from v1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 7 Using where
|
||||
1 PRIMARY t2 ref idx idx 5 test.t1.a 140 Using index; FirstMatch(t1)
|
||||
drop view v1;
|
||||
drop table t1,t2;
|
||||
set optimizer_switch=@exit_optimizer_switch;
|
||||
set join_cache_level=@exit_join_cache_level;
|
||||
|
||||
@@ -426,7 +426,7 @@ c1
|
||||
bb
|
||||
cc
|
||||
Warnings:
|
||||
Warning 1931 Query execution was interrupted. The query examined at least 18 rows, which exceeds LIMIT ROWS EXAMINED (16). The query result may be incomplete.
|
||||
Warning 1931 Query execution was interrupted. The query examined at least 17 rows, which exceeds LIMIT ROWS EXAMINED (16). The query result may be incomplete.
|
||||
select * from v1 LIMIT ROWS EXAMINED 11;
|
||||
c1
|
||||
bb
|
||||
@@ -439,7 +439,8 @@ from (select * from t1
|
||||
where c1 IN (select * from t2 where c2 > ' ' LIMIT ROWS EXAMINED 0)) as tmp
|
||||
LIMIT ROWS EXAMINED 11;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4
|
||||
1 PRIMARY <subquery3> eq_ref distinct_key distinct_key 2 func 1
|
||||
3 MATERIALIZED t2 ALL NULL NULL NULL NULL 4 Using where
|
||||
select *
|
||||
from (select * from t1
|
||||
|
||||
@@ -379,6 +379,7 @@ drop table t3, t4, t5;
|
||||
#
|
||||
# LP BUG#858038 The result of a query with NOT IN subquery depends on the state of the optimizer switch
|
||||
#
|
||||
set @optimizer_switch_save= @@optimizer_switch;
|
||||
create table t1 (c1 char(2) not null, c2 char(2));
|
||||
create table t2 (c3 char(2), c4 char(2));
|
||||
insert into t1 values ('a1', 'b1');
|
||||
@@ -400,6 +401,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
select * from t1 where c1 = 'a2' and (c1, c2) not in (select * from t2);
|
||||
c1 c2
|
||||
drop table t1, t2;
|
||||
set optimizer_switch= @optimizer_switch_save;
|
||||
#
|
||||
# MDEV-12673: cost-based choice between materialization and in-to-exists
|
||||
#
|
||||
@@ -442,3 +444,44 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
2 DEPENDENT SUBQUERY t3 const PRIMARY PRIMARY 4 const 1
|
||||
2 DEPENDENT SUBQUERY t2 index NULL i2 11 NULL 2 Using where; Using index
|
||||
DROP TABLE t1,t2,t3;
|
||||
#
|
||||
# MDEV-7599: in-to-exists chosen after min/max optimization
|
||||
#
|
||||
set @optimizer_switch_save= @@optimizer_switch;
|
||||
CREATE TABLE t1 (a INT, KEY(a)) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES (1),(2);
|
||||
CREATE TABLE t2 (b INT, c INT) ENGINE=MyISAM;
|
||||
INSERT INTO t2 VALUES (1,6),(2,4), (8,9);
|
||||
SELECT * FROM t2 WHERE b != ALL (SELECT MIN(a) FROM t1, t2 WHERE t2.c = t2.b);
|
||||
b c
|
||||
EXPLAIN EXTENDED SELECT * FROM t2 WHERE b != ALL (SELECT MIN(a) FROM t1, t2 WHERE t2.c = t2.b);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 3 100.00 Using where
|
||||
2 MATERIALIZED t1 index NULL a 5 NULL 2 100.00 Using index
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` where (not(<expr_cache><`test`.`t2`.`b`>(<in_optimizer>(`test`.`t2`.`b`,`test`.`t2`.`b` in ( <materialize> (select min(`test`.`t1`.`a`) from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`c` = `test`.`t2`.`b`) ), <primary_index_lookup>(`test`.`t2`.`b` in <temporary table> on distinct_key where ((`test`.`t2`.`b` = `<subquery2>`.`MIN(a)`))))))))
|
||||
set optimizer_switch= 'materialization=off';
|
||||
SELECT * FROM t2 WHERE b != ALL (SELECT MIN(a) FROM t1, t2 WHERE t2.c = t2.b);
|
||||
b c
|
||||
EXPLAIN EXTENDED SELECT * FROM t2 WHERE b != ALL (SELECT MIN(a) FROM t1, t2 WHERE t2.c = t2.b);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 3 100.00 Using where
|
||||
2 DEPENDENT SUBQUERY t1 index NULL a 5 NULL 2 100.00 Using index
|
||||
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` where (not(<expr_cache><`test`.`t2`.`b`>(<in_optimizer>(`test`.`t2`.`b`,<exists>(select min(`test`.`t1`.`a`) from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`c` = `test`.`t2`.`b`) having trigcond((<cache>(`test`.`t2`.`b`) = <ref_null_helper>(min(`test`.`t1`.`a`)))))))))
|
||||
set optimizer_switch= @optimizer_switch_save;
|
||||
DROP TABLE t1,t2;
|
||||
CREATE TABLE t1 (f1 varchar(10)) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES ('foo'),('bar');
|
||||
CREATE TABLE t2 (f2 varchar(10), key(f2)) ENGINE=MyISAM;
|
||||
INSERT INTO t2 VALUES ('baz'),('qux');
|
||||
CREATE TABLE t3 (f3 varchar(10)) ENGINE=MyISAM;
|
||||
INSERT INTO t3 VALUES ('abc'),('def');
|
||||
SELECT * FROM t1
|
||||
WHERE f1 = ALL( SELECT MAX(t2a.f2)
|
||||
FROM t2 AS t2a INNER JOIN t2 t2b INNER JOIN t3
|
||||
ON (f3 = t2b.f2) );
|
||||
f1
|
||||
DROP TABLE t1,t2,t3;
|
||||
|
||||
@@ -1652,9 +1652,9 @@ CREATE VIEW v1 AS SELECT 1;
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 INNER JOIN t2 ON t2.a != 0 AND t2.a IN (SELECT * FROM v1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <derived3> system NULL NULL NULL NULL 1
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
|
||||
2 MATERIALIZED <derived3> system NULL NULL NULL NULL 1
|
||||
3 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
SELECT * FROM t1 INNER JOIN t2 ON t2.a != 0 AND t2.a IN (SELECT * FROM v1);
|
||||
a a
|
||||
@@ -3068,4 +3068,43 @@ project_number
|
||||
aaa
|
||||
drop table t1, t2, t3;
|
||||
set optimizer_switch= @tmp_mdev6859;
|
||||
#
|
||||
# MDEV-12675: subquery subject to semi-join optimizations
|
||||
# in ON expression of INNER JOIN
|
||||
#
|
||||
set @tmp_mdev12675=@@optimizer_switch;
|
||||
set optimizer_switch=default;
|
||||
create table t1 (a int) engine=myisam;
|
||||
insert into t1 values (5),(3),(2),(7),(2),(5),(1);
|
||||
create table t2 (b int, index idx(b)) engine=myisam;
|
||||
insert into t2 values (2),(3),(2),(1),(3),(4);
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
analyze table t1,t2;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
test.t2 analyze status OK
|
||||
explain
|
||||
select a from t1, t2 where b between 1 and 2 and a in (select b from t2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 7 Using where
|
||||
1 PRIMARY t2 ref idx idx 5 test.t1.a 256 Using index; FirstMatch(t1)
|
||||
1 PRIMARY t2 range idx idx 5 NULL 2 Using where; Using index; Using join buffer (flat, BNL join)
|
||||
explain
|
||||
select a from t1 join t2 on b between 1 and 2 and a in (select b from t2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 7 Using where
|
||||
1 PRIMARY t2 ref idx idx 5 test.t1.a 256 Using index; FirstMatch(t1)
|
||||
1 PRIMARY t2 range idx idx 5 NULL 2 Using where; Using index; Using join buffer (flat, BNL join)
|
||||
drop table t1,t2;
|
||||
set optimizer_switch= @tmp_mdev12675;
|
||||
set optimizer_switch=@subselect_sj_tmp;
|
||||
|
||||
@@ -1610,3 +1610,26 @@ i1
|
||||
DROP TABLE t1,t2,t3;
|
||||
set join_cache_level= @save_join_cache_level;
|
||||
set optimizer_switch=@save_optimizer_switch;
|
||||
#
|
||||
# mdev-7791: materialization of a semi-join subquery +
|
||||
# RAND() in WHERE
|
||||
# (materialized table is accessed last)
|
||||
#
|
||||
set @save_optimizer_switch=@@optimizer_switch;
|
||||
set optimizer_switch='materialization=on';
|
||||
create table t1(i int);
|
||||
insert into t1 values (1), (2), (3), (7), (9), (10);
|
||||
create table t2(i int);
|
||||
insert into t2 values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
|
||||
select * from t1 where (rand() < 0) and i in (select i from t2);
|
||||
i
|
||||
explain extended
|
||||
select * from t1 where (rand() < 0) and i in (select i from t2);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 100.00
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 10 100.00
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2`) where ((rand() < 0))
|
||||
drop table t1,t2;
|
||||
set optimizer_switch=@save_optimizer_switch;
|
||||
|
||||
@@ -1665,9 +1665,9 @@ CREATE VIEW v1 AS SELECT 1;
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 INNER JOIN t2 ON t2.a != 0 AND t2.a IN (SELECT * FROM v1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <derived3> system NULL NULL NULL NULL 1
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
|
||||
2 MATERIALIZED <derived3> system NULL NULL NULL NULL 1
|
||||
3 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
SELECT * FROM t1 INNER JOIN t2 ON t2.a != 0 AND t2.a IN (SELECT * FROM v1);
|
||||
a a
|
||||
@@ -3082,6 +3082,45 @@ project_number
|
||||
aaa
|
||||
drop table t1, t2, t3;
|
||||
set optimizer_switch= @tmp_mdev6859;
|
||||
#
|
||||
# MDEV-12675: subquery subject to semi-join optimizations
|
||||
# in ON expression of INNER JOIN
|
||||
#
|
||||
set @tmp_mdev12675=@@optimizer_switch;
|
||||
set optimizer_switch=default;
|
||||
create table t1 (a int) engine=myisam;
|
||||
insert into t1 values (5),(3),(2),(7),(2),(5),(1);
|
||||
create table t2 (b int, index idx(b)) engine=myisam;
|
||||
insert into t2 values (2),(3),(2),(1),(3),(4);
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
analyze table t1,t2;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
test.t2 analyze status OK
|
||||
explain
|
||||
select a from t1, t2 where b between 1 and 2 and a in (select b from t2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 7 Using where
|
||||
1 PRIMARY t2 ref idx idx 5 test.t1.a 256 Using index; FirstMatch(t1)
|
||||
1 PRIMARY t2 range idx idx 5 NULL 2 Using where; Using index; Using join buffer (flat, BNL join)
|
||||
explain
|
||||
select a from t1 join t2 on b between 1 and 2 and a in (select b from t2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 7 Using where
|
||||
1 PRIMARY t2 ref idx idx 5 test.t1.a 256 Using index; FirstMatch(t1)
|
||||
1 PRIMARY t2 range idx idx 5 NULL 2 Using where; Using index; Using join buffer (flat, BNL join)
|
||||
drop table t1,t2;
|
||||
set optimizer_switch= @tmp_mdev12675;
|
||||
set optimizer_switch=@subselect_sj_tmp;
|
||||
#
|
||||
# BUG#49129: Wrong result with IN-subquery with join_cache_level=6 and firstmatch=off
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
SELECT "Digest table has a size 1 and is full already." as use_case;
|
||||
use_case
|
||||
Digest table has a size 1 and is full already.
|
||||
select SCHEMA_NAME, DIGEST, DIGEST_TEXT
|
||||
from performance_schema.events_statements_summary_by_digest;
|
||||
SCHEMA_NAME DIGEST DIGEST_TEXT
|
||||
NULL NULL NULL
|
||||
@@ -0,0 +1 @@
|
||||
--performance-schema-digests-size=1
|
||||
15
mysql-test/suite/perfschema/t/start_server_1_digest.test
Normal file
15
mysql-test/suite/perfschema/t/start_server_1_digest.test
Normal file
@@ -0,0 +1,15 @@
|
||||
# -----------------------------------------------------------------------
|
||||
# Tests for the performance schema statement Digests.
|
||||
# -----------------------------------------------------------------------
|
||||
|
||||
--source include/not_embedded.inc
|
||||
--source include/have_perfschema.inc
|
||||
--source include/no_protocol.inc
|
||||
|
||||
SELECT "Digest table has a size 1 and is full already." as use_case;
|
||||
|
||||
select SCHEMA_NAME, DIGEST, DIGEST_TEXT
|
||||
from performance_schema.events_statements_summary_by_digest;
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
SET @start_value = @@GLOBAL.innodb_empty_free_list_algorithm;
|
||||
SELECT @@GLOBAL.innodb_empty_free_list_algorithm;
|
||||
@@GLOBAL.innodb_empty_free_list_algorithm
|
||||
BACKOFF
|
||||
LEGACY
|
||||
SELECT @@SESSION.innodb_empty_free_list_algorithm;
|
||||
ERROR HY000: Variable 'innodb_empty_free_list_algorithm' is a GLOBAL variable
|
||||
SET GLOBAL innodb_empty_free_list_algorithm='legacy';
|
||||
|
||||
@@ -661,8 +661,8 @@
|
||||
COMMAND_LINE_ARGUMENT OPTIONAL
|
||||
VARIABLE_NAME INNODB_VERSION
|
||||
SESSION_VALUE NULL
|
||||
-GLOBAL_VALUE 5.6.35
|
||||
+GLOBAL_VALUE 5.6.35-80.0
|
||||
-GLOBAL_VALUE 5.6.36
|
||||
+GLOBAL_VALUE 5.6.36-80.0
|
||||
GLOBAL_VALUE_ORIGIN COMPILE-TIME
|
||||
DEFAULT_VALUE NULL
|
||||
VARIABLE_SCOPE GLOBAL
|
||||
|
||||
@@ -2387,7 +2387,7 @@ READ_ONLY NO
|
||||
COMMAND_LINE_ARGUMENT OPTIONAL
|
||||
VARIABLE_NAME INNODB_VERSION
|
||||
SESSION_VALUE NULL
|
||||
GLOBAL_VALUE 5.6.35
|
||||
GLOBAL_VALUE 5.6.36
|
||||
GLOBAL_VALUE_ORIGIN COMPILE-TIME
|
||||
DEFAULT_VALUE NULL
|
||||
VARIABLE_SCOPE GLOBAL
|
||||
|
||||
@@ -1881,6 +1881,36 @@ deallocate prepare stmt1;
|
||||
|
||||
drop table t1,t2;
|
||||
|
||||
--echo #
|
||||
--echo # Bug mdev-12670: mergeable derived / view with subqueries
|
||||
--echo # subject to semi-join optimizations
|
||||
--echo # (actually this is a 5.3 bug.)
|
||||
--echo #
|
||||
|
||||
create table t1 (a int) engine=myisam;
|
||||
insert into t1 values (5),(3),(2),(7),(2),(5),(1);
|
||||
create table t2 (b int, index idx(b)) engine=myisam;
|
||||
insert into t2 values (2),(3),(2),(1),(3),(4);
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
analyze table t1,t2;
|
||||
|
||||
explain select a from t1 where a in (select b from t2);
|
||||
explain select * from (select a from t1 where a in (select b from t2)) t;
|
||||
create view v1 as select a from t1 where a in (select b from t2);
|
||||
explain select * from v1;
|
||||
|
||||
drop view v1;
|
||||
drop table t1,t2;
|
||||
|
||||
# The following command must be the last one the file
|
||||
set optimizer_switch=@exit_optimizer_switch;
|
||||
set join_cache_level=@exit_join_cache_level;
|
||||
|
||||
@@ -406,6 +406,8 @@ drop table t3, t4, t5;
|
||||
--echo # LP BUG#858038 The result of a query with NOT IN subquery depends on the state of the optimizer switch
|
||||
--echo #
|
||||
|
||||
set @optimizer_switch_save= @@optimizer_switch;
|
||||
|
||||
create table t1 (c1 char(2) not null, c2 char(2));
|
||||
create table t2 (c3 char(2), c4 char(2));
|
||||
|
||||
@@ -425,6 +427,8 @@ select * from t1 where c1 = 'a2' and (c1, c2) not in (select * from t2);
|
||||
|
||||
drop table t1, t2;
|
||||
|
||||
set optimizer_switch= @optimizer_switch_save;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-12673: cost-based choice between materialization and in-to-exists
|
||||
--echo #
|
||||
@@ -463,3 +467,43 @@ SELECT * FROM t1 WHERE i1 NOT IN (
|
||||
);
|
||||
|
||||
DROP TABLE t1,t2,t3;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-7599: in-to-exists chosen after min/max optimization
|
||||
--echo #
|
||||
|
||||
set @optimizer_switch_save= @@optimizer_switch;
|
||||
|
||||
CREATE TABLE t1 (a INT, KEY(a)) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES (1),(2);
|
||||
|
||||
CREATE TABLE t2 (b INT, c INT) ENGINE=MyISAM;
|
||||
INSERT INTO t2 VALUES (1,6),(2,4), (8,9);
|
||||
|
||||
let $q=
|
||||
SELECT * FROM t2 WHERE b != ALL (SELECT MIN(a) FROM t1, t2 WHERE t2.c = t2.b);
|
||||
|
||||
eval $q;
|
||||
eval EXPLAIN EXTENDED $q;
|
||||
set optimizer_switch= 'materialization=off';
|
||||
eval $q;
|
||||
eval EXPLAIN EXTENDED $q;
|
||||
set optimizer_switch= @optimizer_switch_save;
|
||||
|
||||
DROP TABLE t1,t2;
|
||||
|
||||
CREATE TABLE t1 (f1 varchar(10)) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES ('foo'),('bar');
|
||||
|
||||
CREATE TABLE t2 (f2 varchar(10), key(f2)) ENGINE=MyISAM;
|
||||
INSERT INTO t2 VALUES ('baz'),('qux');
|
||||
|
||||
CREATE TABLE t3 (f3 varchar(10)) ENGINE=MyISAM;
|
||||
INSERT INTO t3 VALUES ('abc'),('def');
|
||||
|
||||
SELECT * FROM t1
|
||||
WHERE f1 = ALL( SELECT MAX(t2a.f2)
|
||||
FROM t2 AS t2a INNER JOIN t2 t2b INNER JOIN t3
|
||||
ON (f3 = t2b.f2) );
|
||||
|
||||
DROP TABLE t1,t2,t3;
|
||||
|
||||
@@ -2773,5 +2773,37 @@ WHERE ( SELECT z.country
|
||||
drop table t1, t2, t3;
|
||||
set optimizer_switch= @tmp_mdev6859;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-12675: subquery subject to semi-join optimizations
|
||||
--echo # in ON expression of INNER JOIN
|
||||
--echo #
|
||||
|
||||
set @tmp_mdev12675=@@optimizer_switch;
|
||||
set optimizer_switch=default;
|
||||
create table t1 (a int) engine=myisam;
|
||||
insert into t1 values (5),(3),(2),(7),(2),(5),(1);
|
||||
create table t2 (b int, index idx(b)) engine=myisam;
|
||||
insert into t2 values (2),(3),(2),(1),(3),(4);
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
analyze table t1,t2;
|
||||
|
||||
explain
|
||||
select a from t1, t2 where b between 1 and 2 and a in (select b from t2);
|
||||
explain
|
||||
select a from t1 join t2 on b between 1 and 2 and a in (select b from t2);
|
||||
|
||||
drop table t1,t2;
|
||||
set optimizer_switch= @tmp_mdev12675;
|
||||
|
||||
# The following command must be the last one the file
|
||||
set optimizer_switch=@subselect_sj_tmp;
|
||||
|
||||
@@ -263,3 +263,23 @@ DROP TABLE t1,t2,t3;
|
||||
set join_cache_level= @save_join_cache_level;
|
||||
set optimizer_switch=@save_optimizer_switch;
|
||||
|
||||
--echo #
|
||||
--echo # mdev-7791: materialization of a semi-join subquery +
|
||||
--echo # RAND() in WHERE
|
||||
--echo # (materialized table is accessed last)
|
||||
--echo #
|
||||
|
||||
set @save_optimizer_switch=@@optimizer_switch;
|
||||
set optimizer_switch='materialization=on';
|
||||
|
||||
create table t1(i int);
|
||||
insert into t1 values (1), (2), (3), (7), (9), (10);
|
||||
create table t2(i int);
|
||||
insert into t2 values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
|
||||
|
||||
select * from t1 where (rand() < 0) and i in (select i from t2);
|
||||
explain extended
|
||||
select * from t1 where (rand() < 0) and i in (select i from t2);
|
||||
|
||||
drop table t1,t2;
|
||||
set optimizer_switch=@save_optimizer_switch;
|
||||
|
||||
@@ -4038,6 +4038,7 @@ mariadb_dyncol_val_double(double *dbl, DYNAMIC_COLUMN_VALUE *val)
|
||||
*dbl= strtod(str, &end);
|
||||
if (*end != '\0')
|
||||
rc= ER_DYNCOL_TRUNCATED;
|
||||
break;
|
||||
}
|
||||
case DYN_COL_DECIMAL:
|
||||
if (decimal2double(&val->x.decimal.value, dbl) != E_DEC_OK)
|
||||
|
||||
@@ -1430,8 +1430,9 @@ Item_in_subselect::Item_in_subselect(THD *thd, Item * left_exp,
|
||||
st_select_lex *select_lex):
|
||||
Item_exists_subselect(thd), left_expr_cache(0), first_execution(TRUE),
|
||||
in_strategy(SUBS_NOT_TRANSFORMED),
|
||||
pushed_cond_guards(NULL), is_jtbm_merged(FALSE), is_jtbm_const_tab(FALSE),
|
||||
is_flattenable_semijoin(FALSE), is_registered_semijoin(FALSE),
|
||||
pushed_cond_guards(NULL), do_not_convert_to_sj(FALSE), is_jtbm_merged(FALSE),
|
||||
is_jtbm_const_tab(FALSE), is_flattenable_semijoin(FALSE),
|
||||
is_registered_semijoin(FALSE),
|
||||
upper_item(0)
|
||||
{
|
||||
DBUG_ENTER("Item_in_subselect::Item_in_subselect");
|
||||
@@ -2584,6 +2585,27 @@ bool Item_in_subselect::inject_in_to_exists_cond(JOIN *join_arg)
|
||||
DBUG_ENTER("Item_in_subselect::inject_in_to_exists_cond");
|
||||
DBUG_ASSERT(thd == join_arg->thd);
|
||||
|
||||
if (select_lex->min_max_opt_list.elements)
|
||||
{
|
||||
/*
|
||||
MIN/MAX optimizations have been applied to Item_sum objects
|
||||
of the subquery this subquery predicate in opt_sum_query().
|
||||
Injection of new condition invalidates this optimizations.
|
||||
Thus those optimizations must be rolled back.
|
||||
*/
|
||||
List_iterator_fast<Item_sum> it(select_lex->min_max_opt_list);
|
||||
Item_sum *item;
|
||||
while ((item= it++))
|
||||
{
|
||||
item->clear();
|
||||
item->reset_forced_const();
|
||||
}
|
||||
if (where_item)
|
||||
where_item->update_used_tables();
|
||||
if (having_item)
|
||||
having_item->update_used_tables();
|
||||
}
|
||||
|
||||
if (where_item)
|
||||
{
|
||||
List<Item> *and_args= NULL;
|
||||
|
||||
@@ -489,6 +489,8 @@ public:
|
||||
Item *left_expr_orig;
|
||||
/* Priority of this predicate in the convert-to-semi-join-nest process. */
|
||||
int sj_convert_priority;
|
||||
/* May be TRUE only for the candidates to semi-join conversion */
|
||||
bool do_not_convert_to_sj;
|
||||
/*
|
||||
Types of left_expr and subquery's select list allow to perform subquery
|
||||
materialization. Currently, we set this to FALSE when it as well could
|
||||
@@ -579,8 +581,8 @@ public:
|
||||
Item_in_subselect(THD *thd_arg):
|
||||
Item_exists_subselect(thd_arg), left_expr_cache(0), first_execution(TRUE),
|
||||
in_strategy(SUBS_NOT_TRANSFORMED),
|
||||
pushed_cond_guards(NULL), func(NULL), is_jtbm_merged(FALSE),
|
||||
is_jtbm_const_tab(FALSE), upper_item(0) {}
|
||||
pushed_cond_guards(NULL), func(NULL), do_not_convert_to_sj(FALSE),
|
||||
is_jtbm_merged(FALSE), is_jtbm_const_tab(FALSE), upper_item(0) {}
|
||||
void cleanup();
|
||||
subs_type substype() { return IN_SUBS; }
|
||||
void reset()
|
||||
@@ -634,6 +636,8 @@ public:
|
||||
*/
|
||||
int get_identifier();
|
||||
|
||||
void block_conversion_to_sj () { do_not_convert_to_sj= TRUE; }
|
||||
|
||||
bool test_strategy(uchar strategy)
|
||||
{ return MY_TEST(in_strategy & strategy); }
|
||||
|
||||
|
||||
@@ -458,6 +458,7 @@ public:
|
||||
used_tables_cache= 0;
|
||||
const_item_cache= true;
|
||||
}
|
||||
void reset_forced_const() { const_item_cache= false; }
|
||||
virtual bool const_during_execution() const { return false; }
|
||||
virtual void print(String *str, enum_query_type query_type);
|
||||
void fix_num_length_and_dec();
|
||||
|
||||
@@ -126,7 +126,7 @@ extern ulong slave_retried_transactions;
|
||||
extern ulong slave_run_triggers_for_rbr;
|
||||
extern ulonglong slave_type_conversions_options;
|
||||
extern my_bool read_only, opt_readonly;
|
||||
extern my_bool lower_case_file_system;
|
||||
extern MYSQL_PLUGIN_IMPORT my_bool lower_case_file_system;
|
||||
extern my_bool opt_enable_named_pipe, opt_sync_frm, opt_allow_suspicious_udfs;
|
||||
extern my_bool opt_secure_auth;
|
||||
extern const char *current_dbug_option;
|
||||
|
||||
@@ -1003,6 +1003,25 @@ bool check_for_outer_joins(List<TABLE_LIST> *join_list)
|
||||
}
|
||||
|
||||
|
||||
void find_and_block_conversion_to_sj(Item *to_find,
|
||||
List_iterator_fast<Item_in_subselect> &li)
|
||||
{
|
||||
if (to_find->type() != Item::SUBSELECT_ITEM ||
|
||||
((Item_subselect *) to_find)->substype() != Item_subselect::IN_SUBS)
|
||||
return;
|
||||
Item_in_subselect *in_subq;
|
||||
li.rewind();
|
||||
while ((in_subq= li++))
|
||||
{
|
||||
if (in_subq == to_find)
|
||||
{
|
||||
in_subq->block_conversion_to_sj();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Convert semi-join subquery predicates into semi-join join nests
|
||||
|
||||
@@ -1055,7 +1074,6 @@ bool convert_join_subqueries_to_semijoins(JOIN *join)
|
||||
Query_arena *arena, backup;
|
||||
Item_in_subselect *in_subq;
|
||||
THD *thd= join->thd;
|
||||
List_iterator<TABLE_LIST> ti(join->select_lex->leaf_tables);
|
||||
DBUG_ENTER("convert_join_subqueries_to_semijoins");
|
||||
|
||||
if (join->select_lex->sj_subselects.is_empty())
|
||||
@@ -1073,6 +1091,60 @@ bool convert_join_subqueries_to_semijoins(JOIN *join)
|
||||
subq_sel->update_used_tables();
|
||||
}
|
||||
|
||||
/*
|
||||
Check all candidates to semi-join conversion that occur
|
||||
in ON expressions of outer join. Set the flag blocking
|
||||
this conversion for them.
|
||||
*/
|
||||
TABLE_LIST *tbl;
|
||||
List_iterator<TABLE_LIST> ti(join->select_lex->leaf_tables);
|
||||
while ((tbl= ti++))
|
||||
{
|
||||
TABLE_LIST *embedded;
|
||||
TABLE_LIST *embedding= tbl;
|
||||
do
|
||||
{
|
||||
embedded= embedding;
|
||||
if (MY_TEST(embedded->outer_join))
|
||||
{
|
||||
Item *cond= embedded->on_expr;
|
||||
if (!cond)
|
||||
;
|
||||
else if (cond->type() != Item::COND_ITEM)
|
||||
find_and_block_conversion_to_sj(cond, li);
|
||||
else if (((Item_cond*) cond)->functype() ==
|
||||
Item_func::COND_AND_FUNC)
|
||||
{
|
||||
Item *item;
|
||||
List_iterator<Item> it(*(((Item_cond*) cond)->argument_list()));
|
||||
while ((item= it++))
|
||||
{
|
||||
find_and_block_conversion_to_sj(item, li);
|
||||
}
|
||||
}
|
||||
}
|
||||
embedding= embedded->embedding;
|
||||
}
|
||||
while (embedding &&
|
||||
embedding->nested_join->join_list.head() == embedded);
|
||||
}
|
||||
|
||||
/*
|
||||
Block conversion to semi-joins for those candidates that
|
||||
are encountered in the WHERE condition of the multi-table view
|
||||
with CHECK OPTION if this view is used in UPDATE/DELETE.
|
||||
(This limitation can be, probably, easily lifted.)
|
||||
*/
|
||||
li.rewind();
|
||||
while ((in_subq= li++))
|
||||
{
|
||||
if (in_subq->emb_on_expr_nest != NO_JOIN_NEST &&
|
||||
in_subq->emb_on_expr_nest->effective_with_check)
|
||||
{
|
||||
in_subq->block_conversion_to_sj();
|
||||
}
|
||||
}
|
||||
|
||||
li.rewind();
|
||||
/* First, convert child join's subqueries. We proceed bottom-up here */
|
||||
while ((in_subq= li++))
|
||||
@@ -1091,8 +1163,10 @@ bool convert_join_subqueries_to_semijoins(JOIN *join)
|
||||
|
||||
if (convert_join_subqueries_to_semijoins(child_join))
|
||||
DBUG_RETURN(TRUE);
|
||||
|
||||
|
||||
in_subq->sj_convert_priority=
|
||||
MY_TEST(in_subq->emb_on_expr_nest != NO_JOIN_NEST) * MAX_TABLES * 2 +
|
||||
MY_TEST(in_subq->do_not_convert_to_sj) * MAX_TABLES * 2 +
|
||||
in_subq->is_correlated * MAX_TABLES + child_join->outer_tables;
|
||||
}
|
||||
|
||||
@@ -1125,7 +1199,7 @@ bool convert_join_subqueries_to_semijoins(JOIN *join)
|
||||
bool remove_item= TRUE;
|
||||
|
||||
/* Stop processing if we've reached a subquery that's attached to the ON clause */
|
||||
if (in_subq->emb_on_expr_nest != NO_JOIN_NEST)
|
||||
if (in_subq->do_not_convert_to_sj)
|
||||
break;
|
||||
|
||||
if (in_subq->is_flattenable_semijoin)
|
||||
|
||||
@@ -254,6 +254,8 @@ int opt_sum_query(THD *thd,
|
||||
int error= 0;
|
||||
DBUG_ENTER("opt_sum_query");
|
||||
|
||||
thd->lex->current_select->min_max_opt_list.empty();
|
||||
|
||||
if (conds)
|
||||
where_tables= conds->used_tables();
|
||||
|
||||
@@ -447,7 +449,14 @@ int opt_sum_query(THD *thd,
|
||||
item_sum->aggregator_clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
item_sum->reset_and_add();
|
||||
/*
|
||||
Save a reference to the item for possible rollback
|
||||
of the min/max optimizations for this select
|
||||
*/
|
||||
thd->lex->current_select->min_max_opt_list.push_back(item_sum);
|
||||
}
|
||||
item_sum->make_const();
|
||||
recalc_const_item= 1;
|
||||
break;
|
||||
|
||||
@@ -664,7 +664,7 @@ file '%s')", fname);
|
||||
mi->connect_retry= (uint) connect_retry;
|
||||
mi->ssl= (my_bool) ssl;
|
||||
mi->ssl_verify_server_cert= ssl_verify_server_cert;
|
||||
mi->heartbeat_period= master_heartbeat_period;
|
||||
mi->heartbeat_period= MY_MIN(SLAVE_MAX_HEARTBEAT_PERIOD, master_heartbeat_period);
|
||||
}
|
||||
DBUG_PRINT("master_info",("log_file_name: %s position: %ld",
|
||||
mi->master_log_name,
|
||||
@@ -799,8 +799,8 @@ int flush_master_info(Master_info* mi,
|
||||
contents of file). But because of number of lines in the first line
|
||||
of file we don't care about this garbage.
|
||||
*/
|
||||
char heartbeat_buf[sizeof(mi->heartbeat_period) * 4]; // buffer to suffice always
|
||||
sprintf(heartbeat_buf, "%.3f", mi->heartbeat_period);
|
||||
char heartbeat_buf[FLOATING_POINT_BUFFER];
|
||||
my_fcvt(mi->heartbeat_period, 3, heartbeat_buf, NULL);
|
||||
my_b_seek(file, 0L);
|
||||
my_b_printf(file,
|
||||
"%u\n%s\n%s\n%s\n%s\n%s\n%d\n%d\n%d\n%s\n%s\n%s\n%s\n%s\n%d\n%s\n%s\n%s\n%s\n%d\n%s\n%s\n"
|
||||
|
||||
@@ -2095,6 +2095,7 @@ void st_select_lex::init_query()
|
||||
leaf_tables_prep.empty();
|
||||
leaf_tables.empty();
|
||||
item_list.empty();
|
||||
min_max_opt_list.empty();
|
||||
join= 0;
|
||||
having= prep_having= where= prep_where= 0;
|
||||
olap= UNSPECIFIED_OLAP_TYPE;
|
||||
|
||||
@@ -751,6 +751,11 @@ public:
|
||||
*/
|
||||
List<Item_func_match> *ftfunc_list;
|
||||
List<Item_func_match> ftfunc_list_alloc;
|
||||
/*
|
||||
The list of items to which MIN/MAX optimizations of opt_sum_query()
|
||||
have been applied. Used to rollback those optimizations if it's needed.
|
||||
*/
|
||||
List<Item_sum> min_max_opt_list;
|
||||
JOIN *join; /* after JOIN::prepare it is pointer to corresponding JOIN */
|
||||
List<TABLE_LIST> top_join_list; /* join list of the top level */
|
||||
List<TABLE_LIST> *join_list; /* list for the currently parsed join */
|
||||
|
||||
@@ -9674,12 +9674,20 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
|
||||
/*
|
||||
Step #2: Extract WHERE/ON parts
|
||||
*/
|
||||
uint i;
|
||||
for (i= join->top_join_tab_count - 1; i >= join->const_tables; i--)
|
||||
{
|
||||
if (!join->join_tab[i].bush_children)
|
||||
break;
|
||||
}
|
||||
uint last_top_base_tab_idx= i;
|
||||
|
||||
table_map save_used_tables= 0;
|
||||
used_tables=((select->const_tables=join->const_table_map) |
|
||||
OUTER_REF_TABLE_BIT | RAND_TABLE_BIT);
|
||||
JOIN_TAB *tab;
|
||||
table_map current_map;
|
||||
uint i= join->const_tables;
|
||||
i= join->const_tables;
|
||||
for (tab= first_depth_first_tab(join); tab;
|
||||
tab= next_depth_first_tab(join, tab), i++)
|
||||
{
|
||||
@@ -9717,7 +9725,7 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
|
||||
Following force including random expression in last table condition.
|
||||
It solve problem with select like SELECT * FROM t1 WHERE rand() > 0.5
|
||||
*/
|
||||
if (tab == join->join_tab + join->top_join_tab_count - 1)
|
||||
if (tab == join->join_tab + last_top_base_tab_idx)
|
||||
current_map|= RAND_TABLE_BIT;
|
||||
used_tables|=current_map;
|
||||
|
||||
@@ -9757,10 +9765,10 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
|
||||
save_used_tables= 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp= make_cond_for_table(thd, cond, used_tables, current_map, i,
|
||||
{
|
||||
tmp= make_cond_for_table(thd, cond, used_tables, current_map, i,
|
||||
FALSE, FALSE);
|
||||
}
|
||||
}
|
||||
/* Add conditions added by add_not_null_conds(). */
|
||||
if (tab->select_cond)
|
||||
add_cond_and_fix(thd, &tmp, tab->select_cond);
|
||||
|
||||
@@ -18,10 +18,10 @@ SET(CONNECT_PLUGIN_DYNAMIC "connect")
|
||||
|
||||
SET(CONNECT_SOURCES
|
||||
ha_connect.cc connect.cc user_connect.cc mycat.cc
|
||||
fmdlex.c osutil.c plugutil.c rcmsg.c rcmsg.h
|
||||
fmdlex.c osutil.c rcmsg.c rcmsg.h
|
||||
array.cpp blkfil.cpp colblk.cpp csort.cpp
|
||||
filamap.cpp filamdbf.cpp filamfix.cpp filamgz.cpp filamtxt.cpp
|
||||
filter.cpp json.cpp jsonudf.cpp maputil.cpp myconn.cpp myutil.cpp plgdbutl.cpp
|
||||
filamap.cpp filamdbf.cpp filamfix.cpp filamgz.cpp filamtxt.cpp filter.cpp
|
||||
json.cpp jsonudf.cpp maputil.cpp myconn.cpp myutil.cpp plgdbutl.cpp plugutil.cpp
|
||||
reldef.cpp tabcol.cpp tabdos.cpp tabext.cpp tabfix.cpp tabfmt.cpp tabjson.cpp
|
||||
table.cpp tabmul.cpp tabmysql.cpp taboccur.cpp tabpivot.cpp tabsys.cpp tabtbl.cpp
|
||||
tabutil.cpp tabvir.cpp tabxcl.cpp valblk.cpp value.cpp xindex.cpp xobject.cpp
|
||||
@@ -38,7 +38,7 @@ user_connect.h valblk.h value.h xindex.h xobject.h xtable.h)
|
||||
# Definitions that are shared for all OSes
|
||||
#
|
||||
add_definitions( -DMARIADB -DFORCE_INIT_OF_VARS -Dconnect_EXPORTS)
|
||||
add_definitions( -DHUGE_SUPPORT -DGZ_SUPPORT -DPIVOT_SUPPORT )
|
||||
add_definitions( -DHUGE_SUPPORT -DGZ_SUPPORT -DPIVOT_SUPPORT -DUSE_TRY )
|
||||
|
||||
|
||||
#
|
||||
|
||||
@@ -519,8 +519,8 @@ bool ARRAY::FilTest(PGLOBAL g, PVAL valp, OPVAL opc, int opm)
|
||||
vp = valp;
|
||||
|
||||
} else if (opc != OP_EXIST) {
|
||||
sprintf(g->Message, MSG(MISSING_ARG), opc);
|
||||
longjmp(g->jumper[g->jump_level], TYPE_ARRAY);
|
||||
sprintf(g->Message, MSG(MISSING_ARG), opc);
|
||||
throw TYPE_ARRAY;
|
||||
} else // OP_EXIST
|
||||
return Nval > 0;
|
||||
|
||||
@@ -683,15 +683,15 @@ void ARRAY::SetPrecision(PGLOBAL g, int p)
|
||||
{
|
||||
if (Vblp == NULL) {
|
||||
strcpy(g->Message, MSG(PREC_VBLP_NULL));
|
||||
longjmp(g->jumper[g->jump_level], TYPE_ARRAY);
|
||||
throw TYPE_ARRAY;
|
||||
} // endif Vblp
|
||||
|
||||
bool was = Vblp->IsCi();
|
||||
|
||||
if (was && !p) {
|
||||
strcpy(g->Message, MSG(BAD_SET_CASE));
|
||||
longjmp(g->jumper[g->jump_level], TYPE_ARRAY);
|
||||
} // endif Vblp
|
||||
throw TYPE_ARRAY;
|
||||
} // endif Vblp
|
||||
|
||||
if (was || !p)
|
||||
return;
|
||||
@@ -701,7 +701,7 @@ void ARRAY::SetPrecision(PGLOBAL g, int p)
|
||||
if (!was && Type == TYPE_STRING)
|
||||
// Must be resorted to eliminate duplicate strings
|
||||
if (Sort(g))
|
||||
longjmp(g->jumper[g->jump_level], TYPE_ARRAY);
|
||||
throw TYPE_ARRAY;
|
||||
|
||||
} // end of SetPrecision
|
||||
|
||||
@@ -979,7 +979,7 @@ PSZ ARRAY::MakeArrayList(PGLOBAL g)
|
||||
size_t z, len = 2;
|
||||
|
||||
if (Type == TYPE_LIST)
|
||||
return "(?" "?" "?)"; // To be implemented
|
||||
return (PSZ)("(?" "?" "?)"); // To be implemented
|
||||
|
||||
z = MY_MAX(24, GetTypeSize(Type, Len) + 4);
|
||||
tp = (char*)PlugSubAlloc(g, NULL, z);
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/************* BlkFil C++ Program Source Code File (.CPP) **************/
|
||||
/* PROGRAM NAME: BLKFIL */
|
||||
/* ------------- */
|
||||
/* Version 2.5 */
|
||||
/* Version 2.6 */
|
||||
/* */
|
||||
/* COPYRIGHT: */
|
||||
/* ---------- */
|
||||
/* (C) Copyright to the author Olivier BERTRAND 2004-2015 */
|
||||
/* (C) Copyright to the author Olivier BERTRAND 2004-2017 */
|
||||
/* */
|
||||
/* WHAT THIS PROGRAM DOES: */
|
||||
/* ----------------------- */
|
||||
@@ -595,8 +595,8 @@ BLKFILIN::BLKFILIN(PGLOBAL g, PTDBDOS tdbp, int op, int opm, PXOB *xp)
|
||||
|
||||
if (Colp->GetResultType() != Type) {
|
||||
sprintf(g->Message, "BLKFILIN: %s", MSG(VALTYPE_NOMATCH));
|
||||
longjmp(g->jumper[g->jump_level], 99);
|
||||
} else if (Colp->GetValue()->IsCi())
|
||||
throw g->Message;
|
||||
} else if (Colp->GetValue()->IsCi())
|
||||
Arap->SetPrecision(g, 1); // Case insensitive
|
||||
|
||||
Sorted = Colp->IsSorted() > 0;
|
||||
|
||||
@@ -36,7 +36,7 @@ typedef struct _curtab {
|
||||
/* Defines the structure used to get column catalog info. */
|
||||
/***********************************************************************/
|
||||
typedef struct _colinfo {
|
||||
char *Name;
|
||||
PCSZ Name;
|
||||
int Type;
|
||||
int Offset;
|
||||
int Length;
|
||||
@@ -45,9 +45,9 @@ typedef struct _colinfo {
|
||||
int Scale;
|
||||
int Opt;
|
||||
int Freq;
|
||||
char *Remark;
|
||||
char *Datefmt;
|
||||
char *Fieldfmt;
|
||||
PCSZ Remark;
|
||||
PCSZ Datefmt;
|
||||
PCSZ Fieldfmt;
|
||||
ushort Flags; // Used by MariaDB CONNECT handlers
|
||||
} COLINFO, *PCOLINFO;
|
||||
|
||||
@@ -68,11 +68,9 @@ class DllExport CATALOG {
|
||||
bool GetDefHuge(void) {return DefHuge;}
|
||||
void SetDefHuge(bool b) {DefHuge = b;}
|
||||
char *GetCbuf(void) {return Cbuf;}
|
||||
//char *GetDataPath(void) {return (char*)DataPath;}
|
||||
|
||||
// Methods
|
||||
virtual void Reset(void) {}
|
||||
//virtual void SetDataPath(PGLOBAL g, const char *path) {}
|
||||
virtual bool CheckName(PGLOBAL, char*) {return true;}
|
||||
virtual bool ClearName(PGLOBAL, PSZ) {return true;}
|
||||
virtual PRELDEF MakeOneTableDesc(PGLOBAL, LPCSTR, LPCSTR) {return NULL;}
|
||||
@@ -102,7 +100,6 @@ class DllExport CATALOG {
|
||||
int Cblen; /* Length of suballoc. buffer */
|
||||
CURTAB Ctb; /* Used to enumerate tables */
|
||||
bool DefHuge; /* true: tables default to huge */
|
||||
//LPCSTR DataPath; /* Is the Path of DB data dir */
|
||||
}; // end of class CATALOG
|
||||
|
||||
#endif // __CATALOG__H
|
||||
|
||||
@@ -195,10 +195,10 @@ int COLBLK::GetLengthEx(void)
|
||||
/* corresponding to this column and convert it to buffer type. */
|
||||
/***********************************************************************/
|
||||
void COLBLK::ReadColumn(PGLOBAL g)
|
||||
{
|
||||
{
|
||||
sprintf(g->Message, MSG(UNDEFINED_AM), "ReadColumn");
|
||||
longjmp(g->jumper[g->jump_level], TYPE_COLBLK);
|
||||
} // end of ReadColumn
|
||||
throw TYPE_COLBLK;
|
||||
} // end of ReadColumn
|
||||
|
||||
/***********************************************************************/
|
||||
/* WriteColumn: what this routine does is to access the last line */
|
||||
@@ -206,10 +206,10 @@ void COLBLK::ReadColumn(PGLOBAL g)
|
||||
/* corresponding to this column from the column buffer and type. */
|
||||
/***********************************************************************/
|
||||
void COLBLK::WriteColumn(PGLOBAL g)
|
||||
{
|
||||
{
|
||||
sprintf(g->Message, MSG(UNDEFINED_AM), "WriteColumn");
|
||||
longjmp(g->jumper[g->jump_level], TYPE_COLBLK);
|
||||
} // end of WriteColumn
|
||||
throw TYPE_COLBLK;
|
||||
} // end of WriteColumn
|
||||
|
||||
/***********************************************************************/
|
||||
/* Make file output of a column descriptor block. */
|
||||
@@ -260,10 +260,10 @@ SPCBLK::SPCBLK(PCOLUMN cp)
|
||||
/* corresponding to this column from the column buffer and type. */
|
||||
/***********************************************************************/
|
||||
void SPCBLK::WriteColumn(PGLOBAL g)
|
||||
{
|
||||
{
|
||||
sprintf(g->Message, MSG(SPCOL_READONLY), Name);
|
||||
longjmp(g->jumper[g->jump_level], TYPE_COLBLK);
|
||||
} // end of WriteColumn
|
||||
throw TYPE_COLBLK;
|
||||
} // end of WriteColumn
|
||||
|
||||
/***********************************************************************/
|
||||
/* RIDBLK constructor for the ROWID special column. */
|
||||
@@ -377,7 +377,7 @@ PRTBLK::PRTBLK(PCOLUMN cp) : SPCBLK(cp)
|
||||
void PRTBLK::ReadColumn(PGLOBAL g)
|
||||
{
|
||||
if (Pname == NULL) {
|
||||
char *p;
|
||||
const char *p;
|
||||
|
||||
Pname = To_Tdb->GetDef()->GetStringCatInfo(g, "partname", "?");
|
||||
p = strrchr(Pname, '#');
|
||||
@@ -407,7 +407,7 @@ SIDBLK::SIDBLK(PCOLUMN cp) : SPCBLK(cp)
|
||||
void SIDBLK::ReadColumn(PGLOBAL)
|
||||
{
|
||||
//if (Sname == NULL) {
|
||||
Sname = (char*)To_Tdb->GetServer();
|
||||
Sname = To_Tdb->GetServer();
|
||||
Value->SetValue_psz(Sname);
|
||||
// } // endif Sname
|
||||
|
||||
|
||||
@@ -154,7 +154,7 @@ class DllExport FIDBLK : public SPCBLK {
|
||||
virtual void ReadColumn(PGLOBAL g);
|
||||
|
||||
protected:
|
||||
PSZ Fn; // The current To_File of the table
|
||||
PCSZ Fn; // The current To_File of the table
|
||||
OPVAL Op; // The file part operator
|
||||
}; // end of class FIDBLK
|
||||
|
||||
@@ -178,7 +178,7 @@ class DllExport TIDBLK : public SPCBLK {
|
||||
TIDBLK(void) {}
|
||||
|
||||
// Members
|
||||
PSZ Tname; // The current table name
|
||||
PCSZ Tname; // The current table name
|
||||
}; // end of class TIDBLK
|
||||
|
||||
/***********************************************************************/
|
||||
@@ -201,7 +201,7 @@ class DllExport PRTBLK : public SPCBLK {
|
||||
PRTBLK(void) {}
|
||||
|
||||
// Members
|
||||
PSZ Pname; // The current partition name
|
||||
PCSZ Pname; // The current partition name
|
||||
}; // end of class PRTBLK
|
||||
|
||||
/***********************************************************************/
|
||||
@@ -224,7 +224,7 @@ class DllExport SIDBLK : public SPCBLK {
|
||||
SIDBLK(void) {}
|
||||
|
||||
// Members
|
||||
PSZ Sname; // The current server name
|
||||
PCSZ Sname; // The current server name
|
||||
}; // end of class SIDBLK
|
||||
|
||||
#endif // __COLBLK__H
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) Olivier Bertrand 2004 - 2015
|
||||
/* Copyright (C) Olivier Bertrand 2004 - 2017
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -15,10 +15,10 @@
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */
|
||||
|
||||
/***********************************************************************/
|
||||
/* Author Olivier BERTRAND bertrandop@gmail.com 2004-2015 */
|
||||
/* Author Olivier BERTRAND bertrandop@gmail.com 2004-2017 */
|
||||
/* */
|
||||
/* WHAT THIS PROGRAM DOES: */
|
||||
/* ----------------------- */
|
||||
/* WHAT THIS PROGRAM DOES: */
|
||||
/* ----------------------- */
|
||||
/* This program are the CONNECT general purpose semantic routines. */
|
||||
/***********************************************************************/
|
||||
#ifdef USE_PRAGMA_IMPLEMENTATION
|
||||
@@ -117,11 +117,10 @@ bool CntCheckDB(PGLOBAL g, PHC handler, const char *pathname)
|
||||
handler);
|
||||
|
||||
// Set the database path for this table
|
||||
handler->SetDataPath(g, pathname);
|
||||
if (handler->SetDataPath(g, pathname))
|
||||
return true;
|
||||
|
||||
if (dbuserp->Catalog) {
|
||||
// ((MYCAT *)dbuserp->Catalog)->SetHandler(handler); done later
|
||||
// ((MYCAT *)dbuserp->Catalog)->SetDataPath(g, pathname);
|
||||
return false; // Nothing else to do
|
||||
} // endif Catalog
|
||||
|
||||
@@ -138,9 +137,6 @@ bool CntCheckDB(PGLOBAL g, PHC handler, const char *pathname)
|
||||
if (!(dbuserp->Catalog= new MYCAT(handler)))
|
||||
return true;
|
||||
|
||||
//((MYCAT *)dbuserp->Catalog)->SetDataPath(g, pathname);
|
||||
//dbuserp->UseTemp= TMP_AUTO;
|
||||
|
||||
/*********************************************************************/
|
||||
/* All is correct. */
|
||||
/*********************************************************************/
|
||||
@@ -172,7 +168,7 @@ bool CntInfo(PGLOBAL g, PTDB tp, PXF info)
|
||||
|
||||
// info->mean_rec_length= tdbp->GetLrecl();
|
||||
info->mean_rec_length= 0;
|
||||
info->data_file_name= (b) ? NULL : tdbp->GetFile(g);
|
||||
info->data_file_name= (b) ? NULL : (char*)tdbp->GetFile(g);
|
||||
return true;
|
||||
} else {
|
||||
info->data_file_length= 0;
|
||||
@@ -188,49 +184,43 @@ bool CntInfo(PGLOBAL g, PTDB tp, PXF info)
|
||||
/* GetTDB: Get the table description block of a CONNECT table. */
|
||||
/***********************************************************************/
|
||||
PTDB CntGetTDB(PGLOBAL g, LPCSTR name, MODE mode, PHC h)
|
||||
{
|
||||
int rc;
|
||||
PTDB tdbp;
|
||||
PTABLE tabp;
|
||||
PDBUSER dup= PlgGetUser(g);
|
||||
volatile PCATLG cat= (dup) ? dup->Catalog : NULL; // Safe over longjmp
|
||||
{
|
||||
PTDB tdbp;
|
||||
PTABLE tabp;
|
||||
PDBUSER dup = PlgGetUser(g);
|
||||
volatile PCATLG cat = (dup) ? dup->Catalog : NULL; // Safe over longjmp
|
||||
|
||||
if (trace)
|
||||
printf("CntGetTDB: name=%s mode=%d cat=%p\n", name, mode, cat);
|
||||
if (trace)
|
||||
printf("CntGetTDB: name=%s mode=%d cat=%p\n", name, mode, cat);
|
||||
|
||||
if (!cat)
|
||||
return NULL;
|
||||
if (!cat)
|
||||
return NULL;
|
||||
|
||||
// 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
|
||||
try {
|
||||
// Get table object from the catalog
|
||||
tabp = new(g) XTAB(name);
|
||||
|
||||
if ((rc= setjmp(g->jumper[++g->jump_level])) != 0) {
|
||||
tdbp= NULL;
|
||||
goto err;
|
||||
} // endif rc
|
||||
if (trace)
|
||||
printf("CntGetTDB: tabp=%p\n", tabp);
|
||||
|
||||
// Get table object from the catalog
|
||||
tabp= new(g) XTAB(name);
|
||||
// Perhaps this should be made thread safe
|
||||
((MYCAT*)cat)->SetHandler(h);
|
||||
|
||||
if (trace)
|
||||
printf("CntGetTDB: tabp=%p\n", tabp);
|
||||
if (!(tdbp = cat->GetTable(g, tabp, mode)))
|
||||
printf("CntGetTDB: %s\n", g->Message);
|
||||
|
||||
// Perhaps this should be made thread safe
|
||||
((MYCAT*)cat)->SetHandler(h);
|
||||
} catch (int n) {
|
||||
if (trace)
|
||||
htrc("Exception %d: %s\n", n, g->Message);
|
||||
} catch (const char *msg) {
|
||||
strcpy(g->Message, msg);
|
||||
} // end catch
|
||||
|
||||
if (!(tdbp= cat->GetTable(g, tabp, mode)))
|
||||
printf("CntGetTDB: %s\n", g->Message);
|
||||
|
||||
err:
|
||||
if (trace)
|
||||
printf("Returning tdbp=%p mode=%d\n", tdbp, mode);
|
||||
|
||||
g->jump_level--;
|
||||
return tdbp;
|
||||
} // end of CntGetTDB
|
||||
} // end of CntGetTDB
|
||||
|
||||
/***********************************************************************/
|
||||
/* OPENTAB: Open a Table. */
|
||||
@@ -239,7 +229,7 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
|
||||
bool del, PHC)
|
||||
{
|
||||
char *p;
|
||||
int i, n, rc;
|
||||
int i, n;
|
||||
bool rcop= true;
|
||||
PCOL colp;
|
||||
//PCOLUMN cp;
|
||||
@@ -254,120 +244,116 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
|
||||
return true;
|
||||
} // endif tdbp
|
||||
|
||||
// Save stack and allocation environment and prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||
return true;
|
||||
} // endif jump_level
|
||||
try {
|
||||
if (!c1) {
|
||||
if (mode == MODE_INSERT)
|
||||
// Allocate all column blocks for that table
|
||||
tdbp->ColDB(g, NULL, 0);
|
||||
|
||||
if ((rc= setjmp(g->jumper[++g->jump_level])) != 0) {
|
||||
goto err;
|
||||
} // endif rc
|
||||
} else for (p = c1; *p; p += n) {
|
||||
// Allocate only used column blocks
|
||||
if (trace)
|
||||
printf("Allocating column %s\n", p);
|
||||
|
||||
if (!c1) {
|
||||
if (mode == MODE_INSERT)
|
||||
// Allocate all column blocks for that table
|
||||
tdbp->ColDB(g, NULL, 0);
|
||||
g->Message[0] = 0; // To check whether ColDB made an error message
|
||||
colp = tdbp->ColDB(g, p, 0);
|
||||
|
||||
} else for (p= c1; *p; p+= n) {
|
||||
// Allocate only used column blocks
|
||||
if (trace)
|
||||
printf("Allocating column %s\n", p);
|
||||
if (!colp && !(mode == MODE_INSERT && tdbp->IsSpecial(p))) {
|
||||
if (g->Message[0] == 0)
|
||||
sprintf(g->Message, MSG(COL_ISNOT_TABLE), p, tdbp->GetName());
|
||||
|
||||
g->Message[0] = 0; // To check whether ColDB made an error message
|
||||
colp= tdbp->ColDB(g, p, 0);
|
||||
throw 1;
|
||||
} // endif colp
|
||||
|
||||
if (!colp && !(mode == MODE_INSERT && tdbp->IsSpecial(p))) {
|
||||
if (g->Message[0] == 0)
|
||||
sprintf(g->Message, MSG(COL_ISNOT_TABLE), p, tdbp->GetName());
|
||||
n = strlen(p) + 1;
|
||||
} // endfor p
|
||||
|
||||
goto err;
|
||||
} // endif colp
|
||||
for (i = 0, colp = tdbp->GetColumns(); colp; i++, colp = colp->GetNext()) {
|
||||
if (colp->InitValue(g))
|
||||
throw 2;
|
||||
|
||||
n= strlen(p) + 1;
|
||||
} // endfor p
|
||||
if (mode == MODE_INSERT)
|
||||
// Allow type conversion
|
||||
if (colp->SetBuffer(g, colp->GetValue(), true, false))
|
||||
throw 3;
|
||||
|
||||
for (i= 0, colp= tdbp->GetColumns(); colp; i++, colp= colp->GetNext()) {
|
||||
if (colp->InitValue(g))
|
||||
goto err;
|
||||
colp->AddColUse(U_P); // For PLG tables
|
||||
} // endfor colp
|
||||
|
||||
if (mode == MODE_INSERT)
|
||||
// Allow type conversion
|
||||
if (colp->SetBuffer(g, colp->GetValue(), true, false))
|
||||
goto err;
|
||||
/*******************************************************************/
|
||||
/* In Update mode, the updated column blocks must be distinct from */
|
||||
/* the read column blocks. So make a copy of the TDB and allocate */
|
||||
/* its column blocks in mode write (required by XML tables). */
|
||||
/*******************************************************************/
|
||||
if (mode == MODE_UPDATE) {
|
||||
PTDBASE utp;
|
||||
|
||||
colp->AddColUse(U_P); // For PLG tables
|
||||
} // endfor colp
|
||||
if (!(utp = (PTDBASE)tdbp->Duplicate(g))) {
|
||||
sprintf(g->Message, MSG(INV_UPDT_TABLE), tdbp->GetName());
|
||||
throw 4;
|
||||
} // endif tp
|
||||
|
||||
/*********************************************************************/
|
||||
/* In Update mode, the updated column blocks must be distinct from */
|
||||
/* the read column blocks. So make a copy of the TDB and allocate */
|
||||
/* its column blocks in mode write (required by XML tables). */
|
||||
/*********************************************************************/
|
||||
if (mode == MODE_UPDATE) {
|
||||
PTDBASE utp;
|
||||
if (!c2)
|
||||
// Allocate all column blocks for that table
|
||||
utp->ColDB(g, NULL, 0);
|
||||
else for (p = c2; *p; p += n) {
|
||||
// Allocate only used column blocks
|
||||
colp = utp->ColDB(g, p, 0);
|
||||
n = strlen(p) + 1;
|
||||
} // endfor p
|
||||
|
||||
if (!(utp= (PTDBASE)tdbp->Duplicate(g))) {
|
||||
sprintf(g->Message, MSG(INV_UPDT_TABLE), tdbp->GetName());
|
||||
goto err;
|
||||
} // endif tp
|
||||
for (i = 0, colp = utp->GetColumns(); colp; i++, colp = colp->GetNext()) {
|
||||
if (colp->InitValue(g))
|
||||
throw 5;
|
||||
|
||||
if (!c2)
|
||||
// Allocate all column blocks for that table
|
||||
utp->ColDB(g, NULL, 0);
|
||||
else for (p= c2; *p; p+= n) {
|
||||
// Allocate only used column blocks
|
||||
colp= utp->ColDB(g, p, 0);
|
||||
n= strlen(p) + 1;
|
||||
} // endfor p
|
||||
if (colp->SetBuffer(g, colp->GetValue(), true, false))
|
||||
throw 6;
|
||||
|
||||
for (i= 0, colp= utp->GetColumns(); colp; i++, colp= colp->GetNext()) {
|
||||
if (colp->InitValue(g))
|
||||
goto err;
|
||||
} // endfor colp
|
||||
|
||||
if (colp->SetBuffer(g, colp->GetValue(), true, false))
|
||||
goto err;
|
||||
// Attach the updated columns list to the main table
|
||||
tdbp->SetSetCols(utp->GetColumns());
|
||||
} else if (tdbp && mode == MODE_INSERT)
|
||||
tdbp->SetSetCols(tdbp->GetColumns());
|
||||
|
||||
} // endfor colp
|
||||
// Now do open the physical table
|
||||
if (trace)
|
||||
printf("Opening table %s in mode %d tdbp=%p\n",
|
||||
tdbp->GetName(), mode, tdbp);
|
||||
|
||||
// Attach the updated columns list to the main table
|
||||
tdbp->SetSetCols(utp->GetColumns());
|
||||
} else if (tdbp && mode == MODE_INSERT)
|
||||
tdbp->SetSetCols(tdbp->GetColumns());
|
||||
//tdbp->SetMode(mode);
|
||||
|
||||
// Now do open the physical table
|
||||
if (trace)
|
||||
printf("Opening table %s in mode %d tdbp=%p\n",
|
||||
tdbp->GetName(), mode, tdbp);
|
||||
|
||||
//tdbp->SetMode(mode);
|
||||
|
||||
if (del/* && (tdbp->GetFtype() != RECFM_NAF*/) {
|
||||
// To avoid erasing the table when doing a partial delete
|
||||
// make a fake Next
|
||||
if (del/* && (tdbp->GetFtype() != RECFM_NAF*/) {
|
||||
// To avoid erasing the table when doing a partial delete
|
||||
// make a fake Next
|
||||
// PDOSDEF ddp= new(g) DOSDEF;
|
||||
// PTDB tp= new(g) TDBDOS(ddp, NULL);
|
||||
tdbp->SetNext((PTDB)1);
|
||||
dup->Check &= ~CHK_DELETE;
|
||||
} // endif del
|
||||
tdbp->SetNext((PTDB)1);
|
||||
dup->Check &= ~CHK_DELETE;
|
||||
} // endif del
|
||||
|
||||
|
||||
if (trace)
|
||||
printf("About to open the table: tdbp=%p\n", tdbp);
|
||||
if (trace)
|
||||
printf("About to open the table: tdbp=%p\n", tdbp);
|
||||
|
||||
if (mode != MODE_ANY && mode != MODE_ALTER) {
|
||||
if (tdbp->OpenDB(g)) {
|
||||
printf("%s\n", g->Message);
|
||||
goto err;
|
||||
} else
|
||||
tdbp->SetNext(NULL);
|
||||
if (mode != MODE_ANY && mode != MODE_ALTER) {
|
||||
if (tdbp->OpenDB(g)) {
|
||||
printf("%s\n", g->Message);
|
||||
throw 7;
|
||||
} else
|
||||
tdbp->SetNext(NULL);
|
||||
|
||||
} // endif mode
|
||||
} // endif mode
|
||||
|
||||
rcop= false;
|
||||
rcop = false;
|
||||
|
||||
} catch (int n) {
|
||||
if (trace)
|
||||
htrc("Exception %d: %s\n", n, g->Message);
|
||||
} catch (const char *msg) {
|
||||
strcpy(g->Message, msg);
|
||||
} // end catch
|
||||
|
||||
err:
|
||||
g->jump_level--;
|
||||
return rcop;
|
||||
} // end of CntOpenTable
|
||||
|
||||
@@ -387,50 +373,40 @@ bool CntRewindTable(PGLOBAL g, PTDB tdbp)
|
||||
/* Evaluate all columns after a record is read. */
|
||||
/***********************************************************************/
|
||||
RCODE EvalColumns(PGLOBAL g, PTDB tdbp, bool reset, bool mrr)
|
||||
{
|
||||
{
|
||||
RCODE rc= RC_OK;
|
||||
PCOL colp;
|
||||
|
||||
// Save stack and allocation environment and prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
if (trace) {
|
||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||
printf("EvalColumns: %s\n", g->Message);
|
||||
} // endif
|
||||
try {
|
||||
for (colp = tdbp->GetColumns(); rc == RC_OK && colp;
|
||||
colp = colp->GetNext()) {
|
||||
if (reset)
|
||||
colp->Reset();
|
||||
|
||||
return RC_FX;
|
||||
} // endif jump_level
|
||||
// Virtual columns are computed by MariaDB
|
||||
if (!colp->GetColUse(U_VIRTUAL) && (!mrr || colp->GetKcol()))
|
||||
if (colp->Eval(g))
|
||||
rc = RC_FX;
|
||||
|
||||
if (setjmp(g->jumper[++g->jump_level]) != 0) {
|
||||
if (trace)
|
||||
printf("Error reading columns: %s\n", g->Message);
|
||||
} // endfor colp
|
||||
|
||||
rc= RC_FX;
|
||||
goto err;
|
||||
} // endif rc
|
||||
} catch (int n) {
|
||||
if (trace)
|
||||
printf("Error %d reading columns: %s\n", n, g->Message);
|
||||
|
||||
for (colp= tdbp->GetColumns(); rc == RC_OK && colp;
|
||||
colp= colp->GetNext()) {
|
||||
if (reset)
|
||||
colp->Reset();
|
||||
rc = RC_FX;
|
||||
} catch (const char *msg) {
|
||||
strcpy(g->Message, msg);
|
||||
} // end catch
|
||||
|
||||
// Virtual columns are computed by MariaDB
|
||||
if (!colp->GetColUse(U_VIRTUAL) && (!mrr || colp->GetKcol()))
|
||||
if (colp->Eval(g))
|
||||
rc= RC_FX;
|
||||
|
||||
} // endfor colp
|
||||
|
||||
err:
|
||||
g->jump_level--;
|
||||
return rc;
|
||||
} // end of EvalColumns
|
||||
} // end of EvalColumns
|
||||
|
||||
/***********************************************************************/
|
||||
/* ReadNext: Read next record sequentially. */
|
||||
/***********************************************************************/
|
||||
RCODE CntReadNext(PGLOBAL g, PTDB tdbp)
|
||||
{
|
||||
{
|
||||
RCODE rc;
|
||||
|
||||
if (!tdbp)
|
||||
@@ -445,76 +421,66 @@ RCODE CntReadNext(PGLOBAL g, PTDB tdbp)
|
||||
((PTDBASE)tdbp)->ResetKindex(g, NULL);
|
||||
} // endif index
|
||||
|
||||
// Save stack and allocation environment and prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||
return RC_FX;
|
||||
} // endif jump_level
|
||||
try {
|
||||
// Do it now to avoid double eval when filtering
|
||||
for (PCOL colp = tdbp->GetColumns(); colp; colp = colp->GetNext())
|
||||
colp->Reset();
|
||||
|
||||
if ((setjmp(g->jumper[++g->jump_level])) != 0) {
|
||||
rc= RC_FX;
|
||||
goto err;
|
||||
} // endif rc
|
||||
do {
|
||||
if ((rc = (RCODE)tdbp->ReadDB(g)) == RC_OK)
|
||||
if (!ApplyFilter(g, tdbp->GetFilter()))
|
||||
rc = RC_NF;
|
||||
|
||||
// Do it now to avoid double eval when filtering
|
||||
for (PCOL colp= tdbp->GetColumns(); colp; colp= colp->GetNext())
|
||||
colp->Reset();
|
||||
} while (rc == RC_NF);
|
||||
|
||||
do {
|
||||
if ((rc= (RCODE)tdbp->ReadDB(g)) == RC_OK)
|
||||
if (!ApplyFilter(g, tdbp->GetFilter()))
|
||||
rc= RC_NF;
|
||||
if (rc == RC_OK)
|
||||
rc = EvalColumns(g, tdbp, false);
|
||||
|
||||
} while (rc == RC_NF);
|
||||
} catch (int) {
|
||||
rc = RC_FX;
|
||||
} catch (const char *msg) {
|
||||
strcpy(g->Message, msg);
|
||||
rc = RC_FX;
|
||||
} // end catch
|
||||
|
||||
if (rc == RC_OK)
|
||||
rc= EvalColumns(g, tdbp, false);
|
||||
|
||||
err:
|
||||
g->jump_level--;
|
||||
return rc;
|
||||
} // end of CntReadNext
|
||||
} // end of CntReadNext
|
||||
|
||||
/***********************************************************************/
|
||||
/* WriteRow: Insert a new row into a table. */
|
||||
/***********************************************************************/
|
||||
RCODE CntWriteRow(PGLOBAL g, PTDB tdbp)
|
||||
{
|
||||
RCODE rc;
|
||||
PCOL colp;
|
||||
//PTDBASE tp= (PTDBASE)tdbp;
|
||||
{
|
||||
RCODE rc;
|
||||
PCOL colp;
|
||||
//PTDBASE tp= (PTDBASE)tdbp;
|
||||
|
||||
if (!tdbp)
|
||||
return RC_FX;
|
||||
if (!tdbp)
|
||||
return RC_FX;
|
||||
|
||||
// Save stack and allocation environment and prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||
return RC_FX;
|
||||
} // endif jump_level
|
||||
try {
|
||||
// Store column values in table write buffer(s)
|
||||
for (colp = tdbp->GetSetCols(); colp; colp = colp->GetNext())
|
||||
if (!colp->GetColUse(U_VIRTUAL))
|
||||
colp->WriteColumn(g);
|
||||
|
||||
if (setjmp(g->jumper[++g->jump_level]) != 0) {
|
||||
printf("%s\n", g->Message);
|
||||
rc= RC_FX;
|
||||
goto err;
|
||||
} // endif rc
|
||||
if (tdbp->IsIndexed())
|
||||
// Index values must be sorted before updating
|
||||
rc = (RCODE)((PTDBDOS)tdbp)->GetTxfp()->StoreValues(g, true);
|
||||
else
|
||||
// Return result code from write operation
|
||||
rc = (RCODE)tdbp->WriteDB(g);
|
||||
|
||||
// Store column values in table write buffer(s)
|
||||
for (colp= tdbp->GetSetCols(); colp; colp= colp->GetNext())
|
||||
if (!colp->GetColUse(U_VIRTUAL))
|
||||
colp->WriteColumn(g);
|
||||
} catch (int n) {
|
||||
printf("Exception %d: %s\n", n, g->Message);
|
||||
rc = RC_FX;
|
||||
} catch (const char *msg) {
|
||||
strcpy(g->Message, msg);
|
||||
rc = RC_FX;
|
||||
} // end catch
|
||||
|
||||
if (tdbp->IsIndexed())
|
||||
// Index values must be sorted before updating
|
||||
rc= (RCODE)((PTDBDOS)tdbp)->GetTxfp()->StoreValues(g, true);
|
||||
else
|
||||
// Return result code from write operation
|
||||
rc= (RCODE)tdbp->WriteDB(g);
|
||||
|
||||
err:
|
||||
g->jump_level--;
|
||||
return rc;
|
||||
} // end of CntWriteRow
|
||||
return rc;
|
||||
} // end of CntWriteRow
|
||||
|
||||
/***********************************************************************/
|
||||
/* UpdateRow: Update a row into a table. */
|
||||
@@ -562,88 +528,78 @@ RCODE CntDeleteRow(PGLOBAL g, PTDB tdbp, bool all)
|
||||
/* CLOSETAB: Close a table. */
|
||||
/***********************************************************************/
|
||||
int CntCloseTable(PGLOBAL g, PTDB tdbp, bool nox, bool abort)
|
||||
{
|
||||
int rc= RC_OK;
|
||||
//TDBASE *tbxp= (PTDBASE)tdbp;
|
||||
{
|
||||
int rc = RC_OK;
|
||||
//TDBASE *tbxp= (PTDBASE)tdbp;
|
||||
|
||||
if (!tdbp)
|
||||
return rc; // Nothing to do
|
||||
else if (tdbp->GetUse() != USE_OPEN) {
|
||||
if (tdbp->GetAmType() == TYPE_AM_XML)
|
||||
tdbp->CloseDB(g); // Opened by GetMaxSize
|
||||
if (!tdbp)
|
||||
return rc; // Nothing to do
|
||||
else if (tdbp->GetUse() != USE_OPEN) {
|
||||
if (tdbp->GetAmType() == TYPE_AM_XML)
|
||||
tdbp->CloseDB(g); // Opened by GetMaxSize
|
||||
|
||||
return rc;
|
||||
} // endif !USE_OPEN
|
||||
return rc;
|
||||
} // endif !USE_OPEN
|
||||
|
||||
if (trace)
|
||||
printf("CntCloseTable: tdbp=%p mode=%d nox=%d abort=%d\n",
|
||||
tdbp, tdbp->GetMode(), nox, abort);
|
||||
if (trace)
|
||||
printf("CntCloseTable: tdbp=%p mode=%d nox=%d abort=%d\n",
|
||||
tdbp, tdbp->GetMode(), nox, abort);
|
||||
|
||||
if (tdbp->GetMode() == MODE_DELETE && tdbp->GetUse() == USE_OPEN) {
|
||||
if (tdbp->IsIndexed())
|
||||
rc= ((PTDBDOS)tdbp)->GetTxfp()->DeleteSortedRows(g);
|
||||
if (tdbp->GetMode() == MODE_DELETE && tdbp->GetUse() == USE_OPEN) {
|
||||
if (tdbp->IsIndexed())
|
||||
rc = ((PTDBDOS)tdbp)->GetTxfp()->DeleteSortedRows(g);
|
||||
|
||||
if (!rc)
|
||||
rc= tdbp->DeleteDB(g, RC_EF); // Specific A.M. delete routine
|
||||
if (!rc)
|
||||
rc = tdbp->DeleteDB(g, RC_EF); // Specific A.M. delete routine
|
||||
|
||||
} else if (tdbp->GetMode() == MODE_UPDATE && tdbp->IsIndexed())
|
||||
rc= ((PTDBDOX)tdbp)->Txfp->UpdateSortedRows(g);
|
||||
} else if (tdbp->GetMode() == MODE_UPDATE && tdbp->IsIndexed())
|
||||
rc = ((PTDBDOX)tdbp)->Txfp->UpdateSortedRows(g);
|
||||
|
||||
switch(rc) {
|
||||
case RC_FX:
|
||||
abort= true;
|
||||
break;
|
||||
case RC_INFO:
|
||||
PushWarning(g, tdbp);
|
||||
break;
|
||||
} // endswitch rc
|
||||
switch (rc) {
|
||||
case RC_FX:
|
||||
abort = true;
|
||||
break;
|
||||
case RC_INFO:
|
||||
PushWarning(g, tdbp);
|
||||
break;
|
||||
} // endswitch rc
|
||||
|
||||
// Prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||
rc= RC_FX;
|
||||
goto err;
|
||||
} // endif
|
||||
try {
|
||||
// This will close the table file(s) and also finalize write
|
||||
// operations such as Insert, Update, or Delete.
|
||||
tdbp->SetAbort(abort);
|
||||
tdbp->CloseDB(g);
|
||||
tdbp->SetAbort(false);
|
||||
|
||||
if ((rc = setjmp(g->jumper[++g->jump_level])) != 0) {
|
||||
rc= RC_FX;
|
||||
g->jump_level--;
|
||||
goto err;
|
||||
} // endif
|
||||
if (trace > 1)
|
||||
printf("Table %s closed\n", tdbp->GetName());
|
||||
|
||||
// This will close the table file(s) and also finalize write
|
||||
// operations such as Insert, Update, or Delete.
|
||||
tdbp->SetAbort(abort);
|
||||
tdbp->CloseDB(g);
|
||||
tdbp->SetAbort(false);
|
||||
g->jump_level--;
|
||||
if (!nox && tdbp->GetMode() != MODE_READ && tdbp->GetMode() != MODE_ANY) {
|
||||
if (trace > 1)
|
||||
printf("About to reset opt\n");
|
||||
|
||||
if (trace > 1)
|
||||
printf("Table %s closed\n", tdbp->GetName());
|
||||
if (!tdbp->IsRemote()) {
|
||||
// Make all the eventual indexes
|
||||
PTDBDOX tbxp = (PTDBDOX)tdbp;
|
||||
tbxp->ResetKindex(g, NULL);
|
||||
tbxp->SetKey_Col(NULL);
|
||||
rc = tbxp->ResetTableOpt(g, true, tbxp->GetDef()->Indexable() == 1);
|
||||
} // endif remote
|
||||
|
||||
//if (!((PTDBDOX)tdbp)->GetModified())
|
||||
// return 0;
|
||||
} // endif nox
|
||||
|
||||
if (nox || tdbp->GetMode() == MODE_READ || tdbp->GetMode() == MODE_ANY)
|
||||
return 0;
|
||||
} catch (int) {
|
||||
rc = RC_FX;
|
||||
} catch (const char *msg) {
|
||||
strcpy(g->Message, msg);
|
||||
rc = RC_FX;
|
||||
} // end catch
|
||||
|
||||
if (trace > 1)
|
||||
printf("About to reset opt\n");
|
||||
if (trace > 1)
|
||||
htrc("Done rc=%d\n", rc);
|
||||
|
||||
if (!tdbp->IsRemote()) {
|
||||
// Make all the eventual indexes
|
||||
PTDBDOX tbxp = (PTDBDOX)tdbp;
|
||||
tbxp->ResetKindex(g, NULL);
|
||||
tbxp->SetKey_Col(NULL);
|
||||
rc = tbxp->ResetTableOpt(g, true, tbxp->GetDef()->Indexable() == 1);
|
||||
} // endif remote
|
||||
|
||||
err:
|
||||
if (trace > 1)
|
||||
printf("Done rc=%d\n", rc);
|
||||
|
||||
return (rc == RC_OK || rc == RC_INFO) ? 0 : rc;
|
||||
} // end of CntCloseTable
|
||||
return (rc == RC_OK || rc == RC_INFO) ? 0 : rc;
|
||||
} // end of CntCloseTable
|
||||
|
||||
/***********************************************************************/
|
||||
/* Load and initialize the use of an index. */
|
||||
@@ -752,8 +708,9 @@ RCODE CntIndexRead(PGLOBAL g, PTDB ptdb, OPVAL op,
|
||||
sprintf(g->Message, MSG(TABLE_NO_INDEX), ptdb->GetName());
|
||||
return RC_FX;
|
||||
} else if (x == 2) {
|
||||
// Remote index
|
||||
if (op != OP_SAME && ptdb->ReadKey(g, op, kr))
|
||||
// Remote index. Only used in read mode
|
||||
if ((ptdb->GetMode() == MODE_READ || ptdb->GetMode() == MODE_READX)
|
||||
&& op != OP_SAME && ptdb->ReadKey(g, op, kr))
|
||||
return RC_FX;
|
||||
|
||||
goto rnd;
|
||||
|
||||
@@ -58,13 +58,15 @@ void CloseXMLFile(PGLOBAL g, PFBLOCK fp, bool all)
|
||||
if (xp && xp->Count > 1 && !all) {
|
||||
xp->Count--;
|
||||
} else if (xp && xp->Count > 0) {
|
||||
try {
|
||||
try {
|
||||
if (xp->Docp)
|
||||
xp->Docp->Release();
|
||||
|
||||
} catch(_com_error e) {
|
||||
sprintf(g->Message, "%s %s", MSG(COM_ERROR), e.Description());
|
||||
} catch(...) {}
|
||||
} catch(_com_error e) {
|
||||
char *p = _com_util::ConvertBSTRToString(e.Description());
|
||||
sprintf(g->Message, "%s %s", MSG(COM_ERROR), p);
|
||||
delete[] p;
|
||||
} catch(...) {}
|
||||
|
||||
CoUninitialize();
|
||||
xp->Count = 0;
|
||||
@@ -89,7 +91,7 @@ DOMDOC::DOMDOC(char *nsl, char *nsdf, char *enc, PFBLOCK fp)
|
||||
/******************************************************************/
|
||||
/* Initialize XML parser and check library compatibility. */
|
||||
/******************************************************************/
|
||||
bool DOMDOC::Initialize(PGLOBAL g, char *entry, bool zipped)
|
||||
bool DOMDOC::Initialize(PGLOBAL g, PCSZ entry, bool zipped)
|
||||
{
|
||||
if (zipped && InitZip(g, entry))
|
||||
return true;
|
||||
@@ -155,7 +157,7 @@ PFBLOCK DOMDOC::LinkXblock(PGLOBAL g, MODE m, int rc, char *fn)
|
||||
/******************************************************************/
|
||||
/* Create the XML node. */
|
||||
/******************************************************************/
|
||||
bool DOMDOC::NewDoc(PGLOBAL g, char *ver)
|
||||
bool DOMDOC::NewDoc(PGLOBAL g, PCSZ ver)
|
||||
{
|
||||
char buf[64];
|
||||
MSXML2::IXMLDOMProcessingInstructionPtr pip;
|
||||
@@ -490,9 +492,9 @@ PXATTR DOMNODE::GetAttribute(PGLOBAL g, char *name, PXATTR ap)
|
||||
/******************************************************************/
|
||||
/* Add a new element child node to this node and return it. */
|
||||
/******************************************************************/
|
||||
PXNODE DOMNODE::AddChildNode(PGLOBAL g, char *name, PXNODE np)
|
||||
PXNODE DOMNODE::AddChildNode(PGLOBAL g, PCSZ name, PXNODE np)
|
||||
{
|
||||
char *p, *pn;
|
||||
const char *p, *pn;
|
||||
// char *p, *pn, *epf, *pf = NULL;
|
||||
MSXML2::IXMLDOMNodePtr ep;
|
||||
// _bstr_t uri((wchar_t*)NULL);
|
||||
@@ -585,7 +587,7 @@ PXATTR DOMNODE::AddProperty(PGLOBAL g, char *name, PXATTR ap)
|
||||
/******************************************************************/
|
||||
/* Add a new text node to this node. */
|
||||
/******************************************************************/
|
||||
void DOMNODE::AddText(PGLOBAL g, char *txtp)
|
||||
void DOMNODE::AddText(PGLOBAL g, PCSZ txtp)
|
||||
{
|
||||
MSXML2::IXMLDOMTextPtr tp= Docp->createTextNode((_bstr_t)txtp);
|
||||
|
||||
|
||||
@@ -37,9 +37,9 @@ class DOMDOC : public XMLDOCUMENT {
|
||||
virtual void SetNofree(bool b) {} // Only libxml2
|
||||
|
||||
// Methods
|
||||
virtual bool Initialize(PGLOBAL g, char *entry, bool zipped);
|
||||
virtual bool Initialize(PGLOBAL g, PCSZ entry, bool zipped);
|
||||
virtual bool ParseFile(PGLOBAL g, char *fn);
|
||||
virtual bool NewDoc(PGLOBAL g, char *ver);
|
||||
virtual bool NewDoc(PGLOBAL g, PCSZ ver);
|
||||
virtual void AddComment(PGLOBAL g, char *com);
|
||||
virtual PXNODE GetRoot(PGLOBAL g);
|
||||
virtual PXNODE NewRoot(PGLOBAL g, char *name);
|
||||
@@ -78,9 +78,9 @@ class DOMNODE : public XMLNODE {
|
||||
virtual PXLIST SelectNodes(PGLOBAL g, char *xp, PXLIST lp);
|
||||
virtual PXNODE SelectSingleNode(PGLOBAL g, char *xp, PXNODE np);
|
||||
virtual PXATTR GetAttribute(PGLOBAL g, char *name, PXATTR ap);
|
||||
virtual PXNODE AddChildNode(PGLOBAL g, char *name, PXNODE np);
|
||||
virtual PXNODE AddChildNode(PGLOBAL g, PCSZ name, PXNODE np);
|
||||
virtual PXATTR AddProperty(PGLOBAL g, char *name, PXATTR ap);
|
||||
virtual void AddText(PGLOBAL g, char *txtp);
|
||||
virtual void AddText(PGLOBAL g, PCSZ txtp);
|
||||
virtual void DeleteChild(PGLOBAL g, PXNODE dnp);
|
||||
|
||||
protected:
|
||||
|
||||
@@ -301,10 +301,9 @@ int MAPFAM::SkipRecord(PGLOBAL g, bool header)
|
||||
PDBUSER dup = (PDBUSER)g->Activityp->Aptr;
|
||||
|
||||
// Skip this record
|
||||
while (*Mempos++ != '\n') ; // What about Unix ???
|
||||
|
||||
if (Mempos >= Top)
|
||||
return RC_EF;
|
||||
while (*Mempos++ != '\n') // What about Unix ???
|
||||
if (Mempos == Top)
|
||||
return RC_EF;
|
||||
|
||||
// Update progress information
|
||||
dup->ProgCur = GetPos();
|
||||
@@ -320,7 +319,7 @@ int MAPFAM::SkipRecord(PGLOBAL g, bool header)
|
||||
/***********************************************************************/
|
||||
int MAPFAM::ReadBuffer(PGLOBAL g)
|
||||
{
|
||||
int rc, len;
|
||||
int rc, len, n = 1;
|
||||
|
||||
// Are we at the end of the memory
|
||||
if (Mempos >= Top) {
|
||||
@@ -362,10 +361,14 @@ int MAPFAM::ReadBuffer(PGLOBAL g)
|
||||
Placed = false;
|
||||
|
||||
// Immediately calculate next position (Used by DeleteDB)
|
||||
while (*Mempos++ != '\n') ; // What about Unix ???
|
||||
while (*Mempos++ != '\n') // What about Unix ???
|
||||
if (Mempos == Top) {
|
||||
n = 0;
|
||||
break;
|
||||
} // endif Mempos
|
||||
|
||||
// Set caller line buffer
|
||||
len = (Mempos - Fpos) - 1;
|
||||
len = (Mempos - Fpos) - n;
|
||||
|
||||
// Don't rely on ENDING setting
|
||||
if (len > 0 && *(Mempos - 2) == '\r')
|
||||
@@ -619,7 +622,9 @@ int MBKFAM::ReadBuffer(PGLOBAL g)
|
||||
} // endif's
|
||||
|
||||
// Immediately calculate next position (Used by DeleteDB)
|
||||
while (*Mempos++ != '\n') ; // What about Unix ???
|
||||
while (*Mempos++ != '\n') // What about Unix ???
|
||||
if (Mempos == Top)
|
||||
break;
|
||||
|
||||
// Set caller line buffer
|
||||
len = (Mempos - Fpos) - Ending;
|
||||
|
||||
@@ -128,7 +128,7 @@ typedef struct _descriptor {
|
||||
/* Moves file pointer to byte 32; fills buffer at buf with */
|
||||
/* first 32 bytes of file. */
|
||||
/****************************************************************************/
|
||||
static int dbfhead(PGLOBAL g, FILE *file, PSZ fn, DBFHEADER *buf)
|
||||
static int dbfhead(PGLOBAL g, FILE *file, PCSZ fn, DBFHEADER *buf)
|
||||
{
|
||||
char endmark[2];
|
||||
int dbc = 2, rc = RC_OK;
|
||||
@@ -186,7 +186,7 @@ static int dbfhead(PGLOBAL g, FILE *file, PSZ fn, DBFHEADER *buf)
|
||||
/* DBFColumns: constructs the result blocks containing the description */
|
||||
/* of all the columns of a DBF file that will be retrieved by #GetData. */
|
||||
/****************************************************************************/
|
||||
PQRYRES DBFColumns(PGLOBAL g, char *dp, const char *fn, bool info)
|
||||
PQRYRES DBFColumns(PGLOBAL g, PCSZ dp, PCSZ fn, bool info)
|
||||
{
|
||||
int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING,
|
||||
TYPE_INT, TYPE_INT, TYPE_SHORT};
|
||||
@@ -393,7 +393,7 @@ DBFBASE::DBFBASE(DBFBASE *txfp)
|
||||
/* and header length. Set Records, check that Reclen is equal to lrecl and */
|
||||
/* return the header length or 0 in case of error. */
|
||||
/****************************************************************************/
|
||||
int DBFBASE::ScanHeader(PGLOBAL g, PSZ fn, int lrecl, int *rln, char *defpath)
|
||||
int DBFBASE::ScanHeader(PGLOBAL g, PCSZ fn, int lrecl, int *rln, PCSZ defpath)
|
||||
{
|
||||
int rc;
|
||||
char filename[_MAX_PATH];
|
||||
|
||||
@@ -19,7 +19,7 @@ typedef class DBMFAM *PDBMFAM;
|
||||
/****************************************************************************/
|
||||
/* Functions used externally. */
|
||||
/****************************************************************************/
|
||||
PQRYRES DBFColumns(PGLOBAL g, char *dp, const char *fn, bool info);
|
||||
PQRYRES DBFColumns(PGLOBAL g, PCSZ dp, PCSZ fn, bool info);
|
||||
|
||||
/****************************************************************************/
|
||||
/* This is the base class for dBASE file access methods. */
|
||||
@@ -31,7 +31,7 @@ class DllExport DBFBASE {
|
||||
DBFBASE(PDBF txfp);
|
||||
|
||||
// Implementation
|
||||
int ScanHeader(PGLOBAL g, PSZ fname, int lrecl, int *rlen, char *defpath);
|
||||
int ScanHeader(PGLOBAL g, PCSZ fname, int lrecl, int *rlen, PCSZ defpath);
|
||||
|
||||
protected:
|
||||
// Default constructor, not to be used
|
||||
|
||||
@@ -761,7 +761,8 @@ bool BGXFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req)
|
||||
htrc("after write req=%d brc=%d nbw=%d\n", req, brc, nbw);
|
||||
|
||||
if (!brc || nbw != len) {
|
||||
char buf[256], *fn = (h == Hfile) ? To_File : "Tempfile";
|
||||
char buf[256];
|
||||
PCSZ fn = (h == Hfile) ? To_File : "Tempfile";
|
||||
|
||||
if (brc)
|
||||
strcpy(buf, MSG(BAD_BYTE_NUM));
|
||||
|
||||
@@ -920,8 +920,8 @@ int ZLBFAM::GetFileLength(PGLOBAL g)
|
||||
/***********************************************************************/
|
||||
bool ZLBFAM::AllocateBuffer(PGLOBAL g)
|
||||
{
|
||||
char *msg;
|
||||
int n, zrc;
|
||||
PCSZ msg;
|
||||
int n, zrc;
|
||||
|
||||
#if 0
|
||||
if (!Optimized && Tdbp->NeedIndexing(g)) {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/*********** File AM Txt C++ Program Source Code File (.CPP) ***********/
|
||||
/* PROGRAM NAME: FILAMTXT */
|
||||
/* ------------- */
|
||||
/* Version 1.6 */
|
||||
/* Version 1.7 */
|
||||
/* */
|
||||
/* COPYRIGHT: */
|
||||
/* ---------- */
|
||||
/* (C) Copyright to the author Olivier BERTRAND 2005-2015 */
|
||||
/* (C) Copyright to the author Olivier BERTRAND 2005-2017 */
|
||||
/* */
|
||||
/* WHAT THIS PROGRAM DOES: */
|
||||
/* ----------------------- */
|
||||
@@ -71,8 +71,23 @@ TXTFAM::TXTFAM(PDOSDEF tdp)
|
||||
{
|
||||
Tdbp = NULL;
|
||||
To_Fb = NULL;
|
||||
To_File = tdp->Fn;
|
||||
Lrecl = tdp->Lrecl;
|
||||
|
||||
if (tdp) {
|
||||
To_File = tdp->Fn;
|
||||
Lrecl = tdp->Lrecl;
|
||||
Eof = tdp->Eof;
|
||||
Ending = tdp->Ending;
|
||||
} else {
|
||||
To_File = NULL;
|
||||
Lrecl = 0;
|
||||
Eof = false;
|
||||
#if defined(__WIN__)
|
||||
Ending = 2;
|
||||
#else
|
||||
Ending = 1;
|
||||
#endif
|
||||
} // endif tdp
|
||||
|
||||
Placed = false;
|
||||
IsRead = true;
|
||||
Blocked = false;
|
||||
@@ -103,8 +118,6 @@ TXTFAM::TXTFAM(PDOSDEF tdp)
|
||||
Blksize = 0;
|
||||
Fpos = Spos = Tpos = 0;
|
||||
Padded = false;
|
||||
Eof = tdp->Eof;
|
||||
Ending = tdp->Ending;
|
||||
Abort = false;
|
||||
CrLf = (char*)(Ending == 1 ? "\n" : "\r\n");
|
||||
} // end of TXTFAM standard constructor
|
||||
@@ -974,7 +987,7 @@ int DOSFAM::DeleteRecords(PGLOBAL g, int irc)
|
||||
|
||||
} else {
|
||||
/*****************************************************************/
|
||||
/* Move of eventual preceding lines is not required here. */
|
||||
/* Move of eventual preceding lines is not required here. */
|
||||
/* Set the target file as being the source file itself. */
|
||||
/* Set the future Tpos, and give Spos a value to block copying. */
|
||||
/*****************************************************************/
|
||||
@@ -1162,13 +1175,13 @@ int DOSFAM::RenameTempFile(PGLOBAL g)
|
||||
if (rename(filename, filetemp)) { // Save file for security
|
||||
sprintf(g->Message, MSG(RENAME_ERROR),
|
||||
filename, filetemp, strerror(errno));
|
||||
longjmp(g->jumper[g->jump_level], 51);
|
||||
} else if (rename(tempname, filename)) {
|
||||
throw 51;
|
||||
} else if (rename(tempname, filename)) {
|
||||
sprintf(g->Message, MSG(RENAME_ERROR),
|
||||
tempname, filename, strerror(errno));
|
||||
rc = rename(filetemp, filename); // Restore saved file
|
||||
longjmp(g->jumper[g->jump_level], 52);
|
||||
} else if (remove(filetemp)) {
|
||||
throw 52;
|
||||
} else if (remove(filetemp)) {
|
||||
sprintf(g->Message, MSG(REMOVE_ERROR),
|
||||
filetemp, strerror(errno));
|
||||
rc = RC_INFO; // Acceptable
|
||||
|
||||
@@ -80,7 +80,7 @@ class DllExport TXTFAM : public BLOCK {
|
||||
protected:
|
||||
// Members
|
||||
PTDBDOS Tdbp; // To table class
|
||||
PSZ To_File; // Points to table file name
|
||||
PCSZ To_File; // Points to table file name
|
||||
PFBLOCK To_Fb; // Pointer to file block
|
||||
PPARM To_Pos; // Pointer to position list
|
||||
PPARM To_Sos; // Pointer to start position list
|
||||
|
||||
@@ -143,9 +143,9 @@ int VCTFAM::GetFileLength(PGLOBAL g)
|
||||
{
|
||||
if (Split) {
|
||||
// Get the total file length
|
||||
char filename[_MAX_PATH];
|
||||
char *savfile = To_File;
|
||||
int i, len = 0;
|
||||
char filename[_MAX_PATH];
|
||||
PCSZ savfile = To_File;
|
||||
int i, len = 0;
|
||||
|
||||
// Initialize the array of file structures
|
||||
if (!Colfn) {
|
||||
@@ -313,8 +313,8 @@ int VCTFAM::Cardinality(PGLOBAL g)
|
||||
// and Last must be set from the file cardinality.
|
||||
// Only happens when called by sub classes.
|
||||
char filename[_MAX_PATH];
|
||||
PSZ savfn = To_File;
|
||||
int len, clen, card = -1;
|
||||
PCSZ savfn = To_File;
|
||||
int len, clen, card = -1;
|
||||
PCOLDEF cdp = Tdbp->GetDef()->GetCols();
|
||||
|
||||
if (!Colfn) {
|
||||
@@ -368,7 +368,7 @@ int VCTFAM::GetRowID(void)
|
||||
/***********************************************************************/
|
||||
/* VCT Create an empty file for Vector formatted tables. */
|
||||
/***********************************************************************/
|
||||
bool VCTFAM::MakeEmptyFile(PGLOBAL g, char *fn)
|
||||
bool VCTFAM::MakeEmptyFile(PGLOBAL g, PCSZ fn)
|
||||
{
|
||||
// Vector formatted file: this will create an empty file of the
|
||||
// required length if it does not exists yet.
|
||||
@@ -560,7 +560,9 @@ bool VCTFAM::AllocateBuffer(PGLOBAL g)
|
||||
/* Do initial action when inserting. */
|
||||
/***********************************************************************/
|
||||
bool VCTFAM::InitInsert(PGLOBAL g)
|
||||
{
|
||||
{
|
||||
bool rc = false;
|
||||
|
||||
// We come here in MODE_INSERT only
|
||||
if (Last == Nrec) {
|
||||
CurBlk = Block;
|
||||
@@ -574,27 +576,27 @@ bool VCTFAM::InitInsert(PGLOBAL g)
|
||||
CurBlk = Block - 1;
|
||||
CurNum = Last;
|
||||
|
||||
// Prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||
return true;
|
||||
} // endif
|
||||
try {
|
||||
// Last block must be updated by new values
|
||||
for (; cp; cp = (PVCTCOL)cp->Next)
|
||||
cp->ReadBlock(g);
|
||||
|
||||
if ((rc = setjmp(g->jumper[++g->jump_level])) != 0) {
|
||||
g->jump_level--;
|
||||
return true;
|
||||
} // endif
|
||||
} catch (int n) {
|
||||
if (trace)
|
||||
htrc("Exception %d: %s\n", n, g->Message);
|
||||
rc = true;
|
||||
} catch (const char *msg) {
|
||||
strcpy(g->Message, msg);
|
||||
rc = true;
|
||||
} // end catch
|
||||
|
||||
// Last block must be updated by new values
|
||||
for (; cp; cp = (PVCTCOL)cp->Next)
|
||||
cp->ReadBlock(g);
|
||||
|
||||
g->jump_level--;
|
||||
} // endif Last
|
||||
|
||||
// We are not currently using a temporary file for Insert
|
||||
T_Stream = Stream;
|
||||
return false;
|
||||
if (!rc)
|
||||
// We are not currently using a temporary file for Insert
|
||||
T_Stream = Stream;
|
||||
|
||||
return rc;
|
||||
} // end of InitInsert
|
||||
|
||||
/***********************************************************************/
|
||||
@@ -879,8 +881,9 @@ int VCTFAM::DeleteRecords(PGLOBAL g, int irc)
|
||||
/***********************************************************************/
|
||||
bool VCTFAM::OpenTempFile(PGLOBAL g)
|
||||
{
|
||||
char *opmode, tempname[_MAX_PATH];
|
||||
bool rc = false;
|
||||
PCSZ opmode;
|
||||
char tempname[_MAX_PATH];
|
||||
bool rc = false;
|
||||
|
||||
/*********************************************************************/
|
||||
/* Open the temporary file, Spos is at the beginning of file. */
|
||||
@@ -1108,7 +1111,7 @@ void VCTFAM::CloseTableFile(PGLOBAL g, bool abort)
|
||||
} else if (AddBlock) {
|
||||
// Last block was not written
|
||||
rc = ResetTableSize(g, CurBlk, Nrec);
|
||||
longjmp(g->jumper[g->jump_level], 44);
|
||||
throw 44;
|
||||
} // endif
|
||||
|
||||
} else if (mode == MODE_UPDATE) {
|
||||
@@ -1528,8 +1531,8 @@ bool VCMFAM::AllocateBuffer(PGLOBAL g)
|
||||
/* Do initial action when inserting. */
|
||||
/***********************************************************************/
|
||||
bool VCMFAM::InitInsert(PGLOBAL g)
|
||||
{
|
||||
int rc;
|
||||
{
|
||||
bool rc = false;
|
||||
volatile PVCTCOL cp = (PVCTCOL)Tdbp->GetColumns();
|
||||
|
||||
// We come here in MODE_INSERT only
|
||||
@@ -1543,24 +1546,22 @@ bool VCMFAM::InitInsert(PGLOBAL g)
|
||||
CurNum = Last;
|
||||
} // endif Last
|
||||
|
||||
// Prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||
return true;
|
||||
} // endif
|
||||
try {
|
||||
// Initialize the column block pointer
|
||||
for (; cp; cp = (PVCTCOL)cp->Next)
|
||||
cp->ReadBlock(g);
|
||||
|
||||
if ((rc = setjmp(g->jumper[++g->jump_level])) != 0) {
|
||||
g->jump_level--;
|
||||
return true;
|
||||
} // endif
|
||||
} catch (int n) {
|
||||
if (trace)
|
||||
htrc("Exception %d: %s\n", n, g->Message);
|
||||
rc = true;
|
||||
} catch (const char *msg) {
|
||||
strcpy(g->Message, msg);
|
||||
rc = true;
|
||||
} // end catch
|
||||
|
||||
// Initialize the column block pointer
|
||||
for (; cp; cp = (PVCTCOL)cp->Next)
|
||||
cp->ReadBlock(g);
|
||||
|
||||
g->jump_level--;
|
||||
return false;
|
||||
} // end of InitInsert
|
||||
return rc;
|
||||
} // end of InitInsert
|
||||
|
||||
/***********************************************************************/
|
||||
/* Data Base write routine for VMP access method. */
|
||||
@@ -2000,7 +2001,7 @@ bool VECFAM::OpenTableFile(PGLOBAL g)
|
||||
/***********************************************************************/
|
||||
/* Open the file corresponding to one column. */
|
||||
/***********************************************************************/
|
||||
bool VECFAM::OpenColumnFile(PGLOBAL g, char *opmode, int i)
|
||||
bool VECFAM::OpenColumnFile(PGLOBAL g, PCSZ opmode, int i)
|
||||
{
|
||||
char filename[_MAX_PATH];
|
||||
PDBUSER dup = PlgGetUser(g);
|
||||
@@ -2505,7 +2506,7 @@ void VECFAM::CloseTableFile(PGLOBAL g, bool abort)
|
||||
if (wrc != RC_FX)
|
||||
rc = ResetTableSize(g, Block, Last);
|
||||
else
|
||||
longjmp(g->jumper[g->jump_level], 44);
|
||||
throw 44;
|
||||
|
||||
} else if (mode == MODE_UPDATE) {
|
||||
if (UseTemp && !InitUpdate && !Abort) {
|
||||
@@ -3145,7 +3146,8 @@ bool BGVFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req)
|
||||
htrc("after write req=%d brc=%d nbw=%d\n", req, brc, nbw);
|
||||
|
||||
if (!brc || nbw != len) {
|
||||
char buf[256], *fn = (h == Hfile) ? To_File : "Tempfile";
|
||||
char buf[256];
|
||||
PCSZ fn = (h == Hfile) ? To_File : "Tempfile";
|
||||
|
||||
if (brc)
|
||||
strcpy(buf, MSG(BAD_BYTE_NUM));
|
||||
@@ -3321,7 +3323,7 @@ bool BGVFAM::SetBlockInfo(PGLOBAL g)
|
||||
/***********************************************************************/
|
||||
/* VEC Create an empty file for new Vector formatted tables. */
|
||||
/***********************************************************************/
|
||||
bool BGVFAM::MakeEmptyFile(PGLOBAL g, char *fn)
|
||||
bool BGVFAM::MakeEmptyFile(PGLOBAL g, PCSZ fn)
|
||||
{
|
||||
// Vector formatted file this will create an empty file of the
|
||||
// required length if it does not exists yet.
|
||||
@@ -3331,7 +3333,7 @@ bool BGVFAM::MakeEmptyFile(PGLOBAL g, char *fn)
|
||||
PlugSetPath(filename, fn, Tdbp->GetPath());
|
||||
|
||||
#if defined(__WIN__)
|
||||
char *p;
|
||||
PCSZ p;
|
||||
DWORD rc;
|
||||
bool brc;
|
||||
LARGE_INTEGER of;
|
||||
@@ -4167,8 +4169,8 @@ void BGVFAM::CloseTableFile(PGLOBAL g, bool abort)
|
||||
} else if (AddBlock) {
|
||||
// Last block was not written
|
||||
rc = ResetTableSize(g, CurBlk, Nrec);
|
||||
longjmp(g->jumper[g->jump_level], 44);
|
||||
} // endif
|
||||
throw 44;
|
||||
} // endif
|
||||
|
||||
} else if (mode == MODE_UPDATE) {
|
||||
// Write back to file any pending modifications
|
||||
|
||||
@@ -61,7 +61,7 @@ class DllExport VCTFAM : public FIXFAM {
|
||||
virtual bool WriteBlock(PGLOBAL g, PVCTCOL colp);
|
||||
|
||||
protected:
|
||||
virtual bool MakeEmptyFile(PGLOBAL g, char *fn);
|
||||
virtual bool MakeEmptyFile(PGLOBAL g, PCSZ fn);
|
||||
virtual bool OpenTempFile(PGLOBAL g);
|
||||
virtual bool MoveLines(PGLOBAL g) {return false;}
|
||||
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL);
|
||||
@@ -160,7 +160,7 @@ class DllExport VECFAM : public VCTFAM {
|
||||
virtual bool MoveLines(PGLOBAL g);
|
||||
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL);
|
||||
virtual int RenameTempFile(PGLOBAL g);
|
||||
bool OpenColumnFile(PGLOBAL g, char *opmode, int i);
|
||||
bool OpenColumnFile(PGLOBAL g, PCSZ opmode, int i);
|
||||
|
||||
// Members
|
||||
FILE* *Streams; // Points to Dos file structure array
|
||||
@@ -235,7 +235,7 @@ class BGVFAM : public VCTFAM {
|
||||
bool BigSeek(PGLOBAL g, HANDLE h, BIGINT pos, bool b = false);
|
||||
bool BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req);
|
||||
bool BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req);
|
||||
virtual bool MakeEmptyFile(PGLOBAL g, char *fn);
|
||||
virtual bool MakeEmptyFile(PGLOBAL g, PCSZ fn);
|
||||
virtual bool OpenTempFile(PGLOBAL g);
|
||||
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL);
|
||||
virtual bool CleanUnusedSpace(PGLOBAL g);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*********** File AM Zip C++ Program Source Code File (.CPP) ***********/
|
||||
/* PROGRAM NAME: FILAMZIP */
|
||||
/* ------------- */
|
||||
/* Version 1.1 */
|
||||
/* Version 1.3 */
|
||||
/* */
|
||||
/* COPYRIGHT: */
|
||||
/* ---------- */
|
||||
@@ -45,12 +45,12 @@
|
||||
|
||||
#define WRITEBUFFERSIZE (16384)
|
||||
|
||||
bool ZipLoadFile(PGLOBAL g, char *zfn, char *fn, char *entry, bool append, bool mul);
|
||||
bool ZipLoadFile(PGLOBAL g, PCSZ zfn, PCSZ fn, PCSZ entry, bool append, bool mul);
|
||||
|
||||
/***********************************************************************/
|
||||
/* Compress a file in zip when creating a table. */
|
||||
/***********************************************************************/
|
||||
static bool ZipFile(PGLOBAL g, ZIPUTIL *zutp, char *fn, char *entry, char *buf)
|
||||
static bool ZipFile(PGLOBAL g, ZIPUTIL *zutp, PCSZ fn, PCSZ entry, char *buf)
|
||||
{
|
||||
int rc = RC_OK, size_read, size_buf = WRITEBUFFERSIZE;
|
||||
FILE *fin;
|
||||
@@ -88,7 +88,7 @@ static bool ZipFile(PGLOBAL g, ZIPUTIL *zutp, char *fn, char *entry, char *buf)
|
||||
/***********************************************************************/
|
||||
/* Find and Compress several files in zip when creating a table. */
|
||||
/***********************************************************************/
|
||||
static bool ZipFiles(PGLOBAL g, ZIPUTIL *zutp, char *pat, char *buf)
|
||||
static bool ZipFiles(PGLOBAL g, ZIPUTIL *zutp, PCSZ pat, char *buf)
|
||||
{
|
||||
char filename[_MAX_PATH];
|
||||
int rc;
|
||||
@@ -203,7 +203,7 @@ static bool ZipFiles(PGLOBAL g, ZIPUTIL *zutp, char *pat, char *buf)
|
||||
/***********************************************************************/
|
||||
/* Load and Compress a file in zip when creating a table. */
|
||||
/***********************************************************************/
|
||||
bool ZipLoadFile(PGLOBAL g, char *zfn, char *fn, char *entry, bool append, bool mul)
|
||||
bool ZipLoadFile(PGLOBAL g, PCSZ zfn, PCSZ fn, PCSZ entry, bool append, bool mul)
|
||||
{
|
||||
char *buf;
|
||||
bool err;
|
||||
@@ -228,7 +228,7 @@ bool ZipLoadFile(PGLOBAL g, char *zfn, char *fn, char *entry, bool append, bool
|
||||
/***********************************************************************/
|
||||
/* Constructors. */
|
||||
/***********************************************************************/
|
||||
ZIPUTIL::ZIPUTIL(PSZ tgt)
|
||||
ZIPUTIL::ZIPUTIL(PCSZ tgt)
|
||||
{
|
||||
zipfile = NULL;
|
||||
target = tgt;
|
||||
@@ -269,7 +269,7 @@ void ZIPUTIL::getTime(tm_zip& tmZip)
|
||||
/* append: set true to append the zip file */
|
||||
/* return: true if open, false otherwise. */
|
||||
/***********************************************************************/
|
||||
bool ZIPUTIL::open(PGLOBAL g, char *filename, bool append)
|
||||
bool ZIPUTIL::open(PGLOBAL g, PCSZ filename, bool append)
|
||||
{
|
||||
if (!zipfile && !(zipfile = zipOpen64(filename,
|
||||
append ? APPEND_STATUS_ADDINZIP
|
||||
@@ -295,7 +295,7 @@ void ZIPUTIL::close()
|
||||
/***********************************************************************/
|
||||
/* OpenTableFile: Open a DOS/UNIX table file from a ZIP file. */
|
||||
/***********************************************************************/
|
||||
bool ZIPUTIL::OpenTable(PGLOBAL g, MODE mode, char *fn, bool append)
|
||||
bool ZIPUTIL::OpenTable(PGLOBAL g, MODE mode, PCSZ fn, bool append)
|
||||
{
|
||||
/*********************************************************************/
|
||||
/* The file will be compressed. */
|
||||
@@ -338,7 +338,7 @@ bool ZIPUTIL::OpenTable(PGLOBAL g, MODE mode, char *fn, bool append)
|
||||
/***********************************************************************/
|
||||
/* Add target in zip file. */
|
||||
/***********************************************************************/
|
||||
bool ZIPUTIL::addEntry(PGLOBAL g, char *entry)
|
||||
bool ZIPUTIL::addEntry(PGLOBAL g, PCSZ entry)
|
||||
{
|
||||
//?? we dont need the stinking time
|
||||
zip_fileinfo zi = { {0, 0, 0, 0, 0, 0}, 0, 0, 0 };
|
||||
@@ -382,10 +382,11 @@ void ZIPUTIL::closeEntry()
|
||||
/***********************************************************************/
|
||||
/* Constructors. */
|
||||
/***********************************************************************/
|
||||
UNZIPUTL::UNZIPUTL(PSZ tgt, bool mul)
|
||||
UNZIPUTL::UNZIPUTL(PCSZ tgt, bool mul)
|
||||
{
|
||||
zipfile = NULL;
|
||||
target = tgt;
|
||||
pwd = NULL;
|
||||
fp = NULL;
|
||||
memory = NULL;
|
||||
size = 0;
|
||||
@@ -401,6 +402,26 @@ UNZIPUTL::UNZIPUTL(PSZ tgt, bool mul)
|
||||
#endif
|
||||
} // end of UNZIPUTL standard constructor
|
||||
|
||||
UNZIPUTL::UNZIPUTL(PDOSDEF tdp)
|
||||
{
|
||||
zipfile = NULL;
|
||||
target = tdp->GetEntry();
|
||||
pwd = tdp->Pwd;
|
||||
fp = NULL;
|
||||
memory = NULL;
|
||||
size = 0;
|
||||
entryopen = false;
|
||||
multiple = tdp->GetMul();
|
||||
memset(fn, 0, sizeof(fn));
|
||||
|
||||
// Init the case mapping table.
|
||||
#if defined(__WIN__)
|
||||
for (int i = 0; i < 256; ++i) mapCaseTable[i] = toupper(i);
|
||||
#else
|
||||
for (int i = 0; i < 256; ++i) mapCaseTable[i] = i;
|
||||
#endif
|
||||
} // end of UNZIPUTL standard constructor
|
||||
|
||||
#if 0
|
||||
UNZIPUTL::UNZIPUTL(PZIPUTIL zutp)
|
||||
{
|
||||
@@ -418,8 +439,8 @@ UNZIPUTL::UNZIPUTL(PZIPUTIL zutp)
|
||||
/* This code is the copyright property of Alessandro Felice Cantatore. */
|
||||
/* http://xoomer.virgilio.it/acantato/dev/wildcard/wildmatch.html */
|
||||
/***********************************************************************/
|
||||
bool UNZIPUTL::WildMatch(PSZ pat, PSZ str) {
|
||||
PSZ s, p;
|
||||
bool UNZIPUTL::WildMatch(PCSZ pat, PCSZ str) {
|
||||
PCSZ s, p;
|
||||
bool star = FALSE;
|
||||
|
||||
loopStart:
|
||||
@@ -453,7 +474,7 @@ starCheck:
|
||||
/* param: filename path and the filename of the zip file to open. */
|
||||
/* return: true if open, false otherwise. */
|
||||
/***********************************************************************/
|
||||
bool UNZIPUTL::open(PGLOBAL g, char *filename)
|
||||
bool UNZIPUTL::open(PGLOBAL g, PCSZ filename)
|
||||
{
|
||||
if (!zipfile && !(zipfile = unzOpen64(filename)))
|
||||
sprintf(g->Message, "Zipfile open error on %s", filename);
|
||||
@@ -543,7 +564,7 @@ int UNZIPUTL::nextEntry(PGLOBAL g)
|
||||
/***********************************************************************/
|
||||
/* OpenTableFile: Open a DOS/UNIX table file from a ZIP file. */
|
||||
/***********************************************************************/
|
||||
bool UNZIPUTL::OpenTable(PGLOBAL g, MODE mode, char *fn)
|
||||
bool UNZIPUTL::OpenTable(PGLOBAL g, MODE mode, PCSZ fn)
|
||||
{
|
||||
/*********************************************************************/
|
||||
/* The file will be decompressed into virtual memory. */
|
||||
@@ -581,7 +602,7 @@ bool UNZIPUTL::OpenTable(PGLOBAL g, MODE mode, char *fn)
|
||||
if (openEntry(g))
|
||||
return true;
|
||||
|
||||
if (size > 0) {
|
||||
if (size > 0) {
|
||||
/*******************************************************************/
|
||||
/* Link a Fblock. This make possible to automatically close it */
|
||||
/* in case of error g->jump. */
|
||||
@@ -612,6 +633,28 @@ bool UNZIPUTL::OpenTable(PGLOBAL g, MODE mode, char *fn)
|
||||
return false;
|
||||
} // end of OpenTableFile
|
||||
|
||||
/***********************************************************************/
|
||||
/* Insert only if the entry does not exist. */
|
||||
/***********************************************************************/
|
||||
bool UNZIPUTL::IsInsertOk(PGLOBAL g, PCSZ fn)
|
||||
{
|
||||
bool ok = true, b = open(g, fn);
|
||||
|
||||
if (!b) {
|
||||
if (!target || *target == 0) {
|
||||
unz_global_info64 ginfo;
|
||||
int err = unzGetGlobalInfo64(zipfile, &ginfo);
|
||||
|
||||
ok = !(err == UNZ_OK && ginfo.number_entry > 0);
|
||||
} else // Check if the target exist
|
||||
ok = (unzLocateFile(zipfile, target, 0) != UNZ_OK);
|
||||
|
||||
unzClose(zipfile);
|
||||
} // endif b
|
||||
|
||||
return ok;
|
||||
} // end of IsInsertOk
|
||||
|
||||
/***********************************************************************/
|
||||
/* Open target in zip file. */
|
||||
/***********************************************************************/
|
||||
@@ -625,18 +668,24 @@ bool UNZIPUTL::openEntry(PGLOBAL g)
|
||||
if (rc != UNZ_OK) {
|
||||
sprintf(g->Message, "unzGetCurrentFileInfo64 rc=%d", rc);
|
||||
return true;
|
||||
} else if ((rc = unzOpenCurrentFile(zipfile)) != UNZ_OK) {
|
||||
} else if ((rc = unzOpenCurrentFilePassword(zipfile, pwd)) != UNZ_OK) {
|
||||
sprintf(g->Message, "unzOpen fn=%s rc=%d", fn, rc);
|
||||
return true;
|
||||
} // endif rc
|
||||
|
||||
size = finfo.uncompressed_size;
|
||||
memory = new char[size + 1];
|
||||
|
||||
try {
|
||||
memory = new char[size + 1];
|
||||
} catch (...) {
|
||||
strcpy(g->Message, "Out of memory");
|
||||
return true;
|
||||
} // end try/catch
|
||||
|
||||
if ((rc = unzReadCurrentFile(zipfile, memory, size)) < 0) {
|
||||
sprintf(g->Message, "unzReadCurrentFile rc = %d", rc);
|
||||
unzCloseCurrentFile(zipfile);
|
||||
free(memory);
|
||||
delete[] memory;
|
||||
memory = NULL;
|
||||
entryopen = false;
|
||||
} else {
|
||||
@@ -661,7 +710,7 @@ void UNZIPUTL::closeEntry()
|
||||
} // endif entryopen
|
||||
|
||||
if (memory) {
|
||||
free(memory);
|
||||
delete[] memory;
|
||||
memory = NULL;
|
||||
} // endif memory
|
||||
|
||||
@@ -675,15 +724,17 @@ void UNZIPUTL::closeEntry()
|
||||
UNZFAM::UNZFAM(PDOSDEF tdp) : MAPFAM(tdp)
|
||||
{
|
||||
zutp = NULL;
|
||||
target = tdp->GetEntry();
|
||||
mul = tdp->GetMul();
|
||||
tdfp = tdp;
|
||||
//target = tdp->GetEntry();
|
||||
//mul = tdp->GetMul();
|
||||
} // end of UNZFAM standard constructor
|
||||
|
||||
UNZFAM::UNZFAM(PUNZFAM txfp) : MAPFAM(txfp)
|
||||
{
|
||||
zutp = txfp->zutp;
|
||||
target = txfp->target;
|
||||
mul = txfp->mul;
|
||||
tdfp = txfp->tdfp;
|
||||
//target = txfp->target;
|
||||
//mul = txfp->mul;
|
||||
} // end of UNZFAM copy constructor
|
||||
|
||||
/***********************************************************************/
|
||||
@@ -711,7 +762,13 @@ int UNZFAM::Cardinality(PGLOBAL g)
|
||||
int card = -1;
|
||||
int len = GetFileLength(g);
|
||||
|
||||
card = (len / (int)Lrecl) * 2; // Estimated ???
|
||||
if (len) {
|
||||
// Estimated ???
|
||||
card = (len / (int)Lrecl) * 2;
|
||||
card = card ? card : 10; // Lrecl can be too big
|
||||
} else
|
||||
card = 0;
|
||||
|
||||
return card;
|
||||
} // end of Cardinality
|
||||
|
||||
@@ -726,7 +783,7 @@ bool UNZFAM::OpenTableFile(PGLOBAL g)
|
||||
/*********************************************************************/
|
||||
/* Allocate the ZIP utility class. */
|
||||
/*********************************************************************/
|
||||
zutp = new(g) UNZIPUTL(target, mul);
|
||||
zutp = new(g) UNZIPUTL(tdfp);
|
||||
|
||||
// We used the file name relative to recorded datapath
|
||||
PlugSetPath(filename, To_File, Tdbp->GetPath());
|
||||
@@ -841,17 +898,19 @@ void UNZFAM::CloseTableFile(PGLOBAL g, bool)
|
||||
UZXFAM::UZXFAM(PDOSDEF tdp) : MPXFAM(tdp)
|
||||
{
|
||||
zutp = NULL;
|
||||
target = tdp->GetEntry();
|
||||
mul = tdp->GetMul();
|
||||
tdfp = tdp;
|
||||
//target = tdp->GetEntry();
|
||||
//mul = tdp->GetMul();
|
||||
//Lrecl = tdp->GetLrecl();
|
||||
} // end of UZXFAM standard constructor
|
||||
|
||||
UZXFAM::UZXFAM(PUZXFAM txfp) : MPXFAM(txfp)
|
||||
{
|
||||
zutp = txfp->zutp;
|
||||
target = txfp->target;
|
||||
mul = txfp->mul;
|
||||
//Lrecl = txfp->Lrecl;
|
||||
tdfp = txfp->tdfp;
|
||||
//target = txfp->target;
|
||||
//mul = txfp->mul;
|
||||
//Lrecl = txfp->Lrecl;
|
||||
} // end of UZXFAM copy constructor
|
||||
|
||||
/***********************************************************************/
|
||||
@@ -907,7 +966,7 @@ bool UZXFAM::OpenTableFile(PGLOBAL g)
|
||||
/* Allocate the ZIP utility class. */
|
||||
/*********************************************************************/
|
||||
if (!zutp)
|
||||
zutp = new(g)UNZIPUTL(target, mul);
|
||||
zutp = new(g)UNZIPUTL(tdfp);
|
||||
|
||||
// We used the file name relative to recorded datapath
|
||||
PlugSetPath(filename, To_File, Tdbp->GetPath());
|
||||
@@ -969,6 +1028,25 @@ bool ZIPFAM::OpenTableFile(PGLOBAL g)
|
||||
{
|
||||
char filename[_MAX_PATH];
|
||||
MODE mode = Tdbp->GetMode();
|
||||
int len = TXTFAM::GetFileLength(g);
|
||||
|
||||
// We used the file name relative to recorded datapath
|
||||
PlugSetPath(filename, To_File, Tdbp->GetPath());
|
||||
|
||||
if (len < 0)
|
||||
return true;
|
||||
else if (!append && len > 0) {
|
||||
strcpy(g->Message, "No insert into existing zip file");
|
||||
return true;
|
||||
} else if (append && len > 0) {
|
||||
UNZIPUTL *zutp = new(g) UNZIPUTL(target, false);
|
||||
|
||||
if (!zutp->IsInsertOk(g, filename)) {
|
||||
strcpy(g->Message, "No insert into existing entry");
|
||||
return true;
|
||||
} // endif Ok
|
||||
|
||||
} // endif's
|
||||
|
||||
/*********************************************************************/
|
||||
/* Allocate the ZIP utility class. */
|
||||
@@ -1028,15 +1106,31 @@ ZPXFAM::ZPXFAM(PDOSDEF tdp) : FIXFAM(tdp)
|
||||
target = tdp->GetEntry();
|
||||
append = tdp->GetAppend();
|
||||
//Lrecl = tdp->GetLrecl();
|
||||
} // end of UZXFAM standard constructor
|
||||
} // end of ZPXFAM standard constructor
|
||||
|
||||
/***********************************************************************/
|
||||
/* OpenTableFile: Open a DOS/UNIX table file from a ZIP file. */
|
||||
/***********************************************************************/
|
||||
bool ZPXFAM::OpenTableFile(PGLOBAL g)
|
||||
{
|
||||
char filename[_MAX_PATH];
|
||||
MODE mode = Tdbp->GetMode();
|
||||
char filename[_MAX_PATH];
|
||||
MODE mode = Tdbp->GetMode();
|
||||
int len = TXTFAM::GetFileLength(g);
|
||||
|
||||
if (len < 0)
|
||||
return true;
|
||||
else if (!append && len > 0) {
|
||||
strcpy(g->Message, "No insert into existing zip file");
|
||||
return true;
|
||||
} else if (append && len > 0) {
|
||||
UNZIPUTL *zutp = new(g) UNZIPUTL(target, false);
|
||||
|
||||
if (!zutp->IsInsertOk(g, filename)) {
|
||||
strcpy(g->Message, "No insert into existing entry");
|
||||
return true;
|
||||
} // endif Ok
|
||||
|
||||
} // endif's
|
||||
|
||||
/*********************************************************************/
|
||||
/* Allocate the ZIP utility class. */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/************** filamzip H Declares Source Code File (.H) **************/
|
||||
/* Name: filamzip.h Version 1.1 */
|
||||
/* Name: filamzip.h Version 1.2 */
|
||||
/* */
|
||||
/* (C) Copyright to the author Olivier BERTRAND 2016-2017 */
|
||||
/* */
|
||||
@@ -27,16 +27,13 @@ typedef class ZPXFAM *PZPXFAM;
|
||||
class DllExport ZIPUTIL : public BLOCK {
|
||||
public:
|
||||
// Constructor
|
||||
ZIPUTIL(PSZ tgt);
|
||||
ZIPUTIL(PCSZ tgt);
|
||||
//ZIPUTIL(ZIPUTIL *zutp);
|
||||
|
||||
// Implementation
|
||||
//PTXF Duplicate(PGLOBAL g) { return (PTXF) new(g)UNZFAM(this); }
|
||||
|
||||
// Methods
|
||||
bool OpenTable(PGLOBAL g, MODE mode, char *fn, bool append);
|
||||
bool open(PGLOBAL g, char *fn, bool append);
|
||||
bool addEntry(PGLOBAL g, char *entry);
|
||||
bool OpenTable(PGLOBAL g, MODE mode, PCSZ fn, bool append);
|
||||
bool open(PGLOBAL g, PCSZ fn, bool append);
|
||||
bool addEntry(PGLOBAL g, PCSZ entry);
|
||||
void close(void);
|
||||
void closeEntry(void);
|
||||
int writeEntry(PGLOBAL g, char *buf, int len);
|
||||
@@ -44,15 +41,10 @@ class DllExport ZIPUTIL : public BLOCK {
|
||||
|
||||
// Members
|
||||
zipFile zipfile; // The ZIP container file
|
||||
PSZ target; // The target file name
|
||||
//unz_file_info finfo; // The current file info
|
||||
PCSZ target; // The target file name
|
||||
PCSZ pwd; // The ZIP file password
|
||||
PFBLOCK fp;
|
||||
//char *memory;
|
||||
//uint size;
|
||||
//int multiple; // Multiple targets
|
||||
bool entryopen; // True when open current entry
|
||||
//char fn[FILENAME_MAX]; // The current entry file name
|
||||
//char mapCaseTable[256];
|
||||
}; // end of ZIPUTIL
|
||||
|
||||
/***********************************************************************/
|
||||
@@ -61,25 +53,27 @@ class DllExport ZIPUTIL : public BLOCK {
|
||||
class DllExport UNZIPUTL : public BLOCK {
|
||||
public:
|
||||
// Constructor
|
||||
UNZIPUTL(PSZ tgt, bool mul);
|
||||
//UNZIPUTL(UNZIPUTL *zutp);
|
||||
UNZIPUTL(PCSZ tgt, bool mul);
|
||||
UNZIPUTL(PDOSDEF tdp);
|
||||
|
||||
// Implementation
|
||||
//PTXF Duplicate(PGLOBAL g) { return (PTXF) new(g)UNZFAM(this); }
|
||||
|
||||
// Methods
|
||||
bool OpenTable(PGLOBAL g, MODE mode, char *fn);
|
||||
bool open(PGLOBAL g, char *fn);
|
||||
bool OpenTable(PGLOBAL g, MODE mode, PCSZ fn);
|
||||
bool open(PGLOBAL g, PCSZ fn);
|
||||
bool openEntry(PGLOBAL g);
|
||||
void close(void);
|
||||
void closeEntry(void);
|
||||
bool WildMatch(PSZ pat, PSZ str);
|
||||
bool WildMatch(PCSZ pat, PCSZ str);
|
||||
int findEntry(PGLOBAL g, bool next);
|
||||
int nextEntry(PGLOBAL g);
|
||||
bool IsInsertOk(PGLOBAL g, PCSZ fn);
|
||||
|
||||
// Members
|
||||
unzFile zipfile; // The ZIP container file
|
||||
PSZ target; // The target file name
|
||||
PCSZ target; // The target file name
|
||||
PCSZ pwd; // The ZIP file password
|
||||
unz_file_info finfo; // The current file info
|
||||
PFBLOCK fp;
|
||||
char *memory;
|
||||
@@ -119,8 +113,7 @@ class DllExport UNZFAM : public MAPFAM {
|
||||
protected:
|
||||
// Members
|
||||
UNZIPUTL *zutp;
|
||||
PSZ target;
|
||||
bool mul;
|
||||
PDOSDEF tdfp;
|
||||
}; // end of UNZFAM
|
||||
|
||||
/***********************************************************************/
|
||||
@@ -147,8 +140,7 @@ class DllExport UZXFAM : public MPXFAM {
|
||||
protected:
|
||||
// Members
|
||||
UNZIPUTL *zutp;
|
||||
PSZ target;
|
||||
bool mul;
|
||||
PDOSDEF tdfp;
|
||||
}; // end of UZXFAM
|
||||
|
||||
/***********************************************************************/
|
||||
@@ -175,8 +167,9 @@ class DllExport ZIPFAM : public DOSFAM {
|
||||
protected:
|
||||
// Members
|
||||
ZIPUTIL *zutp;
|
||||
PSZ target;
|
||||
PCSZ target;
|
||||
bool append;
|
||||
//bool replace;
|
||||
}; // end of ZIPFAM
|
||||
|
||||
/***********************************************************************/
|
||||
@@ -200,7 +193,7 @@ class DllExport ZPXFAM : public FIXFAM {
|
||||
protected:
|
||||
// Members
|
||||
ZIPUTIL *zutp;
|
||||
PSZ target;
|
||||
PCSZ target;
|
||||
bool append;
|
||||
}; // end of ZPXFAM
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/***************** Filter C++ Class Filter Code (.CPP) *****************/
|
||||
/* Name: FILTER.CPP Version 3.9 */
|
||||
/* Name: FILTER.CPP Version 4.0 */
|
||||
/* */
|
||||
/* (C) Copyright to the author Olivier BERTRAND 1998-2014 */
|
||||
/* (C) Copyright to the author Olivier BERTRAND 1998-2017 */
|
||||
/* */
|
||||
/* This file contains the class FILTER function code. */
|
||||
/***********************************************************************/
|
||||
@@ -87,8 +87,8 @@ BYTE OpBmp(PGLOBAL g, OPVAL opc)
|
||||
case OP_EXIST: bt = 0x00; break;
|
||||
default:
|
||||
sprintf(g->Message, MSG(BAD_FILTER_OP), opc);
|
||||
longjmp(g->jumper[g->jump_level], TYPE_ARRAY);
|
||||
} // endswitch opc
|
||||
throw TYPE_ARRAY;
|
||||
} // endswitch opc
|
||||
|
||||
return bt;
|
||||
} // end of OpBmp
|
||||
@@ -1712,7 +1712,7 @@ PFIL PrepareFilter(PGLOBAL g, PFIL fp, bool having)
|
||||
break; // Remove eventual ending separator(s)
|
||||
|
||||
// if (fp->Convert(g, having))
|
||||
// longjmp(g->jumper[g->jump_level], TYPE_FILTER);
|
||||
// throw TYPE_ARRAY;
|
||||
|
||||
filp = fp;
|
||||
fp = fp->Next;
|
||||
@@ -1745,7 +1745,7 @@ DllExport bool ApplyFilter(PGLOBAL g, PFIL filp)
|
||||
// return TRUE;
|
||||
|
||||
if (filp->Eval(g))
|
||||
longjmp(g->jumper[g->jump_level], TYPE_FILTER);
|
||||
throw TYPE_FILTER;
|
||||
|
||||
if (trace > 1)
|
||||
htrc("PlugFilter filp=%p result=%d\n",
|
||||
|
||||
@@ -61,7 +61,7 @@ class DllExport FILTER : public XOBJECT { /* Filter description block */
|
||||
//virtual PXOB CheckSubQuery(PGLOBAL, PSQL);
|
||||
//virtual bool CheckLocal(PTDB);
|
||||
//virtual int CheckSpcCol(PTDB tdbp, int n);
|
||||
virtual void Print(PGLOBAL g, FILE *f, uint n);
|
||||
virtual void Print(PGLOBAL g, FILE *f, uint n);
|
||||
virtual void Print(PGLOBAL g, char *ps, uint z);
|
||||
// PFIL Linearize(bool nosep);
|
||||
// PFIL Link(PGLOBAL g, PFIL fil2);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/***********************************************************************/
|
||||
/* GLOBAL.H: Declaration file used by all CONNECT implementations. */
|
||||
/* (C) Copyright Olivier Bertrand 1993-2014 */
|
||||
/* (C) Copyright Olivier Bertrand 1993-2017 */
|
||||
/***********************************************************************/
|
||||
|
||||
/***********************************************************************/
|
||||
@@ -59,7 +59,7 @@
|
||||
#define NO_IVAL -95684275 /* Used by GetIntegerOption */
|
||||
#define VMLANG 370 /* Size of olf VM lang blocks */
|
||||
#define MAX_JUMP 24 /* Maximum jump level number */
|
||||
#define MAX_STR 1024 /* Maximum string length */
|
||||
#define MAX_STR 4160 /* Maximum message length */
|
||||
#define STR_SIZE 501 /* Length of char strings. */
|
||||
#define STD_INPUT 0 /* Standard language input */
|
||||
#define STD_OUTPUT 1 /* Standard language output */
|
||||
@@ -229,9 +229,10 @@ typedef struct _parm {
|
||||
typedef struct _global { /* Global structure */
|
||||
void *Sarea; /* Points to work area */
|
||||
uint Sarea_Size; /* Work area size */
|
||||
PACTIVITY Activityp, ActivityStart;
|
||||
PACTIVITY Activityp;
|
||||
char Message[MAX_STR];
|
||||
int Createas; /* To pass info to created table */
|
||||
ulong More; /* Used by jsonudf */
|
||||
int Createas; /* To pass info to created table */
|
||||
void *Xchk; /* indexes in create/alter */
|
||||
short Alchecked; /* Checked for ALTER */
|
||||
short Mrr; /* True when doing mrr */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -61,7 +61,7 @@ public:
|
||||
oldopn= newopn= NULL;
|
||||
oldpix= newpix= NULL;}
|
||||
|
||||
inline char *SetName(PGLOBAL g, char *name) {return PlugDup(g, name);}
|
||||
inline char *SetName(PGLOBAL g, PCSZ name) {return PlugDup(g, name);}
|
||||
|
||||
bool oldsep; // Sepindex before create/alter
|
||||
bool newsep; // Sepindex after create/alter
|
||||
@@ -168,18 +168,18 @@ public:
|
||||
static bool connect_init(void);
|
||||
static bool connect_end(void);
|
||||
TABTYPE GetRealType(PTOS pos= NULL);
|
||||
char *GetRealString(const char *s);
|
||||
char *GetStringOption(char *opname, char *sdef= NULL);
|
||||
char *GetRealString(PCSZ s);
|
||||
PCSZ GetStringOption(PCSZ opname, PCSZ sdef= NULL);
|
||||
PTOS GetTableOptionStruct(TABLE_SHARE *s= NULL);
|
||||
bool GetBooleanOption(char *opname, bool bdef);
|
||||
bool SetBooleanOption(char *opname, bool b);
|
||||
int GetIntegerOption(char *opname);
|
||||
bool GetIndexOption(KEY *kp, char *opname);
|
||||
bool CheckString(const char *str1, const char *str2);
|
||||
bool SameString(TABLE *tab, char *opn);
|
||||
bool SetIntegerOption(char *opname, int n);
|
||||
bool SameInt(TABLE *tab, char *opn);
|
||||
bool SameBool(TABLE *tab, char *opn);
|
||||
bool GetBooleanOption(PCSZ opname, bool bdef);
|
||||
bool SetBooleanOption(PCSZ opname, bool b);
|
||||
int GetIntegerOption(PCSZ opname);
|
||||
bool GetIndexOption(KEY *kp, PCSZ opname);
|
||||
bool CheckString(PCSZ str1, PCSZ str2);
|
||||
bool SameString(TABLE *tab, PCSZ opn);
|
||||
bool SetIntegerOption(PCSZ opname, int n);
|
||||
bool SameInt(TABLE *tab, PCSZ opn);
|
||||
bool SameBool(TABLE *tab, PCSZ opn);
|
||||
bool FileExists(const char *fn, bool bf);
|
||||
bool NoFieldOptionChange(TABLE *tab);
|
||||
PFOS GetFieldOptionStruct(Field *fp);
|
||||
@@ -187,8 +187,8 @@ public:
|
||||
PXOS GetIndexOptionStruct(KEY *kp);
|
||||
PIXDEF GetIndexInfo(TABLE_SHARE *s= NULL);
|
||||
bool CheckVirtualIndex(TABLE_SHARE *s);
|
||||
const char *GetDBName(const char *name);
|
||||
const char *GetTableName(void);
|
||||
PCSZ GetDBName(PCSZ name);
|
||||
PCSZ GetTableName(void);
|
||||
char *GetPartName(void);
|
||||
//int GetColNameLen(Field *fp);
|
||||
//char *GetColName(Field *fp);
|
||||
@@ -197,9 +197,9 @@ public:
|
||||
bool IsSameIndex(PIXDEF xp1, PIXDEF xp2);
|
||||
bool IsPartitioned(void);
|
||||
bool IsUnique(uint n);
|
||||
char *GetDataPath(void) {return (char*)datapath;}
|
||||
PCSZ GetDataPath(void) {return datapath;}
|
||||
|
||||
void SetDataPath(PGLOBAL g, const char *path);
|
||||
bool SetDataPath(PGLOBAL g, PCSZ path);
|
||||
PTDB GetTDB(PGLOBAL g);
|
||||
int OpenTable(PGLOBAL g, bool del= false);
|
||||
bool CheckColumnList(PGLOBAL g);
|
||||
@@ -513,7 +513,7 @@ protected:
|
||||
ulong hnum; // The number of this handler
|
||||
query_id_t valid_query_id; // The one when tdbp was allocated
|
||||
query_id_t creat_query_id; // The one when handler was allocated
|
||||
char *datapath; // Is the Path of DB data directory
|
||||
PCSZ datapath; // Is the Path of DB data directory
|
||||
PTDB tdbp; // To table class object
|
||||
PVAL sdvalin1; // Used to convert date values
|
||||
PVAL sdvalin2; // Used to convert date values
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
|
||||
typedef struct jdbc_parms {
|
||||
int CheckSize(int rows);
|
||||
char *Driver; // JDBC driver
|
||||
char *Url; // Driver URL
|
||||
char *User; // User connect info
|
||||
char *Pwd; // Password connect info
|
||||
PCSZ Driver; // JDBC driver
|
||||
PCSZ Url; // Driver URL
|
||||
PCSZ User; // User connect info
|
||||
PCSZ Pwd; // Password connect info
|
||||
//char *Properties; // Connection property list
|
||||
//int Cto; // Connect timeout
|
||||
//int Qto; // Query timeout
|
||||
@@ -19,12 +19,12 @@ typedef struct jdbc_parms {
|
||||
/* JDBC catalog function prototypes. */
|
||||
/***********************************************************************/
|
||||
#if defined(PROMPT_OK)
|
||||
char *JDBCCheckConnection(PGLOBAL g, char *dsn, int cop);
|
||||
char *JDBCCheckConnection(PGLOBAL g, PCSZ dsn, int cop);
|
||||
#endif // PROMPT_OK
|
||||
//PQRYRES JDBCDataSources(PGLOBAL g, int maxres, bool info);
|
||||
PQRYRES JDBCColumns(PGLOBAL g, char *db, char *table,
|
||||
char *colpat, int maxres, bool info, PJPARM sop);
|
||||
PQRYRES JDBCSrcCols(PGLOBAL g, char *src, PJPARM sop);
|
||||
PQRYRES JDBCTables(PGLOBAL g, char *db, char *tabpat,
|
||||
char *tabtyp, int maxres, bool info, PJPARM sop);
|
||||
PQRYRES JDBCColumns(PGLOBAL g, PCSZ db, PCSZ table,
|
||||
PCSZ colpat, int maxres, bool info, PJPARM sop);
|
||||
PQRYRES JDBCSrcCols(PGLOBAL g, PCSZ src, PJPARM sop);
|
||||
PQRYRES JDBCTables(PGLOBAL g, PCSZ db, PCSZ tabpat,
|
||||
PCSZ tabtyp, int maxres, bool info, PJPARM sop);
|
||||
PQRYRES JDBCDrivers(PGLOBAL g, int maxres, bool info);
|
||||
|
||||
@@ -189,8 +189,8 @@ int TranslateJDBCType(int stp, char *tn, int prec, int& len, char& v)
|
||||
/***********************************************************************/
|
||||
/* Allocate the structure used to refer to the result set. */
|
||||
/***********************************************************************/
|
||||
static JCATPARM *AllocCatInfo(PGLOBAL g, JCATINFO fid, char *db,
|
||||
char *tab, PQRYRES qrp)
|
||||
static JCATPARM *AllocCatInfo(PGLOBAL g, JCATINFO fid, PCSZ db,
|
||||
PCSZ tab, PQRYRES qrp)
|
||||
{
|
||||
JCATPARM *cap;
|
||||
|
||||
@@ -213,7 +213,7 @@ static JCATPARM *AllocCatInfo(PGLOBAL g, JCATINFO fid, char *db,
|
||||
/* JDBCColumns: constructs the result blocks containing all columns */
|
||||
/* of a JDBC table that will be retrieved by GetData commands. */
|
||||
/***********************************************************************/
|
||||
PQRYRES JDBCColumns(PGLOBAL g, char *db, char *table, char *colpat,
|
||||
PQRYRES JDBCColumns(PGLOBAL g, PCSZ db, PCSZ table, PCSZ colpat,
|
||||
int maxres, bool info, PJPARM sjp)
|
||||
{
|
||||
int buftyp[] = {TYPE_STRING, TYPE_STRING, TYPE_STRING, TYPE_STRING,
|
||||
@@ -316,7 +316,7 @@ PQRYRES JDBCColumns(PGLOBAL g, char *db, char *table, char *colpat,
|
||||
/* JDBCSrcCols: constructs the result blocks containing the */
|
||||
/* description of all the columns of a Srcdef option. */
|
||||
/**************************************************************************/
|
||||
PQRYRES JDBCSrcCols(PGLOBAL g, char *src, PJPARM sjp)
|
||||
PQRYRES JDBCSrcCols(PGLOBAL g, PCSZ src, PJPARM sjp)
|
||||
{
|
||||
char *sqry;
|
||||
PQRYRES qrp;
|
||||
@@ -330,7 +330,7 @@ PQRYRES JDBCSrcCols(PGLOBAL g, char *src, PJPARM sjp)
|
||||
sqry = (char*)PlugSubAlloc(g, NULL, strlen(src) + 2);
|
||||
sprintf(sqry, src, "1=1"); // dummy where clause
|
||||
} else
|
||||
sqry = src;
|
||||
sqry = (char*)src;
|
||||
|
||||
qrp = jcp->GetMetaData(g, sqry);
|
||||
jcp->Close();
|
||||
@@ -341,7 +341,7 @@ PQRYRES JDBCSrcCols(PGLOBAL g, char *src, PJPARM sjp)
|
||||
/* JDBCTables: constructs the result blocks containing all tables in */
|
||||
/* an JDBC database that will be retrieved by GetData commands. */
|
||||
/**************************************************************************/
|
||||
PQRYRES JDBCTables(PGLOBAL g, char *db, char *tabpat, char *tabtyp,
|
||||
PQRYRES JDBCTables(PGLOBAL g, PCSZ db, PCSZ tabpat, PCSZ tabtyp,
|
||||
int maxres, bool info, PJPARM sjp)
|
||||
{
|
||||
int buftyp[] = {TYPE_STRING, TYPE_STRING, TYPE_STRING,
|
||||
@@ -1059,7 +1059,7 @@ int JDBConn::Open(PJPARM sop)
|
||||
/***********************************************************************/
|
||||
/* Execute an SQL command. */
|
||||
/***********************************************************************/
|
||||
int JDBConn::ExecSQLcommand(char *sql)
|
||||
int JDBConn::ExecSQLcommand(PCSZ sql)
|
||||
{
|
||||
int rc;
|
||||
jint n;
|
||||
@@ -1142,7 +1142,7 @@ int JDBConn::Fetch(int pos)
|
||||
/***********************************************************************/
|
||||
/* Restart from beginning of result set */
|
||||
/***********************************************************************/
|
||||
int JDBConn::Rewind(char *sql)
|
||||
int JDBConn::Rewind(PCSZ sql)
|
||||
{
|
||||
int rbuf = -1;
|
||||
|
||||
@@ -1200,7 +1200,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
|
||||
if (rank == 0)
|
||||
if (!name || (jn = env->NewStringUTF(name)) == nullptr) {
|
||||
sprintf(g->Message, "Fail to allocate jstring %s", SVP(name));
|
||||
longjmp(g->jumper[g->jump_level], TYPE_AM_JDBC);
|
||||
throw TYPE_AM_JDBC;
|
||||
} // endif name
|
||||
|
||||
// Returns 666 is case of error
|
||||
@@ -1208,7 +1208,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
|
||||
|
||||
if (Check((ctyp == 666) ? -1 : 1)) {
|
||||
sprintf(g->Message, "Getting ctyp: %s", Msg);
|
||||
longjmp(g->jumper[g->jump_level], TYPE_AM_JDBC);
|
||||
throw TYPE_AM_JDBC;
|
||||
} // endif Check
|
||||
|
||||
if (val->GetNullable())
|
||||
@@ -1227,7 +1227,8 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
|
||||
case 12: // VARCHAR
|
||||
case -1: // LONGVARCHAR
|
||||
case 1: // CHAR
|
||||
if (jb)
|
||||
case 3: // DECIMAL
|
||||
if (jb && ctyp != 3)
|
||||
cn = (jstring)jb;
|
||||
else if (!gmID(g, chrfldid, "StringField", "(ILjava/lang/String;)Ljava/lang/String;"))
|
||||
cn = (jstring)env->CallObjectMethod(job, chrfldid, (jint)rank, jn);
|
||||
@@ -1253,7 +1254,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
|
||||
break;
|
||||
case 8: // DOUBLE
|
||||
case 2: // NUMERIC
|
||||
case 3: // DECIMAL
|
||||
//case 3: // DECIMAL
|
||||
if (!gmID(g, dblfldid, "DoubleField", "(ILjava/lang/String;)D"))
|
||||
val->SetValue((double)env->CallDoubleMethod(job, dblfldid, rank, jn));
|
||||
else
|
||||
@@ -1314,7 +1315,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
|
||||
env->DeleteLocalRef(jn);
|
||||
|
||||
sprintf(g->Message, "SetColumnValue: %s rank=%d ctyp=%d", Msg, rank, (int)ctyp);
|
||||
longjmp(g->jumper[g->jump_level], TYPE_AM_JDBC);
|
||||
throw TYPE_AM_JDBC;
|
||||
} // endif Check
|
||||
|
||||
if (rank == 0)
|
||||
@@ -1325,7 +1326,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
|
||||
/***********************************************************************/
|
||||
/* Prepare an SQL statement for insert. */
|
||||
/***********************************************************************/
|
||||
bool JDBConn::PrepareSQL(char *sql)
|
||||
bool JDBConn::PrepareSQL(PCSZ sql)
|
||||
{
|
||||
bool b = true;
|
||||
PGLOBAL& g = m_G;
|
||||
@@ -1348,7 +1349,7 @@ bool JDBConn::PrepareSQL(char *sql)
|
||||
/***********************************************************************/
|
||||
/* Execute an SQL query that returns a result set. */
|
||||
/***********************************************************************/
|
||||
int JDBConn::ExecuteQuery(char *sql)
|
||||
int JDBConn::ExecuteQuery(PCSZ sql)
|
||||
{
|
||||
int rc = RC_FX;
|
||||
jint ncol;
|
||||
@@ -1376,7 +1377,7 @@ int JDBConn::ExecuteQuery(char *sql)
|
||||
/***********************************************************************/
|
||||
/* Execute an SQL query and get the affected rows. */
|
||||
/***********************************************************************/
|
||||
int JDBConn::ExecuteUpdate(char *sql)
|
||||
int JDBConn::ExecuteUpdate(PCSZ sql)
|
||||
{
|
||||
int rc = RC_FX;
|
||||
jint n;
|
||||
@@ -1404,7 +1405,7 @@ int JDBConn::ExecuteUpdate(char *sql)
|
||||
/***********************************************************************/
|
||||
/* Get the number of lines of the result set. */
|
||||
/***********************************************************************/
|
||||
int JDBConn::GetResultSize(char *sql, JDBCCOL *colp)
|
||||
int JDBConn::GetResultSize(PCSZ sql, JDBCCOL *colp)
|
||||
{
|
||||
int rc, n = 0;
|
||||
|
||||
@@ -1642,7 +1643,7 @@ bool JDBConn::SetParam(JDBCCOL *colp)
|
||||
/* GetMetaData: constructs the result blocks containing the */
|
||||
/* description of all the columns of an SQL command. */
|
||||
/**************************************************************************/
|
||||
PQRYRES JDBConn::GetMetaData(PGLOBAL g, char *src)
|
||||
PQRYRES JDBConn::GetMetaData(PGLOBAL g, PCSZ src)
|
||||
{
|
||||
static int buftyp[] = {TYPE_STRING, TYPE_INT, TYPE_INT,
|
||||
TYPE_INT, TYPE_INT};
|
||||
@@ -1844,7 +1845,7 @@ bool JDBConn::SetParam(JDBCCOL *colp)
|
||||
PGLOBAL& g = m_G;
|
||||
// void *buffer;
|
||||
int i, ncol;
|
||||
PSZ fnc = "Unknown";
|
||||
PCSZ fnc = "Unknown";
|
||||
uint n;
|
||||
short len, tp;
|
||||
int crow = 0;
|
||||
|
||||
@@ -46,9 +46,9 @@ enum JCATINFO {
|
||||
typedef struct tagJCATPARM {
|
||||
JCATINFO Id; // Id to indicate function
|
||||
PQRYRES Qrp; // Result set pointer
|
||||
char *DB; // Database (Schema)
|
||||
char *Tab; // Table name or pattern
|
||||
char *Pat; // Table type or column pattern
|
||||
PCSZ DB; // Database (Schema)
|
||||
PCSZ Tab; // Table name or pattern
|
||||
PCSZ Pat; // Table type or column pattern
|
||||
} JCATPARM;
|
||||
|
||||
typedef jint(JNICALL *CRTJVM) (JavaVM **, void **, void *);
|
||||
@@ -77,7 +77,7 @@ public:
|
||||
JDBConn(PGLOBAL g, TDBJDBC *tdbp);
|
||||
|
||||
int Open(PJPARM sop);
|
||||
int Rewind(char *sql);
|
||||
int Rewind(PCSZ sql);
|
||||
void Close(void);
|
||||
PQRYRES AllocateResult(PGLOBAL g);
|
||||
|
||||
@@ -96,19 +96,19 @@ public:
|
||||
//void SetQueryTimeout(DWORD sec) {m_QueryTimeout = sec;}
|
||||
//void SetUserName(PSZ user) {m_User = user;}
|
||||
//void SetUserPwd(PSZ pwd) {m_Pwd = pwd;}
|
||||
int GetResultSize(char *sql, JDBCCOL *colp);
|
||||
int ExecuteQuery(char *sql);
|
||||
int ExecuteUpdate(char *sql);
|
||||
int GetResultSize(PCSZ sql, JDBCCOL *colp);
|
||||
int ExecuteQuery(PCSZ sql);
|
||||
int ExecuteUpdate(PCSZ sql);
|
||||
int Fetch(int pos = 0);
|
||||
bool PrepareSQL(char *sql);
|
||||
bool PrepareSQL(PCSZ sql);
|
||||
int ExecuteSQL(void);
|
||||
bool SetParam(JDBCCOL *colp);
|
||||
int ExecSQLcommand(char *sql);
|
||||
int ExecSQLcommand(PCSZ sql);
|
||||
void SetColumnValue(int rank, PSZ name, PVAL val);
|
||||
int GetCatInfo(JCATPARM *cap);
|
||||
//bool GetDataSources(PQRYRES qrp);
|
||||
bool GetDrivers(PQRYRES qrp);
|
||||
PQRYRES GetMetaData(PGLOBAL g, char *src);
|
||||
PQRYRES GetMetaData(PGLOBAL g, PCSZ src);
|
||||
|
||||
public:
|
||||
// Set static variables
|
||||
@@ -174,16 +174,10 @@ protected:
|
||||
jmethodID timfldid; // The TimeField method ID
|
||||
jmethodID tspfldid; // The TimestampField method ID
|
||||
jmethodID bigfldid; // The BigintField method ID
|
||||
//DWORD m_LoginTimeout;
|
||||
//DWORD m_QueryTimeout;
|
||||
//DWORD m_UpdateOptions;
|
||||
char *Msg;
|
||||
PCSZ Msg;
|
||||
char *m_Wrap;
|
||||
char m_IDQuoteChar[2];
|
||||
//PSZ m_Driver;
|
||||
//PSZ m_Url;
|
||||
//PSZ m_User;
|
||||
PSZ m_Pwd;
|
||||
PCSZ m_Pwd;
|
||||
int m_Ncol;
|
||||
int m_Aff;
|
||||
int m_Rows;
|
||||
|
||||
@@ -60,7 +60,7 @@ char *GetExceptionDesc(PGLOBAL g, unsigned int e);
|
||||
/***********************************************************************/
|
||||
PJSON ParseJson(PGLOBAL g, char *s, int len, int *ptyp, bool *comma)
|
||||
{
|
||||
int i, rc, pretty = (ptyp) ? *ptyp : 3;
|
||||
int i, pretty = (ptyp) ? *ptyp : 3;
|
||||
bool b = false, pty[3] = {true, true, true};
|
||||
PJSON jsp = NULL;
|
||||
STRG src;
|
||||
@@ -81,117 +81,91 @@ PJSON ParseJson(PGLOBAL g, char *s, int len, int *ptyp, bool *comma)
|
||||
if (s[0] == '[' && (s[1] == '\n' || (s[1] == '\r' && s[2] == '\n')))
|
||||
pty[0] = false;
|
||||
|
||||
|
||||
// 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 defined(SE_CATCH)
|
||||
// Let's try to recover from any kind of interrupt
|
||||
_se_translator_function f = _set_se_translator(trans_func);
|
||||
|
||||
try {
|
||||
#endif // SE_CATCH --------------------- try section --------------------
|
||||
if ((rc = setjmp(g->jumper[++g->jump_level])) != 0) {
|
||||
goto err;
|
||||
} // endif rc
|
||||
for (i = 0; i < len; i++)
|
||||
switch (s[i]) {
|
||||
case '[':
|
||||
if (jsp)
|
||||
goto tryit;
|
||||
else if (!(jsp = ParseArray(g, ++i, src, pty)))
|
||||
throw 1;
|
||||
|
||||
#if defined(SE_CATCH) // ------------- end of try section -----------------
|
||||
} catch (SE_Exception e) {
|
||||
sprintf(g->Message, "ParseJson: exception doing setjmp: %s (rc=%hd)",
|
||||
GetExceptionDesc(g, e.nSE), e.nSE);
|
||||
_set_se_translator(f);
|
||||
goto err;
|
||||
} catch (...) {
|
||||
strcpy(g->Message, "Exception doing setjmp");
|
||||
_set_se_translator(f);
|
||||
goto err;
|
||||
} // end of try-catches
|
||||
break;
|
||||
case '{':
|
||||
if (jsp)
|
||||
goto tryit;
|
||||
else if (!(jsp = ParseObject(g, ++i, src, pty)))
|
||||
throw 2;
|
||||
|
||||
_set_se_translator(f);
|
||||
#endif // SE_CATCH
|
||||
break;
|
||||
case ' ':
|
||||
case '\t':
|
||||
case '\n':
|
||||
case '\r':
|
||||
break;
|
||||
case ',':
|
||||
if (jsp && (pretty == 1 || pretty == 3)) {
|
||||
if (comma)
|
||||
*comma = true;
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
switch (s[i]) {
|
||||
case '[':
|
||||
if (jsp)
|
||||
goto tryit;
|
||||
else if (!(jsp = ParseArray(g, ++i, src, pty)))
|
||||
goto err;
|
||||
pty[0] = pty[2] = false;
|
||||
break;
|
||||
} // endif pretty
|
||||
|
||||
break;
|
||||
case '{':
|
||||
if (jsp)
|
||||
goto tryit;
|
||||
else if (!(jsp = ParseObject(g, ++i, src, pty)))
|
||||
goto err;
|
||||
sprintf(g->Message, "Unexpected ',' (pretty=%d)", pretty);
|
||||
throw 3;
|
||||
case '(':
|
||||
b = true;
|
||||
break;
|
||||
case ')':
|
||||
if (b) {
|
||||
b = false;
|
||||
break;
|
||||
} // endif b
|
||||
|
||||
break;
|
||||
case ' ':
|
||||
case '\t':
|
||||
case '\n':
|
||||
case '\r':
|
||||
break;
|
||||
case ',':
|
||||
if (jsp && (pretty == 1 || pretty == 3)) {
|
||||
if (comma)
|
||||
*comma = true;
|
||||
default:
|
||||
if (jsp)
|
||||
goto tryit;
|
||||
else if (!(jsp = ParseValue(g, i, src, pty)))
|
||||
throw 4;
|
||||
|
||||
pty[0] = pty[2] = false;
|
||||
break;
|
||||
} // endif pretty
|
||||
break;
|
||||
}; // endswitch s[i]
|
||||
|
||||
sprintf(g->Message, "Unexpected ',' (pretty=%d)", pretty);
|
||||
goto err;
|
||||
case '(':
|
||||
b = true;
|
||||
break;
|
||||
case ')':
|
||||
if (b) {
|
||||
b = false;
|
||||
break;
|
||||
} // endif b
|
||||
if (!jsp)
|
||||
sprintf(g->Message, "Invalid Json string '%.*s'", 50, s);
|
||||
else if (ptyp && pretty == 3) {
|
||||
*ptyp = 3; // Not recognized pretty
|
||||
|
||||
default:
|
||||
if (jsp)
|
||||
goto tryit;
|
||||
else if (!(jsp = ParseValue(g, i, src, pty)))
|
||||
goto err;
|
||||
for (i = 0; i < 3; i++)
|
||||
if (pty[i]) {
|
||||
*ptyp = i;
|
||||
break;
|
||||
} // endif pty
|
||||
|
||||
break;
|
||||
}; // endswitch s[i]
|
||||
} // endif ptyp
|
||||
|
||||
if (!jsp)
|
||||
sprintf(g->Message, "Invalid Json string '%.*s'", 50, s);
|
||||
else if (ptyp && pretty == 3) {
|
||||
*ptyp = 3; // Not recognized pretty
|
||||
} catch (int n) {
|
||||
if (trace)
|
||||
htrc("Exception %d: %s\n", n, g->Message);
|
||||
jsp = NULL;
|
||||
} catch (const char *msg) {
|
||||
strcpy(g->Message, msg);
|
||||
jsp = NULL;
|
||||
} // end catch
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
if (pty[i]) {
|
||||
*ptyp = i;
|
||||
break;
|
||||
} // endif pty
|
||||
|
||||
} // endif ptyp
|
||||
|
||||
g->jump_level--;
|
||||
return jsp;
|
||||
return jsp;
|
||||
|
||||
tryit:
|
||||
if (pty[0] && (!pretty || pretty > 2)) {
|
||||
if ((jsp = ParseArray(g, (i = 0), src, pty)) && ptyp && pretty == 3)
|
||||
*ptyp = (pty[0]) ? 0 : 3;
|
||||
|
||||
g->jump_level--;
|
||||
return jsp;
|
||||
} else
|
||||
strcpy(g->Message, "More than one item in file");
|
||||
|
||||
err:
|
||||
g->jump_level--;
|
||||
return NULL;
|
||||
return NULL;
|
||||
} // end of ParseJson
|
||||
|
||||
/***********************************************************************/
|
||||
@@ -335,16 +309,16 @@ PJVAL ParseValue(PGLOBAL g, int& i, STRG& src, bool *pty)
|
||||
PJVAL jvp = new(g) JVALUE;
|
||||
|
||||
for (; i < len; i++)
|
||||
switch (s[i]) {
|
||||
case '\n':
|
||||
pty[0] = pty[1] = false;
|
||||
case '\r':
|
||||
case ' ':
|
||||
case '\t':
|
||||
break;
|
||||
default:
|
||||
goto suite;
|
||||
} // endswitch
|
||||
switch (s[i]) {
|
||||
case '\n':
|
||||
pty[0] = pty[1] = false;
|
||||
case '\r':
|
||||
case ' ':
|
||||
case '\t':
|
||||
break;
|
||||
default:
|
||||
goto suite;
|
||||
} // endswitch
|
||||
|
||||
suite:
|
||||
switch (s[i]) {
|
||||
@@ -585,78 +559,75 @@ PVAL ParseNumeric(PGLOBAL g, int& i, STRG& src)
|
||||
PSZ Serialize(PGLOBAL g, PJSON jsp, char *fn, int pretty)
|
||||
{
|
||||
PSZ str = NULL;
|
||||
bool b = false, err = true;
|
||||
JOUT *jp;
|
||||
bool b = false, err = true;
|
||||
JOUT *jp;
|
||||
FILE *fs = NULL;
|
||||
|
||||
g->Message[0] = 0;
|
||||
|
||||
// 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])) {
|
||||
str = NULL;
|
||||
goto fin;
|
||||
} // endif jmp
|
||||
|
||||
if (!jsp) {
|
||||
strcpy(g->Message, "Null json tree");
|
||||
goto fin;
|
||||
} else if (!fn) {
|
||||
// Serialize to a string
|
||||
jp = new(g) JOUTSTR(g);
|
||||
b = pretty == 1;
|
||||
} else {
|
||||
if (!(fs = fopen(fn, "wb"))) {
|
||||
sprintf(g->Message, MSG(OPEN_MODE_ERROR),
|
||||
"w", (int)errno, fn);
|
||||
strcat(strcat(g->Message, ": "), strerror(errno));
|
||||
goto fin;;
|
||||
} else if (pretty >= 2) {
|
||||
// Serialize to a pretty file
|
||||
jp = new(g)JOUTPRT(g, fs);
|
||||
try {
|
||||
if (!jsp) {
|
||||
strcpy(g->Message, "Null json tree");
|
||||
throw 1;
|
||||
} else if (!fn) {
|
||||
// Serialize to a string
|
||||
jp = new(g) JOUTSTR(g);
|
||||
b = pretty == 1;
|
||||
} else {
|
||||
// Serialize to a flat file
|
||||
b = true;
|
||||
jp = new(g)JOUTFILE(g, fs, pretty);
|
||||
if (!(fs = fopen(fn, "wb"))) {
|
||||
sprintf(g->Message, MSG(OPEN_MODE_ERROR),
|
||||
"w", (int)errno, fn);
|
||||
strcat(strcat(g->Message, ": "), strerror(errno));
|
||||
throw 2;
|
||||
} else if (pretty >= 2) {
|
||||
// Serialize to a pretty file
|
||||
jp = new(g)JOUTPRT(g, fs);
|
||||
} else {
|
||||
// Serialize to a flat file
|
||||
b = true;
|
||||
jp = new(g)JOUTFILE(g, fs, pretty);
|
||||
} // endif's
|
||||
|
||||
} // endif's
|
||||
|
||||
switch (jsp->GetType()) {
|
||||
case TYPE_JAR:
|
||||
err = SerializeArray(jp, (PJAR)jsp, b);
|
||||
break;
|
||||
case TYPE_JOB:
|
||||
err = ((b && jp->Prty()) && jp->WriteChr('\t'));
|
||||
err |= SerializeObject(jp, (PJOB)jsp);
|
||||
break;
|
||||
case TYPE_JVAL:
|
||||
err = SerializeValue(jp, (PJVAL)jsp);
|
||||
break;
|
||||
default:
|
||||
strcpy(g->Message, "Invalid json tree");
|
||||
} // endswitch Type
|
||||
|
||||
if (fs) {
|
||||
fputs(EL, fs);
|
||||
fclose(fs);
|
||||
str = (err) ? NULL : strcpy(g->Message, "Ok");
|
||||
} else if (!err) {
|
||||
str = ((JOUTSTR*)jp)->Strp;
|
||||
jp->WriteChr('\0');
|
||||
PlugSubAlloc(g, NULL, ((JOUTSTR*)jp)->N);
|
||||
} else {
|
||||
if (!g->Message[0])
|
||||
strcpy(g->Message, "Error in Serialize");
|
||||
|
||||
} // endif's
|
||||
|
||||
} // endif's
|
||||
} catch (int n) {
|
||||
if (trace)
|
||||
htrc("Exception %d: %s\n", n, g->Message);
|
||||
str = NULL;
|
||||
} catch (const char *msg) {
|
||||
strcpy(g->Message, msg);
|
||||
str = NULL;
|
||||
} // end catch
|
||||
|
||||
switch (jsp->GetType()) {
|
||||
case TYPE_JAR:
|
||||
err = SerializeArray(jp, (PJAR)jsp, b);
|
||||
break;
|
||||
case TYPE_JOB:
|
||||
err = ((b && jp->Prty()) && jp->WriteChr('\t'));
|
||||
err |= SerializeObject(jp, (PJOB)jsp);
|
||||
break;
|
||||
case TYPE_JVAL:
|
||||
err = SerializeValue(jp, (PJVAL)jsp);
|
||||
break;
|
||||
default:
|
||||
strcpy(g->Message, "Invalid json tree");
|
||||
} // endswitch Type
|
||||
|
||||
if (fs) {
|
||||
fputs(EL, fs);
|
||||
fclose(fs);
|
||||
str = (err) ? NULL : strcpy(g->Message, "Ok");
|
||||
} else if (!err) {
|
||||
str = ((JOUTSTR*)jp)->Strp;
|
||||
jp->WriteChr('\0');
|
||||
PlugSubAlloc(g, NULL, ((JOUTSTR*)jp)->N);
|
||||
} else {
|
||||
if (!g->Message[0])
|
||||
strcpy(g->Message, "Error in Serialize");
|
||||
|
||||
} // endif's
|
||||
|
||||
fin:
|
||||
g->jump_level--;
|
||||
return str;
|
||||
} // end of Serialize
|
||||
|
||||
@@ -965,7 +936,7 @@ return false;
|
||||
/***********************************************************************/
|
||||
/* Add a new pair to an Object. */
|
||||
/***********************************************************************/
|
||||
PJPR JOBJECT::AddPair(PGLOBAL g, PSZ key)
|
||||
PJPR JOBJECT::AddPair(PGLOBAL g, PCSZ key)
|
||||
{
|
||||
PJPR jpp = new(g) JPAIR(key);
|
||||
|
||||
@@ -1051,7 +1022,7 @@ bool JOBJECT::Merge(PGLOBAL g, PJSON jsp)
|
||||
/***********************************************************************/
|
||||
/* Set or add a value corresponding to the given key. */
|
||||
/***********************************************************************/
|
||||
void JOBJECT::SetValue(PGLOBAL g, PJVAL jvp, PSZ key)
|
||||
void JOBJECT::SetValue(PGLOBAL g, PJVAL jvp, PCSZ key)
|
||||
{
|
||||
PJPR jp;
|
||||
|
||||
@@ -1071,7 +1042,7 @@ void JOBJECT::SetValue(PGLOBAL g, PJVAL jvp, PSZ key)
|
||||
/***********************************************************************/
|
||||
/* Delete a value corresponding to the given key. */
|
||||
/***********************************************************************/
|
||||
void JOBJECT::DeleteKey(PSZ key)
|
||||
void JOBJECT::DeleteKey(PCSZ key)
|
||||
{
|
||||
PJPR jp, *pjp = &First;
|
||||
|
||||
@@ -1250,10 +1221,10 @@ JVALUE::JVALUE(PGLOBAL g, PVAL valp) : JSON()
|
||||
/***********************************************************************/
|
||||
/* Constructor for a given string. */
|
||||
/***********************************************************************/
|
||||
JVALUE::JVALUE(PGLOBAL g, PSZ strp) : JSON()
|
||||
JVALUE::JVALUE(PGLOBAL g, PCSZ strp) : JSON()
|
||||
{
|
||||
Jsp = NULL;
|
||||
Value = AllocateValue(g, strp, TYPE_STRING);
|
||||
Value = AllocateValue(g, (void*)strp, TYPE_STRING);
|
||||
Next = NULL;
|
||||
Del = false;
|
||||
} // end of JVALUE constructor
|
||||
@@ -1374,7 +1345,7 @@ void JVALUE::SetTiny(PGLOBAL g, char n)
|
||||
{
|
||||
Value = AllocateValue(g, &n, TYPE_TINY);
|
||||
Jsp = NULL;
|
||||
} // end of SetInteger
|
||||
} // end of SetTiny
|
||||
|
||||
/***********************************************************************/
|
||||
/* Set the Value's value as the given big integer. */
|
||||
@@ -1408,6 +1379,6 @@ void JVALUE::SetString(PGLOBAL g, PSZ s, short c)
|
||||
/***********************************************************************/
|
||||
bool JVALUE::IsNull(void)
|
||||
{
|
||||
return (Jsp) ? Jsp->IsNull() : (Value) ? Value->IsZero() : true;
|
||||
return (Jsp) ? Jsp->IsNull() : (Value) ? Value->IsNull() : true;
|
||||
} // end of IsNull
|
||||
|
||||
|
||||
@@ -125,14 +125,14 @@ class JPAIR : public BLOCK {
|
||||
friend PJOB ParseObject(PGLOBAL, int&, STRG&, bool*);
|
||||
friend bool SerializeObject(JOUT *, PJOB);
|
||||
public:
|
||||
JPAIR(PSZ key) : BLOCK() {Key = key; Val = NULL; Next = NULL;}
|
||||
JPAIR(PCSZ key) : BLOCK() {Key = key; Val = NULL; Next = NULL;}
|
||||
|
||||
inline PSZ GetKey(void) {return Key;}
|
||||
inline PCSZ GetKey(void) {return Key;}
|
||||
inline PJVAL GetVal(void) {return Val;}
|
||||
inline PJPR GetNext(void) {return Next;}
|
||||
|
||||
protected:
|
||||
PSZ Key; // This pair key name
|
||||
PCSZ Key; // This pair key name
|
||||
PJVAL Val; // To the value of the pair
|
||||
PJPR Next; // To the next pair
|
||||
}; // end of class JPAIR
|
||||
@@ -150,7 +150,7 @@ class JSON : public BLOCK {
|
||||
virtual JTYP GetValType(void) {X return TYPE_JSON;}
|
||||
virtual void InitArray(PGLOBAL g) {X}
|
||||
//virtual PJVAL AddValue(PGLOBAL g, PJVAL jvp = NULL, int *x = NULL) {X return NULL;}
|
||||
virtual PJPR AddPair(PGLOBAL g, PSZ key) {X return NULL;}
|
||||
virtual PJPR AddPair(PGLOBAL g, PCSZ key) {X return NULL;}
|
||||
virtual PJAR GetKeyList(PGLOBAL g) {X return NULL;}
|
||||
virtual PJVAL GetValue(const char *key) {X return NULL;}
|
||||
virtual PJOB GetObject(void) {return NULL;}
|
||||
@@ -166,13 +166,13 @@ class JSON : public BLOCK {
|
||||
virtual PSZ GetText(PGLOBAL g, PSZ text) {X return NULL;}
|
||||
virtual bool Merge(PGLOBAL g, PJSON jsp) { X return true; }
|
||||
virtual bool SetValue(PGLOBAL g, PJVAL jvp, int i) { X return true; }
|
||||
virtual void SetValue(PGLOBAL g, PJVAL jvp, PSZ key) {X}
|
||||
virtual void SetValue(PGLOBAL g, PJVAL jvp, PCSZ key) {X}
|
||||
virtual void SetValue(PVAL valp) {X}
|
||||
virtual void SetValue(PJSON jsp) {X}
|
||||
virtual void SetString(PGLOBAL g, PSZ s, short c) {X}
|
||||
virtual void SetInteger(PGLOBAL g, int n) {X}
|
||||
virtual void SetFloat(PGLOBAL g, double f) {X}
|
||||
virtual void DeleteKey(char *k) {X}
|
||||
virtual void DeleteKey(PCSZ k) {X}
|
||||
virtual bool DeleteValue(int i) {X return true;}
|
||||
virtual bool IsNull(void) {X return true;}
|
||||
|
||||
@@ -195,14 +195,14 @@ class JOBJECT : public JSON {
|
||||
virtual void Clear(void) {First = Last = NULL; Size = 0;}
|
||||
virtual JTYP GetType(void) {return TYPE_JOB;}
|
||||
virtual PJPR GetFirst(void) {return First;}
|
||||
virtual PJPR AddPair(PGLOBAL g, PSZ key);
|
||||
virtual PJPR AddPair(PGLOBAL g, PCSZ key);
|
||||
virtual PJOB GetObject(void) {return this;}
|
||||
virtual PJVAL GetValue(const char* key);
|
||||
virtual PJAR GetKeyList(PGLOBAL g);
|
||||
virtual PSZ GetText(PGLOBAL g, PSZ text);
|
||||
virtual bool Merge(PGLOBAL g, PJSON jsp);
|
||||
virtual void SetValue(PGLOBAL g, PJVAL jvp, PSZ key);
|
||||
virtual void DeleteKey(char *k);
|
||||
virtual void SetValue(PGLOBAL g, PJVAL jvp, PCSZ key);
|
||||
virtual void DeleteKey(PCSZ k);
|
||||
virtual bool IsNull(void);
|
||||
|
||||
protected:
|
||||
@@ -253,7 +253,7 @@ class JVALUE : public JSON {
|
||||
JVALUE(PJSON jsp) : JSON()
|
||||
{Jsp = jsp; Value = NULL; Next = NULL; Del = false;}
|
||||
JVALUE(PGLOBAL g, PVAL valp);
|
||||
JVALUE(PGLOBAL g, PSZ strp);
|
||||
JVALUE(PGLOBAL g, PCSZ strp);
|
||||
|
||||
using JSON::GetValue;
|
||||
using JSON::SetValue;
|
||||
|
||||
@@ -1104,7 +1104,7 @@ static my_bool JsonInit(UDF_INIT *initid, UDF_ARGS *args,
|
||||
} // endif g
|
||||
|
||||
g->Mrr = (args->arg_count && args->args[0]) ? 1 : 0;
|
||||
g->ActivityStart = (PACTIVITY)more;
|
||||
g->More = more;
|
||||
initid->maybe_null = mbn;
|
||||
initid->max_length = reslen;
|
||||
initid->ptr = (char*)g;
|
||||
@@ -1449,13 +1449,13 @@ static my_bool CheckMemory(PGLOBAL g, UDF_INIT *initid, UDF_ARGS *args, uint n,
|
||||
|
||||
} // endif b
|
||||
|
||||
ml += (unsigned long)g->ActivityStart; // more
|
||||
ml += g->More;
|
||||
|
||||
if (ml > g->Sarea_Size) {
|
||||
free(g->Sarea);
|
||||
|
||||
if (!(g->Sarea = PlugAllocMem(g, ml))) {
|
||||
char errmsg[256];
|
||||
char errmsg[MAX_STR];
|
||||
|
||||
sprintf(errmsg, MSG(WORK_AREA), g->Message);
|
||||
strcpy(g->Message, errmsg);
|
||||
@@ -1496,7 +1496,7 @@ static PSZ MakePSZ(PGLOBAL g, UDF_ARGS *args, int i)
|
||||
/*********************************************************************************/
|
||||
/* Make a valid key from the passed argument. */
|
||||
/*********************************************************************************/
|
||||
static PSZ MakeKey(PGLOBAL g, UDF_ARGS *args, int i)
|
||||
static PCSZ MakeKey(PGLOBAL g, UDF_ARGS *args, int i)
|
||||
{
|
||||
if (args->arg_count > (unsigned)i) {
|
||||
int j = 0, n = args->attribute_lengths[i];
|
||||
@@ -2253,7 +2253,8 @@ my_bool json_object_add_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
||||
char *json_object_add(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||
unsigned long *res_length, char *is_null, char *error)
|
||||
{
|
||||
char *key, *str = NULL;
|
||||
PCSZ key;
|
||||
char *str = NULL;
|
||||
PGLOBAL g = (PGLOBAL)initid->ptr;
|
||||
|
||||
if (g->Xchk) {
|
||||
@@ -2358,7 +2359,7 @@ char *json_object_delete(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||
} // endif Xchk
|
||||
|
||||
if (!CheckMemory(g, initid, args, 1, false, true, true)) {
|
||||
char *key;
|
||||
PCSZ key;
|
||||
PJOB jobp;
|
||||
PJSON jsp, top;
|
||||
PJVAL jvp = MakeValue(g, args, 0, &top);
|
||||
@@ -2914,7 +2915,6 @@ char *jsonget_string(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||
unsigned long *res_length, char *is_null, char *)
|
||||
{
|
||||
char *p, *path, *str = NULL;
|
||||
int rc;
|
||||
PJSON jsp;
|
||||
PJSNX jsx;
|
||||
PJVAL jvp;
|
||||
@@ -2922,68 +2922,64 @@ char *jsonget_string(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||
|
||||
if (g->N) {
|
||||
str = (char*)g->Activityp;
|
||||
goto fin;
|
||||
goto err;
|
||||
} else if (initid->const_item)
|
||||
g->N = 1;
|
||||
|
||||
// Save stack and allocation environment and prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
PUSH_WARNING(MSG(TOO_MANY_JUMPS));
|
||||
*is_null = 1;
|
||||
return NULL;
|
||||
} // endif jump_level
|
||||
try {
|
||||
if (!g->Xchk) {
|
||||
if (CheckMemory(g, initid, args, 1, true)) {
|
||||
PUSH_WARNING("CheckMemory error");
|
||||
goto err;
|
||||
} else
|
||||
jvp = MakeValue(g, args, 0);
|
||||
|
||||
if ((rc= setjmp(g->jumper[++g->jump_level])) != 0) {
|
||||
if ((p = jvp->GetString())) {
|
||||
if (!(jsp = ParseJson(g, p, strlen(p)))) {
|
||||
PUSH_WARNING(g->Message);
|
||||
goto err;
|
||||
} // endif jsp
|
||||
|
||||
} else
|
||||
jsp = jvp->GetJson();
|
||||
|
||||
if (g->Mrr) { // First argument is a constant
|
||||
g->Xchk = jsp;
|
||||
JsonMemSave(g);
|
||||
} // endif Mrr
|
||||
|
||||
} else
|
||||
jsp = (PJSON)g->Xchk;
|
||||
|
||||
path = MakePSZ(g, args, 1);
|
||||
jsx = new(g) JSNX(g, jsp, TYPE_STRING, initid->max_length);
|
||||
|
||||
if (jsx->SetJpath(g, path)) {
|
||||
PUSH_WARNING(g->Message);
|
||||
goto err;
|
||||
} // endif SetJpath
|
||||
|
||||
jsx->ReadValue(g);
|
||||
|
||||
if (!jsx->GetValue()->IsNull())
|
||||
str = jsx->GetValue()->GetCharValue();
|
||||
|
||||
if (initid->const_item)
|
||||
// Keep result of constant function
|
||||
g->Activityp = (PACTIVITY)str;
|
||||
|
||||
} catch (int n) {
|
||||
if (trace)
|
||||
htrc("Exception %d: %s\n", n, g->Message);
|
||||
PUSH_WARNING(g->Message);
|
||||
str = NULL;
|
||||
goto err;
|
||||
} // endif rc
|
||||
|
||||
if (!g->Xchk) {
|
||||
if (CheckMemory(g, initid, args, 1, true)) {
|
||||
PUSH_WARNING("CheckMemory error");
|
||||
goto err;
|
||||
} else
|
||||
jvp = MakeValue(g, args, 0);
|
||||
|
||||
if ((p = jvp->GetString())) {
|
||||
if (!(jsp = ParseJson(g, p, strlen(p)))) {
|
||||
PUSH_WARNING(g->Message);
|
||||
goto err;
|
||||
} // endif jsp
|
||||
|
||||
} else
|
||||
jsp = jvp->GetJson();
|
||||
|
||||
if (g->Mrr) { // First argument is a constant
|
||||
g->Xchk = jsp;
|
||||
JsonMemSave(g);
|
||||
} // endif Mrr
|
||||
|
||||
} else
|
||||
jsp = (PJSON)g->Xchk;
|
||||
|
||||
path = MakePSZ(g, args, 1);
|
||||
jsx = new(g) JSNX(g, jsp, TYPE_STRING, initid->max_length);
|
||||
|
||||
if (jsx->SetJpath(g, path)) {
|
||||
} catch (const char *msg) {
|
||||
strcpy(g->Message, msg);
|
||||
PUSH_WARNING(g->Message);
|
||||
goto err;
|
||||
} // endif SetJpath
|
||||
|
||||
jsx->ReadValue(g);
|
||||
|
||||
if (!jsx->GetValue()->IsNull())
|
||||
str = jsx->GetValue()->GetCharValue();
|
||||
|
||||
if (initid->const_item)
|
||||
// Keep result of constant function
|
||||
g->Activityp = (PACTIVITY)str;
|
||||
str = NULL;
|
||||
} // end catch
|
||||
|
||||
err:
|
||||
g->jump_level--;
|
||||
|
||||
fin:
|
||||
if (!str) {
|
||||
*is_null = 1;
|
||||
*res_length = 0;
|
||||
@@ -3254,7 +3250,7 @@ char *jsonlocate(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||
unsigned long *res_length, char *is_null, char *error)
|
||||
{
|
||||
char *p, *path = NULL;
|
||||
int k, rc;
|
||||
int k;
|
||||
PJVAL jvp, jvp2;
|
||||
PJSON jsp;
|
||||
PJSNX jsx;
|
||||
@@ -3274,61 +3270,58 @@ char *jsonlocate(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||
} else if (initid->const_item)
|
||||
g->N = 1;
|
||||
|
||||
// Save stack and allocation environment and prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
PUSH_WARNING(MSG(TOO_MANY_JUMPS));
|
||||
*error = 1;
|
||||
*is_null = 1;
|
||||
return NULL;
|
||||
} // endif jump_level
|
||||
try {
|
||||
if (!g->Xchk) {
|
||||
if (CheckMemory(g, initid, args, 1, !g->Xchk)) {
|
||||
PUSH_WARNING("CheckMemory error");
|
||||
*error = 1;
|
||||
goto err;
|
||||
} else
|
||||
jvp = MakeValue(g, args, 0);
|
||||
|
||||
if ((rc= setjmp(g->jumper[++g->jump_level])) != 0) {
|
||||
if ((p = jvp->GetString())) {
|
||||
if (!(jsp = ParseJson(g, p, strlen(p)))) {
|
||||
PUSH_WARNING(g->Message);
|
||||
goto err;
|
||||
} // endif jsp
|
||||
|
||||
} else
|
||||
jsp = jvp->GetJson();
|
||||
|
||||
if (g->Mrr) { // First argument is a constant
|
||||
g->Xchk = jsp;
|
||||
JsonMemSave(g);
|
||||
} // endif Mrr
|
||||
|
||||
} else
|
||||
jsp = (PJSON)g->Xchk;
|
||||
|
||||
// The item to locate
|
||||
jvp2 = MakeValue(g, args, 1);
|
||||
|
||||
k = (args->arg_count > 2) ? (int)*(long long*)args->args[2] : 1;
|
||||
|
||||
jsx = new(g) JSNX(g, jsp, TYPE_STRING);
|
||||
path = jsx->Locate(g, jsp, jvp2, k);
|
||||
|
||||
if (initid->const_item)
|
||||
// Keep result of constant function
|
||||
g->Activityp = (PACTIVITY)path;
|
||||
|
||||
} catch (int n) {
|
||||
if (trace)
|
||||
htrc("Exception %d: %s\n", n, g->Message);
|
||||
PUSH_WARNING(g->Message);
|
||||
*error = 1;
|
||||
path = NULL;
|
||||
goto err;
|
||||
} // endif rc
|
||||
|
||||
if (!g->Xchk) {
|
||||
if (CheckMemory(g, initid, args, 1, !g->Xchk)) {
|
||||
PUSH_WARNING("CheckMemory error");
|
||||
*error = 1;
|
||||
goto err;
|
||||
} else
|
||||
jvp = MakeValue(g, args, 0);
|
||||
|
||||
if ((p = jvp->GetString())) {
|
||||
if (!(jsp = ParseJson(g, p, strlen(p)))) {
|
||||
PUSH_WARNING(g->Message);
|
||||
goto err;
|
||||
} // endif jsp
|
||||
|
||||
} else
|
||||
jsp = jvp->GetJson();
|
||||
|
||||
if (g->Mrr) { // First argument is a constant
|
||||
g->Xchk = jsp;
|
||||
JsonMemSave(g);
|
||||
} // endif Mrr
|
||||
|
||||
} else
|
||||
jsp = (PJSON)g->Xchk;
|
||||
|
||||
// The item to locate
|
||||
jvp2 = MakeValue(g, args, 1);
|
||||
|
||||
k = (args->arg_count > 2) ? (int)*(long long*)args->args[2] : 1;
|
||||
|
||||
jsx = new(g) JSNX(g, jsp, TYPE_STRING);
|
||||
path = jsx->Locate(g, jsp, jvp2, k);
|
||||
|
||||
if (initid->const_item)
|
||||
// Keep result of constant function
|
||||
g->Activityp = (PACTIVITY)path;
|
||||
} catch (const char *msg) {
|
||||
strcpy(g->Message, msg);
|
||||
PUSH_WARNING(g->Message);
|
||||
*error = 1;
|
||||
path = NULL;
|
||||
} // end catch
|
||||
|
||||
err:
|
||||
g->jump_level--;
|
||||
|
||||
if (!path) {
|
||||
*res_length = 0;
|
||||
*is_null = 1;
|
||||
@@ -3379,7 +3372,7 @@ char *json_locate_all(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||
unsigned long *res_length, char *is_null, char *error)
|
||||
{
|
||||
char *p, *path = NULL;
|
||||
int rc, mx = 10;
|
||||
int mx = 10;
|
||||
PJVAL jvp, jvp2;
|
||||
PJSON jsp;
|
||||
PJSNX jsx;
|
||||
@@ -3400,62 +3393,59 @@ char *json_locate_all(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||
} else if (initid->const_item)
|
||||
g->N = 1;
|
||||
|
||||
// Save stack and allocation environment and prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
PUSH_WARNING(MSG(TOO_MANY_JUMPS));
|
||||
*error = 1;
|
||||
*is_null = 1;
|
||||
return NULL;
|
||||
} // endif jump_level
|
||||
try {
|
||||
if (!g->Xchk) {
|
||||
if (CheckMemory(g, initid, args, 1, true)) {
|
||||
PUSH_WARNING("CheckMemory error");
|
||||
*error = 1;
|
||||
goto err;
|
||||
} else
|
||||
jvp = MakeValue(g, args, 0);
|
||||
|
||||
if ((rc= setjmp(g->jumper[++g->jump_level])) != 0) {
|
||||
if ((p = jvp->GetString())) {
|
||||
if (!(jsp = ParseJson(g, p, strlen(p)))) {
|
||||
PUSH_WARNING(g->Message);
|
||||
goto err;
|
||||
} // endif jsp
|
||||
|
||||
} else
|
||||
jsp = jvp->GetJson();
|
||||
|
||||
if (g->Mrr) { // First argument is a constant
|
||||
g->Xchk = jsp;
|
||||
JsonMemSave(g);
|
||||
} // endif Mrr
|
||||
|
||||
} else
|
||||
jsp = (PJSON)g->Xchk;
|
||||
|
||||
// The item to locate
|
||||
jvp2 = MakeValue(g, args, 1);
|
||||
|
||||
if (args->arg_count > 2)
|
||||
mx = (int)*(long long*)args->args[2];
|
||||
|
||||
jsx = new(g) JSNX(g, jsp, TYPE_STRING);
|
||||
path = jsx->LocateAll(g, jsp, jvp2, mx);
|
||||
|
||||
if (initid->const_item)
|
||||
// Keep result of constant function
|
||||
g->Activityp = (PACTIVITY)path;
|
||||
|
||||
} catch (int n) {
|
||||
if (trace)
|
||||
htrc("Exception %d: %s\n", n, g->Message);
|
||||
PUSH_WARNING(g->Message);
|
||||
*error = 1;
|
||||
path = NULL;
|
||||
goto err;
|
||||
} // endif rc
|
||||
|
||||
if (!g->Xchk) {
|
||||
if (CheckMemory(g, initid, args, 1, true)) {
|
||||
PUSH_WARNING("CheckMemory error");
|
||||
*error = 1;
|
||||
goto err;
|
||||
} else
|
||||
jvp = MakeValue(g, args, 0);
|
||||
|
||||
if ((p = jvp->GetString())) {
|
||||
if (!(jsp = ParseJson(g, p, strlen(p)))) {
|
||||
PUSH_WARNING(g->Message);
|
||||
goto err;
|
||||
} // endif jsp
|
||||
|
||||
} else
|
||||
jsp = jvp->GetJson();
|
||||
|
||||
if (g->Mrr) { // First argument is a constant
|
||||
g->Xchk = jsp;
|
||||
JsonMemSave(g);
|
||||
} // endif Mrr
|
||||
|
||||
} else
|
||||
jsp = (PJSON)g->Xchk;
|
||||
|
||||
// The item to locate
|
||||
jvp2 = MakeValue(g, args, 1);
|
||||
|
||||
if (args->arg_count > 2)
|
||||
mx = (int)*(long long*)args->args[2];
|
||||
|
||||
jsx = new(g) JSNX(g, jsp, TYPE_STRING);
|
||||
path = jsx->LocateAll(g, jsp, jvp2, mx);
|
||||
|
||||
if (initid->const_item)
|
||||
// Keep result of constant function
|
||||
g->Activityp = (PACTIVITY)path;
|
||||
} catch (const char *msg) {
|
||||
strcpy(g->Message, msg);
|
||||
PUSH_WARNING(g->Message);
|
||||
*error = 1;
|
||||
path = NULL;
|
||||
} // end catch
|
||||
|
||||
err:
|
||||
g->jump_level--;
|
||||
|
||||
if (!path) {
|
||||
*res_length = 0;
|
||||
*is_null = 1;
|
||||
@@ -3637,7 +3627,7 @@ char *handle_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||
unsigned long *res_length, char *is_null, char *error)
|
||||
{
|
||||
char *p, *path, *str = NULL;
|
||||
int w, rc;
|
||||
int w;
|
||||
my_bool b = true;
|
||||
PJSON jsp;
|
||||
PJSNX jsx;
|
||||
@@ -3659,78 +3649,73 @@ char *handle_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||
w = 2;
|
||||
else {
|
||||
PUSH_WARNING("Logical error, please contact CONNECT developer");
|
||||
goto err;
|
||||
goto fin;
|
||||
} // endelse
|
||||
|
||||
// Save stack and allocation environment and prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
PUSH_WARNING(MSG(TOO_MANY_JUMPS));
|
||||
*error = 1;
|
||||
goto fin;
|
||||
} // endif jump_level
|
||||
try {
|
||||
if (!g->Xchk) {
|
||||
if (CheckMemory(g, initid, args, 1, true, false, true)) {
|
||||
PUSH_WARNING("CheckMemory error");
|
||||
throw 1;
|
||||
} else
|
||||
jvp = MakeValue(g, args, 0);
|
||||
|
||||
if ((rc= setjmp(g->jumper[++g->jump_level])) != 0) {
|
||||
if ((p = jvp->GetString())) {
|
||||
if (!(jsp = ParseJson(g, p, strlen(p)))) {
|
||||
throw 2;
|
||||
} // endif jsp
|
||||
|
||||
} else
|
||||
jsp = jvp->GetJson();
|
||||
|
||||
if (g->Mrr) { // First argument is a constant
|
||||
g->Xchk = jsp;
|
||||
JsonMemSave(g);
|
||||
} // endif Mrr
|
||||
|
||||
} else
|
||||
jsp = (PJSON)g->Xchk;
|
||||
|
||||
jsx = new(g)JSNX(g, jsp, TYPE_STRING, initid->max_length, 0, true);
|
||||
|
||||
for (uint i = 1; i + 1 < args->arg_count; i += 2) {
|
||||
jvp = MakeValue(gb, args, i);
|
||||
path = MakePSZ(g, args, i + 1);
|
||||
|
||||
if (jsx->SetJpath(g, path, false)) {
|
||||
PUSH_WARNING(g->Message);
|
||||
continue;
|
||||
} // endif SetJpath
|
||||
|
||||
if (w) {
|
||||
jsx->ReadValue(g);
|
||||
b = jsx->GetValue()->IsNull();
|
||||
b = (w == 1) ? b : !b;
|
||||
} // endif w
|
||||
|
||||
if (b && jsx->WriteValue(gb, jvp))
|
||||
PUSH_WARNING(g->Message);
|
||||
|
||||
} // endfor i
|
||||
|
||||
// In case of error or file, return unchanged argument
|
||||
if (!(str = MakeResult(g, args, jsp, INT_MAX32)))
|
||||
str = MakePSZ(g, args, 0);
|
||||
|
||||
if (g->N)
|
||||
// Keep result of constant function
|
||||
g->Activityp = (PACTIVITY)str;
|
||||
|
||||
} catch (int n) {
|
||||
if (trace)
|
||||
htrc("Exception %d: %s\n", n, g->Message);
|
||||
PUSH_WARNING(g->Message);
|
||||
str = NULL;
|
||||
goto err;
|
||||
} // endif rc
|
||||
|
||||
if (!g->Xchk) {
|
||||
if (CheckMemory(g, initid, args, 1, true, false, true)) {
|
||||
PUSH_WARNING("CheckMemory error");
|
||||
goto err;
|
||||
} else
|
||||
jvp = MakeValue(g, args, 0);
|
||||
|
||||
if ((p = jvp->GetString())) {
|
||||
if (!(jsp = ParseJson(g, p, strlen(p)))) {
|
||||
PUSH_WARNING(g->Message);
|
||||
goto err;
|
||||
} // endif jsp
|
||||
|
||||
} else
|
||||
jsp = jvp->GetJson();
|
||||
|
||||
if (g->Mrr) { // First argument is a constant
|
||||
g->Xchk = jsp;
|
||||
JsonMemSave(g);
|
||||
} // endif Mrr
|
||||
|
||||
} else
|
||||
jsp = (PJSON)g->Xchk;
|
||||
|
||||
jsx = new(g)JSNX(g, jsp, TYPE_STRING, initid->max_length, 0, true);
|
||||
|
||||
for (uint i = 1; i+1 < args->arg_count; i += 2) {
|
||||
jvp = MakeValue(gb, args, i);
|
||||
path = MakePSZ(g, args, i+1);
|
||||
|
||||
if (jsx->SetJpath(g, path, false)) {
|
||||
PUSH_WARNING(g->Message);
|
||||
continue;
|
||||
} // endif SetJpath
|
||||
|
||||
if (w) {
|
||||
jsx->ReadValue(g);
|
||||
b = jsx->GetValue()->IsNull();
|
||||
b = (w == 1) ? b : !b;
|
||||
} // endif w
|
||||
|
||||
if (b && jsx->WriteValue(gb, jvp))
|
||||
PUSH_WARNING(g->Message);
|
||||
|
||||
} // endfor i
|
||||
|
||||
// In case of error or file, return unchanged argument
|
||||
if (!(str = MakeResult(g, args, jsp, INT_MAX32)))
|
||||
str = MakePSZ(g, args, 0);
|
||||
|
||||
if (g->N)
|
||||
// Keep result of constant function
|
||||
g->Activityp = (PACTIVITY)str;
|
||||
|
||||
err:
|
||||
g->jump_level--;
|
||||
} catch (const char *msg) {
|
||||
strcpy(g->Message, msg);
|
||||
PUSH_WARNING(g->Message);
|
||||
str = NULL;
|
||||
} // end catch
|
||||
|
||||
fin:
|
||||
if (!str) {
|
||||
@@ -4557,7 +4542,7 @@ char *jbin_object_add(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||
} // endif bsp
|
||||
|
||||
if (!CheckMemory(g, initid, args, 2, false, true, true)) {
|
||||
char *key;
|
||||
PCSZ key;
|
||||
PJOB jobp;
|
||||
PJVAL jvp = MakeValue(g, args, 0, &top);
|
||||
PJSON jsp = jvp->GetJson();
|
||||
@@ -4637,7 +4622,7 @@ char *jbin_object_delete(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||
} // endif bsp
|
||||
|
||||
if (!CheckMemory(g, initid, args, 1, false, true, true)) {
|
||||
char *key;
|
||||
PCSZ key;
|
||||
PJOB jobp;
|
||||
PJVAL jvp = MakeValue(g, args, 0, &top);
|
||||
PJSON jsp = jvp->GetJson();
|
||||
|
||||
@@ -232,7 +232,7 @@ extern "C" {
|
||||
/*********************************************************************************/
|
||||
typedef struct _jpn {
|
||||
enum JTYP Type;
|
||||
PSZ Key;
|
||||
PCSZ Key;
|
||||
int N;
|
||||
} JPN, *PJPN;
|
||||
|
||||
|
||||
@@ -68,9 +68,9 @@ class LIBXMLDOC : public XMLDOCUMENT {
|
||||
virtual void SetNofree(bool b) {Nofreelist = b;}
|
||||
|
||||
// Methods
|
||||
virtual bool Initialize(PGLOBAL g, char *entry, bool zipped);
|
||||
virtual bool Initialize(PGLOBAL g, PCSZ entry, bool zipped);
|
||||
virtual bool ParseFile(PGLOBAL g, char *fn);
|
||||
virtual bool NewDoc(PGLOBAL g, char *ver);
|
||||
virtual bool NewDoc(PGLOBAL g, PCSZ ver);
|
||||
virtual void AddComment(PGLOBAL g, char *com);
|
||||
virtual PXNODE GetRoot(PGLOBAL g);
|
||||
virtual PXNODE NewRoot(PGLOBAL g, char *name);
|
||||
@@ -119,9 +119,9 @@ class XML2NODE : public XMLNODE {
|
||||
virtual PXLIST SelectNodes(PGLOBAL g, char *xp, PXLIST lp);
|
||||
virtual PXNODE SelectSingleNode(PGLOBAL g, char *xp, PXNODE np);
|
||||
virtual PXATTR GetAttribute(PGLOBAL g, char *name, PXATTR ap);
|
||||
virtual PXNODE AddChildNode(PGLOBAL g, char *name, PXNODE np);
|
||||
virtual PXNODE AddChildNode(PGLOBAL g, PCSZ name, PXNODE np);
|
||||
virtual PXATTR AddProperty(PGLOBAL g, char *name, PXATTR ap);
|
||||
virtual void AddText(PGLOBAL g, char *txtp);
|
||||
virtual void AddText(PGLOBAL g, PCSZ txtp);
|
||||
virtual void DeleteChild(PGLOBAL g, PXNODE dnp);
|
||||
|
||||
protected:
|
||||
@@ -373,7 +373,7 @@ LIBXMLDOC::LIBXMLDOC(char *nsl, char *nsdf, char *enc, PFBLOCK fp)
|
||||
/******************************************************************/
|
||||
/* Initialize XML parser and check library compatibility. */
|
||||
/******************************************************************/
|
||||
bool LIBXMLDOC::Initialize(PGLOBAL g, char *entry, bool zipped)
|
||||
bool LIBXMLDOC::Initialize(PGLOBAL g, PCSZ entry, bool zipped)
|
||||
{
|
||||
if (zipped && InitZip(g, entry))
|
||||
return true;
|
||||
@@ -434,7 +434,7 @@ PFBLOCK LIBXMLDOC::LinkXblock(PGLOBAL g, MODE m, int rc, char *fn)
|
||||
/******************************************************************/
|
||||
/* Construct and add the XML processing instruction node. */
|
||||
/******************************************************************/
|
||||
bool LIBXMLDOC::NewDoc(PGLOBAL g, char *ver)
|
||||
bool LIBXMLDOC::NewDoc(PGLOBAL g, PCSZ ver)
|
||||
{
|
||||
if (trace)
|
||||
htrc("NewDoc\n");
|
||||
@@ -863,14 +863,13 @@ RCODE XML2NODE::GetContent(PGLOBAL g, char *buf, int len)
|
||||
xmlFree(Content);
|
||||
|
||||
if ((Content = xmlNodeGetContent(Nodep))) {
|
||||
char *extra = " \t\r\n";
|
||||
char *p1 = (char*)Content, *p2 = buf;
|
||||
bool b = false;
|
||||
|
||||
// Copy content eliminating extra characters
|
||||
for (; *p1; p1++)
|
||||
if ((p2 - buf) < len) {
|
||||
if (strchr(extra, *p1)) {
|
||||
if (strchr(" \t\r\n", *p1)) {
|
||||
if (b) {
|
||||
// This to have one blank between sub-nodes
|
||||
*p2++ = ' ';
|
||||
@@ -1020,19 +1019,19 @@ PXATTR XML2NODE::GetAttribute(PGLOBAL g, char *name, PXATTR ap)
|
||||
/******************************************************************/
|
||||
/* Add a new child node to this node and return it. */
|
||||
/******************************************************************/
|
||||
PXNODE XML2NODE::AddChildNode(PGLOBAL g, char *name, PXNODE np)
|
||||
PXNODE XML2NODE::AddChildNode(PGLOBAL g, PCSZ name, PXNODE np)
|
||||
{
|
||||
char *p, *pn, *pf = NULL;
|
||||
char *p, *pn, *pf = NULL, *nmp = PlugDup(g, name);
|
||||
|
||||
if (trace)
|
||||
htrc("AddChildNode: %s\n", name);
|
||||
|
||||
// Is a prefix specified
|
||||
if ((pn = strchr(name, ':'))) {
|
||||
pf = name;
|
||||
if ((pn = strchr(nmp, ':'))) {
|
||||
pf = nmp;
|
||||
*pn++ = '\0'; // Separate name from prefix
|
||||
} else
|
||||
pn = name;
|
||||
pn = nmp;
|
||||
|
||||
// If name has the format m[n] only m is taken as node name
|
||||
if ((p = strchr(pn, '[')))
|
||||
@@ -1096,7 +1095,7 @@ PXATTR XML2NODE::AddProperty(PGLOBAL g, char *name, PXATTR ap)
|
||||
/******************************************************************/
|
||||
/* Add a new text node to this node. */
|
||||
/******************************************************************/
|
||||
void XML2NODE::AddText(PGLOBAL g, char *txtp)
|
||||
void XML2NODE::AddText(PGLOBAL g, PCSZ txtp)
|
||||
{
|
||||
if (trace)
|
||||
htrc("AddText: %s\n", txtp);
|
||||
|
||||
@@ -192,7 +192,7 @@ bool MACINFO::GetOneInfo(PGLOBAL g, int flag, void *v, int lv)
|
||||
case 23:
|
||||
break;
|
||||
default:
|
||||
p = "";
|
||||
p = PlugDup(g, "");
|
||||
} // endswitch flag
|
||||
|
||||
} else switch (flag) {
|
||||
|
||||
@@ -161,7 +161,7 @@ TABTYPE GetTypeID(const char *type)
|
||||
#ifdef ZIP_SUPPORT
|
||||
: (!stricmp(type, "ZIP")) ? TAB_ZIP
|
||||
#endif
|
||||
: (!stricmp(type, "OEM")) ? TAB_OEM : TAB_NIY;
|
||||
: (!stricmp(type, "OEM")) ? TAB_OEM : TAB_NIY;
|
||||
} // end of GetTypeID
|
||||
|
||||
/***********************************************************************/
|
||||
@@ -477,39 +477,6 @@ void MYCAT::Reset(void)
|
||||
{
|
||||
} // end of Reset
|
||||
|
||||
#if 0
|
||||
/***********************************************************************/
|
||||
/* This function sets the current database path. */
|
||||
/***********************************************************************/
|
||||
void MYCAT::SetPath(PGLOBAL g, LPCSTR *datapath, const char *path)
|
||||
{
|
||||
if (path) {
|
||||
size_t len= strlen(path) + (*path != '.' ? 4 : 1);
|
||||
char *buf= (char*)PlugSubAlloc(g, NULL, len);
|
||||
|
||||
if (PlugIsAbsolutePath(path))
|
||||
{
|
||||
strcpy(buf, path);
|
||||
*datapath= buf;
|
||||
return;
|
||||
}
|
||||
|
||||
if (*path != '.') {
|
||||
#if defined(__WIN__)
|
||||
char *s= "\\";
|
||||
#else // !__WIN__
|
||||
char *s= "/";
|
||||
#endif // !__WIN__
|
||||
strcat(strcat(strcat(strcpy(buf, "."), s), path), s);
|
||||
} else
|
||||
strcpy(buf, path);
|
||||
|
||||
*datapath= buf;
|
||||
} // endif path
|
||||
|
||||
} // end of SetDataPath
|
||||
#endif // 0
|
||||
|
||||
/***********************************************************************/
|
||||
/* GetTableDesc: retrieve a table descriptor. */
|
||||
/* Look for a table descriptor matching the name and type. */
|
||||
|
||||
@@ -98,10 +98,7 @@ class MYCAT : public CATALOG {
|
||||
|
||||
// Methods
|
||||
void Reset(void);
|
||||
//void SetDataPath(PGLOBAL g, const char *path)
|
||||
// {SetPath(g, &DataPath, path);}
|
||||
bool StoreIndex(PGLOBAL, PTABDEF) {return false;} // Temporary
|
||||
// PRELDEF GetTableDesc(PGLOBAL g, LPCSTR name,
|
||||
PRELDEF GetTableDesc(PGLOBAL g, PTABLE tablep,
|
||||
LPCSTR type, PRELDEF *prp = NULL);
|
||||
PTDB GetTable(PGLOBAL g, PTABLE tablep,
|
||||
@@ -109,9 +106,7 @@ class MYCAT : public CATALOG {
|
||||
void ClearDB(PGLOBAL g);
|
||||
|
||||
protected:
|
||||
// PRELDEF MakeTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am);
|
||||
PRELDEF MakeTableDesc(PGLOBAL g, PTABLE tablep, LPCSTR am);
|
||||
//void SetPath(PGLOBAL g, LPCSTR *datapath, const char *path);
|
||||
|
||||
// Members
|
||||
ha_connect *Hc; // The Connect handler
|
||||
|
||||
@@ -135,10 +135,13 @@ PQRYRES MyColumns(PGLOBAL g, THD *thd, const char *host, const char *db,
|
||||
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, *colname, *chset, *fmt, v, buf[128], uns[16], zero[16];
|
||||
//unsigned int length[] = {0, 4, 16, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0};
|
||||
unsigned int length[] = {0, 4, 0, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0};
|
||||
PCSZ fmt;
|
||||
char *fld, *colname, *chset, v, buf[128], uns[16], zero[16];
|
||||
int i, n, nf, ncol = sizeof(buftyp) / sizeof(int);
|
||||
int len, type, prec, rc, k = 0;
|
||||
bool b;
|
||||
PQRYRES qrp;
|
||||
PCOLRES crp;
|
||||
MYSQLC myc;
|
||||
@@ -157,7 +160,7 @@ PQRYRES MyColumns(PGLOBAL g, THD *thd, const char *host, const char *db,
|
||||
/* Do an evaluation of the result size. */
|
||||
/********************************************************************/
|
||||
STRING cmd(g, 64, "SHOW FULL COLUMNS FROM ");
|
||||
bool b = cmd.Append((PSZ)table);
|
||||
b = cmd.Append((PSZ)table);
|
||||
|
||||
b |= cmd.Append(" FROM ");
|
||||
b |= cmd.Append((PSZ)(db ? db : PlgGetUser(g)->DBName));
|
||||
@@ -232,11 +235,31 @@ PQRYRES MyColumns(PGLOBAL g, THD *thd, const char *host, const char *db,
|
||||
fld = myc.GetCharField(1);
|
||||
prec = 0;
|
||||
len = 0;
|
||||
v = (chset && !strcmp(chset, "binary")) ? 'B' : 0;
|
||||
// v = (chset && !strcmp(chset, "binary")) ? 'B' : 0;
|
||||
v = 0;
|
||||
*uns = 0;
|
||||
*zero = 0;
|
||||
b = false;
|
||||
|
||||
switch ((nf = sscanf(fld, "%[^(](%d,%d", buf, &len, &prec))) {
|
||||
if (!strnicmp(fld, "enum", 4)) {
|
||||
char *p2, *p1 = fld + 6; // to skip enum('
|
||||
|
||||
while (true) {
|
||||
p2 = strchr(p1, '\'');
|
||||
len = MY_MAX(len, p2 - p1);
|
||||
if (*++p2 != ',') break;
|
||||
p1 = p2 + 2;
|
||||
} // endwhile
|
||||
|
||||
v = (len > 255) ? 'V' : 0;
|
||||
strcpy(buf, "enum");
|
||||
b = true;
|
||||
} else if (!strnicmp(fld, "set", 3)) {
|
||||
len = (int)strlen(fld) - 2;
|
||||
v = 'V';
|
||||
strcpy(buf, "set");
|
||||
b = true;
|
||||
} else switch ((nf = sscanf(fld, "%[^(](%d,%d", buf, &len, &prec))) {
|
||||
case 3:
|
||||
nf = sscanf(fld, "%[^(](%d,%d) %s %s", buf, &len, &prec, uns, zero);
|
||||
break;
|
||||
@@ -271,7 +294,7 @@ PQRYRES MyColumns(PGLOBAL g, THD *thd, const char *host, const char *db,
|
||||
colname, len);
|
||||
PushWarning(g, thd);
|
||||
v = 'V';
|
||||
} else
|
||||
} else
|
||||
len = MY_MIN(len, 4096);
|
||||
|
||||
} // endif type
|
||||
@@ -286,6 +309,9 @@ PQRYRES MyColumns(PGLOBAL g, THD *thd, const char *host, const char *db,
|
||||
default: crp->Nulls[i] = v; break;
|
||||
} // endswitch nf
|
||||
|
||||
if (b) // enum or set
|
||||
nf = sscanf(fld, "%s ", buf); // get values
|
||||
|
||||
crp = crp->Next; // Type_Name
|
||||
crp->Kdata->SetValue(buf, i);
|
||||
|
||||
@@ -849,7 +875,8 @@ MYSQL_FIELD *MYSQLC::GetNextField(void)
|
||||
/***********************************************************************/
|
||||
PQRYRES MYSQLC::GetResult(PGLOBAL g, bool pdb)
|
||||
{
|
||||
char *fmt, v;
|
||||
PCSZ fmt;
|
||||
char *name, v;
|
||||
int n;
|
||||
bool uns;
|
||||
PCOLRES *pcrp, crp;
|
||||
@@ -887,8 +914,9 @@ PQRYRES MYSQLC::GetResult(PGLOBAL g, bool pdb)
|
||||
memset(crp, 0, sizeof(COLRES));
|
||||
crp->Ncol = ++qrp->Nbcol;
|
||||
|
||||
crp->Name = (char*)PlugSubAlloc(g, NULL, fld->name_length + 1);
|
||||
strcpy(crp->Name, fld->name);
|
||||
name = (char*)PlugSubAlloc(g, NULL, fld->name_length + 1);
|
||||
strcpy(name, fld->name);
|
||||
crp->Name = name;
|
||||
|
||||
if ((crp->Type = MYSQLtoPLG(fld->type, &v)) == TYPE_ERROR) {
|
||||
sprintf(g->Message, "Type %d not supported for column %s",
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
# Do not use any TAB characters for whitespace.
|
||||
#
|
||||
##############################################################################
|
||||
#jdbc : Variable settings depend on machine configuration
|
||||
#jdbc_new : Variable settings depend on machine configuration
|
||||
jdbc : Variable settings depend on machine configuration
|
||||
jdbc_new : Variable settings depend on machine configuration
|
||||
jdbc_oracle : Variable settings depend on machine configuration
|
||||
jdbc_postgresql : Variable settings depend on machine configuration
|
||||
|
||||
@@ -14,9 +14,7 @@ NULL NULL
|
||||
SET GLOBAL time_zone='+1:00';
|
||||
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC
|
||||
CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/test?user=unknown';
|
||||
SELECT * FROM t1;
|
||||
ERROR HY000: Got error 174 'Connecting: java.sql.SQLException: Access denied for user 'unknown'@'localhost' (using password: NO) rc=-2' from CONNECT
|
||||
DROP TABLE t1;
|
||||
ERROR HY000: Connecting: java.sql.SQLException: Access denied for user 'unknown'@'localhost' (using password: NO) rc=-2
|
||||
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC
|
||||
CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/unknown?user=root';
|
||||
ERROR HY000: Connecting: java.sql.SQLSyntaxErrorException: Unknown database 'unknown' rc=-2
|
||||
|
||||
@@ -24,11 +24,9 @@ SET GLOBAL time_zone='+1:00';
|
||||
# Bad user name
|
||||
# Suppress "mysql_real_connect failed:" (printed in _DEBUG build)
|
||||
--replace_result $SLAVE_MYPORT SLAVE_PORT "mysql_real_connect failed: " ""
|
||||
--error ER_UNKNOWN_ERROR
|
||||
eval CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC
|
||||
CONNECTION='jdbc:mysql://127.0.0.1:$SLAVE_MYPORT/test?user=unknown';
|
||||
--error ER_GET_ERRMSG
|
||||
SELECT * FROM t1;
|
||||
DROP TABLE t1;
|
||||
|
||||
# Bad database name
|
||||
--replace_result $SLAVE_MYPORT SLAVE_PORT "mysql_real_connect failed: " ""
|
||||
|
||||
@@ -42,7 +42,8 @@ int MYSQLtoPLG(char *typname, char *var)
|
||||
type = TYPE_INT;
|
||||
else if (!stricmp(typname, "smallint"))
|
||||
type = TYPE_SHORT;
|
||||
else if (!stricmp(typname, "char") || !stricmp(typname, "varchar"))
|
||||
else if (!stricmp(typname, "char") || !stricmp(typname, "varchar") ||
|
||||
!stricmp(typname, "enum") || !stricmp(typname, "set"))
|
||||
type = TYPE_STRING;
|
||||
else if (!stricmp(typname, "double") || !stricmp(typname, "float") ||
|
||||
!stricmp(typname, "real"))
|
||||
@@ -87,10 +88,12 @@ int MYSQLtoPLG(char *typname, char *var)
|
||||
else if (!stricmp(typname, "year"))
|
||||
*var = 'Y';
|
||||
|
||||
} else if (type == TYPE_STRING && !stricmp(typname, "varchar"))
|
||||
// This is to make the difference between CHAR and VARCHAR
|
||||
*var = 'V';
|
||||
else if (type == TYPE_ERROR && xconv == TPC_SKIP)
|
||||
} else if (type == TYPE_STRING) {
|
||||
if (!stricmp(typname, "varchar"))
|
||||
// This is to make the difference between CHAR and VARCHAR
|
||||
*var = 'V';
|
||||
|
||||
} else if (type == TYPE_ERROR && xconv == TPC_SKIP)
|
||||
*var = 'K';
|
||||
else
|
||||
*var = 0;
|
||||
@@ -266,9 +269,9 @@ int MYSQLtoPLG(int mytype, char *var)
|
||||
/************************************************************************/
|
||||
/* Returns the format corresponding to a MySQL date type number. */
|
||||
/************************************************************************/
|
||||
char *MyDateFmt(int mytype)
|
||||
PCSZ MyDateFmt(int mytype)
|
||||
{
|
||||
char *fmt;
|
||||
PCSZ fmt;
|
||||
|
||||
switch (mytype) {
|
||||
case MYSQL_TYPE_TIMESTAMP:
|
||||
@@ -294,9 +297,9 @@ char *MyDateFmt(int mytype)
|
||||
/************************************************************************/
|
||||
/* Returns the format corresponding to a MySQL date type name. */
|
||||
/************************************************************************/
|
||||
char *MyDateFmt(char *typname)
|
||||
PCSZ MyDateFmt(char *typname)
|
||||
{
|
||||
char *fmt;
|
||||
PCSZ fmt;
|
||||
|
||||
if (!stricmp(typname, "datetime") || !stricmp(typname, "timestamp"))
|
||||
fmt = "YYYY-MM-DD hh:mm:ss";
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
|
||||
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);
|
||||
char *MyDateFmt(char *typname);
|
||||
int MYSQLtoPLG(char *typname, char *var = NULL);
|
||||
int MYSQLtoPLG(int mytype, char *var = NULL);
|
||||
PCSZ MyDateFmt(int mytype);
|
||||
PCSZ MyDateFmt(char *typname);
|
||||
|
||||
#endif // __MYUTIL__H
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
#define DEFAULT_QUERY_TIMEOUT -1 // means do not set
|
||||
|
||||
typedef struct odbc_parms {
|
||||
char *User; // User connect info
|
||||
char *Pwd; // Password connect info
|
||||
int Cto; // Connect timeout
|
||||
int Qto; // Query timeout
|
||||
bool UseCnc; // Use SQLConnect (!SQLDriverConnect)
|
||||
PCSZ User; // User connect info
|
||||
PCSZ Pwd; // Password connect info
|
||||
int Cto; // Connect timeout
|
||||
int Qto; // Query timeout
|
||||
bool UseCnc; // Use SQLConnect (!SQLDriverConnect)
|
||||
} ODBCPARM, *POPARM;
|
||||
|
||||
/***********************************************************************/
|
||||
@@ -17,9 +17,9 @@ typedef struct odbc_parms {
|
||||
char *ODBCCheckConnection(PGLOBAL g, char *dsn, int cop);
|
||||
#endif // PROMPT_OK
|
||||
PQRYRES ODBCDataSources(PGLOBAL g, int maxres, bool info);
|
||||
PQRYRES ODBCColumns(PGLOBAL g, char *dsn, char *db, char *table,
|
||||
char *colpat, int maxres, bool info, POPARM sop);
|
||||
PQRYRES ODBCColumns(PGLOBAL g, PCSZ dsn, PCSZ db, PCSZ table,
|
||||
PCSZ colpat, int maxres, bool info, POPARM sop);
|
||||
PQRYRES ODBCSrcCols(PGLOBAL g, char *dsn, char *src, POPARM sop);
|
||||
PQRYRES ODBCTables(PGLOBAL g, char *dsn, char *db, char *tabpat,
|
||||
char *tabtyp, int maxres, bool info, POPARM sop);
|
||||
PQRYRES ODBCTables(PGLOBAL g, PCSZ dsn, PCSZ db, PCSZ tabpat,
|
||||
PCSZ tabtyp, int maxres, bool info, POPARM sop);
|
||||
PQRYRES ODBCDrivers(PGLOBAL g, int maxres, bool info);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/************ Odbconn C++ Functions Source Code File (.CPP) ************/
|
||||
/* Name: ODBCONN.CPP Version 2.2 */
|
||||
/***********************************************************************/
|
||||
/* Name: ODBCONN.CPP Version 2.3 */
|
||||
/* */
|
||||
/* (C) Copyright to the author Olivier BERTRAND 1998-2016 */
|
||||
/* (C) Copyright to the author Olivier BERTRAND 1998-2017 */
|
||||
/* */
|
||||
/* This file contains the ODBC connection classes functions. */
|
||||
/***********************************************************************/
|
||||
@@ -239,47 +239,43 @@ char *ODBCCheckConnection(PGLOBAL g, char *dsn, int cop)
|
||||
/***********************************************************************/
|
||||
/* Allocate the structure used to refer to the result set. */
|
||||
/***********************************************************************/
|
||||
static CATPARM *AllocCatInfo(PGLOBAL g, CATINFO fid, char *db,
|
||||
char *tab, PQRYRES qrp)
|
||||
{
|
||||
size_t i, m, n;
|
||||
CATPARM *cap;
|
||||
static CATPARM *AllocCatInfo(PGLOBAL g, CATINFO fid, PCSZ db,
|
||||
PCSZ tab, PQRYRES qrp)
|
||||
{
|
||||
size_t i, m, n;
|
||||
CATPARM *cap;
|
||||
|
||||
#if defined(_DEBUG)
|
||||
assert(qrp);
|
||||
assert(qrp);
|
||||
#endif
|
||||
|
||||
// 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
|
||||
try {
|
||||
m = (size_t)qrp->Maxres;
|
||||
n = (size_t)qrp->Nbcol;
|
||||
cap = (CATPARM *)PlugSubAlloc(g, NULL, sizeof(CATPARM));
|
||||
memset(cap, 0, sizeof(CATPARM));
|
||||
cap->Id = fid;
|
||||
cap->Qrp = qrp;
|
||||
cap->DB = db;
|
||||
cap->Tab = tab;
|
||||
cap->Vlen = (SQLLEN* *)PlugSubAlloc(g, NULL, n * sizeof(SQLLEN *));
|
||||
|
||||
if (setjmp(g->jumper[++g->jump_level]) != 0) {
|
||||
printf("%s\n", g->Message);
|
||||
cap = NULL;
|
||||
goto fin;
|
||||
} // endif rc
|
||||
for (i = 0; i < n; i++)
|
||||
cap->Vlen[i] = (SQLLEN *)PlugSubAlloc(g, NULL, m * sizeof(SQLLEN));
|
||||
|
||||
m = (size_t)qrp->Maxres;
|
||||
n = (size_t)qrp->Nbcol;
|
||||
cap = (CATPARM *)PlugSubAlloc(g, NULL, sizeof(CATPARM));
|
||||
memset(cap, 0, sizeof(CATPARM));
|
||||
cap->Id = fid;
|
||||
cap->Qrp = qrp;
|
||||
cap->DB = (PUCHAR)db;
|
||||
cap->Tab = (PUCHAR)tab;
|
||||
cap->Vlen = (SQLLEN* *)PlugSubAlloc(g, NULL, n * sizeof(SQLLEN *));
|
||||
cap->Status = (UWORD *)PlugSubAlloc(g, NULL, m * sizeof(UWORD));
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
cap->Vlen[i] = (SQLLEN *)PlugSubAlloc(g, NULL, m * sizeof(SQLLEN));
|
||||
} catch (int n) {
|
||||
htrc("Exeption %d: %s\n", n, g->Message);
|
||||
cap = NULL;
|
||||
} catch (const char *msg) {
|
||||
htrc(g->Message, msg);
|
||||
printf("%s\n", g->Message);
|
||||
cap = NULL;
|
||||
} // end catch
|
||||
|
||||
cap->Status = (UWORD *)PlugSubAlloc(g, NULL, m * sizeof(UWORD));
|
||||
|
||||
fin:
|
||||
g->jump_level--;
|
||||
return cap;
|
||||
} // end of AllocCatInfo
|
||||
return cap;
|
||||
} // end of AllocCatInfo
|
||||
|
||||
#if 0
|
||||
/***********************************************************************/
|
||||
@@ -309,8 +305,8 @@ static void ResetNullValues(CATPARM *cap)
|
||||
/* ODBCColumns: constructs the result blocks containing all columns */
|
||||
/* of an ODBC table that will be retrieved by GetData commands. */
|
||||
/***********************************************************************/
|
||||
PQRYRES ODBCColumns(PGLOBAL g, char *dsn, char *db, char *table,
|
||||
char *colpat, int maxres, bool info, POPARM sop)
|
||||
PQRYRES ODBCColumns(PGLOBAL g, PCSZ dsn, PCSZ db, PCSZ table,
|
||||
PCSZ colpat, int maxres, bool info, POPARM sop)
|
||||
{
|
||||
int buftyp[] = {TYPE_STRING, TYPE_STRING, TYPE_STRING, TYPE_STRING,
|
||||
TYPE_SHORT, TYPE_STRING, TYPE_INT, TYPE_INT,
|
||||
@@ -383,7 +379,7 @@ PQRYRES ODBCColumns(PGLOBAL g, char *dsn, char *db, char *table,
|
||||
if (!(cap = AllocCatInfo(g, CAT_COL, db, table, qrp)))
|
||||
return NULL;
|
||||
|
||||
cap->Pat = (PUCHAR)colpat;
|
||||
cap->Pat = colpat;
|
||||
|
||||
/************************************************************************/
|
||||
/* Now get the results into blocks. */
|
||||
@@ -618,8 +614,8 @@ PQRYRES ODBCDataSources(PGLOBAL g, int maxres, bool info)
|
||||
/* ODBCTables: constructs the result blocks containing all tables in */
|
||||
/* an ODBC database that will be retrieved by GetData commands. */
|
||||
/**************************************************************************/
|
||||
PQRYRES ODBCTables(PGLOBAL g, char *dsn, char *db, char *tabpat,
|
||||
char *tabtyp, int maxres, bool info, POPARM sop)
|
||||
PQRYRES ODBCTables(PGLOBAL g, PCSZ dsn, PCSZ db, PCSZ tabpat, PCSZ tabtyp,
|
||||
int maxres, bool info, POPARM sop)
|
||||
{
|
||||
int buftyp[] = {TYPE_STRING, TYPE_STRING, TYPE_STRING,
|
||||
TYPE_STRING, TYPE_STRING};
|
||||
@@ -681,7 +677,7 @@ PQRYRES ODBCTables(PGLOBAL g, char *dsn, char *db, char *tabpat,
|
||||
if (!(cap = AllocCatInfo(g, CAT_TAB, db, tabpat, qrp)))
|
||||
return NULL;
|
||||
|
||||
cap->Pat = (PUCHAR)tabtyp;
|
||||
cap->Pat = tabtyp;
|
||||
|
||||
if (trace)
|
||||
htrc("Getting table results ncol=%d\n", cap->Qrp->Nbcol);
|
||||
@@ -879,7 +875,7 @@ PQRYRES ODBCStatistics(PGLOBAL g, ODBConn *op, char *dsn, char *pat,
|
||||
/***********************************************************************/
|
||||
/* Implementation of DBX class. */
|
||||
/***********************************************************************/
|
||||
DBX::DBX(RETCODE rc, PSZ msg)
|
||||
DBX::DBX(RETCODE rc, PCSZ msg)
|
||||
{
|
||||
m_RC = rc;
|
||||
m_Msg = msg;
|
||||
@@ -1020,7 +1016,7 @@ bool ODBConn::Check(RETCODE rc)
|
||||
/***********************************************************************/
|
||||
/* DB exception throw routines. */
|
||||
/***********************************************************************/
|
||||
void ODBConn::ThrowDBX(RETCODE rc, PSZ msg, HSTMT hstmt)
|
||||
void ODBConn::ThrowDBX(RETCODE rc, PCSZ msg, HSTMT hstmt)
|
||||
{
|
||||
DBX* xp = new(m_G) DBX(rc, msg);
|
||||
|
||||
@@ -1030,7 +1026,7 @@ void ODBConn::ThrowDBX(RETCODE rc, PSZ msg, HSTMT hstmt)
|
||||
|
||||
} // end of ThrowDBX
|
||||
|
||||
void ODBConn::ThrowDBX(PSZ msg)
|
||||
void ODBConn::ThrowDBX(PCSZ msg)
|
||||
{
|
||||
DBX* xp = new(m_G) DBX(0, "Error");
|
||||
|
||||
@@ -1110,7 +1106,7 @@ void ODBConn::OnSetOptions(HSTMT hstmt)
|
||||
/***********************************************************************/
|
||||
/* Open: connect to a data source. */
|
||||
/***********************************************************************/
|
||||
int ODBConn::Open(PSZ ConnectString, POPARM sop, DWORD options)
|
||||
int ODBConn::Open(PCSZ ConnectString, POPARM sop, DWORD options)
|
||||
{
|
||||
PGLOBAL& g = m_G;
|
||||
//ASSERT_VALID(this);
|
||||
@@ -1192,7 +1188,7 @@ void ODBConn::AllocConnect(DWORD Options)
|
||||
|
||||
#if defined(_DEBUG)
|
||||
if (Options & traceSQL) {
|
||||
SQLSetConnectOption(m_hdbc, SQL_OPT_TRACEFILE, (DWORD)"xodbc.out");
|
||||
SQLSetConnectOption(m_hdbc, SQL_OPT_TRACEFILE, (SQLULEN)"xodbc.out");
|
||||
SQLSetConnectOption(m_hdbc, SQL_OPT_TRACE, 1);
|
||||
} // endif
|
||||
#endif // _DEBUG
|
||||
@@ -1215,7 +1211,7 @@ void ODBConn::AllocConnect(DWORD Options)
|
||||
|
||||
// Turn on cursor lib support
|
||||
if (Options & useCursorLib)
|
||||
rc = SQLSetConnectOption(m_hdbc, SQL_ODBC_CURSORS, SQL_CUR_USE_ODBC);
|
||||
rc = SQLSetConnectOption(m_hdbc, SQL_ODBC_CURSORS, SQL_CUR_USE_DRIVER);
|
||||
|
||||
return;
|
||||
} // end of AllocConnect
|
||||
@@ -1921,7 +1917,7 @@ bool ODBConn::ExecSQLcommand(char *sql)
|
||||
/* GetMetaData: constructs the result blocks containing the */
|
||||
/* description of all the columns of an SQL command. */
|
||||
/**************************************************************************/
|
||||
PQRYRES ODBConn::GetMetaData(PGLOBAL g, char *dsn, char *src)
|
||||
PQRYRES ODBConn::GetMetaData(PGLOBAL g, PCSZ dsn, PCSZ src)
|
||||
{
|
||||
static int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_INT,
|
||||
TYPE_SHORT, TYPE_SHORT};
|
||||
@@ -2244,7 +2240,7 @@ int ODBConn::GetCatInfo(CATPARM *cap)
|
||||
void *buffer;
|
||||
int i, irc;
|
||||
bool b;
|
||||
PSZ fnc = "Unknown";
|
||||
PCSZ fnc = "Unknown";
|
||||
UWORD n;
|
||||
SWORD ncol, len, tp;
|
||||
SQLULEN crow = 0;
|
||||
@@ -2283,22 +2279,20 @@ int ODBConn::GetCatInfo(CATPARM *cap)
|
||||
// Now do call the proper ODBC API
|
||||
switch (cap->Id) {
|
||||
case CAT_TAB:
|
||||
// rc = SQLSetStmtAttr(hstmt, SQL_ATTR_METADATA_ID,
|
||||
// (SQLPOINTER)false, 0);
|
||||
fnc = "SQLTables";
|
||||
rc = SQLTables(hstmt, name.ptr(2), name.length(2),
|
||||
name.ptr(1), name.length(1),
|
||||
name.ptr(0), name.length(0),
|
||||
cap->Pat, cap->Pat ? SQL_NTS : 0);
|
||||
(SQLCHAR *)cap->Pat,
|
||||
cap->Pat ? SQL_NTS : 0);
|
||||
break;
|
||||
case CAT_COL:
|
||||
// rc = SQLSetStmtAttr(hstmt, SQL_ATTR_METADATA_ID,
|
||||
// (SQLPOINTER)true, 0);
|
||||
fnc = "SQLColumns";
|
||||
rc = SQLColumns(hstmt, name.ptr(2), name.length(2),
|
||||
name.ptr(1), name.length(1),
|
||||
name.ptr(0), name.length(0),
|
||||
cap->Pat, cap->Pat ? SQL_NTS : 0);
|
||||
(SQLCHAR *)cap->Pat,
|
||||
cap->Pat ? SQL_NTS : 0);
|
||||
break;
|
||||
case CAT_KEY:
|
||||
fnc = "SQLPrimaryKeys";
|
||||
|
||||
@@ -54,9 +54,9 @@ enum CATINFO {CAT_TAB = 1, /* SQLTables */
|
||||
typedef struct tagCATPARM {
|
||||
CATINFO Id; // Id to indicate function
|
||||
PQRYRES Qrp; // Result set pointer
|
||||
PUCHAR DB; // Database (Schema)
|
||||
PUCHAR Tab; // Table name or pattern
|
||||
PUCHAR Pat; // Table type or column pattern
|
||||
PCSZ DB; // Database (Schema)
|
||||
PCSZ Tab; // Table name or pattern
|
||||
PCSZ Pat; // Table type or column pattern
|
||||
SQLLEN* *Vlen; // To array of indicator values
|
||||
UWORD *Status; // To status block
|
||||
// For SQLStatistics
|
||||
@@ -80,23 +80,23 @@ class DBX : public BLOCK {
|
||||
friend class ODBConn;
|
||||
// Construction (by ThrowDBX only) -- destruction
|
||||
protected:
|
||||
DBX(RETCODE rc, PSZ msg = NULL);
|
||||
DBX(RETCODE rc, PCSZ msg = NULL);
|
||||
public:
|
||||
//virtual ~DBX() {}
|
||||
//void operator delete(void*, PGLOBAL, void*) {};
|
||||
|
||||
// Implementation (use ThrowDBX to create)
|
||||
RETCODE GetRC(void) {return m_RC;}
|
||||
PSZ GetMsg(void) {return m_Msg;}
|
||||
const char *GetErrorMessage(int i);
|
||||
PCSZ GetMsg(void) {return m_Msg;}
|
||||
PCSZ GetErrorMessage(int i);
|
||||
|
||||
protected:
|
||||
bool BuildErrorMessage(ODBConn* pdb, HSTMT hstmt = SQL_NULL_HSTMT);
|
||||
|
||||
// Attributes
|
||||
RETCODE m_RC;
|
||||
PSZ m_Msg;
|
||||
PSZ m_ErrMsg[MAX_NUM_OF_MSG];
|
||||
PCSZ m_Msg;
|
||||
PCSZ m_ErrMsg[MAX_NUM_OF_MSG];
|
||||
}; // end of DBX class definition
|
||||
|
||||
/***********************************************************************/
|
||||
@@ -119,7 +119,7 @@ class ODBConn : public BLOCK {
|
||||
noOdbcDialog = 0x0008, // Don't display ODBC Connect dialog
|
||||
forceOdbcDialog = 0x0010}; // Always display ODBC connect dialog
|
||||
|
||||
int Open(PSZ ConnectString, POPARM sop, DWORD Options = 0);
|
||||
int Open(PCSZ ConnectString, POPARM sop, DWORD Options = 0);
|
||||
int Rewind(char *sql, ODBCCOL *tocols);
|
||||
void Close(void);
|
||||
PQRYRES AllocateResult(PGLOBAL g);
|
||||
@@ -131,7 +131,7 @@ class ODBConn : public BLOCK {
|
||||
bool IsOpen(void) {return m_hdbc != SQL_NULL_HDBC;}
|
||||
PSZ GetStringInfo(ushort infotype);
|
||||
int GetMaxValue(ushort infotype);
|
||||
PSZ GetConnect(void) {return m_Connect;}
|
||||
PCSZ GetConnect(void) {return m_Connect;}
|
||||
|
||||
public:
|
||||
// Operations
|
||||
@@ -149,7 +149,7 @@ class ODBConn : public BLOCK {
|
||||
int GetCatInfo(CATPARM *cap);
|
||||
bool GetDataSources(PQRYRES qrp);
|
||||
bool GetDrivers(PQRYRES qrp);
|
||||
PQRYRES GetMetaData(PGLOBAL g, char *dsn, char *src);
|
||||
PQRYRES GetMetaData(PGLOBAL g, PCSZ dsn, PCSZ src);
|
||||
|
||||
public:
|
||||
// Set special options
|
||||
@@ -162,8 +162,8 @@ class ODBConn : public BLOCK {
|
||||
// ODBC operations
|
||||
protected:
|
||||
bool Check(RETCODE rc);
|
||||
void ThrowDBX(RETCODE rc, PSZ msg, HSTMT hstmt = SQL_NULL_HSTMT);
|
||||
void ThrowDBX(PSZ msg);
|
||||
void ThrowDBX(RETCODE rc, PCSZ msg, HSTMT hstmt = SQL_NULL_HSTMT);
|
||||
void ThrowDBX(PCSZ msg);
|
||||
void AllocConnect(DWORD dwOptions);
|
||||
void Connect(void);
|
||||
bool DriverConnect(DWORD Options);
|
||||
@@ -187,9 +187,9 @@ class ODBConn : public BLOCK {
|
||||
DWORD m_UpdateOptions;
|
||||
DWORD m_RowsetSize;
|
||||
char m_IDQuoteChar[2];
|
||||
PSZ m_Connect;
|
||||
PSZ m_User;
|
||||
PSZ m_Pwd;
|
||||
PCSZ m_Connect;
|
||||
PCSZ m_User;
|
||||
PCSZ m_Pwd;
|
||||
int m_Catver;
|
||||
int m_Rows;
|
||||
int m_Fetch;
|
||||
|
||||
@@ -17,13 +17,16 @@ typedef off_t off64_t;
|
||||
|
||||
#if defined(__WIN__)
|
||||
typedef __int64 BIGINT;
|
||||
typedef _Null_terminated_ const char *PCSZ;
|
||||
#else // !__WIN__
|
||||
typedef longlong BIGINT;
|
||||
#define FILE_BEGIN SEEK_SET
|
||||
#define FILE_CURRENT SEEK_CUR
|
||||
#define FILE_END SEEK_END
|
||||
typedef const char *PCSZ;
|
||||
#endif // !__WIN__
|
||||
|
||||
|
||||
#if !defined(__WIN__)
|
||||
typedef const void *LPCVOID;
|
||||
typedef const char *LPCTSTR;
|
||||
|
||||
@@ -43,34 +43,6 @@ PSZ strlwr(PSZ p)
|
||||
return (p);
|
||||
} /* end of strlwr */
|
||||
|
||||
#if defined(NOT_USED) /*&& !defined(sun) && !defined(LINUX) && !defined(AIX)*/
|
||||
/***********************************************************************/
|
||||
/* Define stricmp function not existing in some UNIX libraries. */
|
||||
/***********************************************************************/
|
||||
int stricmp(char *str1, char *str2)
|
||||
{
|
||||
register int i;
|
||||
int n;
|
||||
char c;
|
||||
char *sup1 = malloc(strlen(str1) + 1);
|
||||
char *sup2 = malloc(strlen(str2) + 1);
|
||||
|
||||
for (i = 0; c = str1[i]; i++)
|
||||
sup1[i] = toupper(c);
|
||||
|
||||
sup1[i] = 0;
|
||||
|
||||
for (i = 0; c = str2[i]; i++)
|
||||
sup2[i] = toupper(c);
|
||||
|
||||
sup2[i] = 0;
|
||||
n = strcmp(sup1, sup2);
|
||||
free(sup1);
|
||||
free(sup2);
|
||||
return (n);
|
||||
} /* end of stricmp */
|
||||
#endif /* sun */
|
||||
|
||||
/***********************************************************************/
|
||||
/* Define the splitpath function not existing in the UNIX library. */
|
||||
/***********************************************************************/
|
||||
@@ -143,13 +115,6 @@ my_bool CloseFileHandle(HANDLE h)
|
||||
return (close(h)) ? TRUE : FALSE;
|
||||
} /* end of CloseFileHandle */
|
||||
|
||||
#if 0
|
||||
void Sleep(DWORD time)
|
||||
{
|
||||
//FIXME: TODO
|
||||
} /* end of Sleep */
|
||||
#endif
|
||||
|
||||
int GetLastError()
|
||||
{
|
||||
return errno;
|
||||
@@ -210,21 +175,4 @@ BOOL MessageBeep(uint i __attribute__((unused)))
|
||||
return TRUE;
|
||||
} /* end of MessageBeep */
|
||||
|
||||
#if 0
|
||||
/* This function is ridiculous and should be revisited */
|
||||
DWORD FormatMessage(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId,
|
||||
DWORD dwLanguageId, LPSTR lpBuffer, DWORD nSize, ...)
|
||||
{
|
||||
char buff[32];
|
||||
int n;
|
||||
|
||||
//if (dwFlags & FORMAT_MESSAGE_ALLOCATE_BUFFER)
|
||||
// return 0; /* means error */
|
||||
|
||||
n = sprintf(buff, "Error code: %d", (int) dwMessageId);
|
||||
strncpy(lpBuffer, buff, nSize);
|
||||
return min(n, nSize);
|
||||
} /* end of FormatMessage */
|
||||
#endif
|
||||
|
||||
#endif // UNIX
|
||||
|
||||
@@ -80,7 +80,8 @@ enum TABTYPE {TAB_UNDEF = 0, /* Table of undefined type */
|
||||
TAB_DMY = 25, /* DMY Dummy tables NIY */
|
||||
TAB_JDBC = 26, /* Table accessed via JDBC */
|
||||
TAB_ZIP = 27, /* ZIP file info table */
|
||||
TAB_NIY = 28}; /* Table not implemented yet */
|
||||
// TAB_MONGO = 28, /* Table retrieved from MongoDB */
|
||||
TAB_NIY = 30}; /* Table not implemented yet */
|
||||
|
||||
enum AMT {TYPE_AM_ERROR = 0, /* Type not defined */
|
||||
TYPE_AM_ROWID = 1, /* ROWID type (special column) */
|
||||
@@ -143,7 +144,8 @@ enum AMT {TYPE_AM_ERROR = 0, /* Type not defined */
|
||||
TYPE_AM_MYX = 193, /* MYSQL EXEC access method type */
|
||||
TYPE_AM_CAT = 195, /* Catalog access method type no */
|
||||
TYPE_AM_ZIP = 198, /* ZIP access method type no */
|
||||
TYPE_AM_OUT = 200}; /* Output relations (storage) */
|
||||
TYPE_AM_MGO = 199, /* MGO access method type no */
|
||||
TYPE_AM_OUT = 200}; /* Output relations (storage) */
|
||||
|
||||
enum RECFM {RECFM_NAF = -2, /* Not a file */
|
||||
RECFM_OEM = -1, /* OEM file access method */
|
||||
@@ -553,7 +555,7 @@ typedef struct _qryres {
|
||||
typedef struct _colres {
|
||||
PCOLRES Next; /* To next result column */
|
||||
PCOL Colp; /* To matching column block */
|
||||
PSZ Name; /* Column header */
|
||||
PCSZ Name; /* Column header */
|
||||
PVBLK Kdata; /* Column block of values */
|
||||
char *Nulls; /* Column null value array */
|
||||
int Type; /* Internal type */
|
||||
@@ -583,7 +585,7 @@ void PlugLineDB(PGLOBAL, PSZ, short, void *, uint);
|
||||
char *SetPath(PGLOBAL g, const char *path);
|
||||
char *ExtractFromPath(PGLOBAL, char *, char *, OPVAL);
|
||||
void AddPointer(PTABS, void *);
|
||||
PDTP MakeDateFormat(PGLOBAL, PSZ, bool, bool, int);
|
||||
PDTP MakeDateFormat(PGLOBAL, PCSZ, bool, bool, int);
|
||||
int ExtractDate(char *, PDTP, int, int val[6]);
|
||||
|
||||
/**************************************************************************/
|
||||
@@ -615,11 +617,10 @@ DllExport void *PlgDBrealloc(PGLOBAL, void *, MBLOCK&, size_t);
|
||||
DllExport void NewPointer(PTABS, void *, void *);
|
||||
//lExport char *GetIni(int n= 0); // Not used anymore
|
||||
DllExport void SetTrc(void);
|
||||
DllExport char *GetListOption(PGLOBAL, const char *, const char *,
|
||||
const char *def=NULL);
|
||||
DllExport char *GetStringTableOption(PGLOBAL, PTOS, char *, char *);
|
||||
DllExport bool GetBooleanTableOption(PGLOBAL, PTOS, char *, bool);
|
||||
DllExport int GetIntegerTableOption(PGLOBAL, PTOS, char *, int);
|
||||
DllExport PCSZ GetListOption(PGLOBAL, PCSZ, PCSZ, PCSZ def=NULL);
|
||||
DllExport PCSZ GetStringTableOption(PGLOBAL, PTOS, PCSZ, PCSZ);
|
||||
DllExport bool GetBooleanTableOption(PGLOBAL, PTOS, PCSZ, bool);
|
||||
DllExport int GetIntegerTableOption(PGLOBAL, PTOS, PCSZ, int);
|
||||
|
||||
#define MSGID_NONE 0
|
||||
#define MSGID_CANNOT_OPEN 1
|
||||
|
||||
@@ -238,88 +238,84 @@ void ptrc(char const *fmt, ...)
|
||||
PQRYRES PlgAllocResult(PGLOBAL g, int ncol, int maxres, int ids,
|
||||
int *buftyp, XFLD *fldtyp,
|
||||
unsigned int *length, bool blank, bool nonull)
|
||||
{
|
||||
{
|
||||
char cname[NAM_LEN+1];
|
||||
int i;
|
||||
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
|
||||
try {
|
||||
/**********************************************************************/
|
||||
/* Allocate the structure used to contain the result set. */
|
||||
/**********************************************************************/
|
||||
qrp = (PQRYRES)PlugSubAlloc(g, NULL, sizeof(QRYRES));
|
||||
pcrp = &qrp->Colresp;
|
||||
qrp->Continued = false;
|
||||
qrp->Truncated = false;
|
||||
qrp->Info = false;
|
||||
qrp->Suball = true;
|
||||
qrp->Maxres = maxres;
|
||||
qrp->Maxsize = 0;
|
||||
qrp->Nblin = 0;
|
||||
qrp->Nbcol = 0; // will be ncol
|
||||
qrp->Cursor = 0;
|
||||
qrp->BadLines = 0;
|
||||
|
||||
if (setjmp(g->jumper[++g->jump_level]) != 0) {
|
||||
printf("%s\n", g->Message);
|
||||
qrp = NULL;
|
||||
goto fin;
|
||||
} // endif rc
|
||||
for (i = 0; i < ncol; i++) {
|
||||
*pcrp = (PCOLRES)PlugSubAlloc(g, NULL, sizeof(COLRES));
|
||||
crp = *pcrp;
|
||||
pcrp = &crp->Next;
|
||||
memset(crp, 0, sizeof(COLRES));
|
||||
crp->Colp = NULL;
|
||||
crp->Ncol = ++qrp->Nbcol;
|
||||
crp->Type = buftyp[i];
|
||||
crp->Length = length[i];
|
||||
crp->Clen = GetTypeSize(crp->Type, length[i]);
|
||||
crp->Prec = 0;
|
||||
|
||||
/************************************************************************/
|
||||
/* Allocate the structure used to contain the result set. */
|
||||
/************************************************************************/
|
||||
qrp = (PQRYRES)PlugSubAlloc(g, NULL, sizeof(QRYRES));
|
||||
pcrp = &qrp->Colresp;
|
||||
qrp->Continued = false;
|
||||
qrp->Truncated = false;
|
||||
qrp->Info = false;
|
||||
qrp->Suball = true;
|
||||
qrp->Maxres = maxres;
|
||||
qrp->Maxsize = 0;
|
||||
qrp->Nblin = 0;
|
||||
qrp->Nbcol = 0; // will be ncol
|
||||
qrp->Cursor = 0;
|
||||
qrp->BadLines = 0;
|
||||
|
||||
for (i = 0; i < ncol; i++) {
|
||||
*pcrp = (PCOLRES)PlugSubAlloc(g, NULL, sizeof(COLRES));
|
||||
crp = *pcrp;
|
||||
pcrp = &crp->Next;
|
||||
memset(crp, 0, sizeof(COLRES));
|
||||
crp->Colp = NULL;
|
||||
crp->Ncol = ++qrp->Nbcol;
|
||||
crp->Type = buftyp[i];
|
||||
crp->Length = length[i];
|
||||
crp->Clen = GetTypeSize(crp->Type, length[i]);
|
||||
crp->Prec = 0;
|
||||
|
||||
if (ids > 0) {
|
||||
if (ids > 0) {
|
||||
#if defined(XMSG)
|
||||
// Get header from message file
|
||||
strncpy(cname, PlugReadMessage(g, ids + crp->Ncol, NULL), NAM_LEN);
|
||||
cname[NAM_LEN] = 0; // for truncated long names
|
||||
// Get header from message file
|
||||
strncpy(cname, PlugReadMessage(g, ids + crp->Ncol, NULL), NAM_LEN);
|
||||
cname[NAM_LEN] = 0; // for truncated long names
|
||||
#else // !XMSG
|
||||
GetRcString(ids + crp->Ncol, cname, sizeof(cname));
|
||||
GetRcString(ids + crp->Ncol, cname, sizeof(cname));
|
||||
#endif // !XMSG
|
||||
crp->Name = (PSZ)PlugDup(g, cname);
|
||||
} else
|
||||
crp->Name = NULL; // Will be set by caller
|
||||
crp->Name = (PSZ)PlugDup(g, cname);
|
||||
} else
|
||||
crp->Name = NULL; // Will be set by caller
|
||||
|
||||
if (fldtyp)
|
||||
crp->Fld = fldtyp[i];
|
||||
else
|
||||
crp->Fld = FLD_NO;
|
||||
if (fldtyp)
|
||||
crp->Fld = fldtyp[i];
|
||||
else
|
||||
crp->Fld = FLD_NO;
|
||||
|
||||
// Allocate the Value Block that will contain data
|
||||
if (crp->Length || nonull)
|
||||
crp->Kdata = AllocValBlock(g, NULL, crp->Type, maxres,
|
||||
crp->Length, 0, true, blank, false);
|
||||
else
|
||||
crp->Kdata = NULL;
|
||||
// Allocate the Value Block that will contain data
|
||||
if (crp->Length || nonull)
|
||||
crp->Kdata = AllocValBlock(g, NULL, crp->Type, maxres,
|
||||
crp->Length, 0, true, blank, false);
|
||||
else
|
||||
crp->Kdata = NULL;
|
||||
|
||||
if (trace)
|
||||
htrc("Column(%d) %s type=%d len=%d value=%p\n",
|
||||
crp->Ncol, crp->Name, crp->Type, crp->Length, crp->Kdata);
|
||||
if (trace)
|
||||
htrc("Column(%d) %s type=%d len=%d value=%p\n",
|
||||
crp->Ncol, crp->Name, crp->Type, crp->Length, crp->Kdata);
|
||||
|
||||
} // endfor i
|
||||
} // endfor i
|
||||
|
||||
*pcrp = NULL;
|
||||
*pcrp = NULL;
|
||||
|
||||
fin:
|
||||
g->jump_level--;
|
||||
return qrp;
|
||||
} // end of PlgAllocResult
|
||||
} catch (int n) {
|
||||
htrc("Exception %d: %s\n", n, g->Message);
|
||||
qrp = NULL;
|
||||
} catch (const char *msg) {
|
||||
strcpy(g->Message, msg);
|
||||
htrc("%s\n", g->Message);
|
||||
qrp = NULL;
|
||||
} // end catch
|
||||
|
||||
return qrp;
|
||||
} // end of PlgAllocResult
|
||||
|
||||
/***********************************************************************/
|
||||
/* Allocate and initialize the new DB User Block. */
|
||||
@@ -365,8 +361,8 @@ PCATLG PlgGetCatalog(PGLOBAL g, bool jump)
|
||||
if (!cat && jump) {
|
||||
// Raise exception so caller doesn't have to check return value
|
||||
strcpy(g->Message, MSG(NO_ACTIVE_DB));
|
||||
longjmp(g->jumper[g->jump_level], 1);
|
||||
} // endif cat
|
||||
throw 1;
|
||||
} // endif cat
|
||||
|
||||
return cat;
|
||||
} // end of PlgGetCatalog
|
||||
@@ -391,26 +387,27 @@ char *SetPath(PGLOBAL g, const char *path)
|
||||
char *buf= NULL;
|
||||
|
||||
if (path) {
|
||||
size_t len= strlen(path) + (*path != '.' ? 4 : 1);
|
||||
size_t len = strlen(path) + (*path != '.' ? 4 : 1);
|
||||
|
||||
if (!(buf = (char*)PlgDBSubAlloc(g, NULL, len)))
|
||||
return NULL;
|
||||
|
||||
buf= (char*)PlugSubAlloc(g, NULL, len);
|
||||
|
||||
if (PlugIsAbsolutePath(path)) {
|
||||
strcpy(buf, path);
|
||||
return buf;
|
||||
} // endif path
|
||||
strcpy(buf, path);
|
||||
return buf;
|
||||
} // endif path
|
||||
|
||||
if (*path != '.') {
|
||||
#if defined(__WIN__)
|
||||
char *s= "\\";
|
||||
const char *s = "\\";
|
||||
#else // !__WIN__
|
||||
char *s= "/";
|
||||
const char *s = "/";
|
||||
#endif // !__WIN__
|
||||
strcat(strcat(strcat(strcpy(buf, "."), s), path), s);
|
||||
} else
|
||||
strcpy(buf, path);
|
||||
|
||||
} // endif path
|
||||
} // endif path
|
||||
|
||||
return buf;
|
||||
} // end of SetPath
|
||||
@@ -448,7 +445,7 @@ char *ExtractFromPath(PGLOBAL g, char *pBuff, char *FileName, OPVAL op)
|
||||
static bool PlugCheckPattern(PGLOBAL g, LPCSTR string, LPCSTR pat)
|
||||
{
|
||||
if (pat && strlen(pat)) {
|
||||
// This leaves 512 bytes (MAX_STR / 2) for each components
|
||||
// This leaves 2048 bytes (MAX_STR / 2) for each components
|
||||
LPSTR name = g->Message + MAX_STR / 2;
|
||||
|
||||
strlwr(strcpy(name, string));
|
||||
@@ -476,8 +473,8 @@ bool PlugEvalLike(PGLOBAL g, LPCSTR strg, LPCSTR pat, bool ci)
|
||||
tp = g->Message;
|
||||
else if (!(tp = new char[strlen(pat) + strlen(strg) + 2])) {
|
||||
strcpy(g->Message, MSG(NEW_RETURN_NULL));
|
||||
longjmp(g->jumper[g->jump_level], OP_LIKE);
|
||||
} /* endif tp */
|
||||
throw OP_LIKE;
|
||||
} /* endif tp */
|
||||
|
||||
sp = tp + strlen(pat) + 1;
|
||||
strlwr(strcpy(tp, pat)); /* Make a lower case copy of pat */
|
||||
@@ -487,8 +484,8 @@ bool PlugEvalLike(PGLOBAL g, LPCSTR strg, LPCSTR pat, bool ci)
|
||||
tp = g->Message; /* Use this as temporary work space. */
|
||||
else if (!(tp = new char[strlen(pat) + 1])) {
|
||||
strcpy(g->Message, MSG(NEW_RETURN_NULL));
|
||||
longjmp(g->jumper[g->jump_level], OP_LIKE);
|
||||
} /* endif tp */
|
||||
throw OP_LIKE;
|
||||
} /* endif tp */
|
||||
|
||||
strcpy(tp, pat); /* Make a copy to be worked into */
|
||||
sp = (char*)strg;
|
||||
@@ -676,7 +673,7 @@ void PlugConvertConstant(PGLOBAL g, void* & value, short& type)
|
||||
/* format and a Strftime output format. Flag if not 0 indicates that */
|
||||
/* non quoted blanks are not included in the output format. */
|
||||
/***********************************************************************/
|
||||
PDTP MakeDateFormat(PGLOBAL g, PSZ dfmt, bool in, bool out, int flag)
|
||||
PDTP MakeDateFormat(PGLOBAL g, PCSZ dfmt, bool in, bool out, int flag)
|
||||
{
|
||||
int rc;
|
||||
PDTP pdp = (PDTP)PlugSubAlloc(g, NULL, sizeof(DATPAR));
|
||||
@@ -685,7 +682,7 @@ PDTP MakeDateFormat(PGLOBAL g, PSZ dfmt, bool in, bool out, int flag)
|
||||
htrc("MakeDateFormat: dfmt=%s\n", dfmt);
|
||||
|
||||
memset(pdp, 0, sizeof(DATPAR));
|
||||
pdp->Format = pdp->Curp = dfmt;
|
||||
pdp->Format = pdp->Curp = PlugDup(g, dfmt);
|
||||
pdp->Outsize = 2 * strlen(dfmt) + 1;
|
||||
|
||||
if (in)
|
||||
@@ -727,10 +724,11 @@ PDTP MakeDateFormat(PGLOBAL g, PSZ dfmt, bool in, bool out, int flag)
|
||||
/***********************************************************************/
|
||||
int ExtractDate(char *dts, PDTP pdp, int defy, int val[6])
|
||||
{
|
||||
char *fmt, c, d, e, W[8][12];
|
||||
int i, k, m, numval;
|
||||
int n, y = 30;
|
||||
bool b = true; // true for null dates
|
||||
PCSZ fmt;
|
||||
char c, d, e, W[8][12];
|
||||
int i, k, m, numval;
|
||||
int n, y = 30;
|
||||
bool b = true; // true for null dates
|
||||
|
||||
if (pdp)
|
||||
fmt = pdp->InFmt;
|
||||
@@ -1255,7 +1253,7 @@ void *PlgDBalloc(PGLOBAL g, void *area, MBLOCK& mp)
|
||||
// in the area, do allocate from virtual storage.
|
||||
#if defined(__WIN__)
|
||||
if (mp.Size >= BIGMEM)
|
||||
mp.Memp = VirtualAlloc(NULL, mp.Size, MEM_COMMIT, PAGE_READWRITE);
|
||||
mp.Memp = VirtualAlloc(NULL, mp.Size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
|
||||
else
|
||||
#endif
|
||||
mp.Memp = malloc(mp.Size);
|
||||
@@ -1520,8 +1518,8 @@ DllExport void NewPointer(PTABS t, void *oldv, void *newv)
|
||||
PGLOBAL g = t->G;
|
||||
|
||||
sprintf(g->Message, "NewPointer: %s", MSG(MEM_ALLOC_ERROR));
|
||||
longjmp(g->jumper[g->jump_level], 3);
|
||||
} else {
|
||||
throw 3;
|
||||
} else {
|
||||
tp->Next = t->P1;
|
||||
tp->Num = 0;
|
||||
t->P1 = tp;
|
||||
@@ -1557,15 +1555,15 @@ int FileComp(PGLOBAL g, char *file1, char *file2)
|
||||
sprintf(g->Message, MSG(OPEN_MODE_ERROR),
|
||||
"rb", (int)errno, fn[i]);
|
||||
strcat(strcat(g->Message, ": "), strerror(errno));
|
||||
longjmp(g->jumper[g->jump_level], 666);
|
||||
// } else
|
||||
throw 666;
|
||||
// } else
|
||||
// len[i] = 0; // File does not exist yet
|
||||
|
||||
} else {
|
||||
if ((len[i] = _filelength(h[i])) < 0) {
|
||||
sprintf(g->Message, MSG(FILELEN_ERROR), "_filelength", fn[i]);
|
||||
longjmp(g->jumper[g->jump_level], 666);
|
||||
} // endif len
|
||||
throw 666;
|
||||
} // endif len
|
||||
|
||||
} // endif h
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ XMLDOCUMENT::XMLDOCUMENT(char *nsl, char *nsdf, char *enc)
|
||||
/******************************************************************/
|
||||
/* Initialize zipped file processing. */
|
||||
/******************************************************************/
|
||||
bool XMLDOCUMENT::InitZip(PGLOBAL g, char *entry)
|
||||
bool XMLDOCUMENT::InitZip(PGLOBAL g, PCSZ entry)
|
||||
{
|
||||
#if defined(ZIP_SUPPORT)
|
||||
bool mul = (entry) ? strchr(entry, '*') || strchr(entry, '?') : false;
|
||||
@@ -173,7 +173,7 @@ void XMLNODE::Delete(PXNODE dnp)
|
||||
/******************************************************************/
|
||||
/* Store a string in Buf, enventually reallocating it. */
|
||||
/******************************************************************/
|
||||
char *XMLNODE::BufAlloc(PGLOBAL g, char *p, int n)
|
||||
char *XMLNODE::BufAlloc(PGLOBAL g, const char *p, int n)
|
||||
{
|
||||
if (Len < n) {
|
||||
Len = n;
|
||||
|
||||
@@ -76,9 +76,9 @@ class XMLDOCUMENT : public BLOCK {
|
||||
virtual void SetNofree(bool b) = 0;
|
||||
|
||||
// Methods
|
||||
virtual bool Initialize(PGLOBAL, char *, bool) = 0;
|
||||
virtual bool Initialize(PGLOBAL, PCSZ, bool) = 0;
|
||||
virtual bool ParseFile(PGLOBAL, char *) = 0;
|
||||
virtual bool NewDoc(PGLOBAL, char *) = 0;
|
||||
virtual bool NewDoc(PGLOBAL, PCSZ) = 0;
|
||||
virtual void AddComment(PGLOBAL, char *) = 0;
|
||||
virtual PXNODE GetRoot(PGLOBAL) = 0;
|
||||
virtual PXNODE NewRoot(PGLOBAL, char *) = 0;
|
||||
@@ -95,7 +95,7 @@ class XMLDOCUMENT : public BLOCK {
|
||||
|
||||
// Utility
|
||||
bool MakeNSlist(PGLOBAL g);
|
||||
bool InitZip(PGLOBAL g, char *entry);
|
||||
bool InitZip(PGLOBAL g, PCSZ entry);
|
||||
char *GetMemDoc(PGLOBAL g, char *fn);
|
||||
void CloseZip(void);
|
||||
|
||||
@@ -131,15 +131,15 @@ class XMLNODE : public BLOCK {
|
||||
virtual PXLIST SelectNodes(PGLOBAL, char *, PXLIST = NULL) = 0;
|
||||
virtual PXNODE SelectSingleNode(PGLOBAL, char *, PXNODE = NULL) = 0;
|
||||
virtual PXATTR GetAttribute(PGLOBAL, char *, PXATTR = NULL) = 0;
|
||||
virtual PXNODE AddChildNode(PGLOBAL, char *, PXNODE = NULL) = 0;
|
||||
virtual PXNODE AddChildNode(PGLOBAL, PCSZ, PXNODE = NULL) = 0;
|
||||
virtual PXATTR AddProperty(PGLOBAL, char *, PXATTR = NULL) = 0;
|
||||
virtual void AddText(PGLOBAL, char *) = 0;
|
||||
virtual void AddText(PGLOBAL, PCSZ) = 0;
|
||||
virtual void DeleteChild(PGLOBAL, PXNODE) = 0;
|
||||
|
||||
protected:
|
||||
PXNODE NewChild(PXNODE ncp);
|
||||
void Delete(PXNODE dnp);
|
||||
char *BufAlloc(PGLOBAL g, char *p, int n);
|
||||
char *BufAlloc(PGLOBAL g, const char *p, int n);
|
||||
|
||||
// Constructor
|
||||
XMLNODE(PXDOC dp);
|
||||
|
||||
@@ -139,31 +139,39 @@ PGLOBAL PlugInit(LPCSTR Language, uint worksize)
|
||||
htrc("PlugInit: Language='%s'\n",
|
||||
((!Language) ? "Null" : (char*)Language));
|
||||
|
||||
if (!(g = malloc(sizeof(GLOBAL)))) {
|
||||
fprintf(stderr, MSG(GLOBAL_ERROR), (int)sizeof(GLOBAL));
|
||||
return NULL;
|
||||
} else {
|
||||
try {
|
||||
g = new GLOBAL;
|
||||
} catch (...) {
|
||||
fprintf(stderr, MSG(GLOBAL_ERROR), (int)sizeof(GLOBAL));
|
||||
return NULL;
|
||||
} // end try/catch
|
||||
|
||||
//if (!(g = (PGLOBAL)malloc(sizeof(GLOBAL)))) {
|
||||
// fprintf(stderr, MSG(GLOBAL_ERROR), (int)sizeof(GLOBAL));
|
||||
// return NULL;
|
||||
// } else {
|
||||
g->Sarea = NULL;
|
||||
g->Createas = 0;
|
||||
g->Alchecked = 0;
|
||||
g->Mrr = 0;
|
||||
g->Activityp = g->ActivityStart = NULL;
|
||||
g->Activityp = NULL;
|
||||
g->Xchk = NULL;
|
||||
g->N = 0;
|
||||
g->More = 0;
|
||||
strcpy(g->Message, "");
|
||||
|
||||
/*******************************************************************/
|
||||
/* Allocate the main work segment. */
|
||||
/*******************************************************************/
|
||||
if (worksize && !(g->Sarea = PlugAllocMem(g, worksize))) {
|
||||
char errmsg[256];
|
||||
char errmsg[MAX_STR];
|
||||
sprintf(errmsg, MSG(WORK_AREA), g->Message);
|
||||
strcpy(g->Message, errmsg);
|
||||
g->Sarea_Size = 0;
|
||||
} else
|
||||
g->Sarea_Size = worksize;
|
||||
|
||||
} /* endif g */
|
||||
//} /* endif g */
|
||||
|
||||
g->jump_level = -1; /* New setting to allow recursive call of Plug */
|
||||
return(g);
|
||||
@@ -182,7 +190,7 @@ int PlugExit(PGLOBAL g)
|
||||
if (g->Sarea)
|
||||
free(g->Sarea);
|
||||
|
||||
free(g);
|
||||
delete g;
|
||||
return rc;
|
||||
} /* end of PlugExit */
|
||||
|
||||
@@ -475,7 +483,7 @@ void *PlugAllocMem(PGLOBAL g, uint size)
|
||||
/***********************************************************************/
|
||||
BOOL PlugSubSet(PGLOBAL g __attribute__((unused)), void *memp, uint size)
|
||||
{
|
||||
PPOOLHEADER pph = memp;
|
||||
PPOOLHEADER pph = (PPOOLHEADER)memp;
|
||||
|
||||
pph->To_Free = (OFFSET)sizeof(POOLHEADER);
|
||||
pph->FreeBlk = size - pph->To_Free;
|
||||
@@ -501,7 +509,6 @@ void *PlugSubAlloc(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 */
|
||||
pph = (PPOOLHEADER)memp;
|
||||
|
||||
@@ -510,26 +517,24 @@ void *PlugSubAlloc(PGLOBAL g, void *memp, size_t size)
|
||||
memp, size, pph->To_Free, pph->FreeBlk);
|
||||
|
||||
if ((uint)size > pph->FreeBlk) { /* Not enough memory left in pool */
|
||||
char *pname = "Work";
|
||||
PCSZ pname = "Work";
|
||||
|
||||
sprintf(g->Message,
|
||||
"Not enough memory in %s area for request of %u (used=%d free=%d)",
|
||||
pname, (uint) size, pph->To_Free, pph->FreeBlk);
|
||||
pname, (uint)size, pph->To_Free, pph->FreeBlk);
|
||||
|
||||
if (trace)
|
||||
htrc("PlugSubAlloc: %s\n", g->Message);
|
||||
|
||||
/* Nothing we can do if longjmp is not initialized. */
|
||||
assert(g->jump_level >= 0);
|
||||
longjmp(g->jumper[g->jump_level], 1);
|
||||
throw 1234;
|
||||
} /* endif size OS32 code */
|
||||
|
||||
/*********************************************************************/
|
||||
/* Do the suballocation the simplest way. */
|
||||
/*********************************************************************/
|
||||
memp = MakePtr(memp, pph->To_Free); /* Points to suballocated block */
|
||||
pph->To_Free += size; /* New offset of pool free block */
|
||||
pph->FreeBlk -= size; /* New size of pool free block */
|
||||
pph->To_Free += (OFFSET)size; /* New offset of pool free block */
|
||||
pph->FreeBlk -= (uint)size; /* New size of pool free block */
|
||||
|
||||
if (trace > 3)
|
||||
htrc("Done memp=%p used=%d free=%d\n",
|
||||
@@ -7,14 +7,14 @@
|
||||
/* Struct of variables used by the date format pre-parser. */
|
||||
/***********************************************************************/
|
||||
typedef struct _datpar {
|
||||
char *Format; // Points to format to decode
|
||||
const char *Format; // Points to format to decode
|
||||
char *Curp; // Points to current parsing position
|
||||
char *InFmt; // Start of input format
|
||||
char *OutFmt; // Start of output format
|
||||
int Index[8]; // Indexes of date values
|
||||
int Num; // Number of values to retrieve
|
||||
int Flag; // 1: Input, 2: Output, 4: no output blank
|
||||
int Outsize; // Size of output buffers
|
||||
int Outsize; // Size of output buffers
|
||||
} DATPAR, *PDTP;
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
@@ -88,7 +88,7 @@ PTOS RELDEF::GetTopt(void)
|
||||
/***********************************************************************/
|
||||
/* This function sets an integer table information. */
|
||||
/***********************************************************************/
|
||||
bool RELDEF::SetIntCatInfo(PSZ what, int n)
|
||||
bool RELDEF::SetIntCatInfo(PCSZ what, int n)
|
||||
{
|
||||
return Hc->SetIntegerOption(what, n);
|
||||
} // end of SetIntCatInfo
|
||||
@@ -96,7 +96,7 @@ bool RELDEF::SetIntCatInfo(PSZ what, int n)
|
||||
/***********************************************************************/
|
||||
/* This function returns integer table information. */
|
||||
/***********************************************************************/
|
||||
int RELDEF::GetIntCatInfo(PSZ what, int idef)
|
||||
int RELDEF::GetIntCatInfo(PCSZ what, int idef)
|
||||
{
|
||||
int n= Hc->GetIntegerOption(what);
|
||||
|
||||
@@ -106,7 +106,7 @@ int RELDEF::GetIntCatInfo(PSZ what, int idef)
|
||||
/***********************************************************************/
|
||||
/* This function returns Boolean table information. */
|
||||
/***********************************************************************/
|
||||
bool RELDEF::GetBoolCatInfo(PSZ what, bool bdef)
|
||||
bool RELDEF::GetBoolCatInfo(PCSZ what, bool bdef)
|
||||
{
|
||||
bool b= Hc->GetBooleanOption(what, bdef);
|
||||
|
||||
@@ -116,9 +116,10 @@ bool RELDEF::GetBoolCatInfo(PSZ what, bool bdef)
|
||||
/***********************************************************************/
|
||||
/* This function returns size catalog information. */
|
||||
/***********************************************************************/
|
||||
int RELDEF::GetSizeCatInfo(PSZ what, PSZ sdef)
|
||||
int RELDEF::GetSizeCatInfo(PCSZ what, PCSZ sdef)
|
||||
{
|
||||
char * s, c;
|
||||
char c;
|
||||
PCSZ s;
|
||||
int i, n= 0;
|
||||
|
||||
if (!(s= Hc->GetStringOption(what)))
|
||||
@@ -139,9 +140,9 @@ int RELDEF::GetSizeCatInfo(PSZ what, PSZ sdef)
|
||||
/***********************************************************************/
|
||||
/* This function sets char table information in buf. */
|
||||
/***********************************************************************/
|
||||
int RELDEF::GetCharCatInfo(PSZ what, PSZ sdef, char *buf, int size)
|
||||
int RELDEF::GetCharCatInfo(PCSZ what, PCSZ sdef, char *buf, int size)
|
||||
{
|
||||
char *s= Hc->GetStringOption(what);
|
||||
PCSZ s= Hc->GetStringOption(what);
|
||||
|
||||
strncpy(buf, ((s) ? s : sdef), size);
|
||||
return size;
|
||||
@@ -159,9 +160,10 @@ bool RELDEF::Partitioned(void)
|
||||
/* This function returns string table information. */
|
||||
/* Default parameter is "*" to get the handler default. */
|
||||
/***********************************************************************/
|
||||
char *RELDEF::GetStringCatInfo(PGLOBAL g, PSZ what, PSZ sdef)
|
||||
char *RELDEF::GetStringCatInfo(PGLOBAL g, PCSZ what, PCSZ sdef)
|
||||
{
|
||||
char *name, *sval= NULL, *s= Hc->GetStringOption(what, sdef);
|
||||
char *sval = NULL;
|
||||
PCSZ name, s= Hc->GetStringOption(what, sdef);
|
||||
|
||||
if (s) {
|
||||
if (!Hc->IsPartitioned() ||
|
||||
@@ -169,12 +171,12 @@ char *RELDEF::GetStringCatInfo(PGLOBAL g, PSZ what, PSZ sdef)
|
||||
&& stricmp(what, "connect")))
|
||||
sval= PlugDup(g, s);
|
||||
else
|
||||
sval= s;
|
||||
sval= (char*)s;
|
||||
|
||||
} else if (!stricmp(what, "filename")) {
|
||||
// Return default file name
|
||||
char *ftype= Hc->GetStringOption("Type", "*");
|
||||
int i, n;
|
||||
PCSZ ftype= Hc->GetStringOption("Type", "*");
|
||||
int i, n;
|
||||
|
||||
if (IsFileType(GetTypeID(ftype))) {
|
||||
name= Hc->GetPartName();
|
||||
@@ -252,9 +254,9 @@ bool TABDEF::Define(PGLOBAL g, PCATLG cat,
|
||||
/***********************************************************************/
|
||||
/* This function returns the database data path. */
|
||||
/***********************************************************************/
|
||||
PSZ TABDEF::GetPath(void)
|
||||
PCSZ TABDEF::GetPath(void)
|
||||
{
|
||||
return (Database) ? (PSZ)Database : (Hc) ? Hc->GetDataPath() : NULL;
|
||||
return (Database) ? Database : (Hc) ? Hc->GetDataPath() : NULL;
|
||||
} // end of GetPath
|
||||
|
||||
/***********************************************************************/
|
||||
@@ -278,8 +280,13 @@ int TABDEF::GetColCatInfo(PGLOBAL g)
|
||||
// Take care of the column definitions
|
||||
i= poff= nof= nlg= 0;
|
||||
|
||||
#if defined(__WIN__)
|
||||
// Offsets of HTML and DIR tables start from 0, DBF at 1
|
||||
loff= (tc == TAB_DBF) ? 1 : (tc == TAB_XML || tc == TAB_DIR) ? -1 : 0;
|
||||
loff= (tc == TAB_DBF) ? 1 : (tc == TAB_XML || tc == TAB_DIR) ? -1 : 0;
|
||||
#else // !__WIN__
|
||||
// Offsets of HTML tables start from 0, DIR and DBF at 1
|
||||
loff = (tc == TAB_DBF || tc == TAB_DIR) ? 1 : (tc == TAB_XML) ? -1 : 0;
|
||||
#endif // !__WIN__
|
||||
|
||||
while (true) {
|
||||
// Default Offset depends on table type
|
||||
@@ -611,9 +618,10 @@ bool OEMDEF::DefineAM(PGLOBAL g, LPCSTR, int)
|
||||
if (!*Module)
|
||||
Module = Subtype;
|
||||
|
||||
Desc = (char*)PlugSubAlloc(g, NULL, strlen(Module)
|
||||
+ strlen(Subtype) + 3);
|
||||
sprintf(Desc, "%s(%s)", Module, Subtype);
|
||||
char *desc = (char*)PlugSubAlloc(g, NULL, strlen(Module)
|
||||
+ strlen(Subtype) + 3);
|
||||
sprintf(desc, "%s(%s)", Module, Subtype);
|
||||
Desc = desc;
|
||||
return false;
|
||||
} // end of DefineAM
|
||||
|
||||
|
||||
@@ -42,13 +42,13 @@ class DllExport RELDEF : public BLOCK { // Relation definition block
|
||||
|
||||
// Methods
|
||||
PTOS GetTopt(void);
|
||||
bool GetBoolCatInfo(PSZ what, bool bdef);
|
||||
bool SetIntCatInfo(PSZ what, int ival);
|
||||
bool GetBoolCatInfo(PCSZ what, bool bdef);
|
||||
bool SetIntCatInfo(PCSZ what, int ival);
|
||||
bool Partitioned(void);
|
||||
int GetIntCatInfo(PSZ what, int idef);
|
||||
int GetSizeCatInfo(PSZ what, PSZ sdef);
|
||||
int GetCharCatInfo(PSZ what, PSZ sdef, char *buf, int size);
|
||||
char *GetStringCatInfo(PGLOBAL g, PSZ what, PSZ sdef);
|
||||
int GetIntCatInfo(PCSZ what, int idef);
|
||||
int GetSizeCatInfo(PCSZ what, PCSZ sdef);
|
||||
int GetCharCatInfo(PCSZ what, PCSZ sdef, char *buf, int size);
|
||||
char *GetStringCatInfo(PGLOBAL g, PCSZ what, PCSZ sdef);
|
||||
virtual int Indexable(void) {return 0;}
|
||||
virtual bool Define(PGLOBAL g, PCATLG cat,
|
||||
LPCSTR name, LPCSTR schema, LPCSTR am) = 0;
|
||||
@@ -84,7 +84,7 @@ public:
|
||||
void SetNext(PTABDEF tdfp) {Next = tdfp;}
|
||||
int GetMultiple(void) {return Multiple;}
|
||||
int GetPseudo(void) {return Pseudo;}
|
||||
PSZ GetPath(void);
|
||||
PCSZ GetPath(void);
|
||||
//PSZ GetPath(void)
|
||||
// {return (Database) ? (PSZ)Database : Cat->GetDataPath();}
|
||||
bool SepIndex(void) {return GetBoolCatInfo("SepIndex", false);}
|
||||
@@ -105,8 +105,8 @@ public:
|
||||
|
||||
protected:
|
||||
// Members
|
||||
PSZ Schema; /* Table schema (for ODBC) */
|
||||
PSZ Desc; /* Table description */
|
||||
PCSZ Schema; /* Table schema (for ODBC) */
|
||||
PCSZ Desc; /* Table description */
|
||||
uint Catfunc; /* Catalog function ID */
|
||||
int Card; /* (max) number of rows in table */
|
||||
int Elemt; /* Number of rows in blocks or rowset */
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/************* TabDos C++ Program Source Code File (.CPP) **************/
|
||||
/* PROGRAM NAME: TABDOS */
|
||||
/* ------------- */
|
||||
/* Version 4.9.2 */
|
||||
/* Version 4.9.3 */
|
||||
/* */
|
||||
/* COPYRIGHT: */
|
||||
/* ---------- */
|
||||
/* (C) Copyright to the author Olivier BERTRAND 1998-2016 */
|
||||
/* (C) Copyright to the author Olivier BERTRAND 1998-2017 */
|
||||
/* */
|
||||
/* WHAT THIS PROGRAM DOES: */
|
||||
/* ----------------------- */
|
||||
@@ -98,6 +98,7 @@ DOSDEF::DOSDEF(void)
|
||||
Ofn = NULL;
|
||||
Entry = NULL;
|
||||
To_Indx = NULL;
|
||||
Pwd = NULL;
|
||||
Recfm = RECFM_VAR;
|
||||
Mapped = false;
|
||||
Zipped = false;
|
||||
@@ -131,7 +132,7 @@ bool DOSDEF::DefineAM(PGLOBAL g, LPCSTR am, int)
|
||||
bool map = (am && (*am == 'M' || *am == 'm'));
|
||||
LPCSTR dfm = (am && (*am == 'F' || *am == 'f')) ? "F"
|
||||
: (am && (*am == 'B' || *am == 'b')) ? "B"
|
||||
: (am && !stricmp(am, "DBF")) ? "D" : "V";
|
||||
: (am && !stricmp(am, "DBF")) ? "D" : "V";
|
||||
|
||||
if ((Zipped = GetBoolCatInfo("Zipped", false))) {
|
||||
Entry = GetStringCatInfo(g, "Entry", NULL);
|
||||
@@ -139,14 +140,15 @@ bool DOSDEF::DefineAM(PGLOBAL g, LPCSTR am, int)
|
||||
: false;
|
||||
Mulentries = GetBoolCatInfo("Mulentries", Mulentries);
|
||||
Append = GetBoolCatInfo("Append", false);
|
||||
}
|
||||
Pwd = GetStringCatInfo(g, "Password", NULL);
|
||||
} // endif Zipped
|
||||
|
||||
Desc = Fn = GetStringCatInfo(g, "Filename", NULL);
|
||||
Ofn = GetStringCatInfo(g, "Optname", Fn);
|
||||
GetCharCatInfo("Recfm", (PSZ)dfm, buf, sizeof(buf));
|
||||
Recfm = (toupper(*buf) == 'F') ? RECFM_FIX :
|
||||
(toupper(*buf) == 'B') ? RECFM_BIN :
|
||||
(toupper(*buf) == 'D') ? RECFM_DBF : RECFM_VAR;
|
||||
(toupper(*buf) == 'D') ? RECFM_DBF : RECFM_VAR;
|
||||
Lrecl = GetIntCatInfo("Lrecl", 0);
|
||||
|
||||
if (Recfm != RECFM_DBF)
|
||||
@@ -180,7 +182,7 @@ bool DOSDEF::DefineAM(PGLOBAL g, LPCSTR am, int)
|
||||
/***********************************************************************/
|
||||
bool DOSDEF::GetOptFileName(PGLOBAL g, char *filename)
|
||||
{
|
||||
char *ftype;
|
||||
PCSZ ftype;
|
||||
|
||||
switch (Recfm) {
|
||||
case RECFM_VAR: ftype = ".dop"; break;
|
||||
@@ -237,9 +239,9 @@ void DOSDEF::RemoveOptValues(PGLOBAL g)
|
||||
/***********************************************************************/
|
||||
bool DOSDEF::DeleteIndexFile(PGLOBAL g, PIXDEF pxdf)
|
||||
{
|
||||
char *ftype;
|
||||
char filename[_MAX_PATH];
|
||||
bool sep, rc = false;
|
||||
PCSZ ftype;
|
||||
char filename[_MAX_PATH];
|
||||
bool sep, rc = false;
|
||||
|
||||
if (!To_Indx)
|
||||
return false; // No index
|
||||
@@ -351,7 +353,7 @@ PTDB DOSDEF::GetTable(PGLOBAL g, MODE mode)
|
||||
if (Zipped) {
|
||||
#if defined(ZIP_SUPPORT)
|
||||
if (Recfm == RECFM_VAR) {
|
||||
if (mode == MODE_READ || mode == MODE_ANY) {
|
||||
if (mode == MODE_READ || mode == MODE_ANY || mode == MODE_ALTER) {
|
||||
txfp = new(g) UNZFAM(this);
|
||||
} else if (mode == MODE_INSERT) {
|
||||
txfp = new(g) ZIPFAM(this);
|
||||
@@ -362,7 +364,7 @@ PTDB DOSDEF::GetTable(PGLOBAL g, MODE mode)
|
||||
|
||||
tdbp = new(g) TDBDOS(this, txfp);
|
||||
} else {
|
||||
if (mode == MODE_READ || mode == MODE_ANY) {
|
||||
if (mode == MODE_READ || mode == MODE_ANY || mode == MODE_ALTER) {
|
||||
txfp = new(g) UZXFAM(this);
|
||||
} else if (mode == MODE_INSERT) {
|
||||
txfp = new(g) ZPXFAM(this);
|
||||
@@ -1510,8 +1512,8 @@ PBF TDBDOS::CheckBlockFilari(PGLOBAL g, PXOB *arg, int op, bool *cnv)
|
||||
if (n == 8 && ctype != TYPE_LIST) {
|
||||
// Should never happen
|
||||
strcpy(g->Message, "Block opt: bad constant");
|
||||
longjmp(g->jumper[g->jump_level], 99);
|
||||
} // endif Conv
|
||||
throw 99;
|
||||
} // endif Conv
|
||||
|
||||
if (type[0] == 1) {
|
||||
// Make it always as Column-op-Value
|
||||
@@ -1791,8 +1793,8 @@ err:
|
||||
/* Make a dynamic index. */
|
||||
/***********************************************************************/
|
||||
bool TDBDOS::InitialyzeIndex(PGLOBAL g, volatile PIXDEF xdp, bool sorted)
|
||||
{
|
||||
int k, rc;
|
||||
{
|
||||
int k;
|
||||
volatile bool dynamic;
|
||||
bool brc;
|
||||
PCOL colp;
|
||||
@@ -1862,13 +1864,7 @@ bool TDBDOS::InitialyzeIndex(PGLOBAL g, volatile PIXDEF xdp, bool sorted)
|
||||
} else // Column contains same values as ROWID
|
||||
kxp = new(g) XXROW(this);
|
||||
|
||||
// Prepare error return
|
||||
if (g->jump_level == MAX_JUMP) {
|
||||
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
|
||||
return true;
|
||||
} // endif
|
||||
|
||||
if (!(rc = setjmp(g->jumper[++g->jump_level])) != 0) {
|
||||
try {
|
||||
if (dynamic) {
|
||||
ResetBlockFilter(g);
|
||||
kxp->SetDynamic(dynamic);
|
||||
@@ -1893,12 +1889,17 @@ bool TDBDOS::InitialyzeIndex(PGLOBAL g, volatile PIXDEF xdp, bool sorted)
|
||||
|
||||
} // endif brc
|
||||
|
||||
} else
|
||||
brc = true;
|
||||
} catch (int n) {
|
||||
if (trace)
|
||||
htrc("Exception %d: %s\n", n, g->Message);
|
||||
brc = true;
|
||||
} catch (const char *msg) {
|
||||
strcpy(g->Message, msg);
|
||||
brc = true;
|
||||
} // end catch
|
||||
|
||||
g->jump_level--;
|
||||
return brc;
|
||||
} // end of InitialyzeIndex
|
||||
return brc;
|
||||
} // end of InitialyzeIndex
|
||||
|
||||
/***********************************************************************/
|
||||
/* DOS GetProgMax: get the max value for progress information. */
|
||||
@@ -2119,7 +2120,8 @@ bool TDBDOS::OpenDB(PGLOBAL g)
|
||||
return false;
|
||||
} // endif use
|
||||
|
||||
if (Mode == MODE_DELETE && !Next && Txfp->GetAmType() != TYPE_AM_DOS) {
|
||||
if (Mode == MODE_DELETE && !Next && Txfp->GetAmType() != TYPE_AM_DOS
|
||||
&& Txfp->GetAmType() != TYPE_AM_MGO) {
|
||||
// Delete all lines. Not handled in MAP or block mode
|
||||
Txfp = new(g) DOSFAM((PDOSDEF)To_Def);
|
||||
Txfp->SetTdbp(this);
|
||||
@@ -2157,16 +2159,18 @@ bool TDBDOS::OpenDB(PGLOBAL g)
|
||||
To_BlkFil = InitBlockFilter(g, To_Filter);
|
||||
|
||||
/*********************************************************************/
|
||||
/* Allocate the line buffer plus a null character. */
|
||||
/*********************************************************************/
|
||||
To_Line = (char*)PlugSubAlloc(g, NULL, Lrecl + 1);
|
||||
/* Lrecl does not include line ending */
|
||||
/*********************************************************************/
|
||||
size_t linelen = Lrecl + ((PDOSDEF)To_Def)->Ending + 1;
|
||||
|
||||
To_Line = (char*)PlugSubAlloc(g, NULL, linelen);
|
||||
|
||||
if (Mode == MODE_INSERT) {
|
||||
// Spaces between fields must be filled with blanks
|
||||
memset(To_Line, ' ', Lrecl);
|
||||
To_Line[Lrecl] = '\0';
|
||||
} else
|
||||
memset(To_Line, 0, Lrecl + 1);
|
||||
memset(To_Line, 0, linelen);
|
||||
|
||||
if (trace)
|
||||
htrc("OpenDos: R%hd mode=%d To_Line=%p\n", Tdb_No, Mode, To_Line);
|
||||
@@ -2305,8 +2309,8 @@ void TDBDOS::CloseDB(PGLOBAL g)
|
||||
/***********************************************************************/
|
||||
/* DOSCOL public constructor (also called by MAPCOL). */
|
||||
/***********************************************************************/
|
||||
DOSCOL::DOSCOL(PGLOBAL g, PCOLDEF cdp, PTDB tp, PCOL cp, int i, PSZ am)
|
||||
: COLBLK(cdp, tp, i)
|
||||
DOSCOL::DOSCOL(PGLOBAL g, PCOLDEF cdp, PTDB tp, PCOL cp, int i, PCSZ am)
|
||||
: COLBLK(cdp, tp, i)
|
||||
{
|
||||
char *p;
|
||||
int prec = Format.Prec;
|
||||
@@ -2336,7 +2340,7 @@ DOSCOL::DOSCOL(PGLOBAL g, PCOLDEF cdp, PTDB tp, PCOL cp, int i, PSZ am)
|
||||
Dval = NULL;
|
||||
Buf = NULL;
|
||||
|
||||
if (txfp->Blocked && Opt && (cdp->GetMin() || cdp->GetDval())) {
|
||||
if (txfp && txfp->Blocked && Opt && (cdp->GetMin() || cdp->GetDval())) {
|
||||
int nblk = txfp->GetBlock();
|
||||
|
||||
Clustered = (cdp->GetXdb2()) ? 2 : 1;
|
||||
@@ -2515,8 +2519,8 @@ void DOSCOL::ReadColumn(PGLOBAL g)
|
||||
if (rc == RC_EF)
|
||||
sprintf(g->Message, MSG(INV_DEF_READ), rc);
|
||||
|
||||
longjmp(g->jumper[g->jump_level], 11);
|
||||
} // endif
|
||||
throw 11;
|
||||
} // endif
|
||||
|
||||
p = tdbp->To_Line + Deplac;
|
||||
field = Long;
|
||||
@@ -2571,8 +2575,8 @@ void DOSCOL::ReadColumn(PGLOBAL g)
|
||||
break;
|
||||
default:
|
||||
sprintf(g->Message, MSG(BAD_RECFM), tdbp->Ftype);
|
||||
longjmp(g->jumper[g->jump_level], 34);
|
||||
} // endswitch Ftype
|
||||
throw 34;
|
||||
} // endswitch Ftype
|
||||
|
||||
// Set null when applicable
|
||||
if (Nullable)
|
||||
@@ -2680,8 +2684,8 @@ void DOSCOL::WriteColumn(PGLOBAL g)
|
||||
break;
|
||||
default:
|
||||
sprintf(g->Message, "Invalid field format for column %s", Name);
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
} // endswitch BufType
|
||||
throw 31;
|
||||
} // endswitch BufType
|
||||
|
||||
p2 = Buf;
|
||||
} else // Standard CONNECT format
|
||||
@@ -2692,8 +2696,8 @@ void DOSCOL::WriteColumn(PGLOBAL g)
|
||||
|
||||
if ((len = strlen(p2)) > field) {
|
||||
sprintf(g->Message, MSG(VALUE_TOO_LONG), p2, Name, field);
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
} else if (Dsp)
|
||||
throw 31;
|
||||
} else if (Dsp)
|
||||
for (i = 0; i < len; i++)
|
||||
if (p2[i] == '.')
|
||||
p2[i] = Dsp;
|
||||
|
||||
@@ -39,9 +39,9 @@ class DllExport DOSDEF : public TABDEF { /* Logical table description */
|
||||
virtual PIXDEF GetIndx(void) {return To_Indx;}
|
||||
virtual void SetIndx(PIXDEF xdp) {To_Indx = xdp;}
|
||||
virtual bool IsHuge(void) {return Huge;}
|
||||
PSZ GetFn(void) {return Fn;}
|
||||
PSZ GetOfn(void) {return Ofn;}
|
||||
PSZ GetEntry(void) {return Entry;}
|
||||
PCSZ GetFn(void) {return Fn;}
|
||||
PCSZ GetOfn(void) {return Ofn;}
|
||||
PCSZ GetEntry(void) {return Entry;}
|
||||
bool GetMul(void) {return Mulentries;}
|
||||
bool GetAppend(void) {return Append;}
|
||||
void SetBlock(int block) { Block = block; }
|
||||
@@ -74,9 +74,10 @@ class DllExport DOSDEF : public TABDEF { /* Logical table description */
|
||||
//virtual bool Erase(char *filename);
|
||||
|
||||
// Members
|
||||
PSZ Fn; /* Path/Name of corresponding file */
|
||||
PSZ Ofn; /* Base Path/Name of matching index files*/
|
||||
PSZ Entry; /* Zip entry name or pattern */
|
||||
PCSZ Fn; /* Path/Name of corresponding file */
|
||||
PCSZ Ofn; /* Base Path/Name of matching index files*/
|
||||
PCSZ Entry; /* Zip entry name or pattern */
|
||||
PCSZ Pwd; /* Zip password */
|
||||
PIXDEF To_Indx; /* To index definitions blocks */
|
||||
RECFM Recfm; /* 0:VAR, 1:FIX, 2:BIN, 3:VCT, 6:DBF */
|
||||
bool Mapped; /* 0: disk file, 1: memory mapped file */
|
||||
@@ -132,8 +133,8 @@ class DllExport TDBDOS : public TDBASE {
|
||||
|
||||
// Implementation
|
||||
virtual AMT GetAmType(void) {return Txfp->GetAmType();}
|
||||
virtual PSZ GetFile(PGLOBAL) {return Txfp->To_File;}
|
||||
virtual void SetFile(PGLOBAL, PSZ fn) {Txfp->To_File = fn;}
|
||||
virtual PCSZ GetFile(PGLOBAL) {return Txfp->To_File;}
|
||||
virtual void SetFile(PGLOBAL, PCSZ fn) {Txfp->To_File = fn;}
|
||||
virtual void SetAbort(bool b) {Abort = b;}
|
||||
virtual RECFM GetFtype(void) {return Ftype;}
|
||||
virtual bool SkipHeader(PGLOBAL) {return false;}
|
||||
@@ -213,7 +214,7 @@ class DllExport DOSCOL : public COLBLK {
|
||||
friend class TDBFIX;
|
||||
public:
|
||||
// Constructors
|
||||
DOSCOL(PGLOBAL g, PCOLDEF cdp, PTDB tp, PCOL cp, int i, PSZ am = "DOS");
|
||||
DOSCOL(PGLOBAL g, PCOLDEF cdp, PTDB tp, PCOL cp, int i, PCSZ am = "DOS");
|
||||
DOSCOL(DOSCOL *colp, PTDB tdbp); // Constructor used in copy process
|
||||
|
||||
// Implementation
|
||||
|
||||
@@ -35,9 +35,9 @@
|
||||
/***********************************************************************/
|
||||
/* CONDFIL Constructor. */
|
||||
/***********************************************************************/
|
||||
CONDFIL::CONDFIL(const Item *cond, uint idx, AMT type)
|
||||
CONDFIL::CONDFIL(uint idx, AMT type)
|
||||
{
|
||||
Cond = cond;
|
||||
//Cond = cond;
|
||||
Idx = idx;
|
||||
Type = type;
|
||||
Op = OP_XX;
|
||||
@@ -61,7 +61,7 @@ int CONDFIL::Init(PGLOBAL g, PHC hc)
|
||||
bool h;
|
||||
|
||||
if (options)
|
||||
alt = GetListOption(g, "Alias", options->oplist, NULL);
|
||||
alt = (char*)GetListOption(g, "Alias", options->oplist, NULL);
|
||||
|
||||
while (alt) {
|
||||
if (!(p = strchr(alt, '='))) {
|
||||
@@ -267,7 +267,7 @@ TDBEXT::TDBEXT(PTDBEXT tdbp) : TDB(tdbp)
|
||||
/******************************************************************/
|
||||
/* Convert an UTF-8 string to latin characters. */
|
||||
/******************************************************************/
|
||||
int TDBEXT::Decode(char *txt, char *buf, size_t n)
|
||||
int TDBEXT::Decode(PCSZ txt, char *buf, size_t n)
|
||||
{
|
||||
uint dummy_errors;
|
||||
uint32 len = copy_and_convert(buf, n, &my_charset_latin1,
|
||||
@@ -285,16 +285,17 @@ int TDBEXT::Decode(char *txt, char *buf, size_t n)
|
||||
/***********************************************************************/
|
||||
bool TDBEXT::MakeSQL(PGLOBAL g, bool cnt)
|
||||
{
|
||||
char *schmp = NULL, *catp = NULL, buf[NAM_LEN * 3];
|
||||
PCSZ schmp = NULL;
|
||||
char *catp = NULL, buf[NAM_LEN * 3];
|
||||
int len;
|
||||
bool oom = false, first = true;
|
||||
bool first = true;
|
||||
PTABLE tablep = To_Table;
|
||||
PCOL colp;
|
||||
|
||||
if (Srcdef) {
|
||||
if ((catp = strstr(Srcdef, "%s"))) {
|
||||
char *fil1, *fil2;
|
||||
PSZ ph = ((EXTDEF*)To_Def)->Phpos;
|
||||
PCSZ ph = ((EXTDEF*)To_Def)->Phpos;
|
||||
|
||||
if (!ph)
|
||||
ph = (strstr(catp + 2, "%s")) ? const_cast<char*>("WH") :
|
||||
@@ -342,7 +343,7 @@ bool TDBEXT::MakeSQL(PGLOBAL g, bool cnt)
|
||||
for (colp = Columns; colp; colp = colp->GetNext())
|
||||
if (!colp->IsSpecial()) {
|
||||
if (!first)
|
||||
oom |= Query->Append(", ");
|
||||
Query->Append(", ");
|
||||
else
|
||||
first = false;
|
||||
|
||||
@@ -351,11 +352,11 @@ bool TDBEXT::MakeSQL(PGLOBAL g, bool cnt)
|
||||
|
||||
if (Quote) {
|
||||
// Put column name between identifier quotes in case in contains blanks
|
||||
oom |= Query->Append(Quote);
|
||||
oom |= Query->Append(buf);
|
||||
oom |= Query->Append(Quote);
|
||||
Query->Append(Quote);
|
||||
Query->Append(buf);
|
||||
Query->Append(Quote);
|
||||
} else
|
||||
oom |= Query->Append(buf);
|
||||
Query->Append(buf);
|
||||
|
||||
((PEXTCOL)colp)->SetRank(++Ncol);
|
||||
} // endif colp
|
||||
@@ -363,13 +364,13 @@ bool TDBEXT::MakeSQL(PGLOBAL g, bool cnt)
|
||||
} else
|
||||
// !Columns can occur for queries such that sql count(*) from...
|
||||
// for which we will count the rows from sql * from...
|
||||
oom |= Query->Append('*');
|
||||
Query->Append('*');
|
||||
|
||||
} else
|
||||
// SQL statement used to retrieve the size of the result
|
||||
oom |= Query->Append("count(*)");
|
||||
Query->Append("count(*)");
|
||||
|
||||
oom |= Query->Append(" FROM ");
|
||||
Query->Append(" FROM ");
|
||||
|
||||
if (Catalog && *Catalog)
|
||||
catp = Catalog;
|
||||
@@ -381,17 +382,17 @@ bool TDBEXT::MakeSQL(PGLOBAL g, bool cnt)
|
||||
schmp = Schema;
|
||||
|
||||
if (catp) {
|
||||
oom |= Query->Append(catp);
|
||||
Query->Append(catp);
|
||||
|
||||
if (schmp) {
|
||||
oom |= Query->Append('.');
|
||||
oom |= Query->Append(schmp);
|
||||
Query->Append('.');
|
||||
Query->Append(schmp);
|
||||
} // endif schmp
|
||||
|
||||
oom |= Query->Append('.');
|
||||
Query->Append('.');
|
||||
} else if (schmp) {
|
||||
oom |= Query->Append(schmp);
|
||||
oom |= Query->Append('.');
|
||||
Query->Append(schmp);
|
||||
Query->Append('.');
|
||||
} // endif schmp
|
||||
|
||||
// Table name can be encoded in UTF-8
|
||||
@@ -399,18 +400,18 @@ bool TDBEXT::MakeSQL(PGLOBAL g, bool cnt)
|
||||
|
||||
if (Quote) {
|
||||
// Put table name between identifier quotes in case in contains blanks
|
||||
oom |= Query->Append(Quote);
|
||||
oom |= Query->Append(buf);
|
||||
oom |= Query->Append(Quote);
|
||||
Query->Append(Quote);
|
||||
Query->Append(buf);
|
||||
Query->Append(Quote);
|
||||
} else
|
||||
oom |= Query->Append(buf);
|
||||
Query->Append(buf);
|
||||
|
||||
len = Query->GetLength();
|
||||
|
||||
if (To_CondFil) {
|
||||
if (Mode == MODE_READ) {
|
||||
oom |= Query->Append(" WHERE ");
|
||||
oom |= Query->Append(To_CondFil->Body);
|
||||
Query->Append(" WHERE ");
|
||||
Query->Append(To_CondFil->Body);
|
||||
len = Query->GetLength() + 1;
|
||||
} else
|
||||
len += (strlen(To_CondFil->Body) + 256);
|
||||
@@ -418,10 +419,11 @@ bool TDBEXT::MakeSQL(PGLOBAL g, bool cnt)
|
||||
} else
|
||||
len += ((Mode == MODE_READX) ? 256 : 1);
|
||||
|
||||
if (oom || Query->Resize(len)) {
|
||||
if (Query->IsTruncated()) {
|
||||
strcpy(g->Message, "MakeSQL: Out of memory");
|
||||
return true;
|
||||
} // endif oom
|
||||
} else
|
||||
Query->Resize(len);
|
||||
|
||||
if (trace)
|
||||
htrc("Query=%s\n", Query->GetStr());
|
||||
@@ -435,15 +437,17 @@ bool TDBEXT::MakeSQL(PGLOBAL g, bool cnt)
|
||||
/***********************************************************************/
|
||||
bool TDBEXT::MakeCommand(PGLOBAL g)
|
||||
{
|
||||
char *p, *stmt, name[68], *body = NULL;
|
||||
PCSZ schmp = NULL;
|
||||
char *p, *stmt, name[132], *body = NULL;
|
||||
char *qrystr = (char*)PlugSubAlloc(g, NULL, strlen(Qrystr) + 1);
|
||||
bool qtd = Quoted > 0;
|
||||
char q = qtd ? *Quote : ' ';
|
||||
int i = 0, k = 0;
|
||||
|
||||
// Make a lower case copy of the originale query and change
|
||||
// back ticks to the data source identifier quoting character
|
||||
do {
|
||||
qrystr[i] = (Qrystr[i] == '`') ? *Quote : tolower(Qrystr[i]);
|
||||
qrystr[i] = (Qrystr[i] == '`') ? q : tolower(Qrystr[i]);
|
||||
} while (Qrystr[i++]);
|
||||
|
||||
if (To_CondFil && (p = strstr(qrystr, " where "))) {
|
||||
@@ -460,27 +464,50 @@ bool TDBEXT::MakeCommand(PGLOBAL g)
|
||||
strlwr(strcat(strcat(strcpy(name, " "), Name), " "));
|
||||
|
||||
if (strstr(" update delete low_priority ignore quick from ", name)) {
|
||||
strlwr(strcat(strcat(strcpy(name, Quote), Name), Quote));
|
||||
k += 2;
|
||||
if (Quote) {
|
||||
strlwr(strcat(strcat(strcpy(name, Quote), Name), Quote));
|
||||
k += 2;
|
||||
} else {
|
||||
strcpy(g->Message, "Quoted must be specified");
|
||||
return true;
|
||||
} // endif Quote
|
||||
|
||||
} else
|
||||
strlwr(strcpy(name, Name)); // Not a keyword
|
||||
|
||||
if ((p = strstr(qrystr, name))) {
|
||||
for (i = 0; i < p - qrystr; i++)
|
||||
stmt[i] = (Qrystr[i] == '`') ? *Quote : Qrystr[i];
|
||||
stmt[i] = (Qrystr[i] == '`') ? q : Qrystr[i];
|
||||
|
||||
stmt[i] = 0;
|
||||
|
||||
k += i + (int)strlen(Name);
|
||||
|
||||
if (qtd && *(p - 1) == ' ')
|
||||
if (Schema && *Schema)
|
||||
schmp = Schema;
|
||||
|
||||
if (qtd && *(p - 1) == ' ') {
|
||||
if (schmp)
|
||||
strcat(strcat(stmt, schmp), ".");
|
||||
|
||||
strcat(strcat(strcat(stmt, Quote), TableName), Quote);
|
||||
else
|
||||
} else {
|
||||
if (schmp) {
|
||||
if (qtd && *(p - 1) != ' ') {
|
||||
stmt[i - 1] = 0;
|
||||
strcat(strcat(strcat(stmt, schmp), "."), Quote);
|
||||
} else
|
||||
strcat(strcat(stmt, schmp), ".");
|
||||
|
||||
} // endif schmp
|
||||
|
||||
strcat(stmt, TableName);
|
||||
} // endif's
|
||||
|
||||
i = (int)strlen(stmt);
|
||||
|
||||
do {
|
||||
stmt[i++] = (Qrystr[k] == '`') ? *Quote : Qrystr[k];
|
||||
stmt[i++] = (Qrystr[k] == '`') ? q : Qrystr[k];
|
||||
} while (Qrystr[k++]);
|
||||
|
||||
if (body)
|
||||
@@ -539,7 +566,7 @@ int TDBEXT::GetProgMax(PGLOBAL g)
|
||||
/***********************************************************************/
|
||||
/* EXTCOL public constructor. */
|
||||
/***********************************************************************/
|
||||
EXTCOL::EXTCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am)
|
||||
EXTCOL::EXTCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PCSZ am)
|
||||
: COLBLK(cdp, tdbp, i)
|
||||
{
|
||||
if (cprec) {
|
||||
|
||||
@@ -28,14 +28,14 @@ class ALIAS : public BLOCK {
|
||||
class CONDFIL : public BLOCK {
|
||||
public:
|
||||
// Constructor
|
||||
CONDFIL(const Item *cond, uint idx, AMT type);
|
||||
CONDFIL(uint idx, AMT type);
|
||||
|
||||
// Functions
|
||||
int Init(PGLOBAL g, PHC hc);
|
||||
const char *Chk(const char *cln, bool *h);
|
||||
|
||||
// Members
|
||||
const Item *Cond;
|
||||
//const Item *Cond;
|
||||
AMT Type;
|
||||
uint Idx;
|
||||
OPVAL Op;
|
||||
@@ -60,10 +60,10 @@ public:
|
||||
|
||||
// Implementation
|
||||
virtual const char *GetType(void) { return "EXT"; }
|
||||
inline PSZ GetTabname(void) { return Tabname; }
|
||||
inline PSZ GetTabschema(void) { return Tabschema; }
|
||||
inline PSZ GetUsername(void) { return Username; };
|
||||
inline PSZ GetPassword(void) { return Password; };
|
||||
inline PCSZ GetTabname(void) { return Tabname; }
|
||||
inline PCSZ GetTabschema(void) { return Tabschema; }
|
||||
inline PCSZ GetUsername(void) { return Username; };
|
||||
inline PCSZ GetPassword(void) { return Password; };
|
||||
inline PSZ GetTabcat(void) { return Tabcat; }
|
||||
inline PSZ GetSrcdef(void) { return Srcdef; }
|
||||
inline char GetSep(void) { return (Sep) ? *Sep : 0; }
|
||||
@@ -76,10 +76,10 @@ public:
|
||||
|
||||
protected:
|
||||
// Members
|
||||
PSZ Tabname; /* External table name */
|
||||
PSZ Tabschema; /* External table schema */
|
||||
PSZ Username; /* User connect name */
|
||||
PSZ Password; /* Password connect info */
|
||||
PCSZ Tabname; /* External table name */
|
||||
PCSZ Tabschema; /* External table schema */
|
||||
PCSZ Username; /* User connect name */
|
||||
PCSZ Password; /* Password connect info */
|
||||
PSZ Tabcat; /* External table catalog */
|
||||
PSZ Tabtyp; /* Catalog table type */
|
||||
PSZ Colpat; /* Catalog column pattern */
|
||||
@@ -115,7 +115,7 @@ public:
|
||||
virtual bool IsRemote(void) { return true; }
|
||||
|
||||
// Methods
|
||||
virtual PSZ GetServer(void) { return "Remote"; }
|
||||
virtual PCSZ GetServer(void) { return "Remote"; }
|
||||
virtual int GetRecpos(void);
|
||||
|
||||
// Database routines
|
||||
@@ -127,19 +127,19 @@ protected:
|
||||
virtual bool MakeSQL(PGLOBAL g, bool cnt);
|
||||
//virtual bool MakeInsert(PGLOBAL g);
|
||||
virtual bool MakeCommand(PGLOBAL g);
|
||||
int Decode(char *utf, char *buf, size_t n);
|
||||
int Decode(PCSZ utf, char *buf, size_t n);
|
||||
|
||||
// Members
|
||||
PQRYRES Qrp; // Points to storage result
|
||||
PSTRG Query; // Constructed SQL query
|
||||
char *TableName; // Points to ODBC table name
|
||||
char *Schema; // Points to ODBC table Schema
|
||||
char *User; // User connect info
|
||||
char *Pwd; // Password connect info
|
||||
PCSZ TableName; // Points to ODBC table name
|
||||
PCSZ Schema; // Points to ODBC table Schema
|
||||
PCSZ User; // User connect info
|
||||
PCSZ Pwd; // Password connect info
|
||||
char *Catalog; // Points to ODBC table Catalog
|
||||
char *Srcdef; // The source table SQL definition
|
||||
char *Count; // Points to count(*) SQL statement
|
||||
//char *Where; // Points to local where clause
|
||||
//char *Where; // Points to local where clause
|
||||
char *Quote; // The identifier quoting character
|
||||
char *MulConn; // Used for multiple ODBC tables
|
||||
char *DBQ; // The address part of Connect string
|
||||
@@ -170,7 +170,7 @@ class DllExport EXTCOL : public COLBLK {
|
||||
friend class TDBEXT;
|
||||
public:
|
||||
// Constructor
|
||||
EXTCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am);
|
||||
EXTCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PCSZ am);
|
||||
EXTCOL(PEXTCOL colp, PTDB tdbp); // Constructor used in copy process
|
||||
|
||||
// Implementation
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/************* TabFix C++ Program Source Code File (.CPP) **************/
|
||||
/* PROGRAM NAME: TABFIX */
|
||||
/* ------------- */
|
||||
/* Version 4.9.1 */
|
||||
/* Version 4.9.2 */
|
||||
/* */
|
||||
/* COPYRIGHT: */
|
||||
/* ---------- */
|
||||
/* (C) Copyright to the author Olivier BERTRAND 1998-2016 */
|
||||
/* (C) Copyright to the author Olivier BERTRAND 1998-2017 */
|
||||
/* */
|
||||
/* WHAT THIS PROGRAM DOES: */
|
||||
/* ----------------------- */
|
||||
@@ -373,7 +373,7 @@ int TDBFIX::WriteDB(PGLOBAL g)
|
||||
/***********************************************************************/
|
||||
/* BINCOL public constructor. */
|
||||
/***********************************************************************/
|
||||
BINCOL::BINCOL(PGLOBAL g, PCOLDEF cdp, PTDB tp, PCOL cp, int i, PSZ am)
|
||||
BINCOL::BINCOL(PGLOBAL g, PCOLDEF cdp, PTDB tp, PCOL cp, int i, PCSZ am)
|
||||
: DOSCOL(g, cdp, tp, cp, i, am)
|
||||
{
|
||||
char c, *fmt = cdp->GetFmt();
|
||||
@@ -411,8 +411,8 @@ BINCOL::BINCOL(PGLOBAL g, PCOLDEF cdp, PTDB tp, PCOL cp, int i, PSZ am)
|
||||
case 'D': M = sizeof(double); break;
|
||||
default:
|
||||
sprintf(g->Message, MSG(BAD_BIN_FMT), Fmt, Name);
|
||||
longjmp(g->jumper[g->jump_level], 11);
|
||||
} // endswitch Fmt
|
||||
throw 11;
|
||||
} // endswitch Fmt
|
||||
|
||||
} else if (IsTypeChar(Buf_Type))
|
||||
Eds = 0;
|
||||
@@ -486,8 +486,8 @@ void BINCOL::ReadColumn(PGLOBAL g)
|
||||
if (rc == RC_EF)
|
||||
sprintf(g->Message, MSG(INV_DEF_READ), rc);
|
||||
|
||||
longjmp(g->jumper[g->jump_level], 11);
|
||||
} // endif
|
||||
throw 11;
|
||||
} // endif
|
||||
|
||||
p = tdbp->To_Line + Deplac;
|
||||
|
||||
@@ -545,8 +545,8 @@ void BINCOL::ReadColumn(PGLOBAL g)
|
||||
break;
|
||||
default:
|
||||
sprintf(g->Message, MSG(BAD_BIN_FMT), Fmt, Name);
|
||||
longjmp(g->jumper[g->jump_level], 11);
|
||||
} // endswitch Fmt
|
||||
throw 11;
|
||||
} // endswitch Fmt
|
||||
|
||||
// Set null when applicable
|
||||
if (Nullable)
|
||||
@@ -595,8 +595,8 @@ void BINCOL::WriteColumn(PGLOBAL g)
|
||||
} else if (Value->GetBinValue(p, Long, Status)) {
|
||||
sprintf(g->Message, MSG(BIN_F_TOO_LONG),
|
||||
Name, Value->GetSize(), Long);
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
} // endif p
|
||||
throw 31;
|
||||
} // endif p
|
||||
|
||||
break;
|
||||
case 'S': // Short integer
|
||||
@@ -604,8 +604,8 @@ void BINCOL::WriteColumn(PGLOBAL g)
|
||||
|
||||
if (n > 32767LL || n < -32768LL) {
|
||||
sprintf(g->Message, MSG(VALUE_TOO_BIG), n, Name);
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
} else if (Status)
|
||||
throw 31;
|
||||
} else if (Status)
|
||||
Value->GetValueNonAligned<short>(p, (short)n);
|
||||
|
||||
break;
|
||||
@@ -614,8 +614,8 @@ void BINCOL::WriteColumn(PGLOBAL g)
|
||||
|
||||
if (n > 255LL || n < -256LL) {
|
||||
sprintf(g->Message, MSG(VALUE_TOO_BIG), n, Name);
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
} else if (Status)
|
||||
throw 31;
|
||||
} else if (Status)
|
||||
*p = (char)n;
|
||||
|
||||
break;
|
||||
@@ -624,8 +624,8 @@ void BINCOL::WriteColumn(PGLOBAL g)
|
||||
|
||||
if (n > INT_MAX || n < INT_MIN) {
|
||||
sprintf(g->Message, MSG(VALUE_TOO_BIG), n, Name);
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
} else if (Status)
|
||||
throw 31;
|
||||
} else if (Status)
|
||||
Value->GetValueNonAligned<int>(p, (int)n);
|
||||
|
||||
break;
|
||||
@@ -648,8 +648,8 @@ void BINCOL::WriteColumn(PGLOBAL g)
|
||||
case 'C': // Characters
|
||||
if ((n = (signed)strlen(Value->GetCharString(Buf))) > Long) {
|
||||
sprintf(g->Message, MSG(BIN_F_TOO_LONG), Name, (int) n, Long);
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
} // endif n
|
||||
throw 31;
|
||||
} // endif n
|
||||
|
||||
if (Status) {
|
||||
s = Value->GetCharString(Buf);
|
||||
@@ -660,8 +660,8 @@ void BINCOL::WriteColumn(PGLOBAL g)
|
||||
break;
|
||||
default:
|
||||
sprintf(g->Message, MSG(BAD_BIN_FMT), Fmt, Name);
|
||||
longjmp(g->jumper[g->jump_level], 11);
|
||||
} // endswitch Fmt
|
||||
throw 31;
|
||||
} // endswitch Fmt
|
||||
|
||||
if (Eds && Status) {
|
||||
p = tdbp->To_Line + Deplac;
|
||||
|
||||
@@ -65,7 +65,7 @@ class DllExport BINCOL : public DOSCOL {
|
||||
friend class TDBFIX;
|
||||
public:
|
||||
// Constructors
|
||||
BINCOL(PGLOBAL g, PCOLDEF cdp, PTDB tp, PCOL cp, int i, PSZ am = "BIN");
|
||||
BINCOL(PGLOBAL g, PCOLDEF cdp, PTDB tp, PCOL cp, int i, PCSZ am = "BIN");
|
||||
BINCOL(BINCOL *colp, PTDB tdbp); // Constructor used in copy process
|
||||
|
||||
// Implementation
|
||||
@@ -108,7 +108,7 @@ class TDBDCL : public TDBCAT {
|
||||
{return DBFColumns(g, ((PTABDEF)To_Def)->GetPath(), Fn, false);}
|
||||
|
||||
// Members
|
||||
char *Fn; // The DBF file (path) name
|
||||
PCSZ Fn; // The DBF file (path) name
|
||||
}; // end of class TDBOCL
|
||||
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ USETEMP UseTemp(void);
|
||||
/* of types (TYPE_STRING < TYPE_DOUBLE < TYPE_INT) (1 < 2 < 7). */
|
||||
/* If these values are changed, this will have to be revisited. */
|
||||
/***********************************************************************/
|
||||
PQRYRES CSVColumns(PGLOBAL g, char *dp, PTOS topt, bool info)
|
||||
PQRYRES CSVColumns(PGLOBAL g, PCSZ dp, PTOS topt, bool info)
|
||||
{
|
||||
static int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING,
|
||||
TYPE_INT, TYPE_INT, TYPE_SHORT};
|
||||
@@ -153,7 +153,7 @@ PQRYRES CSVColumns(PGLOBAL g, char *dp, PTOS topt, bool info)
|
||||
tdp->Lrecl = 4096;
|
||||
|
||||
tdp->Multiple = GetIntegerTableOption(g, topt, "Multiple", 0);
|
||||
p = GetStringTableOption(g, topt, "Separator", ",");
|
||||
p = (char*)GetStringTableOption(g, topt, "Separator", ",");
|
||||
tdp->Sep = (strlen(p) == 2 && p[0] == '\\' && p[1] == 't') ? '\t' : *p;
|
||||
|
||||
#if defined(__WIN__)
|
||||
@@ -167,7 +167,7 @@ PQRYRES CSVColumns(PGLOBAL g, char *dp, PTOS topt, bool info)
|
||||
|
||||
sep = tdp->Sep;
|
||||
tdp->Quoted = GetIntegerTableOption(g, topt, "Quoted", -1);
|
||||
p = GetStringTableOption(g, topt, "Qchar", "");
|
||||
p = (char*)GetStringTableOption(g, topt, "Qchar", "");
|
||||
tdp->Qot = *p;
|
||||
|
||||
if (tdp->Qot && tdp->Quoted < 0)
|
||||
@@ -517,7 +517,7 @@ PTDB CSVDEF::GetTable(PGLOBAL g, MODE mode)
|
||||
/*******************************************************************/
|
||||
if (Zipped) {
|
||||
#if defined(ZIP_SUPPORT)
|
||||
if (mode == MODE_READ || mode == MODE_ANY) {
|
||||
if (mode == MODE_READ || mode == MODE_ANY || mode == MODE_ALTER) {
|
||||
txfp = new(g) UNZFAM(this);
|
||||
} else if (mode == MODE_INSERT) {
|
||||
txfp = new(g) ZIPFAM(this);
|
||||
@@ -1435,8 +1435,8 @@ void CSVCOL::ReadColumn(PGLOBAL g)
|
||||
if (rc == RC_EF)
|
||||
sprintf(g->Message, MSG(INV_DEF_READ), rc);
|
||||
|
||||
longjmp(g->jumper[g->jump_level], 34);
|
||||
} // endif
|
||||
throw 34;
|
||||
} // endif
|
||||
|
||||
if (tdbp->Mode != MODE_UPDATE) {
|
||||
int colen = Long; // Column length
|
||||
@@ -1453,8 +1453,8 @@ void CSVCOL::ReadColumn(PGLOBAL g)
|
||||
Long = colen; // Restore column length
|
||||
sprintf(g->Message, MSG(FLD_TOO_LNG_FOR),
|
||||
Fldnum + 1, Name, To_Tdb->RowNumber(g), tdbp->GetFile(g));
|
||||
longjmp(g->jumper[g->jump_level], 34);
|
||||
} // endif Long
|
||||
throw 34;
|
||||
} // endif Long
|
||||
|
||||
// Now do the reading
|
||||
DOSCOL::ReadColumn(g);
|
||||
@@ -1516,8 +1516,8 @@ void CSVCOL::WriteColumn(PGLOBAL g)
|
||||
if ((signed)strlen(p) > flen) {
|
||||
sprintf(g->Message, MSG(BAD_FLD_LENGTH), Name, p, flen,
|
||||
tdbp->RowNumber(g), tdbp->GetFile(g));
|
||||
longjmp(g->jumper[g->jump_level], 34);
|
||||
} else if (Dsp)
|
||||
throw 34;
|
||||
} else if (Dsp)
|
||||
for (int i = 0; p[i]; i++)
|
||||
if (p[i] == '.')
|
||||
p[i] = Dsp;
|
||||
@@ -1532,8 +1532,8 @@ void CSVCOL::WriteColumn(PGLOBAL g)
|
||||
if (Fldnum < 0) {
|
||||
// This can happen for wrong offset value in XDB files
|
||||
sprintf(g->Message, MSG(BAD_FIELD_RANK), Fldnum + 1, Name);
|
||||
longjmp(g->jumper[g->jump_level], 34);
|
||||
} else
|
||||
throw 34;
|
||||
} else
|
||||
strncpy(tdbp->Field[Fldnum], p, flen);
|
||||
|
||||
if (trace > 1)
|
||||
|
||||
@@ -13,7 +13,7 @@ typedef class TDBFMT *PTDBFMT;
|
||||
/***********************************************************************/
|
||||
/* Functions used externally. */
|
||||
/***********************************************************************/
|
||||
PQRYRES CSVColumns(PGLOBAL g, char *dp, PTOS topt, bool info);
|
||||
PQRYRES CSVColumns(PGLOBAL g, PCSZ dp, PTOS topt, bool info);
|
||||
|
||||
/***********************************************************************/
|
||||
/* CSV table. */
|
||||
@@ -21,7 +21,7 @@ PQRYRES CSVColumns(PGLOBAL g, char *dp, PTOS topt, bool info);
|
||||
class DllExport CSVDEF : public DOSDEF { /* Logical table description */
|
||||
friend class TDBCSV;
|
||||
friend class TDBCCL;
|
||||
friend PQRYRES CSVColumns(PGLOBAL, char *, PTOS, bool);
|
||||
friend PQRYRES CSVColumns(PGLOBAL, PCSZ, PTOS, bool);
|
||||
public:
|
||||
// Constructor
|
||||
CSVDEF(void);
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
class DllExport TDBCSV : public TDBDOS {
|
||||
friend class CSVCOL;
|
||||
friend class MAPFAM;
|
||||
friend PQRYRES CSVColumns(PGLOBAL, char *, PTOS, bool);
|
||||
friend PQRYRES CSVColumns(PGLOBAL, PCSZ, PTOS, bool);
|
||||
public:
|
||||
// Constructor
|
||||
TDBCSV(PCSVDEF tdp, PTXF txfp);
|
||||
|
||||
@@ -227,41 +227,8 @@ bool JDBCDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
|
||||
|
||||
if (rc == RC_FX) // Error
|
||||
return true;
|
||||
//else if (rc == RC_OK) { // Url was not a server name
|
||||
// Tabname = GetStringCatInfo(g, "Name",
|
||||
// (Catfunc & (FNC_TABLE | FNC_COL)) ? NULL : Name);
|
||||
// Tabname = GetStringCatInfo(g, "Tabname", Tabname);
|
||||
// Username = GetStringCatInfo(g, "User", NULL);
|
||||
// Password = GetStringCatInfo(g, "Password", NULL);
|
||||
//} // endif rc
|
||||
|
||||
//if ((Srcdef = GetStringCatInfo(g, "Srcdef", NULL)))
|
||||
// Read_Only = true;
|
||||
|
||||
Wrapname = GetStringCatInfo(g, "Wrapper", NULL);
|
||||
//Prop = GetStringCatInfo(g, "Properties", NULL);
|
||||
//Tabcat = GetStringCatInfo(g, "Qualifier", NULL);
|
||||
//Tabcat = GetStringCatInfo(g, "Catalog", Tabcat);
|
||||
//Tabschema = GetStringCatInfo(g, "Dbname", NULL);
|
||||
//Tabschema = GetStringCatInfo(g, "Schema", Tabschema);
|
||||
|
||||
//if (Catfunc == FNC_COL)
|
||||
// Colpat = GetStringCatInfo(g, "Colpat", NULL);
|
||||
|
||||
//if (Catfunc == FNC_TABLE)
|
||||
// Tabtyp = GetStringCatInfo(g, "Tabtype", NULL);
|
||||
|
||||
//Qrystr = GetStringCatInfo(g, "Query_String", "?");
|
||||
//Sep = GetStringCatInfo(g, "Separator", NULL);
|
||||
//Xsrc = GetBoolCatInfo("Execsrc", FALSE);
|
||||
//Maxerr = GetIntCatInfo("Maxerr", 0);
|
||||
//Maxres = GetIntCatInfo("Maxres", 0);
|
||||
//Quoted = GetIntCatInfo("Quoted", 0);
|
||||
// Cto= GetIntCatInfo("ConnectTimeout", DEFAULT_LOGIN_TIMEOUT);
|
||||
// Qto= GetIntCatInfo("QueryTimeout", DEFAULT_QUERY_TIMEOUT);
|
||||
//Scrollable = GetBoolCatInfo("Scrollable", false);
|
||||
//Memory = GetIntCatInfo("Memory", 0);
|
||||
//Pseudo = 2; // FILID is Ok but not ROWID
|
||||
return false;
|
||||
} // end of DefineAM
|
||||
|
||||
@@ -341,9 +308,6 @@ TDBJDBC::TDBJDBC(PJDBCDEF tdp) : TDBEXT(tdp)
|
||||
WrapName = tdp->Wrapname;
|
||||
Ops.User = tdp->Username;
|
||||
Ops.Pwd = tdp->Password;
|
||||
// Ops.Properties = tdp->Prop;
|
||||
// Ops.Cto = tdp->Cto;
|
||||
// Ops.Qto = tdp->Qto;
|
||||
Ops.Scrollable = tdp->Scrollable;
|
||||
} else {
|
||||
WrapName = NULL;
|
||||
@@ -351,13 +315,9 @@ TDBJDBC::TDBJDBC(PJDBCDEF tdp) : TDBEXT(tdp)
|
||||
Ops.Url = NULL;
|
||||
Ops.User = NULL;
|
||||
Ops.Pwd = NULL;
|
||||
// Ops.Properties = NULL;
|
||||
// Ops.Cto = DEFAULT_LOGIN_TIMEOUT;
|
||||
// Ops.Qto = DEFAULT_QUERY_TIMEOUT;
|
||||
Ops.Scrollable = false;
|
||||
} // endif tdp
|
||||
|
||||
//Ncol = 0;
|
||||
Prepared = false;
|
||||
Werr = false;
|
||||
Rerr = false;
|
||||
@@ -370,7 +330,6 @@ TDBJDBC::TDBJDBC(PTDBJDBC tdbp) : TDBEXT(tdbp)
|
||||
Cnp = tdbp->Cnp;
|
||||
WrapName = tdbp->WrapName;
|
||||
Ops = tdbp->Ops;
|
||||
//Ncol = tdbp->Ncol;
|
||||
Prepared = tdbp->Prepared;
|
||||
Werr = tdbp->Werr;
|
||||
Rerr = tdbp->Rerr;
|
||||
@@ -406,10 +365,11 @@ PCOL TDBJDBC::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n)
|
||||
/***********************************************************************/
|
||||
bool TDBJDBC::MakeInsert(PGLOBAL g)
|
||||
{
|
||||
char *schmp = NULL, *catp = NULL, buf[NAM_LEN * 3];
|
||||
PCSZ schmp = NULL;
|
||||
char *catp = NULL, buf[NAM_LEN * 3];
|
||||
int len = 0;
|
||||
uint pos;
|
||||
bool b = false, oom = false;
|
||||
bool b = false;
|
||||
PTABLE tablep = To_Table;
|
||||
PCOL colp;
|
||||
|
||||
@@ -446,32 +406,32 @@ bool TDBJDBC::MakeInsert(PGLOBAL g)
|
||||
Query = new(g)STRING(g, len, "INSERT INTO ");
|
||||
|
||||
if (catp) {
|
||||
oom |= Query->Append(catp);
|
||||
Query->Append(catp);
|
||||
|
||||
if (schmp) {
|
||||
oom |= Query->Append('.');
|
||||
oom |= Query->Append(schmp);
|
||||
Query->Append('.');
|
||||
Query->Append(schmp);
|
||||
} // endif schmp
|
||||
|
||||
oom |= Query->Append('.');
|
||||
Query->Append('.');
|
||||
} else if (schmp) {
|
||||
oom |= Query->Append(schmp);
|
||||
oom |= Query->Append('.');
|
||||
Query->Append(schmp);
|
||||
Query->Append('.');
|
||||
} // endif schmp
|
||||
|
||||
if (Quote) {
|
||||
// Put table name between identifier quotes in case in contains blanks
|
||||
oom |= Query->Append(Quote);
|
||||
oom |= Query->Append(buf);
|
||||
oom |= Query->Append(Quote);
|
||||
Query->Append(Quote);
|
||||
Query->Append(buf);
|
||||
Query->Append(Quote);
|
||||
} else
|
||||
oom |= Query->Append(buf);
|
||||
Query->Append(buf);
|
||||
|
||||
oom |= Query->Append('(');
|
||||
Query->Append('(');
|
||||
|
||||
for (colp = Columns; colp; colp = colp->GetNext()) {
|
||||
if (b)
|
||||
oom |= Query->Append(", ");
|
||||
Query->Append(", ");
|
||||
else
|
||||
b = true;
|
||||
|
||||
@@ -480,15 +440,15 @@ bool TDBJDBC::MakeInsert(PGLOBAL g)
|
||||
|
||||
if (Quote) {
|
||||
// Put column name between identifier quotes in case in contains blanks
|
||||
oom |= Query->Append(Quote);
|
||||
oom |= Query->Append(buf);
|
||||
oom |= Query->Append(Quote);
|
||||
Query->Append(Quote);
|
||||
Query->Append(buf);
|
||||
Query->Append(Quote);
|
||||
} else
|
||||
oom |= Query->Append(buf);
|
||||
Query->Append(buf);
|
||||
|
||||
} // endfor colp
|
||||
|
||||
if ((oom |= Query->Append(") VALUES ("))) {
|
||||
if ((Query->Append(") VALUES ("))) {
|
||||
strcpy(g->Message, "MakeInsert: Out of memory");
|
||||
return true;
|
||||
} else // in case prepared statement fails
|
||||
@@ -496,9 +456,9 @@ bool TDBJDBC::MakeInsert(PGLOBAL g)
|
||||
|
||||
// Make prepared statement
|
||||
for (int i = 0; i < Nparm; i++)
|
||||
oom |= Query->Append("?,");
|
||||
Query->Append("?,");
|
||||
|
||||
if (oom) {
|
||||
if (Query->IsTruncated()) {
|
||||
strcpy(g->Message, "MakeInsert: Out of memory");
|
||||
return true;
|
||||
} else
|
||||
@@ -737,18 +697,12 @@ bool TDBJDBC::SetRecpos(PGLOBAL g, int recpos)
|
||||
{
|
||||
if (Jcp->m_Full) {
|
||||
Fpos = 0;
|
||||
// CurNum = 0;
|
||||
CurNum = 1;
|
||||
} else if (Memory == 3) {
|
||||
// Fpos = recpos;
|
||||
// CurNum = -1;
|
||||
Fpos = 0;
|
||||
CurNum = recpos;
|
||||
} else if (Ops.Scrollable) {
|
||||
// Is new position in the current row set?
|
||||
// if (recpos >= Curpos && recpos < Curpos + Rbuf) {
|
||||
// CurNum = recpos - Curpos;
|
||||
// Fpos = 0;
|
||||
if (recpos > 0 && recpos <= Rbuf) {
|
||||
CurNum = recpos;
|
||||
Fpos = recpos;
|
||||
@@ -797,7 +751,7 @@ bool TDBJDBC::ReadKey(PGLOBAL g, OPVAL op, const key_range *kr)
|
||||
To_CondFil->Body= (char*)PlugSubAlloc(g, NULL, 0);
|
||||
*To_CondFil->Body= 0;
|
||||
|
||||
if ((To_CondFil = hc->CheckCond(g, To_CondFil, To_CondFil->Cond)))
|
||||
if ((To_CondFil = hc->CheckCond(g, To_CondFil, Cond)))
|
||||
PlugSubAlloc(g, NULL, strlen(To_CondFil->Body) + 1);
|
||||
|
||||
} // endif active_index
|
||||
@@ -911,7 +865,6 @@ int TDBJDBC::WriteDB(PGLOBAL g)
|
||||
// an insert query for each line to insert
|
||||
uint len = Query->GetLength();
|
||||
char buf[64];
|
||||
bool oom = false;
|
||||
|
||||
// Make the Insert command value list
|
||||
for (PCOL colp = Columns; colp; colp = colp->GetNext()) {
|
||||
@@ -919,28 +872,28 @@ int TDBJDBC::WriteDB(PGLOBAL g)
|
||||
char *s = colp->GetValue()->GetCharString(buf);
|
||||
|
||||
if (colp->GetResultType() == TYPE_STRING)
|
||||
oom |= Query->Append_quoted(s);
|
||||
Query->Append_quoted(s);
|
||||
else if (colp->GetResultType() == TYPE_DATE) {
|
||||
DTVAL *dtv = (DTVAL*)colp->GetValue();
|
||||
|
||||
if (dtv->IsFormatted())
|
||||
oom |= Query->Append_quoted(s);
|
||||
Query->Append_quoted(s);
|
||||
else
|
||||
oom |= Query->Append(s);
|
||||
Query->Append(s);
|
||||
|
||||
} else
|
||||
oom |= Query->Append(s);
|
||||
Query->Append(s);
|
||||
|
||||
} else
|
||||
oom |= Query->Append("NULL");
|
||||
Query->Append("NULL");
|
||||
|
||||
oom |= Query->Append(',');
|
||||
Query->Append(',');
|
||||
} // endfor colp
|
||||
|
||||
if (unlikely(oom)) {
|
||||
if (unlikely(Query->IsTruncated())) {
|
||||
strcpy(g->Message, "WriteDB: Out of memory");
|
||||
return RC_FX;
|
||||
} // endif oom
|
||||
} // endif Query
|
||||
|
||||
Query->RepLast(')');
|
||||
|
||||
@@ -990,11 +943,6 @@ int TDBJDBC::DeleteDB(PGLOBAL g, int irc)
|
||||
/***********************************************************************/
|
||||
void TDBJDBC::CloseDB(PGLOBAL g)
|
||||
{
|
||||
//if (To_Kindex) {
|
||||
// To_Kindex->Close();
|
||||
// To_Kindex = NULL;
|
||||
// } // endif
|
||||
|
||||
if (Jcp)
|
||||
Jcp->Close();
|
||||
|
||||
@@ -1019,7 +967,7 @@ void TDBJDBC::CloseDB(PGLOBAL g)
|
||||
/***********************************************************************/
|
||||
/* JDBCCOL public constructor. */
|
||||
/***********************************************************************/
|
||||
JDBCCOL::JDBCCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am)
|
||||
JDBCCOL::JDBCCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PCSZ am)
|
||||
: EXTCOL(cdp, tdbp, cprec, i, am)
|
||||
{
|
||||
} // end of JDBCCOL constructor
|
||||
@@ -1039,54 +987,6 @@ JDBCCOL::JDBCCOL(JDBCCOL *col1, PTDB tdbp) : EXTCOL(col1, tdbp)
|
||||
{
|
||||
} // end of JDBCCOL copy constructor
|
||||
|
||||
#if 0
|
||||
/***********************************************************************/
|
||||
/* SetBuffer: prepare a column block for write operation. */
|
||||
/***********************************************************************/
|
||||
bool JDBCCOL::SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check)
|
||||
{
|
||||
if (!(To_Val = value)) {
|
||||
sprintf(g->Message, MSG(VALUE_ERROR), Name);
|
||||
return true;
|
||||
} else if (Buf_Type == value->GetType()) {
|
||||
// Values are of the (good) column type
|
||||
if (Buf_Type == TYPE_DATE) {
|
||||
// If any of the date values is formatted
|
||||
// output format must be set for the receiving table
|
||||
if (GetDomain() || ((DTVAL *)value)->IsFormatted())
|
||||
goto newval; // This will make a new value;
|
||||
|
||||
} else if (Buf_Type == TYPE_DOUBLE)
|
||||
// Float values must be written with the correct (column) precision
|
||||
// Note: maybe this should be forced by ShowValue instead of this ?
|
||||
value->SetPrec(GetScale());
|
||||
|
||||
Value = value; // Directly access the external value
|
||||
} else {
|
||||
// Values are not of the (good) column type
|
||||
if (check) {
|
||||
sprintf(g->Message, MSG(TYPE_VALUE_ERR), Name,
|
||||
GetTypeName(Buf_Type), GetTypeName(value->GetType()));
|
||||
return true;
|
||||
} // endif check
|
||||
|
||||
newval:
|
||||
if (InitValue(g)) // Allocate the matching value block
|
||||
return true;
|
||||
|
||||
} // endif's Value, Buf_Type
|
||||
|
||||
// Because Colblk's have been made from a copy of the original TDB in
|
||||
// case of Update, we must reset them to point to the original one.
|
||||
if (To_Tdb->GetOrig())
|
||||
To_Tdb = (PTDB)To_Tdb->GetOrig();
|
||||
|
||||
// Set the Column
|
||||
Status = (ok) ? BUF_EMPTY : BUF_NO;
|
||||
return false;
|
||||
} // end of SetBuffer
|
||||
#endif // 0
|
||||
|
||||
/***********************************************************************/
|
||||
/* ReadColumn: when SQLFetch is used there is nothing to do as the */
|
||||
/* column buffer was bind to the record set. This is also the case */
|
||||
@@ -1196,26 +1096,6 @@ PCMD TDBXJDC::MakeCMD(PGLOBAL g)
|
||||
return xcmd;
|
||||
} // end of MakeCMD
|
||||
|
||||
#if 0
|
||||
/***********************************************************************/
|
||||
/* JDBC Bind Parameter function. */
|
||||
/***********************************************************************/
|
||||
bool TDBXJDC::BindParameters(PGLOBAL g)
|
||||
{
|
||||
PJDBCCOL colp;
|
||||
|
||||
for (colp = (PJDBCCOL)Columns; colp; colp = (PJDBCCOL)colp->Next) {
|
||||
colp->AllocateBuffers(g, 0);
|
||||
|
||||
if (Jcp->BindParam(colp))
|
||||
return true;
|
||||
|
||||
} // endfor colp
|
||||
|
||||
return false;
|
||||
} // end of BindParameters
|
||||
#endif // 0
|
||||
|
||||
/***********************************************************************/
|
||||
/* XDBC GetMaxSize: returns table size (not always one row). */
|
||||
/***********************************************************************/
|
||||
@@ -1332,8 +1212,8 @@ int TDBXJDC::DeleteDB(PGLOBAL g, int irc)
|
||||
/***********************************************************************/
|
||||
/* JSRCCOL public constructor. */
|
||||
/***********************************************************************/
|
||||
JSRCCOL::JSRCCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am)
|
||||
: JDBCCOL(cdp, tdbp, cprec, i, am)
|
||||
JSRCCOL::JSRCCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PCSZ am)
|
||||
: JDBCCOL(cdp, tdbp, cprec, i, am)
|
||||
{
|
||||
// Set additional JDBC access method information for column.
|
||||
Flag = cdp->GetOffset();
|
||||
@@ -1416,17 +1296,3 @@ PQRYRES TDBJDBCL::GetResult(PGLOBAL g)
|
||||
{
|
||||
return JDBCColumns(g, Schema, Tab, Colpat, Maxres, false, &Ops);
|
||||
} // end of GetResult
|
||||
|
||||
#if 0
|
||||
/* ---------------------------TDBJSRC class -------------------------- */
|
||||
|
||||
/***********************************************************************/
|
||||
/* GetResult: Get the list of JDBC data sources. */
|
||||
/***********************************************************************/
|
||||
PQRYRES TDBJSRC::GetResult(PGLOBAL g)
|
||||
{
|
||||
return JDBCDataSources(g, Maxres, false);
|
||||
} // end of GetResult
|
||||
|
||||
/* ------------------------ End of TabJDBC --------------------------- */
|
||||
#endif // 0
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*************** Tabjdbc H Declares Source Code File (.H) **************/
|
||||
/* Name: TABJDBC.H Version 1.0 */
|
||||
/* Name: TABJDBC.H Version 1.1 */
|
||||
/* */
|
||||
/* (C) Copyright to the author Olivier BERTRAND 2016 */
|
||||
/* (C) Copyright to the author Olivier BERTRAND 2016-2017 */
|
||||
/* */
|
||||
/* This file contains the TDBJDBC classes declares. */
|
||||
/***********************************************************************/
|
||||
@@ -14,9 +14,6 @@ typedef class TDBJDBC *PTDBJDBC;
|
||||
typedef class JDBCCOL *PJDBCCOL;
|
||||
typedef class TDBXJDC *PTDBXJDC;
|
||||
typedef class JSRCCOL *PJSRCCOL;
|
||||
//typedef class TDBOIF *PTDBOIF;
|
||||
//typedef class OIFCOL *POIFCOL;
|
||||
//typedef class TDBJSRC *PTDBJSRC;
|
||||
|
||||
/***********************************************************************/
|
||||
/* JDBC table. */
|
||||
@@ -68,20 +65,14 @@ public:
|
||||
|
||||
// Methods
|
||||
virtual PTDB Clone(PTABS t);
|
||||
//virtual int GetRecpos(void);
|
||||
virtual bool SetRecpos(PGLOBAL g, int recpos);
|
||||
//virtual PSZ GetFile(PGLOBAL g);
|
||||
//virtual void SetFile(PGLOBAL g, PSZ fn);
|
||||
virtual void ResetSize(void);
|
||||
//virtual int GetAffectedRows(void) {return AftRows;}
|
||||
virtual PSZ GetServer(void) { return "JDBC"; }
|
||||
virtual PCSZ GetServer(void) { return "JDBC"; }
|
||||
virtual int Indexable(void) { return 2; }
|
||||
|
||||
// Database routines
|
||||
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
|
||||
virtual int Cardinality(PGLOBAL g);
|
||||
//virtual int GetMaxSize(PGLOBAL g);
|
||||
//virtual int GetProgMax(PGLOBAL g);
|
||||
virtual bool OpenDB(PGLOBAL g);
|
||||
virtual int ReadDB(PGLOBAL g);
|
||||
virtual int WriteDB(PGLOBAL g);
|
||||
@@ -91,21 +82,14 @@ public:
|
||||
|
||||
protected:
|
||||
// Internal functions
|
||||
//int Decode(char *utf, char *buf, size_t n);
|
||||
//bool MakeSQL(PGLOBAL g, bool cnt);
|
||||
bool MakeInsert(PGLOBAL g);
|
||||
//virtual bool MakeCommand(PGLOBAL g);
|
||||
//bool MakeFilter(PGLOBAL g, bool c);
|
||||
bool SetParameters(PGLOBAL g);
|
||||
//char *MakeUpdate(PGLOBAL g);
|
||||
//char *MakeDelete(PGLOBAL g);
|
||||
|
||||
// Members
|
||||
JDBConn *Jcp; // Points to a JDBC connection class
|
||||
JDBCCOL *Cnp; // Points to count(*) column
|
||||
JDBCPARM Ops; // Additional parameters
|
||||
char *WrapName; // Points to Java wrapper name
|
||||
//int Ncol; // The column number
|
||||
bool Prepared; // True when using prepared statement
|
||||
bool Werr; // Write error
|
||||
bool Rerr; // Rewind error
|
||||
@@ -119,7 +103,7 @@ class JDBCCOL : public EXTCOL {
|
||||
friend class TDBJDBC;
|
||||
public:
|
||||
// Constructors
|
||||
JDBCCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am = "JDBC");
|
||||
JDBCCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PCSZ am = "JDBC");
|
||||
JDBCCOL(JDBCCOL *colp, PTDB tdbp); // Constructor used in copy process
|
||||
|
||||
// Implementation
|
||||
@@ -152,12 +136,6 @@ public:
|
||||
virtual AMT GetAmType(void) {return TYPE_AM_XDBC;}
|
||||
|
||||
// Methods
|
||||
//virtual int GetRecpos(void);
|
||||
//virtual PSZ GetFile(PGLOBAL g);
|
||||
//virtual void SetFile(PGLOBAL g, PSZ fn);
|
||||
//virtual void ResetSize(void);
|
||||
//virtual int GetAffectedRows(void) {return AftRows;}
|
||||
//virtual PSZ GetServer(void) {return "JDBC";}
|
||||
|
||||
// Database routines
|
||||
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
|
||||
@@ -172,7 +150,6 @@ public:
|
||||
protected:
|
||||
// Internal functions
|
||||
PCMD MakeCMD(PGLOBAL g);
|
||||
//bool BindParameters(PGLOBAL g);
|
||||
|
||||
// Members
|
||||
PCMD Cmdlist; // The commands to execute
|
||||
@@ -188,7 +165,7 @@ class JSRCCOL : public JDBCCOL {
|
||||
friend class TDBXJDC;
|
||||
public:
|
||||
// Constructors
|
||||
JSRCCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am = "JDBC");
|
||||
JSRCCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PCSZ am = "JDBC");
|
||||
|
||||
// Implementation
|
||||
virtual int GetAmType(void) {return TYPE_AM_JDBC;}
|
||||
@@ -233,9 +210,9 @@ protected:
|
||||
virtual PQRYRES GetResult(PGLOBAL g);
|
||||
|
||||
// Members
|
||||
char *Schema; // Points to schema name or NULL
|
||||
char *Tab; // Points to JDBC table name or pattern
|
||||
char *Tabtype; // Points to JDBC table type
|
||||
PCSZ Schema; // Points to schema name or NULL
|
||||
PCSZ Tab; // Points to JDBC table name or pattern
|
||||
PCSZ Tabtype; // Points to JDBC table type
|
||||
JDBCPARM Ops; // Additional parameters
|
||||
}; // end of class TDBJTB
|
||||
|
||||
@@ -252,24 +229,7 @@ protected:
|
||||
virtual PQRYRES GetResult(PGLOBAL g);
|
||||
|
||||
// Members
|
||||
char *Colpat; // Points to catalog column pattern
|
||||
PCSZ Colpat; // Points to catalog column pattern
|
||||
}; // end of class TDBJDBCL
|
||||
|
||||
#if 0
|
||||
/***********************************************************************/
|
||||
/* This is the class declaration for the Data Sources catalog table. */
|
||||
/***********************************************************************/
|
||||
class TDBJSRC : public TDBJDRV {
|
||||
public:
|
||||
// Constructor
|
||||
TDBJSRC(PJDBCDEF tdp) : TDBJDRV(tdp) {}
|
||||
|
||||
protected:
|
||||
// Specific routines
|
||||
virtual PQRYRES GetResult(PGLOBAL g);
|
||||
|
||||
// No additional Members
|
||||
}; // end of class TDBJSRC
|
||||
#endif // 0
|
||||
|
||||
#endif // !NJDBC
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/************* tabjson C++ Program Source Code File (.CPP) *************/
|
||||
/* PROGRAM NAME: tabjson Version 1.3 */
|
||||
/* (C) Copyright to the author Olivier BERTRAND 2014 - 2016 */
|
||||
/* PROGRAM NAME: tabjson Version 1.4 */
|
||||
/* (C) Copyright to the author Olivier BERTRAND 2014 - 2017 */
|
||||
/* This program are the JSON class DB execution routines. */
|
||||
/***********************************************************************/
|
||||
|
||||
@@ -117,7 +117,9 @@ PQRYRES JSONColumns(PGLOBAL g, char *db, PTOS topt, bool info)
|
||||
return NULL;
|
||||
} // endif Fn
|
||||
|
||||
tdp->Database = SetPath(g, db);
|
||||
if (!(tdp->Database = SetPath(g, db)))
|
||||
return NULL;
|
||||
|
||||
tdp->Objname = GetStringTableOption(g, topt, "Object", NULL);
|
||||
tdp->Base = GetIntegerTableOption(g, topt, "Base", 0) ? 1 : 0;
|
||||
tdp->Pretty = GetIntegerTableOption(g, topt, "Pretty", 2);
|
||||
@@ -151,7 +153,7 @@ PQRYRES JSONColumns(PGLOBAL g, char *db, PTOS topt, bool info)
|
||||
|
||||
if (tdp->Zipped) {
|
||||
#if defined(ZIP_SUPPORT)
|
||||
tjnp = new(g)TDBJSN(tdp, new(g)UNZFAM(tdp));
|
||||
tjnp = new(g)TDBJSN(tdp, new(g) UNZFAM(tdp));
|
||||
#else // !ZIP_SUPPORT
|
||||
sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "ZIP");
|
||||
return NULL;
|
||||
@@ -168,7 +170,7 @@ PQRYRES JSONColumns(PGLOBAL g, char *db, PTOS topt, bool info)
|
||||
G->Sarea_Size = tdp->Lrecl * 10;
|
||||
G->Sarea = PlugSubAlloc(g, NULL, G->Sarea_Size);
|
||||
PlugSubSet(G, G->Sarea, G->Sarea_Size);
|
||||
G->jump_level = -1;
|
||||
G->jump_level = 0;
|
||||
tjnp->SetG(G);
|
||||
#else
|
||||
tjnp->SetG(g);
|
||||
@@ -262,8 +264,13 @@ PQRYRES JSONColumns(PGLOBAL g, char *db, PTOS topt, bool info)
|
||||
break;
|
||||
|
||||
if (jcp) {
|
||||
if (jcp->Type != jcol.Type)
|
||||
jcp->Type = TYPE_STRING;
|
||||
if (jcp->Type != jcol.Type) {
|
||||
if (jcp->Type == TYPE_UNKNOWN)
|
||||
jcp->Type = jcol.Type;
|
||||
else if (jcol.Type != TYPE_UNKNOWN)
|
||||
jcp->Type = TYPE_STRING;
|
||||
|
||||
} // endif Type
|
||||
|
||||
if (*fmt && (!jcp->Fmt || strlen(jcp->Fmt) < strlen(fmt))) {
|
||||
jcp->Fmt = PlugDup(g, fmt);
|
||||
@@ -336,7 +343,7 @@ PQRYRES JSONColumns(PGLOBAL g, char *db, PTOS topt, bool info)
|
||||
|
||||
skipit:
|
||||
if (trace)
|
||||
htrc("CSVColumns: n=%d len=%d\n", n, length[0]);
|
||||
htrc("JSONColumns: n=%d len=%d\n", n, length[0]);
|
||||
|
||||
/*********************************************************************/
|
||||
/* Allocate the structures used to refer to the result set. */
|
||||
@@ -417,7 +424,7 @@ bool JSONDEF::DefineAM(PGLOBAL g, LPCSTR, int poff)
|
||||
Pretty = GetIntCatInfo("Pretty", 2);
|
||||
Limit = GetIntCatInfo("Limit", 10);
|
||||
Base = GetIntCatInfo("Base", 0) ? 1 : 0;
|
||||
return DOSDEF::DefineAM(g, "DOS", poff);
|
||||
return DOSDEF::DefineAM(g, "DOS", poff);
|
||||
} // end of DefineAM
|
||||
|
||||
/***********************************************************************/
|
||||
@@ -441,7 +448,7 @@ PTDB JSONDEF::GetTable(PGLOBAL g, MODE m)
|
||||
|
||||
if (Zipped) {
|
||||
#if defined(ZIP_SUPPORT)
|
||||
if (m == MODE_READ || m == MODE_UPDATE) {
|
||||
if (m == MODE_READ || m == MODE_ANY || m == MODE_ALTER) {
|
||||
txfp = new(g) UNZFAM(this);
|
||||
} else if (m == MODE_INSERT) {
|
||||
txfp = new(g) ZIPFAM(this);
|
||||
@@ -463,7 +470,7 @@ PTDB JSONDEF::GetTable(PGLOBAL g, MODE m)
|
||||
sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "GZ");
|
||||
return NULL;
|
||||
#endif // !GZ_SUPPORT
|
||||
} else if (map)
|
||||
} else if (map)
|
||||
txfp = new(g) MAPFAM(this);
|
||||
else
|
||||
txfp = new(g) DOSFAM(this);
|
||||
@@ -478,7 +485,7 @@ PTDB JSONDEF::GetTable(PGLOBAL g, MODE m)
|
||||
G->Sarea_Size = Lrecl * 10;
|
||||
G->Sarea = PlugSubAlloc(g, NULL, G->Sarea_Size);
|
||||
PlugSubSet(G, G->Sarea, G->Sarea_Size);
|
||||
G->jump_level = -1;
|
||||
G->jump_level = 0;
|
||||
((TDBJSN*)tdbp)->G = G;
|
||||
#else
|
||||
((TDBJSN*)tdbp)->G = g;
|
||||
@@ -486,7 +493,7 @@ PTDB JSONDEF::GetTable(PGLOBAL g, MODE m)
|
||||
} else {
|
||||
if (Zipped) {
|
||||
#if defined(ZIP_SUPPORT)
|
||||
if (m == MODE_READ || m == MODE_UPDATE) {
|
||||
if (m == MODE_READ || m == MODE_ANY || m == MODE_ALTER) {
|
||||
txfp = new(g) UNZFAM(this);
|
||||
} else if (m == MODE_INSERT) {
|
||||
strcpy(g->Message, "INSERT supported only for zipped JSON when pretty=0");
|
||||
@@ -535,7 +542,7 @@ TDBJSN::TDBJSN(PJDEF tdp, PTXF txfp) : TDBDOS(tdp, txfp)
|
||||
} else {
|
||||
Jmode = MODE_OBJECT;
|
||||
Objname = NULL;
|
||||
Xcol = NULL;
|
||||
Xcol = NULL;
|
||||
Limit = 1;
|
||||
Pretty = 0;
|
||||
B = 0;
|
||||
@@ -695,6 +702,9 @@ bool TDBJSN::OpenDB(PGLOBAL g)
|
||||
return true;
|
||||
} // endswitch Jmode
|
||||
|
||||
if (Xcol && Txfp->GetAmType() != TYPE_AM_MGO)
|
||||
To_Filter = NULL; // Imcompatible
|
||||
|
||||
} // endif Use
|
||||
|
||||
return TDBDOS::OpenDB(g);
|
||||
@@ -865,24 +875,21 @@ int TDBJSN::MakeTopTree(PGLOBAL g, PJSON jsp)
|
||||
|
||||
} // end of PrepareWriting
|
||||
|
||||
/***********************************************************************/
|
||||
/* WriteDB: Data Base write routine for DOS access method. */
|
||||
/***********************************************************************/
|
||||
int TDBJSN::WriteDB(PGLOBAL g)
|
||||
/***********************************************************************/
|
||||
/* WriteDB: Data Base write routine for DOS access method. */
|
||||
/***********************************************************************/
|
||||
int TDBJSN::WriteDB(PGLOBAL g)
|
||||
{
|
||||
int rc = TDBDOS::WriteDB(g);
|
||||
|
||||
#if USE_G
|
||||
if (rc == RC_FX)
|
||||
strcpy(g->Message, G->Message);
|
||||
|
||||
PlugSubSet(G, G->Sarea, G->Sarea_Size);
|
||||
#endif
|
||||
Row->Clear();
|
||||
return rc;
|
||||
} // end of WriteDB
|
||||
|
||||
/* ---------------------------- JSONCOL ------------------------------ */
|
||||
/* ---------------------------- JSONCOL ------------------------------ */
|
||||
|
||||
/***********************************************************************/
|
||||
/* JSONCOL public constructor. */
|
||||
@@ -1146,12 +1153,62 @@ bool JSONCOL::ParseJpath(PGLOBAL g)
|
||||
return false;
|
||||
} // end of ParseJpath
|
||||
|
||||
/***********************************************************************/
|
||||
/* Get Jpath converted to Mongo path. */
|
||||
/***********************************************************************/
|
||||
char *JSONCOL::GetJpath(PGLOBAL g, bool proj)
|
||||
{
|
||||
if (Jpath) {
|
||||
char *p1, *p2, *mgopath;
|
||||
int i = 0;
|
||||
|
||||
if (strcmp(Jpath, "*"))
|
||||
mgopath = PlugDup(g, Jpath);
|
||||
else
|
||||
return NULL;
|
||||
|
||||
for (p1 = p2 = mgopath; *p1; p1++)
|
||||
if (i) { // Inside []
|
||||
if (isdigit(*p1)) {
|
||||
if (!proj)
|
||||
*p2++ = *p1;
|
||||
|
||||
i = 2;
|
||||
} else if (*p1 == ']' && i == 2) {
|
||||
if (proj && *(p1 + 1) == ':')
|
||||
p1++;
|
||||
|
||||
i = 0;
|
||||
} else if (proj)
|
||||
i = 2;
|
||||
else
|
||||
return NULL;
|
||||
|
||||
} else switch (*p1) {
|
||||
case ':': *p2++ = '.'; break;
|
||||
case '[': i = 1; break;
|
||||
case '*':
|
||||
if (*(p2 - 1) == '.' && !*(p1 + 1)) {
|
||||
p2--; // Suppress last :*
|
||||
break;
|
||||
} // endif p2
|
||||
|
||||
default: *p2++ = *p1; break;
|
||||
} // endswitch p1;
|
||||
|
||||
*p2 = 0;
|
||||
return mgopath;
|
||||
} else
|
||||
return NULL;
|
||||
|
||||
} // end of GetJpath
|
||||
|
||||
/***********************************************************************/
|
||||
/* MakeJson: Serialize the json item and set value to it. */
|
||||
/***********************************************************************/
|
||||
PVAL JSONCOL::MakeJson(PGLOBAL g, PJSON jsp)
|
||||
{
|
||||
if (Value->IsTypeNum()) {
|
||||
{
|
||||
if (Value->IsTypeNum()) {
|
||||
strcpy(g->Message, "Cannot make Json for a numeric column");
|
||||
Value->Reset();
|
||||
} else
|
||||
@@ -1171,7 +1228,8 @@ void JSONCOL::SetJsonValue(PGLOBAL g, PVAL vp, PJVAL val, int n)
|
||||
case TYPE_INTG:
|
||||
case TYPE_BINT:
|
||||
case TYPE_DBL:
|
||||
vp->SetValue_pval(val->GetValue());
|
||||
case TYPE_DATE:
|
||||
vp->SetValue_pval(val->GetValue());
|
||||
break;
|
||||
case TYPE_BOOL:
|
||||
if (vp->IsTypeNum())
|
||||
@@ -1190,11 +1248,14 @@ void JSONCOL::SetJsonValue(PGLOBAL g, PVAL vp, PJVAL val, int n)
|
||||
// } // endif Type
|
||||
|
||||
default:
|
||||
vp->Reset();
|
||||
} // endswitch Type
|
||||
vp->Reset();
|
||||
vp->SetNull(true);
|
||||
} // endswitch Type
|
||||
|
||||
} else
|
||||
vp->Reset();
|
||||
} else {
|
||||
vp->Reset();
|
||||
vp->SetNull(true);
|
||||
} // endif val
|
||||
|
||||
} // end of SetJsonValue
|
||||
|
||||
@@ -1207,8 +1268,8 @@ void JSONCOL::ReadColumn(PGLOBAL g)
|
||||
Value->SetValue_pval(GetColumnValue(g, Tjp->Row, 0));
|
||||
|
||||
// Set null when applicable
|
||||
if (Nullable)
|
||||
Value->SetNull(Value->IsZero());
|
||||
if (!Nullable)
|
||||
Value->SetNull(false);
|
||||
|
||||
} // end of ReadColumn
|
||||
|
||||
@@ -1289,8 +1350,8 @@ PVAL JSONCOL::ExpandArray(PGLOBAL g, PJAR arp, int n)
|
||||
|
||||
if (!(jvp = arp->GetValue((Nodes[n].Rx = Nodes[n].Nx)))) {
|
||||
strcpy(g->Message, "Logical error expanding array");
|
||||
longjmp(g->jumper[g->jump_level], 666);
|
||||
} // endif jvp
|
||||
throw 666;
|
||||
} // endif jvp
|
||||
|
||||
if (n < Nod - 1 && jvp->GetJson()) {
|
||||
jval.SetValue(GetColumnValue(g, jvp->GetJson(), n + 1));
|
||||
@@ -1475,8 +1536,8 @@ void JSONCOL::WriteColumn(PGLOBAL g)
|
||||
{
|
||||
if (Xpd && Tjp->Pretty < 2) {
|
||||
strcpy(g->Message, "Cannot write expanded column when Pretty is not 2");
|
||||
longjmp(g->jumper[g->jump_level], 666);
|
||||
} // endif Xpd
|
||||
throw 666;
|
||||
} // endif Xpd
|
||||
|
||||
/*********************************************************************/
|
||||
/* Check whether this node must be written. */
|
||||
@@ -1510,8 +1571,8 @@ void JSONCOL::WriteColumn(PGLOBAL g)
|
||||
|
||||
if (!(jsp = ParseJson(G, s, (int)strlen(s)))) {
|
||||
strcpy(g->Message, s);
|
||||
longjmp(g->jumper[g->jump_level], 666);
|
||||
} // endif jsp
|
||||
throw 666;
|
||||
} // endif jsp
|
||||
|
||||
if (arp) {
|
||||
if (Nod > 1 && Nodes[Nod-2].Op == OP_EQ)
|
||||
@@ -1533,6 +1594,7 @@ void JSONCOL::WriteColumn(PGLOBAL g)
|
||||
// fall through
|
||||
case TYPE_DATE:
|
||||
case TYPE_INT:
|
||||
case TYPE_TINY:
|
||||
case TYPE_SHORT:
|
||||
case TYPE_BIGINT:
|
||||
case TYPE_DOUBLE:
|
||||
@@ -1860,8 +1922,11 @@ bool TDBJSON::OpenDB(PGLOBAL g)
|
||||
return true;
|
||||
} // endswitch Jmode
|
||||
|
||||
Use = USE_OPEN;
|
||||
return false;
|
||||
if (Xcol)
|
||||
To_Filter = NULL; // Imcompatible
|
||||
|
||||
Use = USE_OPEN;
|
||||
return false;
|
||||
} // end of OpenDB
|
||||
|
||||
/***********************************************************************/
|
||||
@@ -1871,7 +1936,7 @@ int TDBJSON::ReadDB(PGLOBAL)
|
||||
{
|
||||
int rc;
|
||||
|
||||
N++;
|
||||
N++;
|
||||
|
||||
if (NextSame) {
|
||||
SameRow = NextSame;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user