Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
postgres-lambda-diff
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jakob Huber
postgres-lambda-diff
Commits
f4473440
Commit
f4473440
authored
26 years ago
by
Tom Lane
Browse files
Options
Downloads
Patches
Plain Diff
Simplify pg_result by using new libpq PQresultErrorMessage;
fix some memory leaks in pg_select.
parent
6428074e
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/interfaces/libpgtcl/pgtclCmds.c
+20
-23
20 additions, 23 deletions
src/interfaces/libpgtcl/pgtclCmds.c
with
20 additions
and
23 deletions
src/interfaces/libpgtcl/pgtclCmds.c
+
20
−
23
View file @
f4473440
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclCmds.c,v 1.3
5
1998/
09/2
1 01:
02:01 momjian
Exp $
* $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclCmds.c,v 1.3
6
1998/
10/0
1 01:
45:38 tgl
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -508,7 +508,6 @@ int
Pg_result
(
ClientData
cData
,
Tcl_Interp
*
interp
,
int
argc
,
char
*
argv
[])
{
PGresult
*
result
;
PGconn
*
conn
;
char
*
opt
;
int
i
;
int
tupno
;
...
...
@@ -538,24 +537,8 @@ Pg_result(ClientData cData, Tcl_Interp * interp, int argc, char *argv[])
}
else
if
(
strcmp
(
opt
,
"-error"
)
==
0
)
{
switch
(
PQresultStatus
(
result
))
{
case
PGRES_EMPTY_QUERY
:
case
PGRES_COMMAND_OK
:
case
PGRES_TUPLES_OK
:
case
PGRES_COPY_OUT
:
case
PGRES_COPY_IN
:
Tcl_ResetResult
(
interp
);
break
;
default:
if
(
PgGetConnByResultId
(
interp
,
argv
[
1
])
!=
TCL_OK
)
return
TCL_ERROR
;
conn
=
PgGetConnectionId
(
interp
,
interp
->
result
,
(
Pg_ConnectionId
**
)
NULL
);
if
(
conn
==
(
PGconn
*
)
NULL
)
return
TCL_ERROR
;
Tcl_SetResult
(
interp
,
PQerrorMessage
(
conn
),
TCL_VOLATILE
);
break
;
}
Tcl_SetResult
(
interp
,
(
char
*
)
PQresultErrorMessage
(
result
),
TCL_STATIC
);
return
TCL_OK
;
}
else
if
(
strcmp
(
opt
,
"-conn"
)
==
0
)
...
...
@@ -1270,7 +1253,7 @@ Pg_select(ClientData cData, Tcl_Interp * interp, int argc, char **argv)
if
((
result
=
PQexec
(
conn
,
argv
[
2
]))
==
0
)
{
/* error occurred
dur
ing the query */
/* error occurred
send
ing the query */
Tcl_SetResult
(
interp
,
PQerrorMessage
(
conn
),
TCL_VOLATILE
);
return
TCL_ERROR
;
}
...
...
@@ -1278,9 +1261,19 @@ Pg_select(ClientData cData, Tcl_Interp * interp, int argc, char **argv)
/* Transfer any notify events from libpq to Tcl event queue. */
PgNotifyTransferEvents
(
connid
);
if
(
PQresultStatus
(
result
)
!=
PGRES_TUPLES_OK
)
{
/* query failed, or it wasn't SELECT */
Tcl_SetResult
(
interp
,
(
char
*
)
PQresultErrorMessage
(
result
),
TCL_VOLATILE
);
PQclear
(
result
);
return
TCL_ERROR
;
}
if
((
info
=
(
struct
info_s
*
)
ckalloc
(
sizeof
(
*
info
)
*
(
ncols
=
PQnfields
(
result
))))
==
NULL
)
{
Tcl_AppendResult
(
interp
,
"Not enough memory"
,
0
);
PQclear
(
result
);
return
TCL_ERROR
;
}
...
...
@@ -1311,7 +1304,10 @@ Pg_select(ClientData cData, Tcl_Interp * interp, int argc, char **argv)
if
((
r
=
Tcl_Eval
(
interp
,
argv
[
4
]))
!=
TCL_OK
&&
r
!=
TCL_CONTINUE
)
{
if
(
r
==
TCL_BREAK
)
{
PQclear
(
result
);
return
TCL_OK
;
}
if
(
r
==
TCL_ERROR
)
{
...
...
@@ -1322,13 +1318,14 @@ Pg_select(ClientData cData, Tcl_Interp * interp, int argc, char **argv)
Tcl_AddErrorInfo
(
interp
,
msg
);
}
PQclear
(
result
);
return
r
;
}
}
ckfree
((
void
*
)
info
);
Tcl_UnsetVar
(
interp
,
argv
[
3
],
0
);
Tcl_AppendResult
(
interp
,
""
,
0
);
PQclear
(
result
);
return
TCL_OK
;
}
...
...
@@ -1352,7 +1349,7 @@ Pg_have_listener (Pg_ConnectionId *connid, const char * relname)
if
(
interp
==
NULL
)
continue
;
/* ignore deleted interpreter */
entry
=
Tcl_FindHashEntry
(
&
notifies
->
notify_hash
,
relname
);
entry
=
Tcl_FindHashEntry
(
&
notifies
->
notify_hash
,
(
char
*
)
relname
);
if
(
entry
==
NULL
)
continue
;
/* no pg_listen in this interpreter */
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment