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
4db7f15b
Commit
4db7f15b
authored
Aug 10, 1996
by
Marc G. Fournier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updates to libpq to fix breakage in previous patch...
Submitted by: darcy@druid.druid.com (D'Arcy J.M. Cain)
parent
ae472529
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
56 deletions
+57
-56
src/interfaces/libpq/fe-connect.c
src/interfaces/libpq/fe-connect.c
+4
-3
src/interfaces/libpq/fe-exec.c
src/interfaces/libpq/fe-exec.c
+53
-53
No files found.
src/interfaces/libpq/fe-connect.c
View file @
4db7f15b
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.
5 1996/08/06 16:16:45
scrappy Exp $
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.
6 1996/08/10 00:22:44
scrappy Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -35,7 +35,8 @@ strdup(const char *string)
...
@@ -35,7 +35,8 @@ strdup(const char *string)
{
{
char
*
nstr
;
char
*
nstr
;
nstr
=
strcpy
((
char
*
)
malloc
(
strlen
(
string
)
+
1
),
string
);
if
((
nstr
=
malloc
(
strlen
(
string
)
+
1
))
!=
NULL
)
strcpy
(
nstr
,
string
);
return
nstr
;
return
nstr
;
}
}
#endif
#endif
...
@@ -133,7 +134,7 @@ PQsetdb(const char *pghost, const char* pgport, const char* pgoptions, const cha
...
@@ -133,7 +134,7 @@ PQsetdb(const char *pghost, const char* pgport, const char* pgoptions, const cha
conn
->
dbName
=
strdup
(
tmp
);
conn
->
dbName
=
strdup
(
tmp
);
}
else
{
}
else
{
char
errorMessage
[
ERROR_MSG_LENGTH
];
char
errorMessage
[
ERROR_MSG_LENGTH
];
if
(
tmp
=
fe_getauthname
(
errorMessage
)
)
{
if
(
(
tmp
=
fe_getauthname
(
errorMessage
))
!=
0
)
{
conn
->
dbName
=
strdup
(
tmp
);
conn
->
dbName
=
strdup
(
tmp
);
free
(
tmp
);
free
(
tmp
);
}
else
{
}
else
{
...
...
src/interfaces/libpq/fe-exec.c
View file @
4db7f15b
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.1
3 1996/08/06 16:16:46
scrappy Exp $
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.1
4 1996/08/10 00:22:48
scrappy Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -131,7 +131,7 @@ getTuple(PGconn *conn, PGresult* result, int binary)
...
@@ -131,7 +131,7 @@ getTuple(PGconn *conn, PGresult* result, int binary)
int
bitcnt
=
0
;
/* number of bits examined in current byte */
int
bitcnt
=
0
;
/* number of bits examined in current byte */
int
vlen
;
/* length of the current field value */
int
vlen
;
/* length of the current field value */
FILE
*
pfin
=
conn
->
Pfin
;
FILE
*
pfin
=
conn
->
Pfin
;
FILE
*
P
fdebug
=
conn
->
Pfdebug
;
FILE
*
p
fdebug
=
conn
->
Pfdebug
;
PGresAttValue
*
tup
;
PGresAttValue
*
tup
;
...
@@ -145,7 +145,7 @@ getTuple(PGconn *conn, PGresult* result, int binary)
...
@@ -145,7 +145,7 @@ getTuple(PGconn *conn, PGresult* result, int binary)
if
(
(
nfields
%
BYTELEN
)
>
0
)
if
(
(
nfields
%
BYTELEN
)
>
0
)
nbytes
++
;
nbytes
++
;
if
(
pqGetnchar
(
bitmap
,
nbytes
,
pfin
,
P
fdebug
)
==
1
){
if
(
pqGetnchar
(
bitmap
,
nbytes
,
pfin
,
p
fdebug
)
==
1
){
sprintf
(
conn
->
errorMessage
,
sprintf
(
conn
->
errorMessage
,
"Error reading null-values bitmap from tuple data stream
\n
"
);
"Error reading null-values bitmap from tuple data stream
\n
"
);
return
NULL
;
return
NULL
;
...
@@ -164,7 +164,7 @@ getTuple(PGconn *conn, PGresult* result, int binary)
...
@@ -164,7 +164,7 @@ getTuple(PGconn *conn, PGresult* result, int binary)
}
}
else
{
else
{
/* get the value length (the first four bytes are for length) */
/* get the value length (the first four bytes are for length) */
pqGetInt
(
&
vlen
,
VARHDRSZ
,
pfin
,
P
fdebug
);
pqGetInt
(
&
vlen
,
VARHDRSZ
,
pfin
,
p
fdebug
);
if
(
binary
==
0
)
{
if
(
binary
==
0
)
{
vlen
=
vlen
-
VARHDRSZ
;
vlen
=
vlen
-
VARHDRSZ
;
}
}
...
@@ -174,7 +174,7 @@ getTuple(PGconn *conn, PGresult* result, int binary)
...
@@ -174,7 +174,7 @@ getTuple(PGconn *conn, PGresult* result, int binary)
tup
[
i
].
value
=
(
char
*
)
malloc
(
vlen
+
1
);
tup
[
i
].
value
=
(
char
*
)
malloc
(
vlen
+
1
);
/* read in the value; */
/* read in the value; */
if
(
vlen
>
0
)
if
(
vlen
>
0
)
pqGetnchar
((
char
*
)(
tup
[
i
].
value
),
vlen
,
pfin
,
P
fdebug
);
pqGetnchar
((
char
*
)(
tup
[
i
].
value
),
vlen
,
pfin
,
p
fdebug
);
tup
[
i
].
value
[
vlen
]
=
'\0'
;
tup
[
i
].
value
[
vlen
]
=
'\0'
;
}
}
/* get the appropriate bitmap */
/* get the appropriate bitmap */
...
@@ -241,7 +241,7 @@ makePGresult(PGconn* conn, char* pname)
...
@@ -241,7 +241,7 @@ makePGresult(PGconn* conn, char* pname)
PGresAttValue
*
newTup
;
PGresAttValue
*
newTup
;
FILE
*
pfin
=
conn
->
Pfin
;
FILE
*
pfin
=
conn
->
Pfin
;
FILE
*
P
fdebug
=
conn
->
Pfdebug
;
FILE
*
p
fdebug
=
conn
->
Pfdebug
;
result
=
makeEmptyPGresult
(
conn
,
PGRES_TUPLES_OK
);
result
=
makeEmptyPGresult
(
conn
,
PGRES_TUPLES_OK
);
...
@@ -249,7 +249,7 @@ makePGresult(PGconn* conn, char* pname)
...
@@ -249,7 +249,7 @@ makePGresult(PGconn* conn, char* pname)
/* id of the stream is 'T' to start with */
/* id of the stream is 'T' to start with */
/* the next two bytes are the number of fields */
/* the next two bytes are the number of fields */
if
(
pqGetInt
(
&
nfields
,
2
,
pfin
,
P
fdebug
)
==
1
)
{
if
(
pqGetInt
(
&
nfields
,
2
,
pfin
,
p
fdebug
)
==
1
)
{
sprintf
(
conn
->
errorMessage
,
sprintf
(
conn
->
errorMessage
,
"could not get the number of fields from the 'T' message
\n
"
);
"could not get the number of fields from the 'T' message
\n
"
);
goto
makePGresult_badResponse_return
;
goto
makePGresult_badResponse_return
;
...
@@ -268,9 +268,9 @@ makePGresult(PGconn* conn, char* pname)
...
@@ -268,9 +268,9 @@ makePGresult(PGconn* conn, char* pname)
int
adtid
;
int
adtid
;
int
adtsize
;
int
adtsize
;
if
(
pqGets
(
typName
,
MAX_MESSAGE_LEN
,
pfin
,
P
fdebug
)
||
if
(
pqGets
(
typName
,
MAX_MESSAGE_LEN
,
pfin
,
p
fdebug
)
||
pqGetInt
(
&
adtid
,
4
,
pfin
,
P
fdebug
)
||
pqGetInt
(
&
adtid
,
4
,
pfin
,
p
fdebug
)
||
pqGetInt
(
&
adtsize
,
2
,
pfin
,
P
fdebug
))
{
pqGetInt
(
&
adtsize
,
2
,
pfin
,
p
fdebug
))
{
sprintf
(
conn
->
errorMessage
,
sprintf
(
conn
->
errorMessage
,
"error reading type information from the 'T' message
\n
"
);
"error reading type information from the 'T' message
\n
"
);
goto
makePGresult_badResponse_return
;
goto
makePGresult_badResponse_return
;
...
@@ -281,7 +281,7 @@ makePGresult(PGconn* conn, char* pname)
...
@@ -281,7 +281,7 @@ makePGresult(PGconn* conn, char* pname)
result
->
attDescs
[
i
].
adtsize
=
adtsize
;
/* casting from int to int2 here */
result
->
attDescs
[
i
].
adtsize
=
adtsize
;
/* casting from int to int2 here */
}
}
id
=
pqGetc
(
pfin
,
P
fdebug
);
id
=
pqGetc
(
pfin
,
p
fdebug
);
/* process the data stream until we're finished */
/* process the data stream until we're finished */
while
(
!
done
)
{
while
(
!
done
)
{
...
@@ -306,12 +306,12 @@ makePGresult(PGconn* conn, char* pname)
...
@@ -306,12 +306,12 @@ makePGresult(PGconn* conn, char* pname)
case
'C'
:
/* end of portal tuple stream */
case
'C'
:
/* end of portal tuple stream */
{
{
char
command
[
MAX_MESSAGE_LEN
];
char
command
[
MAX_MESSAGE_LEN
];
pqGets
(
command
,
MAX_MESSAGE_LEN
,
pfin
,
P
fdebug
);
/* read the command tag */
pqGets
(
command
,
MAX_MESSAGE_LEN
,
pfin
,
p
fdebug
);
/* read the command tag */
done
=
1
;
done
=
1
;
}
}
break
;
break
;
case
'E'
:
/* errors */
case
'E'
:
/* errors */
if
(
pqGets
(
conn
->
errorMessage
,
ERROR_MSG_LENGTH
,
pfin
,
P
fdebug
)
==
1
)
{
if
(
pqGets
(
conn
->
errorMessage
,
ERROR_MSG_LENGTH
,
pfin
,
p
fdebug
)
==
1
)
{
sprintf
(
conn
->
errorMessage
,
sprintf
(
conn
->
errorMessage
,
"Error return detected from backend, but error message cannot be read"
);
"Error return detected from backend, but error message cannot be read"
);
}
}
...
@@ -319,7 +319,7 @@ makePGresult(PGconn* conn, char* pname)
...
@@ -319,7 +319,7 @@ makePGresult(PGconn* conn, char* pname)
return
result
;
return
result
;
break
;
break
;
case
'N'
:
/* notices from the backend */
case
'N'
:
/* notices from the backend */
if
(
pqGets
(
conn
->
errorMessage
,
ERROR_MSG_LENGTH
,
pfin
,
P
fdebug
)
==
1
)
{
if
(
pqGets
(
conn
->
errorMessage
,
ERROR_MSG_LENGTH
,
pfin
,
p
fdebug
)
==
1
)
{
sprintf
(
conn
->
errorMessage
,
sprintf
(
conn
->
errorMessage
,
"Notice return detected from backend, but error message cannot be read"
);
"Notice return detected from backend, but error message cannot be read"
);
}
else
}
else
...
@@ -370,7 +370,7 @@ PQexec(PGconn* conn, const char* query)
...
@@ -370,7 +370,7 @@ PQexec(PGconn* conn, const char* query)
char
cmdStatus
[
MAX_MESSAGE_LEN
];
char
cmdStatus
[
MAX_MESSAGE_LEN
];
char
pname
[
MAX_MESSAGE_LEN
];
/* portal name */
char
pname
[
MAX_MESSAGE_LEN
];
/* portal name */
PGnotify
*
newNotify
;
PGnotify
*
newNotify
;
FILE
*
pfin
,
*
pfout
,
*
P
fdebug
;
FILE
*
pfin
,
*
pfout
,
*
p
fdebug
;
pname
[
0
]
=
'\0'
;
pname
[
0
]
=
'\0'
;
...
@@ -380,9 +380,9 @@ PQexec(PGconn* conn, const char* query)
...
@@ -380,9 +380,9 @@ PQexec(PGconn* conn, const char* query)
return
NULL
;
return
NULL
;
}
}
P
fin
=
conn
->
Pfin
;
p
fin
=
conn
->
Pfin
;
P
fout
=
conn
->
Pfout
;
p
fout
=
conn
->
Pfout
;
P
fdebug
=
conn
->
Pfdebug
;
p
fdebug
=
conn
->
Pfdebug
;
/*clear the error string */
/*clear the error string */
conn
->
errorMessage
[
0
]
=
'\0'
;
conn
->
errorMessage
[
0
]
=
'\0'
;
...
@@ -397,7 +397,7 @@ PQexec(PGconn* conn, const char* query)
...
@@ -397,7 +397,7 @@ PQexec(PGconn* conn, const char* query)
sprintf
(
buffer
,
"Q%s"
,
query
);
sprintf
(
buffer
,
"Q%s"
,
query
);
/* send the query to the backend; */
/* send the query to the backend; */
if
(
pqPuts
(
buffer
,
pfout
,
P
fdebug
)
==
1
)
{
if
(
pqPuts
(
buffer
,
pfout
,
p
fdebug
)
==
1
)
{
(
void
)
sprintf
(
conn
->
errorMessage
,
(
void
)
sprintf
(
conn
->
errorMessage
,
"PQexec() -- while sending query: %s
\n
-- fprintf to Pfout failed: errno=%d
\n
%s
\n
"
,
"PQexec() -- while sending query: %s
\n
-- fprintf to Pfout failed: errno=%d
\n
%s
\n
"
,
query
,
errno
,
strerror
(
errno
));
query
,
errno
,
strerror
(
errno
));
...
@@ -412,7 +412,7 @@ PQexec(PGconn* conn, const char* query)
...
@@ -412,7 +412,7 @@ PQexec(PGconn* conn, const char* query)
while
(
1
)
{
while
(
1
)
{
/* read the result id */
/* read the result id */
id
=
pqGetc
(
pfin
,
P
fdebug
);
id
=
pqGetc
(
pfin
,
p
fdebug
);
if
(
id
==
EOF
)
{
if
(
id
==
EOF
)
{
/* hmm, no response from the backend-end, that's bad */
/* hmm, no response from the backend-end, that's bad */
(
void
)
sprintf
(
conn
->
errorMessage
,
(
void
)
sprintf
(
conn
->
errorMessage
,
...
@@ -423,14 +423,14 @@ PQexec(PGconn* conn, const char* query)
...
@@ -423,14 +423,14 @@ PQexec(PGconn* conn, const char* query)
switch
(
id
)
{
switch
(
id
)
{
case
'A'
:
case
'A'
:
newNotify
=
(
PGnotify
*
)
malloc
(
sizeof
(
PGnotify
));
newNotify
=
(
PGnotify
*
)
malloc
(
sizeof
(
PGnotify
));
pqGetInt
(
&
(
newNotify
->
be_pid
),
4
,
pfin
,
P
fdebug
);
pqGetInt
(
&
(
newNotify
->
be_pid
),
4
,
pfin
,
p
fdebug
);
pqGets
(
newNotify
->
relname
,
NAMEDATALEN
,
pfin
,
P
fdebug
);
pqGets
(
newNotify
->
relname
,
NAMEDATALEN
,
pfin
,
p
fdebug
);
DLAddTail
(
conn
->
notifyList
,
DLNewElem
(
newNotify
));
DLAddTail
(
conn
->
notifyList
,
DLNewElem
(
newNotify
));
/* async messages are piggy'ed back on other messages,
/* async messages are piggy'ed back on other messages,
so we stay in the while loop for other messages */
so we stay in the while loop for other messages */
break
;
break
;
case
'C'
:
/* portal query command, no tuples returned */
case
'C'
:
/* portal query command, no tuples returned */
if
(
pqGets
(
cmdStatus
,
MAX_MESSAGE_LEN
,
pfin
,
P
fdebug
)
==
1
)
{
if
(
pqGets
(
cmdStatus
,
MAX_MESSAGE_LEN
,
pfin
,
p
fdebug
)
==
1
)
{
sprintf
(
conn
->
errorMessage
,
sprintf
(
conn
->
errorMessage
,
"PQexec() -- query command completed, but return message from backend cannot be read"
);
"PQexec() -- query command completed, but return message from backend cannot be read"
);
return
(
PGresult
*
)
NULL
;
return
(
PGresult
*
)
NULL
;
...
@@ -444,10 +444,10 @@ PQexec(PGconn* conn, const char* query)
...
@@ -444,10 +444,10 @@ PQexec(PGconn* conn, const char* query)
*/
*/
clear
=
0
;
clear
=
0
;
pqPuts
(
"Q "
,
pfout
,
P
fdebug
);
/* send an empty query */
pqPuts
(
"Q "
,
pfout
,
p
fdebug
);
/* send an empty query */
while
(
!
clear
)
while
(
!
clear
)
{
{
if
(
pqGets
(
buffer
,
ERROR_MSG_LENGTH
,
pfin
,
P
fdebug
)
==
1
)
if
(
pqGets
(
buffer
,
ERROR_MSG_LENGTH
,
pfin
,
p
fdebug
)
==
1
)
clear
=
1
;
clear
=
1
;
clear
=
(
buffer
[
0
]
==
'I'
);
clear
=
(
buffer
[
0
]
==
'I'
);
}
}
...
@@ -457,7 +457,7 @@ PQexec(PGconn* conn, const char* query)
...
@@ -457,7 +457,7 @@ PQexec(PGconn* conn, const char* query)
}
}
break
;
break
;
case
'E'
:
/* error return */
case
'E'
:
/* error return */
if
(
pqGets
(
conn
->
errorMessage
,
ERROR_MSG_LENGTH
,
pfin
,
P
fdebug
)
==
1
)
{
if
(
pqGets
(
conn
->
errorMessage
,
ERROR_MSG_LENGTH
,
pfin
,
p
fdebug
)
==
1
)
{
(
void
)
sprintf
(
conn
->
errorMessage
,
(
void
)
sprintf
(
conn
->
errorMessage
,
"PQexec() -- error return detected from backend, but error message cannot be read"
);
"PQexec() -- error return detected from backend, but error message cannot be read"
);
}
}
...
@@ -467,7 +467,7 @@ PQexec(PGconn* conn, const char* query)
...
@@ -467,7 +467,7 @@ PQexec(PGconn* conn, const char* query)
/* read the throw away the closing '\0' */
/* read the throw away the closing '\0' */
{
{
int
c
;
int
c
;
if
((
c
=
pqGetc
(
pfin
,
P
fdebug
))
!=
'\0'
)
{
if
((
c
=
pqGetc
(
pfin
,
p
fdebug
))
!=
'\0'
)
{
fprintf
(
stderr
,
"error!, unexpected character %c following 'I'
\n
"
,
c
);
fprintf
(
stderr
,
"error!, unexpected character %c following 'I'
\n
"
,
c
);
}
}
result
=
makeEmptyPGresult
(
conn
,
PGRES_EMPTY_QUERY
);
result
=
makeEmptyPGresult
(
conn
,
PGRES_EMPTY_QUERY
);
...
@@ -475,7 +475,7 @@ PQexec(PGconn* conn, const char* query)
...
@@ -475,7 +475,7 @@ PQexec(PGconn* conn, const char* query)
}
}
break
;
break
;
case
'N'
:
/* notices from the backend */
case
'N'
:
/* notices from the backend */
if
(
pqGets
(
conn
->
errorMessage
,
ERROR_MSG_LENGTH
,
pfin
,
P
fdebug
)
==
1
)
{
if
(
pqGets
(
conn
->
errorMessage
,
ERROR_MSG_LENGTH
,
pfin
,
p
fdebug
)
==
1
)
{
sprintf
(
conn
->
errorMessage
,
sprintf
(
conn
->
errorMessage
,
"PQexec() -- error return detected from backend, but error message cannot be read"
);
"PQexec() -- error return detected from backend, but error message cannot be read"
);
return
(
PGresult
*
)
NULL
;
return
(
PGresult
*
)
NULL
;
...
@@ -484,7 +484,7 @@ PQexec(PGconn* conn, const char* query)
...
@@ -484,7 +484,7 @@ PQexec(PGconn* conn, const char* query)
fprintf
(
stderr
,
"%s"
,
conn
->
errorMessage
);
fprintf
(
stderr
,
"%s"
,
conn
->
errorMessage
);
break
;
break
;
case
'P'
:
/* synchronous (normal) portal */
case
'P'
:
/* synchronous (normal) portal */
pqGets
(
pname
,
MAX_MESSAGE_LEN
,
pfin
,
P
fdebug
);
/* read in the portal name*/
pqGets
(
pname
,
MAX_MESSAGE_LEN
,
pfin
,
p
fdebug
);
/* read in the portal name*/
break
;
break
;
case
'T'
:
/* actual tuple results: */
case
'T'
:
/* actual tuple results: */
return
makePGresult
(
conn
,
pname
);
return
makePGresult
(
conn
,
pname
);
...
@@ -605,21 +605,21 @@ int
...
@@ -605,21 +605,21 @@ int
PQendcopy
(
PGconn
*
conn
)
PQendcopy
(
PGconn
*
conn
)
{
{
char
id
;
char
id
;
FILE
*
pfin
,
*
P
fdebug
;
FILE
*
pfin
,
*
p
fdebug
;
if
(
!
conn
)
return
(
int
)
NULL
;
if
(
!
conn
)
return
(
int
)
NULL
;
P
fin
=
conn
->
Pfin
;
p
fin
=
conn
->
Pfin
;
P
fdebug
=
conn
->
Pfdebug
;
p
fdebug
=
conn
->
Pfdebug
;
if
(
(
id
=
pqGetc
(
pfin
,
P
fdebug
))
>
0
)
if
(
(
id
=
pqGetc
(
pfin
,
p
fdebug
))
>
0
)
return
(
0
);
return
(
0
);
switch
(
id
)
{
switch
(
id
)
{
case
'Z'
:
/* backend finished the copy */
case
'Z'
:
/* backend finished the copy */
return
(
1
);
return
(
1
);
case
'E'
:
case
'E'
:
case
'N'
:
case
'N'
:
if
(
pqGets
(
conn
->
errorMessage
,
ERROR_MSG_LENGTH
,
pfin
,
P
fdebug
)
==
1
)
{
if
(
pqGets
(
conn
->
errorMessage
,
ERROR_MSG_LENGTH
,
pfin
,
p
fdebug
)
==
1
)
{
sprintf
(
conn
->
errorMessage
,
sprintf
(
conn
->
errorMessage
,
"Error return detected from backend, but error message cannot be read"
);
"Error return detected from backend, but error message cannot be read"
);
}
}
...
@@ -1197,37 +1197,37 @@ PQfn(PGconn *conn,
...
@@ -1197,37 +1197,37 @@ PQfn(PGconn *conn,
PQArgBlock
*
args
,
PQArgBlock
*
args
,
int
nargs
)
int
nargs
)
{
{
FILE
*
pfin
,
*
pfout
,
*
P
fdebug
;
FILE
*
pfin
,
*
pfout
,
*
p
fdebug
;
int
id
;
int
id
;
int
i
;
int
i
;
if
(
!
conn
)
return
NULL
;
if
(
!
conn
)
return
NULL
;
P
fin
=
conn
->
Pfin
;
p
fin
=
conn
->
Pfin
;
P
fout
=
conn
->
Pfout
;
p
fout
=
conn
->
Pfout
;
P
fdebug
=
conn
->
Pfdebug
;
p
fdebug
=
conn
->
Pfdebug
;
/* clear the error string */
/* clear the error string */
conn
->
errorMessage
[
0
]
=
'\0'
;
conn
->
errorMessage
[
0
]
=
'\0'
;
pqPuts
(
"F "
,
pfout
,
P
fdebug
);
/* function */
pqPuts
(
"F "
,
pfout
,
p
fdebug
);
/* function */
pqPutInt
(
fnid
,
4
,
pfout
,
P
fdebug
);
/* function id */
pqPutInt
(
fnid
,
4
,
pfout
,
p
fdebug
);
/* function id */
pqPutInt
(
nargs
,
4
,
pfout
,
P
fdebug
);
/* # of args */
pqPutInt
(
nargs
,
4
,
pfout
,
p
fdebug
);
/* # of args */
for
(
i
=
0
;
i
<
nargs
;
++
i
)
{
/* len.int4 + contents */
for
(
i
=
0
;
i
<
nargs
;
++
i
)
{
/* len.int4 + contents */
pqPutInt
(
args
[
i
].
len
,
4
,
pfout
,
P
fdebug
);
pqPutInt
(
args
[
i
].
len
,
4
,
pfout
,
p
fdebug
);
if
(
args
[
i
].
isint
)
{
if
(
args
[
i
].
isint
)
{
pqPutInt
(
args
[
i
].
u
.
integer
,
4
,
pfout
,
P
fdebug
);
pqPutInt
(
args
[
i
].
u
.
integer
,
4
,
pfout
,
p
fdebug
);
}
else
{
}
else
{
pqPutnchar
((
char
*
)
args
[
i
].
u
.
ptr
,
args
[
i
].
len
,
pfout
,
P
fdebug
);
pqPutnchar
((
char
*
)
args
[
i
].
u
.
ptr
,
args
[
i
].
len
,
pfout
,
p
fdebug
);
}
}
}
}
pqFlush
(
pfout
,
P
fdebug
);
pqFlush
(
pfout
,
p
fdebug
);
id
=
pqGetc
(
pfin
,
P
fdebug
);
id
=
pqGetc
(
pfin
,
p
fdebug
);
if
(
id
!=
'V'
)
{
if
(
id
!=
'V'
)
{
if
(
id
==
'E'
)
{
if
(
id
==
'E'
)
{
pqGets
(
conn
->
errorMessage
,
ERROR_MSG_LENGTH
,
pfin
,
P
fdebug
);
pqGets
(
conn
->
errorMessage
,
ERROR_MSG_LENGTH
,
pfin
,
p
fdebug
);
}
else
}
else
sprintf
(
conn
->
errorMessage
,
sprintf
(
conn
->
errorMessage
,
"PQfn: expected a 'V' from the backend. Got '%c' instead"
,
"PQfn: expected a 'V' from the backend. Got '%c' instead"
,
...
@@ -1235,19 +1235,19 @@ PQfn(PGconn *conn,
...
@@ -1235,19 +1235,19 @@ PQfn(PGconn *conn,
return
makeEmptyPGresult
(
conn
,
PGRES_FATAL_ERROR
);
return
makeEmptyPGresult
(
conn
,
PGRES_FATAL_ERROR
);
}
}
id
=
pqGetc
(
pfin
,
P
fdebug
);
id
=
pqGetc
(
pfin
,
p
fdebug
);
for
(;;)
{
for
(;;)
{
int
c
;
int
c
;
switch
(
id
)
{
switch
(
id
)
{
case
'G'
:
/* function returned properly */
case
'G'
:
/* function returned properly */
pqGetInt
(
actual_result_len
,
4
,
pfin
,
P
fdebug
);
pqGetInt
(
actual_result_len
,
4
,
pfin
,
p
fdebug
);
if
(
result_is_int
)
{
if
(
result_is_int
)
{
pqGetInt
(
result_buf
,
4
,
pfin
,
P
fdebug
);
pqGetInt
(
result_buf
,
4
,
pfin
,
p
fdebug
);
}
else
{
}
else
{
pqGetnchar
((
char
*
)
result_buf
,
*
actual_result_len
,
pqGetnchar
((
char
*
)
result_buf
,
*
actual_result_len
,
pfin
,
P
fdebug
);
pfin
,
p
fdebug
);
}
}
c
=
pqGetc
(
pfin
,
P
fdebug
);
/* get the last '0'*/
c
=
pqGetc
(
pfin
,
p
fdebug
);
/* get the last '0'*/
return
makeEmptyPGresult
(
conn
,
PGRES_COMMAND_OK
);
return
makeEmptyPGresult
(
conn
,
PGRES_COMMAND_OK
);
case
'E'
:
case
'E'
:
sprintf
(
conn
->
errorMessage
,
sprintf
(
conn
->
errorMessage
,
...
@@ -1255,7 +1255,7 @@ PQfn(PGconn *conn,
...
@@ -1255,7 +1255,7 @@ PQfn(PGconn *conn,
return
makeEmptyPGresult
(
conn
,
PGRES_FATAL_ERROR
);
return
makeEmptyPGresult
(
conn
,
PGRES_FATAL_ERROR
);
case
'N'
:
case
'N'
:
/* print notice and go back to processing return values */
/* print notice and go back to processing return values */
if
(
pqGets
(
conn
->
errorMessage
,
ERROR_MSG_LENGTH
,
pfin
,
P
fdebug
)
==
1
)
{
if
(
pqGets
(
conn
->
errorMessage
,
ERROR_MSG_LENGTH
,
pfin
,
p
fdebug
)
==
1
)
{
sprintf
(
conn
->
errorMessage
,
sprintf
(
conn
->
errorMessage
,
"Notice return detected from backend, but error message cannot be read"
);
"Notice return detected from backend, but error message cannot be read"
);
}
else
}
else
...
...
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