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
148f7203
Commit
148f7203
authored
27 years ago
by
Bruce Momjian
Browse files
Options
Downloads
Patches
Plain Diff
Preserve putenv() memory in psql \connect user fix.
parent
65ff0fea
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/bin/psql/psql.c
+5
-4
5 additions, 4 deletions
src/bin/psql/psql.c
with
5 additions
and
4 deletions
src/bin/psql/psql.c
+
5
−
4
View file @
148f7203
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.6
1
1997/05/22
18:55:35
momjian Exp $
* $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.6
2
1997/05/22
23:57:27
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -836,7 +836,7 @@ do_connect(const char *new_dbname,
...
@@ -836,7 +836,7 @@ do_connect(const char *new_dbname,
fprintf
(
stderr
,
"
\\
connect must be followed by a database name
\n
"
);
fprintf
(
stderr
,
"
\\
connect must be followed by a database name
\n
"
);
else
{
else
{
PGconn
*
olddb
=
settings
->
db
;
PGconn
*
olddb
=
settings
->
db
;
char
*
userenv
;
static
char
*
userenv
=
NULL
;
printf
(
"closing connection to database: %s
\n
"
,
dbname
);
printf
(
"closing connection to database: %s
\n
"
,
dbname
);
if
(
new_user
!=
NULL
)
{
if
(
new_user
!=
NULL
)
{
...
@@ -844,10 +844,11 @@ do_connect(const char *new_dbname,
...
@@ -844,10 +844,11 @@ do_connect(const char *new_dbname,
PQsetdb() does not allow us to specify the user,
PQsetdb() does not allow us to specify the user,
so we have to do it via PGUSER
so we have to do it via PGUSER
*/
*/
if
(
userenv
!=
NULL
)
free
(
userenv
);
userenv
=
malloc
(
strlen
(
"PGUSER="
)
+
strlen
(
new_user
)
+
1
);
userenv
=
malloc
(
strlen
(
"PGUSER="
)
+
strlen
(
new_user
)
+
1
);
sprintf
(
userenv
,
"PGUSER=%s"
,
new_user
);
sprintf
(
userenv
,
"PGUSER=%s"
,
new_user
);
putenv
(
userenv
);
putenv
(
userenv
);
/* putenv() continues to use memory in env. */
free
(
userenv
);
}
}
settings
->
db
=
PQsetdb
(
PQhost
(
olddb
),
PQport
(
olddb
),
settings
->
db
=
PQsetdb
(
PQhost
(
olddb
),
PQport
(
olddb
),
NULL
,
NULL
,
new_dbname
);
NULL
,
NULL
,
new_dbname
);
...
...
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