mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v3.1.3.1
This commit is contained in:
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.dbs.engines; import gplx.*; import gplx.dbs.*;
|
||||
import gplx.core.stores.*;
|
||||
import gplx.core.stores.*; import gplx.dbs.metas.*;
|
||||
public interface Db_engine {
|
||||
String Tid();
|
||||
Db_conn_info Conn_info();
|
||||
@@ -33,12 +33,13 @@ public interface Db_engine {
|
||||
void Conn_open();
|
||||
void Conn_term();
|
||||
Object Exec_as_obj(Db_qry qry);
|
||||
void Ddl_create_tbl(Db_meta_tbl meta);
|
||||
void Ddl_create_idx(Gfo_usr_dlg usr_dlg, Db_meta_idx... ary);
|
||||
void Ddl_append_fld(String tbl, Db_meta_fld fld);
|
||||
void Ddl_create_tbl(Dbmeta_tbl_itm meta);
|
||||
void Ddl_create_idx(Gfo_usr_dlg usr_dlg, Dbmeta_idx_itm... ary);
|
||||
void Ddl_append_fld(String tbl, Dbmeta_fld_itm fld);
|
||||
void Ddl_delete_tbl(String tbl);
|
||||
void Env_db_attach(String alias, Io_url db_url);
|
||||
void Env_db_detach(String alias);
|
||||
boolean Meta_tbl_exists(String tbl);
|
||||
boolean Meta_fld_exists(String tbl, String fld);
|
||||
Dbmeta_tbl_mgr Meta_tbl_load_all();
|
||||
}
|
||||
|
||||
@@ -18,16 +18,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.dbs.engines; import gplx.*; import gplx.dbs.*;
|
||||
import java.sql.*;
|
||||
import gplx.core.stores.*;
|
||||
import gplx.dbs.engines.*; import gplx.dbs.qrys.*; import gplx.dbs.sqls.*;
|
||||
import gplx.dbs.engines.*; import gplx.dbs.qrys.*; import gplx.dbs.sqls.*; import gplx.dbs.metas.*;
|
||||
public abstract class Db_engine_sql_base implements Db_engine {
|
||||
@gplx.Internal protected void Ctor(Db_conn_info conn_info) {this.conn_info = conn_info;}
|
||||
public abstract String Tid();
|
||||
public Db_conn_info Conn_info() {return conn_info;} protected Db_conn_info conn_info;
|
||||
public abstract Db_engine New_clone(Db_conn_info conn_info);
|
||||
public Db_rdr New_rdr__rls_manual(Object rdr_obj, String sql) {return New_rdr(null, rdr_obj, sql);}
|
||||
public Db_rdr New_rdr__rls_auto(Db_stmt stmt, Object rdr_obj, String sql) {return New_rdr(stmt, rdr_obj, sql);}
|
||||
@gplx.Virtual public Db_rdr New_rdr_clone() {return new Db_rdr__basic();}
|
||||
public Db_stmt New_stmt_prep(Db_qry qry) {return new Db_stmt_cmd(this, qry);}
|
||||
public abstract String Tid();
|
||||
public Db_conn_info Conn_info() {return conn_info;} protected Db_conn_info conn_info;
|
||||
public abstract Db_engine New_clone(Db_conn_info conn_info);
|
||||
public Db_rdr New_rdr__rls_manual(Object rdr_obj, String sql) {return New_rdr(null, rdr_obj, sql);}
|
||||
public Db_rdr New_rdr__rls_auto(Db_stmt stmt, Object rdr_obj, String sql) {return New_rdr(stmt, rdr_obj, sql);}
|
||||
@gplx.Virtual public Db_rdr New_rdr_clone() {return new Db_rdr__basic();}
|
||||
public Db_stmt New_stmt_prep(Db_qry qry) {return new Db_stmt_cmd(this, qry);}
|
||||
@gplx.Virtual public void Txn_bgn(String name) {Exec_as_obj(Db_qry_sql.xtn_("BEGIN TRANSACTION;"));}
|
||||
@gplx.Virtual public String Txn_end() {Exec_as_obj(Db_qry_sql.xtn_("COMMIT TRANSACTION;")); return "";}
|
||||
@gplx.Virtual public void Txn_cxl() {Exec_as_obj(Db_qry_sql.xtn_("ROLLBACK TRANSACTION;"));}
|
||||
@@ -56,16 +56,16 @@ public abstract class Db_engine_sql_base implements Db_engine {
|
||||
}
|
||||
catch (Exception e) {throw Err_.new_exc(e, "db", "db.engine:rdr failed", "url", conn_info.Xto_api(), "sql", sql);}
|
||||
}
|
||||
public void Ddl_create_tbl(Db_meta_tbl tbl) {Exec_as_int(tbl.To_sql_create());}
|
||||
public void Ddl_create_idx(Gfo_usr_dlg usr_dlg, Db_meta_idx... ary) {
|
||||
public void Ddl_create_tbl(Dbmeta_tbl_itm tbl) {Exec_as_int(tbl.To_sql_create());}
|
||||
public void Ddl_create_idx(Gfo_usr_dlg usr_dlg, Dbmeta_idx_itm... ary) {
|
||||
int len = ary.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Db_meta_idx idx = ary[i];
|
||||
Dbmeta_idx_itm idx = ary[i];
|
||||
usr_dlg.Plog_many("", "", "creating database index (please wait); db=~{0} idx=~{1}", conn_info.Database(), idx.Name());
|
||||
Exec_as_int(idx.To_sql_create());
|
||||
}
|
||||
}
|
||||
public void Ddl_append_fld(String tbl, Db_meta_fld fld) {
|
||||
public void Ddl_append_fld(String tbl, Dbmeta_fld_itm fld) {
|
||||
Gfo_usr_dlg_.Instance.Plog_many("", "", "adding column to table: db=~{0} tbl=~{1} fld=~{2}", conn_info.Database(), tbl, fld.Name());
|
||||
try {
|
||||
Exec_as_int(Db_sqlbldr__sqlite.Instance.Bld_alter_tbl_add(tbl, fld));
|
||||
@@ -75,12 +75,13 @@ public abstract class Db_engine_sql_base implements Db_engine {
|
||||
Gfo_usr_dlg_.Instance.Warn_many("", "", "column not added to table: db=~{0} tbl=~{1} fld=~{2} err=~{3}", conn_info.Database(), tbl, fld.Name(), Err_.Message_gplx_full(e));
|
||||
}
|
||||
}
|
||||
public void Ddl_delete_tbl(String tbl) {Exec_as_int(Db_sqlbldr__sqlite.Instance.Bld_drop_tbl(tbl));}
|
||||
@gplx.Virtual public void Env_db_attach(String alias, Io_url db_url) {}
|
||||
@gplx.Virtual public void Env_db_detach(String alias) {}
|
||||
public void Ddl_delete_tbl(String tbl) {Exec_as_int(Db_sqlbldr__sqlite.Instance.Bld_drop_tbl(tbl));}
|
||||
@gplx.Virtual public void Env_db_attach(String alias, Io_url db_url) {}
|
||||
@gplx.Virtual public void Env_db_detach(String alias) {}
|
||||
@gplx.Virtual public boolean Meta_tbl_exists(String tbl) {return false;}
|
||||
@gplx.Virtual public boolean Meta_fld_exists(String tbl, String fld) {return false;}
|
||||
@gplx.Virtual public DataRdr New_rdr(ResultSet rdr, String sql) {return gplx.core.stores.Db_data_rdr_.new_(rdr, sql);}
|
||||
public abstract Dbmeta_tbl_mgr Meta_tbl_load_all();
|
||||
@gplx.Virtual public DataRdr New_rdr(ResultSet rdr, String sql) {return gplx.core.stores.Db_data_rdr_.new_(rdr, sql);}
|
||||
@gplx.Virtual public Sql_qry_wtr SqlWtr() {return Sql_qry_wtr_.new_ansi();}
|
||||
private Db_rdr New_rdr(Db_stmt stmt, Object rdr, String sql) {
|
||||
Db_rdr__basic rv = (Db_rdr__basic)New_rdr_clone();
|
||||
|
||||
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.dbs.engines.mems; import gplx.*; import gplx.dbs.*; import gplx.dbs.engines.*;
|
||||
import gplx.core.stores.*;
|
||||
import gplx.core.stores.*; import gplx.dbs.metas.*;
|
||||
public class Db_engine__mem implements Db_engine {
|
||||
private final Hash_adp tbl_hash = Hash_adp_.new_();
|
||||
Db_engine__mem(Db_conn_info conn_info) {this.conn_info = conn_info;}
|
||||
@@ -38,20 +38,21 @@ public class Db_engine__mem implements Db_engine {
|
||||
public Db_rdr New_rdr__rls_auto(Db_stmt stmt, Object rdr_obj, String sql) {throw Err_.new_unimplemented();}
|
||||
public DataRdr New_rdr(java.sql.ResultSet rdr, String sql) {throw Err_.new_unimplemented();}
|
||||
public Object New_stmt_prep_as_obj(String sql) {throw Err_.new_unimplemented();}
|
||||
public void Ddl_create_tbl(Db_meta_tbl meta) {
|
||||
public void Ddl_create_tbl(Dbmeta_tbl_itm meta) {
|
||||
Mem_tbl mem_tbl = new Mem_tbl(meta);
|
||||
tbl_hash.Add_if_dupe_use_nth(meta.Name(), mem_tbl);
|
||||
meta_tbl_mgr.Add(meta);
|
||||
}
|
||||
public void Ddl_create_idx(Gfo_usr_dlg usr_dlg, Db_meta_idx... ary) {} // TODO: implement unique index
|
||||
public void Ddl_append_fld(String tbl, Db_meta_fld fld) {}
|
||||
public void Ddl_create_idx(Gfo_usr_dlg usr_dlg, Dbmeta_idx_itm... ary) {} // TODO: implement unique index
|
||||
public void Ddl_append_fld(String tbl, Dbmeta_fld_itm fld) {}
|
||||
public void Ddl_delete_tbl(String tbl) {}
|
||||
public void Env_db_attach(String alias, Io_url db_url) {}
|
||||
public void Env_db_detach(String alias) {}
|
||||
public boolean Meta_tbl_exists(String tbl) {return tbl_hash.Has(tbl);}
|
||||
public boolean Meta_fld_exists(String tbl, String fld) {
|
||||
Mem_tbl mem_tbl = (Mem_tbl)tbl_hash.Get_by(tbl); if (mem_tbl == null) return false;
|
||||
return mem_tbl.Meta().Flds_has(fld);
|
||||
return mem_tbl.Meta().Flds().Has(fld);
|
||||
}
|
||||
// public boolean Meta_fld_exists(String name) {return tbl_hash.Has(name);}
|
||||
public Dbmeta_tbl_mgr Meta_tbl_load_all() {return meta_tbl_mgr;} private final Dbmeta_tbl_mgr meta_tbl_mgr = new Dbmeta_tbl_mgr();
|
||||
public static final Db_engine__mem Instance = new Db_engine__mem(); Db_engine__mem() {}
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ public class Db_stmt__mem implements Db_stmt {
|
||||
}
|
||||
public Object Exec_select_val() {throw Err_.new_unimplemented();}
|
||||
private void Add(String k, boolean where, Object v) {
|
||||
if (k == Db_meta_fld.Key_null) return; // key is explicitly null; ignore; allows schema_2+ type definitions
|
||||
if (k == Dbmeta_fld_itm.Key_null) return; // key is explicitly null; ignore; allows schema_2+ type definitions
|
||||
val_list.Add_if_dupe_use_1st(k, v); // NOTE: only add if new; WHERE with IN will call Add many times; fld_ttl IN ('A.png', 'B.png');
|
||||
if (where) {
|
||||
List_adp list = (List_adp)crt_hash.Get_by(k);
|
||||
|
||||
@@ -17,17 +17,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.dbs.engines.mems; import gplx.*; import gplx.dbs.*; import gplx.dbs.engines.*;
|
||||
import gplx.core.primitives.*; import gplx.core.criterias.*; import gplx.dbs.qrys.*;
|
||||
import gplx.dbs.metas.*;
|
||||
public class Mem_tbl {
|
||||
private final List_adp rows = List_adp_.new_(); private final List_adp where_rows = List_adp_.new_();
|
||||
private final Hash_adp autonum_hash = Hash_adp_.new_();
|
||||
public Mem_tbl(Db_meta_tbl meta) {this.meta = meta;}
|
||||
public Db_meta_tbl Meta() {return meta;} private final Db_meta_tbl meta;
|
||||
public Mem_tbl(Dbmeta_tbl_itm meta) {this.meta = meta;}
|
||||
public Dbmeta_tbl_itm Meta() {return meta;} private final Dbmeta_tbl_itm meta;
|
||||
public int Insert(Db_stmt__mem stmt) {
|
||||
Mem_row itm = new Mem_row();
|
||||
Db_meta_fld[] flds = meta.Flds();
|
||||
int len = flds.length;
|
||||
Dbmeta_fld_mgr flds = meta.Flds();
|
||||
int len = flds.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Db_meta_fld fld = flds[i];
|
||||
Dbmeta_fld_itm fld = flds.Get_at(i);
|
||||
String fld_name = fld.Name();
|
||||
Object val = fld.Autonum() ? Autonum_calc(fld_name) : stmt.Args_get_by(fld_name);
|
||||
itm.Set_by(fld_name, val);
|
||||
|
||||
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.dbs.engines.mysql; import gplx.*; import gplx.dbs.*; import gplx.dbs.engines.*;
|
||||
import gplx.core.stores.*; import gplx.dbs.engines.*; import gplx.dbs.sqls.*;
|
||||
import gplx.core.stores.*; import gplx.dbs.engines.*; import gplx.dbs.sqls.*; import gplx.dbs.metas.*;
|
||||
import java.sql.*;
|
||||
public class Mysql_engine extends Db_engine_sql_base {
|
||||
@Override public String Tid() {return Mysql_conn_info.Tid_const;}
|
||||
@@ -27,6 +27,7 @@ public class Mysql_engine extends Db_engine_sql_base {
|
||||
return rv;
|
||||
}
|
||||
@Override public DataRdr New_rdr(ResultSet rdr, String commandText) {return Mysql_rdr.new_(rdr, commandText);}
|
||||
@Override public Dbmeta_tbl_mgr Meta_tbl_load_all() {throw Err_.new_unimplemented();}
|
||||
@gplx.Internal @Override protected Connection Conn_new() {
|
||||
Mysql_conn_info conn_info_as_mysql = (Mysql_conn_info)conn_info;
|
||||
return Conn_make_by_url("jdbc:mysql://localhost/" + conn_info_as_mysql.Database() + "?characterEncoding=UTF8", conn_info_as_mysql.Uid(), conn_info_as_mysql.Pwd());
|
||||
|
||||
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.dbs.engines.nulls; import gplx.*; import gplx.dbs.*; import gplx.dbs.engines.*;
|
||||
import gplx.core.stores.*;
|
||||
import gplx.core.stores.*; import gplx.dbs.metas.*;
|
||||
public class Noop_engine implements Db_engine {
|
||||
public String Tid() {return Noop_conn_info.Tid_const;}
|
||||
public Db_conn_info Conn_info() {return Db_conn_info_.Null;}
|
||||
@@ -33,13 +33,14 @@ public class Noop_engine implements Db_engine {
|
||||
public void Txn_cxl() {}
|
||||
public void Txn_sav() {}
|
||||
public Object Exec_as_obj(Db_qry cmd) {return cmd.Exec_is_rdr() ? (Object)DataRdr_.Null : -1;}
|
||||
public void Ddl_create_tbl(Db_meta_tbl meta) {}
|
||||
public void Ddl_create_idx(Gfo_usr_dlg usr_dlg, Db_meta_idx... ary) {}
|
||||
public void Ddl_append_fld(String tbl, Db_meta_fld fld) {}
|
||||
public void Ddl_create_tbl(Dbmeta_tbl_itm meta) {}
|
||||
public void Ddl_create_idx(Gfo_usr_dlg usr_dlg, Dbmeta_idx_itm... ary) {}
|
||||
public void Ddl_append_fld(String tbl, Dbmeta_fld_itm fld) {}
|
||||
public void Ddl_delete_tbl(String tbl) {}
|
||||
public void Env_db_attach(String alias, Io_url db_url) {}
|
||||
public void Env_db_detach(String alias) {}
|
||||
public boolean Meta_tbl_exists(String tbl) {return false;}
|
||||
public boolean Meta_fld_exists(String tbl, String fld) {return false;}
|
||||
public Dbmeta_tbl_mgr Meta_tbl_load_all() {return meta_tbl_mgr;} private final Dbmeta_tbl_mgr meta_tbl_mgr = new Dbmeta_tbl_mgr();
|
||||
public static final Noop_engine Instance = new Noop_engine(); Noop_engine() {}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.dbs.engines.postgres; import gplx.*; import gplx.dbs.*; import gplx.dbs.engines.*;
|
||||
import gplx.core.stores.*; import gplx.dbs.engines.*; import gplx.dbs.sqls.*;
|
||||
import gplx.core.stores.*; import gplx.dbs.engines.*; import gplx.dbs.sqls.*; import gplx.dbs.metas.*;
|
||||
import java.sql.*;
|
||||
public class Postgres_engine extends Db_engine_sql_base {
|
||||
@Override public String Tid() {return Postgres_conn_info.Tid_const;}
|
||||
@@ -27,6 +27,7 @@ public class Postgres_engine extends Db_engine_sql_base {
|
||||
return rv;
|
||||
}
|
||||
@Override public DataRdr New_rdr(ResultSet rdr, String commandText) {return Db_data_rdr_.new_(rdr, commandText);}
|
||||
@Override public Dbmeta_tbl_mgr Meta_tbl_load_all() {throw Err_.new_unimplemented();}
|
||||
@gplx.Internal @Override protected Connection Conn_new() {
|
||||
Postgres_conn_info conn_info_as_postgres = (Postgres_conn_info)conn_info;
|
||||
return Conn_make_by_url("jdbc:" + conn_info_as_postgres.Tid() + "://localhost/" + conn_info_as_postgres.Database(), conn_info_as_postgres.Uid(), conn_info_as_postgres.Pwd());
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.dbs.engines.sqlite; import gplx.*; import gplx.dbs.*; import gplx.dbs.engines.*;
|
||||
import java.sql.*;
|
||||
import gplx.core.stores.*; import gplx.dbs.engines.*; import gplx.dbs.engines.sqlite.*;
|
||||
import gplx.core.stores.*; import gplx.dbs.engines.*; import gplx.dbs.engines.sqlite.*; import gplx.dbs.metas.*;
|
||||
import gplx.dbs.qrys.*;
|
||||
public class Sqlite_engine extends Db_engine_sql_base {
|
||||
private final Sqlite_txn_mgr txn_mgr; private final Sqlite_schema_mgr schema_mgr;
|
||||
@@ -41,7 +41,9 @@ public class Sqlite_engine extends Db_engine_sql_base {
|
||||
@Override public void Txn_sav() {txn_mgr.Txn_sav();}
|
||||
@Override public boolean Meta_tbl_exists(String tbl) {return schema_mgr.Tbl_exists(tbl);}
|
||||
@Override public boolean Meta_fld_exists(String tbl, String fld) {return schema_mgr.Fld_exists(tbl, fld);}
|
||||
static boolean loaded = false;
|
||||
@Override public Dbmeta_tbl_mgr Meta_tbl_load_all() {return schema_mgr.Tbl_load_all();}
|
||||
private static boolean loaded = false;
|
||||
protected void Meta_tbl_gather_hook() {throw Err_.new_unimplemented();}
|
||||
@gplx.Internal @Override protected Connection Conn_new() {
|
||||
if (!loaded) {
|
||||
try {
|
||||
|
||||
@@ -54,10 +54,10 @@ public class Sqlite_engine_ {
|
||||
Db_qry qry = Db_qry_sql.ddl_("PRAGMA page_size = " + Int_.To_str(val) + ";");
|
||||
p.Exec_qry(qry);
|
||||
}
|
||||
public static void Idx_create(Gfo_usr_dlg usr_dlg, Db_conn conn, String tbl, Db_meta_idx[] idx_ary) {
|
||||
public static void Idx_create(Gfo_usr_dlg usr_dlg, Db_conn conn, String tbl, Dbmeta_idx_itm[] idx_ary) {
|
||||
int len = idx_ary.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Db_meta_idx idx = idx_ary[i];
|
||||
Dbmeta_idx_itm idx = idx_ary[i];
|
||||
String idx_sql = idx.To_sql_create();
|
||||
usr_dlg.Plog_many("", "", "creating index: ~{0} ~{1}", tbl, idx_sql);
|
||||
conn.Exec_qry(Db_qry_sql.ddl_(idx.To_sql_create()));
|
||||
|
||||
@@ -20,22 +20,28 @@ import gplx.dbs.qrys.*;
|
||||
import gplx.dbs.metas.*; import gplx.dbs.metas.parsers.*;
|
||||
public class Sqlite_schema_mgr {
|
||||
private final Db_engine engine; private boolean init = true;
|
||||
private final Dbmeta_idx_mgr idx_mgr = new Dbmeta_idx_mgr();
|
||||
private final Dbmeta_tbl_mgr tbl_mgr = new Dbmeta_tbl_mgr();
|
||||
public Sqlite_schema_mgr(Db_engine engine) {this.engine = engine;}
|
||||
public Meta_tbl_mgr Tbl_mgr() {return tbl_mgr;} private final Meta_tbl_mgr tbl_mgr = new Meta_tbl_mgr();
|
||||
public Meta_idx_mgr Idx_mgr() {return idx_mgr;} private final Meta_idx_mgr idx_mgr = new Meta_idx_mgr();
|
||||
public boolean Tbl_exists(String name) {
|
||||
if (init) Init(engine);
|
||||
return tbl_mgr.Has(name);
|
||||
}
|
||||
public boolean Fld_exists(String tbl, String fld) {
|
||||
if (init) Init(engine);
|
||||
Meta_tbl_itm tbl_itm = tbl_mgr.Get_by(tbl);
|
||||
return (tbl_itm == null) ? false : tbl_itm.Flds().Has(fld);
|
||||
Dbmeta_tbl_itm tbl_itm = tbl_mgr.Get_by(tbl);
|
||||
return tbl_itm == null ? false : tbl_itm.Flds().Has(fld);
|
||||
}
|
||||
public Dbmeta_tbl_mgr Tbl_load_all() {
|
||||
Init(engine);
|
||||
return tbl_mgr;
|
||||
}
|
||||
private void Init(Db_engine engine) {
|
||||
init = false;
|
||||
Gfo_usr_dlg_.Instance.Log_many("", "", "db.schema.load.bgn: conn=~{0}", engine.Conn_info().Xto_api());
|
||||
Meta_parser__tbl tbl_parser = new Meta_parser__tbl();
|
||||
tbl_mgr.Clear(); idx_mgr.Clear();
|
||||
Dbmeta_parser__tbl tbl_parser = new Dbmeta_parser__tbl();
|
||||
Dbmeta_parser__idx idx_parser = new Dbmeta_parser__idx();
|
||||
Db_qry__select_in_tbl qry = Db_qry__select_in_tbl.new_("sqlite_master", String_.Ary_empty, String_.Ary("type", "name", "sql"), Db_qry__select_in_tbl.Order_by_null);
|
||||
Db_rdr rdr = engine.New_stmt_prep(qry).Exec_select__rls_auto();
|
||||
try {
|
||||
@@ -43,17 +49,14 @@ public class Sqlite_schema_mgr {
|
||||
String type_str = rdr.Read_str("type");
|
||||
String name = rdr.Read_str("name");
|
||||
String sql = rdr.Read_str("sql");
|
||||
int type_int = Meta_itm_tid.Xto_int(type_str);
|
||||
int type_int = Dbmeta_itm_tid.Xto_int(type_str);
|
||||
switch (type_int) {
|
||||
case Meta_itm_tid.Tid_table:
|
||||
case Dbmeta_itm_tid.Tid_table:
|
||||
if (String_.Eq(name, "sqlite_sequence")) continue; // ignore b/c of non-orthodox syntax; EX: "CREATE TABLE sqlite_sequence(name, seq)";
|
||||
// Meta_tbl_itm tbl_itm = new Meta_tbl_itm(tbl_name, tbl_sql);
|
||||
Meta_tbl_itm tbl_itm = tbl_parser.Parse(Bry_.new_u8(sql));
|
||||
tbl_mgr.Add(tbl_itm);
|
||||
tbl_mgr.Add(tbl_parser.Parse(Bry_.new_u8(sql)));
|
||||
break;
|
||||
case Meta_itm_tid.Tid_index:
|
||||
Meta_idx_itm idx_itm = new Meta_idx_itm(name, sql);
|
||||
idx_mgr.Add(idx_itm);
|
||||
case Dbmeta_itm_tid.Tid_index:
|
||||
idx_mgr.Add(idx_parser.Parse(Bry_.new_u8(sql)));
|
||||
break;
|
||||
default:
|
||||
Gfo_usr_dlg_.Instance.Log_many("", "", "db.schema.unknown type: conn=~{0} type=~{1} name=~{2} sql=~{3}", engine.Conn_info().Xto_api(), type_str, name, sql);
|
||||
|
||||
21
140_dbs/src/gplx/dbs/engines/sqlite/Sqlite_tid.java
Normal file
21
140_dbs/src/gplx/dbs/engines/sqlite/Sqlite_tid.java
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.dbs.engines.sqlite; import gplx.*; import gplx.dbs.*; import gplx.dbs.engines.*;
|
||||
public class Sqlite_tid {
|
||||
public static final int Tid_int = 1, Tid_text = 2, Tid_none = 3, Tid_real = 4, Tid_numeric = 5;
|
||||
}
|
||||
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.dbs.engines.tdbs; import gplx.*; import gplx.dbs.*; import gplx.dbs.engines.*;
|
||||
import gplx.core.stores.*;
|
||||
import gplx.core.stores.*; import gplx.dbs.metas.*;
|
||||
import gplx.dbs.qrys.*; import gplx.dbs.sqls.*;
|
||||
public class TdbEngine implements Db_engine {
|
||||
public String Tid() {return Tdb_conn_info.Tid_const;}
|
||||
@@ -58,14 +58,15 @@ public class TdbEngine implements Db_engine {
|
||||
public void FlushTbl(TdbTable tbl) {
|
||||
saveMgr.SaveFile(db, tbl.File());
|
||||
}
|
||||
public void Ddl_create_tbl(Db_meta_tbl meta) {throw Err_.new_unimplemented();}
|
||||
public void Ddl_create_idx(Gfo_usr_dlg usr_dlg, Db_meta_idx... ary) {throw Err_.new_unimplemented();}
|
||||
public void Ddl_append_fld(String tbl, Db_meta_fld fld) {throw Err_.new_unimplemented();}
|
||||
public void Ddl_delete_tbl(String tbl) {}
|
||||
public void Env_db_attach(String alias, Io_url db_url) {}
|
||||
public void Env_db_detach(String alias) {}
|
||||
public boolean Meta_tbl_exists(String name) {return false;}
|
||||
public boolean Meta_fld_exists(String tbl, String fld) {return false;}
|
||||
public void Ddl_create_tbl(Dbmeta_tbl_itm meta) {throw Err_.new_unimplemented();}
|
||||
public void Ddl_create_idx(Gfo_usr_dlg usr_dlg, Dbmeta_idx_itm... ary) {throw Err_.new_unimplemented();}
|
||||
public void Ddl_append_fld(String tbl, Dbmeta_fld_itm fld) {throw Err_.new_unimplemented();}
|
||||
public void Ddl_delete_tbl(String tbl) {}
|
||||
public void Env_db_attach(String alias, Io_url db_url) {}
|
||||
public void Env_db_detach(String alias) {}
|
||||
public boolean Meta_tbl_exists(String name) {return false;}
|
||||
public boolean Meta_fld_exists(String tbl, String fld) {return false;}
|
||||
public Dbmeta_tbl_mgr Meta_tbl_load_all() {return meta_tbl_mgr;} private final Dbmeta_tbl_mgr meta_tbl_mgr = new Dbmeta_tbl_mgr();
|
||||
|
||||
Hash_adp wkrs = Hash_adp_.new_(); TdbDbLoadMgr loadMgr = TdbDbLoadMgr.new_(); TdbDbSaveMgr saveMgr = TdbDbSaveMgr.new_();
|
||||
public static final TdbEngine Instance = new TdbEngine();
|
||||
|
||||
Reference in New Issue
Block a user