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
4e82924e
Commit
4e82924e
authored
Jul 31, 1996
by
Marc G. Fournier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Row count patch from Bruce
parent
7d2000e3
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
26 deletions
+38
-26
src/interfaces/libpq/fe-exec.c
src/interfaces/libpq/fe-exec.c
+35
-23
src/interfaces/libpq/libpq-fe.h
src/interfaces/libpq/libpq-fe.h
+3
-3
No files found.
src/interfaces/libpq/fe-exec.c
View file @
4e82924e
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.1
1 1996/07/31 06:05:46
scrappy Exp $
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.1
2 1996/07/31 18:40:09
scrappy Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -831,17 +831,18 @@ PQprint(FILE *fout,
...
@@ -831,17 +831,18 @@ PQprint(FILE *fout,
if
(
nFields
>
0
)
{
/* only print tuples with at least 1 field. */
if
(
nFields
>
0
)
{
/* only print tuples with at least 1 field. */
int
i
,
j
;
int
i
,
j
;
int
nTups
;
int
nTups
;
int
*
fieldMax
=
NULL
;
/* keep -Wall happy */
int
*
fieldMax
=
NULL
;
/* in case we don't use them */
unsigned
char
*
fieldNotNum
=
NULL
;
/* keep -Wall happy */
unsigned
char
*
fieldNotNum
=
NULL
;
char
**
fields
=
NULL
;
/*keep -Wall happy */
char
*
border
=
NULL
;
char
**
fields
=
NULL
;
char
**
fieldNames
;
char
**
fieldNames
;
int
fieldMaxLen
=
0
;
int
fieldMaxLen
=
0
;
char
*
border
=
NULL
;
int
numFieldName
;
int
numFieldName
;
int
fs_len
=
strlen
(
po
->
fieldSep
);
int
fs_len
=
strlen
(
po
->
fieldSep
);
int
total_line_length
=
0
;
int
total_line_length
=
0
;
int
usePipe
=
0
;
int
usePipe
=
0
;
char
*
pagerenv
;
char
*
pagerenv
;
char
buf
[
8192
*
2
+
1
];
nTups
=
PQntuples
(
res
);
nTups
=
PQntuples
(
res
);
if
(
!
(
fieldNames
=
(
char
**
)
calloc
(
nFields
,
sizeof
(
char
*
))))
if
(
!
(
fieldNames
=
(
char
**
)
calloc
(
nFields
,
sizeof
(
char
*
))))
...
@@ -882,7 +883,10 @@ PQprint(FILE *fout,
...
@@ -882,7 +883,10 @@ PQprint(FILE *fout,
if
(
fout
==
NULL
)
if
(
fout
==
NULL
)
fout
=
stdout
;
fout
=
stdout
;
if
(
po
->
pager
&&
fout
==
stdout
&&
isatty
(
fileno
(
stdout
)))
{
if
(
po
->
pager
&&
fout
==
stdout
&&
isatty
(
fileno
(
stdin
))
&&
isatty
(
fileno
(
stdout
)))
{
/* try to pipe to the pager program if possible */
/* try to pipe to the pager program if possible */
#ifdef TIOCGWINSZ
#ifdef TIOCGWINSZ
if
(
ioctl
(
fileno
(
stdout
),
TIOCGWINSZ
,
&
screen_size
)
==
-
1
||
if
(
ioctl
(
fileno
(
stdout
),
TIOCGWINSZ
,
&
screen_size
)
==
-
1
||
...
@@ -907,8 +911,7 @@ PQprint(FILE *fout,
...
@@ -907,8 +911,7 @@ PQprint(FILE *fout,
screen_size
.
ws_row
-
screen_size
.
ws_row
-
(
po
->
header
!=
0
)
*
(
po
->
header
!=
0
)
*
(
total_line_length
/
screen_size
.
ws_col
+
1
)
*
2
(
total_line_length
/
screen_size
.
ws_col
+
1
)
*
2
/*- 1 */
/* newline at end of tuple list */
-
(
po
->
header
!=
0
)
*
2
/* row count and newline */
/*- (quiet == 0)*/
)))
)))
{
{
fout
=
popen
(
pagerenv
,
"w"
);
fout
=
popen
(
pagerenv
,
"w"
);
...
@@ -927,7 +930,8 @@ PQprint(FILE *fout,
...
@@ -927,7 +930,8 @@ PQprint(FILE *fout,
perror
(
"calloc"
);
perror
(
"calloc"
);
exit
(
1
);
exit
(
1
);
}
}
}
else
}
else
if
(
po
->
header
&&
!
po
->
html3
)
if
(
po
->
header
&&
!
po
->
html3
)
{
{
if
(
po
->
expanded
)
if
(
po
->
expanded
)
...
@@ -936,7 +940,8 @@ PQprint(FILE *fout,
...
@@ -936,7 +940,8 @@ PQprint(FILE *fout,
fprintf
(
fout
,
"%-*s%s Value
\n
"
,
fieldMaxLen
-
fs_len
,
"Field"
,
po
->
fieldSep
);
fprintf
(
fout
,
"%-*s%s Value
\n
"
,
fieldMaxLen
-
fs_len
,
"Field"
,
po
->
fieldSep
);
else
else
fprintf
(
fout
,
"%s%sValue
\n
"
,
"Field"
,
po
->
fieldSep
);
fprintf
(
fout
,
"%s%sValue
\n
"
,
"Field"
,
po
->
fieldSep
);
}
else
}
else
{
{
int
len
=
0
;
int
len
=
0
;
for
(
j
=
0
;
j
<
nFields
;
j
++
)
for
(
j
=
0
;
j
<
nFields
;
j
++
)
...
@@ -959,8 +964,8 @@ PQprint(FILE *fout,
...
@@ -959,8 +964,8 @@ PQprint(FILE *fout,
else
else
fprintf
(
fout
,
"<centre><h2>Query retrieved %d tuples * %d fields</h2></centre>
\n
"
,
nTups
,
nFields
);
fprintf
(
fout
,
"<centre><h2>Query retrieved %d tuples * %d fields</h2></centre>
\n
"
,
nTups
,
nFields
);
}
}
for
(
i
=
0
;
i
<
nTups
;
i
++
)
{
for
(
i
=
0
;
i
<
nTups
;
i
++
)
char
buf
[
8192
*
2
+
1
];
{
if
(
po
->
expanded
)
if
(
po
->
expanded
)
{
{
if
(
po
->
html3
)
if
(
po
->
html3
)
...
@@ -968,7 +973,8 @@ PQprint(FILE *fout,
...
@@ -968,7 +973,8 @@ PQprint(FILE *fout,
else
else
fprintf
(
fout
,
"-- RECORD %d --
\n
"
,
i
);
fprintf
(
fout
,
"-- RECORD %d --
\n
"
,
i
);
}
}
for
(
j
=
0
;
j
<
nFields
;
j
++
)
{
for
(
j
=
0
;
j
<
nFields
;
j
++
)
{
char
*
pval
,
*
p
,
*
o
;
char
*
pval
,
*
p
,
*
o
;
int
plen
;
int
plen
;
if
((
plen
=
PQgetlength
(
res
,
i
,
j
))
<
1
||
!
(
pval
=
PQgetvalue
(
res
,
i
,
j
))
||
!*
pval
)
if
((
plen
=
PQgetlength
(
res
,
i
,
j
))
<
1
||
!
(
pval
=
PQgetvalue
(
res
,
i
,
j
))
||
!*
pval
)
...
@@ -996,7 +1002,8 @@ PQprint(FILE *fout,
...
@@ -996,7 +1002,8 @@ PQprint(FILE *fout,
exit
(
1
);
exit
(
1
);
}
}
strcpy
(
fields
[
i
*
nFields
+
j
],
buf
);
strcpy
(
fields
[
i
*
nFields
+
j
],
buf
);
}
else
}
else
{
{
if
(
po
->
expanded
)
if
(
po
->
expanded
)
{
{
...
@@ -1089,7 +1096,8 @@ efield:
...
@@ -1089,7 +1096,8 @@ efield:
{
{
fprintf
(
fout
,
"<th align=%s>%s</th>"
,
fieldNotNum
[
j
]
?
"left"
:
"right"
,
fprintf
(
fout
,
"<th align=%s>%s</th>"
,
fieldNotNum
[
j
]
?
"left"
:
"right"
,
fieldNames
[
j
]);
fieldNames
[
j
]);
}
else
}
else
{
{
int
n
=
strlen
(
s
);
int
n
=
strlen
(
s
);
if
(
n
>
fieldMax
[
j
])
if
(
n
>
fieldMax
[
j
])
...
@@ -1139,10 +1147,14 @@ efield:
...
@@ -1139,10 +1147,14 @@ efield:
}
}
free
(
fields
);
free
(
fields
);
}
}
if
(
po
->
header
&&
!
po
->
html3
)
fprintf
(
fout
,
"(%d row%s)
\n\n
"
,
PQntuples
(
res
),
(
PQntuples
(
res
)
==
1
)
?
""
:
"s"
);
free
(
fieldMax
);
free
(
fieldMax
);
free
(
fieldNotNum
);
free
(
fieldNotNum
);
free
(
fieldNames
);
free
(
fieldNames
);
if
(
usePipe
)
{
if
(
usePipe
)
{
pclose
(
fout
);
pclose
(
fout
);
signal
(
SIGPIPE
,
SIG_DFL
);
signal
(
SIGPIPE
,
SIG_DFL
);
}
}
...
...
src/interfaces/libpq/libpq-fe.h
View file @
4e82924e
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
*
*
* Copyright (c) 1994, Regents of the University of California
* Copyright (c) 1994, Regents of the University of California
*
*
* $Id: libpq-fe.h,v 1.
4 1996/07/27 02:55:23
scrappy Exp $
* $Id: libpq-fe.h,v 1.
5 1996/07/31 18:40:12
scrappy Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -128,7 +128,7 @@ typedef struct pg_result{
...
@@ -128,7 +128,7 @@ typedef struct pg_result{
}
PGresult
;
}
PGresult
;
struct
_PQprintOpt
{
struct
_PQprintOpt
{
bool
header
;
/* print output field head
ers or no
t */
bool
header
;
/* print output field head
ings and row coun
t */
bool
align
;
/* fill align the fields */
bool
align
;
/* fill align the fields */
bool
standard
;
/* old brain dead format */
bool
standard
;
/* old brain dead format */
bool
html3
;
/* output html tables */
bool
html3
;
/* output html tables */
...
...
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