summaryrefslogtreecommitdiffstats
path: root/frontends/php
diff options
context:
space:
mode:
authoralex <alex@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-02-27 12:53:58 +0000
committeralex <alex@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-02-27 12:53:58 +0000
commit2713d9853752255ed1b53c7f9ed2abf92af5cac8 (patch)
tree9ba9dcf1536e720f3ebbc8643de218e63b032ed2 /frontends/php
parentc8b70e6fece0a0aed254bb34cdc02b07dcf8c08e (diff)
downloadzabbix-2713d9853752255ed1b53c7f9ed2abf92af5cac8.tar.gz
zabbix-2713d9853752255ed1b53c7f9ed2abf92af5cac8.tar.xz
zabbix-2713d9853752255ed1b53c7f9ed2abf92af5cac8.zip
- added new table 'ids' which will store last IDs for all tables (Alexei)
git-svn-id: svn://svn.zabbix.com/trunk@3841 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php')
-rw-r--r--frontends/php/include/db.inc.php46
1 files changed, 45 insertions, 1 deletions
diff --git a/frontends/php/include/db.inc.php b/frontends/php/include/db.inc.php
index 31ba741b..d0fc8018 100644
--- a/frontends/php/include/db.inc.php
+++ b/frontends/php/include/db.inc.php
@@ -466,7 +466,7 @@ if(isset($DB_TYPE) && $DB_TYPE == "ORACLE") {
if(!isset($ZBX_CURNODEID)) init_nodes();
- $row=DBfetch(DBselect("select max($field) as id from $table where ".DBid2nodeid($field)." in (".$ZBX_CURNODEID.")"));
+/* $row=DBfetch(DBselect("select max($field) as id from $table where ".DBid2nodeid($field)." in (".$ZBX_CURNODEID.")"));
if($row && !is_null($row["id"]))
{
return bcadd($row["id"],1);
@@ -474,6 +474,50 @@ if(isset($DB_TYPE) && $DB_TYPE == "ORACLE") {
else
{
return bcadd(bcmul($ZBX_CURNODEID,"100000000000000"),1);
+ }*/
+
+
+ $found = false;
+ do
+ {
+ $row = DBfetch(DBselect("select nextid from ids where nodeid=$ZBX_CURNODEID and table_name='$table' and field_name='$field'"));
+ if(!$row || is_null($row["nextid"]))
+ {
+ $row=DBfetch(DBselect("select max($field) as id from $table where ".DBid2nodeid($field)." in (".$ZBX_CURNODEID.")"));
+ if(!$row || is_null($row["id"]))
+ {
+ DBexecute("insert into ids (nodeid,table_name,field_name,nextid) values ($ZBX_CURNODEID,'$table','$field',1)");
+ }
+ else
+ {
+ DBexecute("insert into ids (nodeid,table_name,field_name,nextid) values ($ZBX_CURNODEID,'$table','$field',".$row["id"].")");
+ }
+ continue;
+ }
+ else
+ {
+ $ret1 = $row["nextid"];
+
+ DBexecute("update ids set nextid=nextid+1 where nodeid=$ZBX_CURNODEID and table_name='$table' and field_name='$field'");
+
+ $row = DBfetch(DBselect("select nextid from ids where nodeid=$ZBX_CURNODEID and table_name='$table' and field_name='$field'"));
+ if(!$row || is_null($row["nextid"]))
+ {
+ /* Should never be here */
+ continue;
+ }
+ else
+ {
+ $ret2 = $row["nextid"];
+ if(bccomp(bcadd($ret1,1),$ret2) ==0)
+ {
+ $found = true;
+ }
+ }
+ }
}
+ while(false == $found);
+
+ return bcadd(bcmul($ZBX_CURNODEID,"100000000000000"),$ret2);
}
?>