Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
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
Abuhujair Javed
Postgres FD Implementation
Commits
871293fb
Commit
871293fb
authored
Mar 23, 2015
by
Alvaro Herrera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vacuumdb: Check result status of PQsendQuery
Noticed by Coverity
parent
4babae1a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
5 deletions
+20
-5
src/bin/scripts/vacuumdb.c
src/bin/scripts/vacuumdb.c
+20
-5
No files found.
src/bin/scripts/vacuumdb.c
View file @
871293fb
...
@@ -484,6 +484,11 @@ vacuum_one_database(const char *dbname, vacuumingOptions *vacopts,
...
@@ -484,6 +484,11 @@ vacuum_one_database(const char *dbname, vacuumingOptions *vacopts,
else
else
free_slot
=
slots
;
free_slot
=
slots
;
/*
* Execute the vacuum. If not in parallel mode, this terminates the
* program in case of an error. (The parallel case handles query
* errors in GetQueryResult through GetIdleSlot.)
*/
run_vacuum_command
(
free_slot
->
connection
,
sql
.
data
,
run_vacuum_command
(
free_slot
->
connection
,
sql
.
data
,
echo
,
dbname
,
tabname
,
progname
,
parallel
);
echo
,
dbname
,
tabname
,
progname
,
parallel
);
...
@@ -661,21 +666,27 @@ prepare_vacuum_command(PQExpBuffer sql, PGconn *conn, vacuumingOptions *vacopts,
...
@@ -661,21 +666,27 @@ prepare_vacuum_command(PQExpBuffer sql, PGconn *conn, vacuumingOptions *vacopts,
/*
/*
* Execute a vacuum/analyze command to the server.
* Execute a vacuum/analyze command to the server.
*
*
* Result status is checked only if 'async' is false.
* Any errors during command execution are reported to stderr. If async is
* false, this function exits the program after reporting the error.
*/
*/
static
void
static
void
run_vacuum_command
(
PGconn
*
conn
,
const
char
*
sql
,
bool
echo
,
run_vacuum_command
(
PGconn
*
conn
,
const
char
*
sql
,
bool
echo
,
const
char
*
dbname
,
const
char
*
table
,
const
char
*
dbname
,
const
char
*
table
,
const
char
*
progname
,
bool
async
)
const
char
*
progname
,
bool
async
)
{
{
bool
status
;
if
(
async
)
if
(
async
)
{
{
if
(
echo
)
if
(
echo
)
printf
(
"%s
\n
"
,
sql
);
printf
(
"%s
\n
"
,
sql
);
PQsendQuery
(
conn
,
sql
)
;
status
=
PQsendQuery
(
conn
,
sql
)
==
1
;
}
}
else
if
(
!
executeMaintenanceCommand
(
conn
,
sql
,
echo
))
else
status
=
executeMaintenanceCommand
(
conn
,
sql
,
echo
);
if
(
!
status
)
{
{
if
(
table
)
if
(
table
)
fprintf
(
stderr
,
fprintf
(
stderr
,
...
@@ -684,9 +695,13 @@ run_vacuum_command(PGconn *conn, const char *sql, bool echo,
...
@@ -684,9 +695,13 @@ run_vacuum_command(PGconn *conn, const char *sql, bool echo,
else
else
fprintf
(
stderr
,
_
(
"%s: vacuuming of database
\"
%s
\"
failed: %s"
),
fprintf
(
stderr
,
_
(
"%s: vacuuming of database
\"
%s
\"
failed: %s"
),
progname
,
dbname
,
PQerrorMessage
(
conn
));
progname
,
dbname
,
PQerrorMessage
(
conn
));
if
(
!
async
)
{
PQfinish
(
conn
);
PQfinish
(
conn
);
exit
(
1
);
exit
(
1
);
}
}
}
}
}
/*
/*
...
...
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