Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
proview
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Esteban Blanc
proview
Commits
d9c8bf86
Commit
d9c8bf86
authored
Mar 24, 2011
by
Claes Sjofors
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Sev check/repair program for mysql history database
parent
45980764
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
253 additions
and
1 deletion
+253
-1
sev/exe/sev_repair/src/os_templ/hw_templ/makefile
sev/exe/sev_repair/src/os_templ/hw_templ/makefile
+12
-0
sev/exe/sev_repair/src/os_templ/link_rule.mk
sev/exe/sev_repair/src/os_templ/link_rule.mk
+9
-0
sev/exe/sev_repair/src/sev_repair.cpp
sev/exe/sev_repair/src/sev_repair.cpp
+89
-0
sev/exe/sev_repair/src/sev_repair.h
sev/exe/sev_repair/src/sev_repair.h
+42
-0
sev/lib/sev/src/sev_db.h
sev/lib/sev/src/sev_db.h
+1
-1
sev/lib/sev/src/sev_dbms.cpp
sev/lib/sev/src/sev_dbms.cpp
+98
-0
sev/lib/sev/src/sev_dbms.h
sev/lib/sev/src/sev_dbms.h
+1
-0
src/msg/rt/src/rt_sev_msg.msg
src/msg/rt/src/rt_sev_msg.msg
+1
-0
No files found.
sev/exe/sev_repair/src/os_templ/hw_templ/makefile
0 → 100644
View file @
d9c8bf86
include
$(pwre_dir_symbols)
-include
$(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/$(type_name)_generic.mk
ifeq
($($(type_name)_generic_mk),)
-include
$(pwre_kroot)/tools/bld/src/$(os_name)/$(type_name)_generic.mk
endif
ifeq
($($(type_name)_generic_mk),)
include
$(pwre_kroot)/tools/bld/src/$(type_name)_generic.mk
endif
sev/exe/sev_repair/src/os_templ/link_rule.mk
0 → 100644
View file @
d9c8bf86
ifndef
link_rule_mk
link_rule_mk
:=
1
link
=
$(ldxx)
$(elinkflags)
$(domap)
-o
$(export_exe)
\
$(export_obj)
$(objects)
$(wb_msg_eobjs)
$(rt_msg_eobjs)
\
$(pwr_eobj)
/rt_io_user.o
\
$(pwre_conf_libdir)
$(pwre_conf_libpwrsev)
$(pwre_conf_libpwrrt)
$(pwre_conf_lib)
endif
sev/exe/sev_repair/src/sev_repair.cpp
0 → 100644
View file @
d9c8bf86
/*
* Proview $Id$
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the Free Software Foundation, either version 2 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
#if defined PWRE_CONF_MYSQL
#include "pwr.h"
#include "co_cdh.h"
#include "co_dcli.h"
#include "co_time.h"
#include "sev_repair.h"
#include "sev_dbms.h"
#include "rt_sev_msg.h"
int
sev_repair
::
init
()
{
sev_dbms_env
*
env
;
pwr_tFileName
envname
;
sprintf
(
envname
,
"$pwrp_db/%s.db"
,
sev_dbms_env
::
dbName
());
dcli_translate_filename
(
envname
,
envname
);
env
=
new
sev_dbms_env
(
envname
);
env
->
open
(
envname
);
if
(
!
env
->
exists
())
{
printf
(
"** Error: Database environment doesn't exist
\n
"
);
exit
(
0
);
}
if
(
!
env
->
openDb
())
{
printf
(
"Failed to connect to database '%s'"
,
sev_dbms_env
::
dbName
());
exit
(
0
);
}
m_db
=
new
sev_dbms
(
env
);
printf
(
"-- Database opened '%s'
\n
"
,
sev_dbms_env
::
dbName
());
m_db
->
get_items
(
&
m_sts
);
m_db
->
get_objectitems
(
&
m_sts
);
return
1
;
}
int
sev_repair
::
check
()
{
pwr_tStatus
sts
;
int
fail_cnt
=
0
;
printf
(
"-- Number of tables to check: %u
\n
"
,
m_db
->
m_items
.
size
());
for
(
unsigned
int
i
=
0
;
i
<
m_db
->
m_items
.
size
();
i
++
)
{
m_db
->
repair_table
(
&
sts
,
m_db
->
m_items
[
i
].
tablename
);
if
(
EVEN
(
sts
))
fail_cnt
++
;
}
if
(
fail_cnt
)
printf
(
"** Repair failed on %d tables
\n
"
,
fail_cnt
);
else
printf
(
"-- Tables successfully repaired
\n
"
);
return
1
;
}
int
main
(
int
argc
,
char
*
argv
[])
{
sev_repair
rep
;
rep
.
init
();
rep
.
check
();
}
#else
int
main
(){}
#endif
sev/exe/sev_repair/src/sev_repair.h
0 → 100644
View file @
d9c8bf86
/*
* Proview $Id$
* Copyright (C) 2005 SSAB Oxelösund AB.
*
* 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 the Free Software Foundation, either version 2 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef sev_repair_h
#define sev_repair_h
#include <vector>
#include <map>
#include "pwr.h"
#include "pwr_class.h"
#include "rt_sev_net.h"
#include "sev_db.h"
class
sev_repair
{
public:
sev_repair
()
{}
pwr_tStatus
m_sts
;
sev_db
*
m_db
;
int
init
();
int
check
();
};
#endif
sev/lib/sev/src/sev_db.h
View file @
d9c8bf86
...
...
@@ -116,7 +116,7 @@ class sev_db {
unsigned
int
size
,
pwr_tTime
*
starttime
,
pwr_tTime
*
endtime
,
int
maxsize
,
pwr_tTime
**
tbuf
,
void
**
vbuf
,
unsigned
int
*
bsize
)
{
return
0
;}
virtual
int
handle_objectchange
(
pwr_tStatus
*
sts
,
char
*
tablename
,
unsigned
int
item_idx
,
bool
newObject
)
{
return
0
;}
virtual
int
repair_table
(
pwr_tStatus
*
sts
,
char
*
tablename
)
{
return
0
;}
};
#endif
sev/lib/sev/src/sev_dbms.cpp
View file @
d9c8bf86
...
...
@@ -3294,6 +3294,104 @@ int sev_dbms::handle_objectchange(pwr_tStatus *sts, char *tablename, unsigned in
return
1
;
}
int
sev_dbms
::
repair_table
(
pwr_tStatus
*
sts
,
char
*
tablename
)
{
char
query
[
200
];
int
rc
;
int
repair_table
;
int
repair_failed
;
// Check table
printf
(
"-- Checking table %s...
\n
"
,
tablename
);
sprintf
(
query
,
"check table %s"
,
tablename
);
rc
=
mysql_query
(
m_env
->
con
(),
query
);
if
(
rc
)
{
printf
(
"In %s row %d:
\n
"
,
__FILE__
,
__LINE__
);
printf
(
"%s: %s
\n
"
,
__FUNCTION__
,
mysql_error
(
m_env
->
con
()));
*
sts
=
SEV__DBERROR
;
return
0
;
}
else
{
MYSQL_ROW
row
;
MYSQL_RES
*
result
=
mysql_store_result
(
m_env
->
con
());
if
(
!
result
)
{
printf
(
"In %s row %d:
\n
"
,
__FILE__
,
__LINE__
);
printf
(
"%s Status Result Error
\n
"
,
__FUNCTION__
);
*
sts
=
SEV__DBERROR
;
return
0
;
}
int
rows
=
mysql_num_rows
(
result
);
for
(
int
i
=
0
;
i
<
rows
;
i
++
)
{
row
=
mysql_fetch_row
(
result
);
if
(
!
row
)
break
;
printf
(
"-- Check result '%s %s %s %s'
\n
"
,
row
[
0
],
row
[
1
],
row
[
2
],
row
[
3
]);
}
if
(
cdh_NoCaseStrcmp
(
row
[
3
],
"ok"
)
==
0
)
repair_table
=
0
;
else
repair_table
=
1
;
mysql_free_result
(
result
);
}
if
(
!
repair_table
)
{
*
sts
=
SEV__SUCCESS
;
return
*
sts
;
}
// Repair table
printf
(
"-- Repairing %s...
\n
"
,
tablename
);
sprintf
(
query
,
"repair table %s"
,
tablename
);
rc
=
mysql_query
(
m_env
->
con
(),
query
);
if
(
rc
)
{
printf
(
"In %s row %d:
\n
"
,
__FILE__
,
__LINE__
);
printf
(
"%s: %s
\n
"
,
__FUNCTION__
,
mysql_error
(
m_env
->
con
()));
*
sts
=
SEV__DBERROR
;
return
0
;
}
else
{
MYSQL_ROW
row
;
MYSQL_RES
*
result
=
mysql_store_result
(
m_env
->
con
());
if
(
!
result
)
{
printf
(
"In %s row %d:
\n
"
,
__FILE__
,
__LINE__
);
printf
(
"%s Status Result Error
\n
"
,
__FUNCTION__
);
*
sts
=
SEV__DBERROR
;
return
0
;
}
int
rows
=
mysql_num_rows
(
result
);
for
(
int
i
=
0
;
i
<
rows
;
i
++
)
{
row
=
mysql_fetch_row
(
result
);
if
(
!
row
)
break
;
printf
(
"-- Repair result '%s %s %s %s'
\n
"
,
row
[
0
],
row
[
1
],
row
[
2
],
row
[
3
]);
}
if
(
cdh_NoCaseStrcmp
(
row
[
3
],
"ok"
)
!=
0
)
{
printf
(
"** Error, repair failure %s
\n
"
,
row
[
0
]);
repair_failed
=
1
;
}
else
repair_failed
=
0
;
mysql_free_result
(
result
);
}
if
(
repair_failed
)
*
sts
=
SEV__REPAIR_FAILED
;
else
*
sts
=
SEV__SUCCESS
;
return
ODD
(
*
sts
);
}
sev_dbms
::~
sev_dbms
()
...
...
sev/lib/sev/src/sev_dbms.h
View file @
d9c8bf86
...
...
@@ -171,6 +171,7 @@ class sev_dbms : public sev_db {
pwr_tUInt64
get_nextAutoIncrement
(
char
*
tablename
);
int
handle_itemchange
(
pwr_tStatus
*
sts
,
char
*
tablename
,
unsigned
int
item_idx
);
int
handle_objectchange
(
pwr_tStatus
*
sts
,
char
*
tablename
,
unsigned
int
item_idx
,
bool
newObject
);
int
repair_table
(
pwr_tStatus
*
sts
,
char
*
tablename
);
inline
char
*
create_colName
(
unsigned
int
index
,
char
*
attributename
)
{
static
char
colName
[
constMaxColNameLength
];
strncpy
(
colName
,
attributename
,
constMaxColNameLength
);
...
...
src/msg/rt/src/rt_sev_msg.msg
View file @
d9c8bf86
...
...
@@ -30,6 +30,7 @@ noitems <No items found> /error
unknownnode <Unknown server nodename> /error
init <Initialization done> /info
exportfile <Unable to open export file> /error
repair_failed <Repair failed> /error
.end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment