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
256d4639
Commit
256d4639
authored
May 23, 2004
by
Neil Conway
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
A few cosmetic fixes and code cleanup.
parent
9d6570b8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
13 deletions
+16
-13
src/bin/psql/common.c
src/bin/psql/common.c
+3
-2
src/bin/psql/print.c
src/bin/psql/print.c
+13
-11
No files found.
src/bin/psql/common.c
View file @
256d4639
...
...
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/bin/psql/common.c,v 1.8
6 2004/05/07 00:24:58 tgl
Exp $
* $PostgreSQL: pgsql/src/bin/psql/common.c,v 1.8
7 2004/05/23 22:20:10 neilc
Exp $
*/
#include "postgres_fe.h"
#include "common.h"
...
...
@@ -802,7 +802,8 @@ PrintQueryResults(PGresult *results)
char
buf
[
10
];
success
=
true
;
sprintf
(
buf
,
"%u"
,
(
unsigned
int
)
PQoidValue
(
results
));
snprintf
(
buf
,
sizeof
(
buf
),
"%u"
,
(
unsigned
int
)
PQoidValue
(
results
));
if
(
!
QUIET
())
{
if
(
pset
.
popt
.
topt
.
format
==
PRINT_HTML
)
...
...
src/bin/psql/print.c
View file @
256d4639
...
...
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/bin/psql/print.c,v 1.4
7 2004/05/18 20:18:58 momjian
Exp $
* $PostgreSQL: pgsql/src/bin/psql/print.c,v 1.4
8 2004/05/23 22:20:10 neilc
Exp $
*/
#include "postgres_fe.h"
#include "common.h"
...
...
@@ -1133,15 +1133,14 @@ void
printQuery
(
const
PGresult
*
result
,
const
printQueryOpt
*
opt
,
FILE
*
fout
)
{
int
nfields
;
int
ncells
;
const
char
**
headers
;
const
char
**
cells
;
char
**
footers
;
char
*
align
;
int
i
;
/* extract headers */
nfields
=
PQnfields
(
result
);
headers
=
calloc
(
nfields
+
1
,
sizeof
(
*
headers
));
...
...
@@ -1155,15 +1154,15 @@ printQuery(const PGresult *result, const printQueryOpt *opt, FILE *fout)
headers
[
i
]
=
mbvalidate
(
PQfname
(
result
,
i
),
opt
->
topt
.
encoding
);
/* set cells */
cells
=
calloc
(
n
fields
*
PQntuples
(
result
)
+
1
,
sizeof
(
*
cells
));
ncells
=
PQntuples
(
result
)
*
nfields
;
cells
=
calloc
(
n
cells
+
1
,
sizeof
(
*
cells
));
if
(
!
cells
)
{
perror
(
"calloc"
);
exit
(
EXIT_FAILURE
);
}
for
(
i
=
0
;
i
<
n
fields
*
PQntuples
(
result
)
;
i
++
)
for
(
i
=
0
;
i
<
n
cells
;
i
++
)
{
if
(
PQgetisnull
(
result
,
i
/
nfields
,
i
%
nfields
))
cells
[
i
]
=
opt
->
nullPrint
?
opt
->
nullPrint
:
""
;
...
...
@@ -1185,6 +1184,11 @@ printQuery(const PGresult *result, const printQueryOpt *opt, FILE *fout)
}
footers
[
0
]
=
malloc
(
100
);
if
(
!
footers
[
0
])
{
perror
(
"malloc"
);
exit
(
EXIT_FAILURE
);
}
if
(
PQntuples
(
result
)
==
1
)
snprintf
(
footers
[
0
],
100
,
gettext
(
"(1 row)"
));
else
...
...
@@ -1194,7 +1198,6 @@ printQuery(const PGresult *result, const printQueryOpt *opt, FILE *fout)
footers
=
NULL
;
/* set alignment */
align
=
calloc
(
nfields
+
1
,
sizeof
(
*
align
));
if
(
!
align
)
{
...
...
@@ -1221,13 +1224,12 @@ printQuery(const PGresult *result, const printQueryOpt *opt, FILE *fout)
}
/* call table printer */
printTable
(
opt
->
title
,
headers
,
cells
,
footers
?
(
const
char
*
const
*
)
footers
:
(
const
char
*
const
*
)
(
opt
->
footers
)
,
(
const
char
*
const
*
)
footers
,
align
,
&
opt
->
topt
,
fout
);
free
(
(
void
*
)
headers
);
free
(
(
void
*
)
cells
);
free
(
headers
);
free
(
cells
);
if
(
footers
)
{
free
(
footers
[
0
]);
...
...
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