mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
'v3.4.1.1'
This commit is contained in:
@@ -30,7 +30,7 @@ public class Db_stmt_cmd implements Db_stmt {
|
||||
Reset_stmt();
|
||||
}
|
||||
public Db_stmt Reset_stmt() {
|
||||
stmt = (PreparedStatement)engine.New_stmt_prep_as_obj(sql);
|
||||
stmt = (PreparedStatement)engine.Stmt_by_sql(sql);
|
||||
return this;
|
||||
}
|
||||
public Db_stmt Crt_bool_as_byte(String k, boolean v) {return Add_byte_by_bool(Bool_.Y, k, v);}
|
||||
@@ -152,10 +152,10 @@ public class Db_stmt_cmd implements Db_stmt {
|
||||
try {DataRdr rv = engine.New_rdr(stmt.executeQuery(), sql); return rv;} catch (Exception e) {throw Err_.new_exc(e, "db", "failed to exec prepared statement", "sql", sql);}
|
||||
}
|
||||
public Db_rdr Exec_select__rls_auto() {
|
||||
try {return engine.New_rdr__rls_auto(this, stmt.executeQuery(), sql);} catch (Exception e) {throw Err_.new_exc(e, "db", "select failed", "sql", sql);}
|
||||
try {return engine.Exec_as_rdr__rls_auto(this, stmt.executeQuery(), sql);} catch (Exception e) {throw Err_.new_exc(e, "db", "select failed", "sql", sql);}
|
||||
}
|
||||
public Db_rdr Exec_select__rls_manual() {
|
||||
try {return engine.New_rdr__rls_manual(stmt.executeQuery(), sql);} catch (Exception e) {throw Err_.new_exc(e, "db", "select failed", "sql", sql);}
|
||||
try {return engine.Exec_as_rdr__rls_manual(stmt.executeQuery(), sql);} catch (Exception e) {throw Err_.new_exc(e, "db", "select failed", "sql", sql);}
|
||||
}
|
||||
public Object Exec_select_val() {
|
||||
try {Object rv = DataRdr_.Read_1st_row_and_1st_fld(engine.New_rdr(stmt.executeQuery(), sql)); return rv;} catch (Exception e) {throw Err_.new_exc(e, "db", "failed to exec prepared statement", "sql", sql);}
|
||||
|
||||
48
140_dbs/src/gplx/dbs/qrys/bats/Db_batch__journal_off.java
Normal file
48
140_dbs/src/gplx/dbs/qrys/bats/Db_batch__journal_off.java
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
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.qrys.bats; import gplx.*; import gplx.dbs.*; import gplx.dbs.qrys.*;
|
||||
import gplx.dbs.engines.*; import gplx.dbs.engines.sqlite.*;
|
||||
public class Db_batch__journal_off {
|
||||
public static void Batch__init(Db_batch_mgr batch_mgr) {
|
||||
batch_mgr.Conn_bgn().Add(Db_batch__journal_off__conn_bgn.Instance);
|
||||
batch_mgr.Conn_end().Add(Db_batch__journal_off__conn_end.Instance);
|
||||
}
|
||||
public static void Batch__term(Db_batch_mgr batch_mgr) {
|
||||
batch_mgr.Conn_bgn().Del(Db_batch__journal_off__conn_bgn.Instance.Key());
|
||||
batch_mgr.Conn_end().Del(Db_batch__journal_off__conn_end.Instance.Key());
|
||||
}
|
||||
}
|
||||
class Db_batch__journal_off__conn_bgn implements Db_batch_itm {
|
||||
public String Key() {return KEY;} public static final String KEY = "journal_off.conn_bgn";
|
||||
public void Qry_bat__run(Db_engine engine) {
|
||||
engine.Props().Add(Sqlite_pragma.Const__journal_mode, Sqlite_pragma.Const__journal_mode__off);
|
||||
engine.Exec_as_obj(Sqlite_pragma.New__journal__off()); // off b/c failure and corruption doesn't matter to import
|
||||
engine.Exec_as_obj(Sqlite_pragma.New__synchronous__off()); // off b/c failure and corruption doesn't matter to import
|
||||
}
|
||||
public static final Db_batch__journal_off__conn_bgn Instance = new Db_batch__journal_off__conn_bgn(); Db_batch__journal_off__conn_bgn() {}
|
||||
}
|
||||
class Db_batch__journal_off__conn_end implements Db_batch_itm {
|
||||
public String Key() {return KEY;} public static final String KEY = "journal_off.conn_end";
|
||||
public void Qry_bat__run(Db_engine engine) {
|
||||
if (!engine.Props().Match(Sqlite_pragma.Const__journal_mode, Sqlite_pragma.Const__journal_mode__off)) return;
|
||||
engine.Exec_as_obj(Sqlite_pragma.New__journal__delete());
|
||||
engine.Exec_as_obj(Sqlite_pragma.New__synchronous__full());
|
||||
engine.Props().Del(Sqlite_pragma.Const__journal_mode);
|
||||
}
|
||||
public static final Db_batch__journal_off__conn_end Instance = new Db_batch__journal_off__conn_end(); Db_batch__journal_off__conn_end() {}
|
||||
}
|
||||
62
140_dbs/src/gplx/dbs/qrys/bats/Db_batch__journal_wal.java
Normal file
62
140_dbs/src/gplx/dbs/qrys/bats/Db_batch__journal_wal.java
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
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.qrys.bats; import gplx.*; import gplx.dbs.*; import gplx.dbs.qrys.*;
|
||||
import gplx.dbs.engines.*; import gplx.dbs.engines.sqlite.*;
|
||||
public class Db_batch__journal_wal {
|
||||
public static void Batch__init(Db_batch_mgr batch_mgr) {
|
||||
batch_mgr.Conn_bgn().Add(Db_batch__journal_wal__conn_bgn.Instance);
|
||||
batch_mgr.Conn_end().Add(Db_batch__journal_wal__conn_end.Instance);
|
||||
batch_mgr.Conn_bgn().Add(Db_batch__journal_wal__txn_end.Instance);
|
||||
}
|
||||
public static void Batch__term(Db_batch_mgr batch_mgr) {
|
||||
batch_mgr.Conn_bgn().Del(Db_batch__journal_wal__conn_bgn.Instance.Key());
|
||||
batch_mgr.Conn_end().Del(Db_batch__journal_wal__conn_end.Instance.Key());
|
||||
batch_mgr.Txn_end().Del(Db_batch__journal_wal__txn_end.Instance.Key());
|
||||
}
|
||||
}
|
||||
class Db_batch__journal_wal__conn_bgn implements Db_batch_itm {
|
||||
public String Key() {return KEY;} public static final String KEY = "journal_wal.conn_bgn";
|
||||
public void Qry_bat__run(Db_engine engine) {
|
||||
if (engine.Props().Match(Sqlite_pragma.Const__journal_mode, Sqlite_pragma.Const__journal_mode__off)) return; // if off, don't enable wal
|
||||
if (engine.Props().Match(Sqlite_pragma.Const__journal_mode, Sqlite_pragma.Const__journal_mode__wal)) return; // if wal, don't enable again
|
||||
engine.Props().Add(Sqlite_pragma.Const__journal_mode, Sqlite_pragma.Const__journal_mode__wal);
|
||||
engine.Exec_as_obj(Sqlite_pragma.New__journal__wal());
|
||||
engine.Exec_as_obj(Sqlite_pragma.New__synchronous__normal());
|
||||
engine.Exec_as_obj(Sqlite_pragma.New__wal_autocheckpoint(0));
|
||||
}
|
||||
public static final Db_batch__journal_wal__conn_bgn Instance = new Db_batch__journal_wal__conn_bgn(); Db_batch__journal_wal__conn_bgn() {}
|
||||
}
|
||||
class Db_batch__journal_wal__conn_end implements Db_batch_itm {
|
||||
public String Key() {return KEY;} public static final String KEY = "journal_wal.conn_end";
|
||||
public void Qry_bat__run(Db_engine engine) {
|
||||
if (!engine.Props().Match(Sqlite_pragma.Const__journal_mode, Sqlite_pragma.Const__journal_mode__wal)) return; // if in off mode, don't enable wal
|
||||
engine.Exec_as_obj(Sqlite_pragma.New__wal_checkpoint__truncate());
|
||||
engine.Exec_as_obj(Sqlite_pragma.New__journal__delete());
|
||||
engine.Exec_as_obj(Sqlite_pragma.New__synchronous__full());
|
||||
engine.Props().Del(Sqlite_pragma.Const__journal_mode);
|
||||
}
|
||||
public static final Db_batch__journal_wal__conn_end Instance = new Db_batch__journal_wal__conn_end(); Db_batch__journal_wal__conn_end() {}
|
||||
}
|
||||
class Db_batch__journal_wal__txn_end implements Db_batch_itm {
|
||||
public String Key() {return KEY;} public static final String KEY = "journal_wal.txn_end";
|
||||
public void Qry_bat__run(Db_engine engine) {
|
||||
if (!engine.Props().Match(Sqlite_pragma.Const__journal_mode, Sqlite_pragma.Const__journal_mode__wal)) return; // if in off mode, don't enable wal
|
||||
engine.Exec_as_obj(Sqlite_pragma.New__wal_checkpoint__truncate());
|
||||
}
|
||||
public static final Db_batch__journal_wal__txn_end Instance = new Db_batch__journal_wal__txn_end(); Db_batch__journal_wal__txn_end() {}
|
||||
}
|
||||
43
140_dbs/src/gplx/dbs/qrys/bats/Db_batch_grp.java
Normal file
43
140_dbs/src/gplx/dbs/qrys/bats/Db_batch_grp.java
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
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.qrys.bats; import gplx.*; import gplx.dbs.*; import gplx.dbs.qrys.*;
|
||||
import gplx.dbs.engines.*;
|
||||
public class Db_batch_grp {
|
||||
public final Ordered_hash hash = Ordered_hash_.New();
|
||||
public Db_batch_grp(byte tid) {this.tid = tid;}
|
||||
public byte Tid() {return tid;} private final byte tid;
|
||||
public int Len() {return hash.Len();}
|
||||
public Db_batch_itm Get_at(int idx) {return (Db_batch_itm)hash.Get_at(idx); }
|
||||
public void Add(Db_batch_itm itm) {hash.Add(itm.Key(), itm);}
|
||||
public void Del(String key) {hash.Del(key);}
|
||||
public void Run(Db_engine engine) {
|
||||
int len = hash.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Db_batch_itm itm = (Db_batch_itm)hash.Get_at(i);
|
||||
itm.Qry_bat__run(engine);
|
||||
}
|
||||
}
|
||||
public void Copy(Db_batch_grp src) {
|
||||
int len = src.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Db_batch_itm itm = src.Get_at(i);
|
||||
this.Add(itm);
|
||||
}
|
||||
}
|
||||
public static final byte Tid__conn_bgn = 0, Tid__conn_end = 1, Tid__txn_bgn = 2, Tid__txn_end = 3;
|
||||
}
|
||||
23
140_dbs/src/gplx/dbs/qrys/bats/Db_batch_itm.java
Normal file
23
140_dbs/src/gplx/dbs/qrys/bats/Db_batch_itm.java
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
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.qrys.bats; import gplx.*; import gplx.dbs.*; import gplx.dbs.qrys.*;
|
||||
import gplx.dbs.engines.*;
|
||||
public interface Db_batch_itm {
|
||||
String Key();
|
||||
void Qry_bat__run(Db_engine engine);
|
||||
}
|
||||
28
140_dbs/src/gplx/dbs/qrys/bats/Db_batch_mgr.java
Normal file
28
140_dbs/src/gplx/dbs/qrys/bats/Db_batch_mgr.java
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
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.qrys.bats; import gplx.*; import gplx.dbs.*; import gplx.dbs.qrys.*;
|
||||
public class Db_batch_mgr {
|
||||
public Db_batch_grp Conn_bgn() {return conn_bgn;} private final Db_batch_grp conn_bgn = new Db_batch_grp(Db_batch_grp.Tid__conn_bgn);
|
||||
public Db_batch_grp Conn_end() {return conn_end;} private final Db_batch_grp conn_end = new Db_batch_grp(Db_batch_grp.Tid__conn_end);
|
||||
public Db_batch_grp Txn_end () {return txn_end;} private final Db_batch_grp txn_end = new Db_batch_grp(Db_batch_grp.Tid__txn_end);
|
||||
public void Copy(String src_tid, Db_batch_mgr src) {
|
||||
conn_bgn.Copy(src.conn_bgn);
|
||||
conn_end.Copy(src.conn_end);
|
||||
txn_end.Copy(src.txn_end);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user