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
bf62527f
Commit
bf62527f
authored
Jan 13, 2016
by
Claes Sjofors
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Sev server, mysql database created if it doesn't exist even if dbms enviroment exist
parent
afdff344
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
10 deletions
+22
-10
sev/lib/sev/src/sev_dbms.cpp
sev/lib/sev/src/sev_dbms.cpp
+21
-9
sev/lib/sev/src/sev_dbms.h
sev/lib/sev/src/sev_dbms.h
+1
-1
No files found.
sev/lib/sev/src/sev_dbms.cpp
View file @
bf62527f
...
@@ -45,6 +45,7 @@
...
@@ -45,6 +45,7 @@
#include <string>
#include <string>
#include <iostream>
#include <iostream>
#include <sstream>
#include <sstream>
#include <mysql/mysqld_error.h>
#include "pwr.h"
#include "pwr.h"
#include "pwr_baseclasses.h"
#include "pwr_baseclasses.h"
...
@@ -492,15 +493,15 @@ int sev_dbms_env::createSevVersion3Tables(void)
...
@@ -492,15 +493,15 @@ int sev_dbms_env::createSevVersion3Tables(void)
return
1
;
return
1
;
}
}
MYSQL
*
sev_dbms_env
::
openDb
()
MYSQL
*
sev_dbms_env
::
openDb
(
unsigned
int
*
sts
)
{
{
*
sts
=
0
;
m_con
=
mysql_init
(
NULL
);
m_con
=
mysql_init
(
NULL
);
MYSQL
*
con
=
mysql_real_connect
(
m_con
,
host
(),
user
(),
passwd
(),
dbName
(),
port
(),
socket
(),
0
);
MYSQL
*
con
=
mysql_real_connect
(
m_con
,
host
(),
user
(),
passwd
(),
dbName
(),
port
(),
socket
(),
0
);
// printf("Tried to connect to database, con %x: Status: %s\n", (int)con, mysql_error(m_con));
if
(
con
==
0
)
{
if
(
con
==
0
)
{
printf
(
"In %s row %d:
\n
"
,
__FILE__
,
__LINE__
);
*
sts
=
mysql_errno
(
m_con
);
printf
(
"Failed to connect to database: Error: %s
\n
"
,
mysql_error
(
m_con
));
return
0
;
return
0
;
}
}
...
@@ -573,8 +574,8 @@ int sev_dbms_env::open(void)
...
@@ -573,8 +574,8 @@ int sev_dbms_env::open(void)
FILE
*
fp
=
fopen
(
buf
,
"r"
);
FILE
*
fp
=
fopen
(
buf
,
"r"
);
if
(
fp
==
NULL
)
{
if
(
fp
==
NULL
)
{
printf
(
"In %s row %d:
\n
"
,
__FILE__
,
__LINE__
);
//
printf("In %s row %d:\n", __FILE__, __LINE__);
printf
(
"** Cannot open file: %s, %s
\n
"
,
buf
,
strerror
(
errno
));
//
printf("** Cannot open file: %s, %s\n", buf, strerror(errno));
return
errno
;
return
errno
;
}
}
...
@@ -674,6 +675,7 @@ sev_db *sev_dbms::open_database()
...
@@ -674,6 +675,7 @@ sev_db *sev_dbms::open_database()
char
socket
[
200
];
char
socket
[
200
];
sev_dbms_env
*
env
;
sev_dbms_env
*
env
;
sev_dbms
*
db
;
sev_dbms
*
db
;
unsigned
int
rc
;
sprintf
(
envname
,
"$pwrp_db/%s.db"
,
sev_dbms_env
::
dbName
());
sprintf
(
envname
,
"$pwrp_db/%s.db"
,
sev_dbms_env
::
dbName
());
dcli_translate_filename
(
envname
,
envname
);
dcli_translate_filename
(
envname
,
envname
);
...
@@ -693,11 +695,21 @@ sev_db *sev_dbms::open_database()
...
@@ -693,11 +695,21 @@ sev_db *sev_dbms::open_database()
}
}
}
}
else
{
else
{
if
(
!
env
->
openDb
())
{
if
(
!
env
->
openDb
(
&
rc
))
{
if
(
rc
==
ER_BAD_DB_ERROR
||
rc
==
ER_NO_DB_ERROR
)
{
// Database not created
if
(
!
env
->
createDb
())
{
errh_Fatal
(
"Failed to create to database '%s'"
,
sev_dbms_env
::
dbName
());
exit
(
0
);
}
}
else
{
printf
(
"No such database
\n
"
);
errh_Fatal
(
"Failed to connect to database '%s'"
,
sev_dbms_env
::
dbName
());
errh_Fatal
(
"Failed to connect to database '%s'"
,
sev_dbms_env
::
dbName
());
exit
(
0
);
exit
(
0
);
}
}
}
}
}
if
(
!
env
->
checkAndUpdateVersion
(
sev_cVersion
)
)
{
if
(
!
env
->
checkAndUpdateVersion
(
sev_cVersion
)
)
{
errh_Fatal
(
"Failed to upgrade tables to sev version %d db:'%s'"
,
sev_cVersion
,
sev_dbms_env
::
dbName
());
errh_Fatal
(
"Failed to upgrade tables to sev version %d db:'%s'"
,
sev_cVersion
,
sev_dbms_env
::
dbName
());
...
...
sev/lib/sev/src/sev_dbms.h
View file @
bf62527f
...
@@ -89,7 +89,7 @@ class sev_dbms_env
...
@@ -89,7 +89,7 @@ class sev_dbms_env
int
createSevVersion2Tables
(
void
);
int
createSevVersion2Tables
(
void
);
int
createSevVersion3Tables
(
void
);
int
createSevVersion3Tables
(
void
);
MYSQL
*
createDb
(
void
);
MYSQL
*
createDb
(
void
);
MYSQL
*
openDb
(
void
);
MYSQL
*
openDb
(
unsigned
int
*
sts
);
bool
exists
()
{
return
m_exists
;}
bool
exists
()
{
return
m_exists
;}
int
close
(
void
);
int
close
(
void
);
static
int
get_systemname
();
static
int
get_systemname
();
...
...
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