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
8fc386a2
Commit
8fc386a2
authored
Jan 15, 2000
by
Tatsuo Ishii
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Eliminate using putenv().
parent
6095e36c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
23 deletions
+46
-23
src/interfaces/libpq/fe-connect.c
src/interfaces/libpq/fe-connect.c
+16
-11
src/interfaces/libpq/fe-print.c
src/interfaces/libpq/fe-print.c
+20
-8
src/interfaces/libpq/libpq-fe.h
src/interfaces/libpq/libpq-fe.h
+7
-3
src/interfaces/libpq/libpq-int.h
src/interfaces/libpq/libpq-int.h
+3
-1
No files found.
src/interfaces/libpq/fe-connect.c
View file @
8fc386a2
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.1
09 2000/01/14 05:33:15 tgl
Exp $
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.1
10 2000/01/15 05:37:21 ishii
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -1299,7 +1299,7 @@ PQconnectPoll(PGconn *conn)
...
@@ -1299,7 +1299,7 @@ PQconnectPoll(PGconn *conn)
these queries. */
these queries. */
conn
->
status
=
CONNECTION_OK
;
conn
->
status
=
CONNECTION_OK
;
switch
(
PQsetenvPoll
(
conn
->
setenv_handle
))
switch
(
PQsetenvPoll
(
conn
))
{
{
case
PGRES_POLLING_OK
:
/* Success */
case
PGRES_POLLING_OK
:
/* Success */
conn
->
status
=
CONNECTION_OK
;
conn
->
status
=
CONNECTION_OK
;
...
@@ -1384,8 +1384,9 @@ PQsetenvStart(PGconn *conn)
...
@@ -1384,8 +1384,9 @@ PQsetenvStart(PGconn *conn)
* ----------------
* ----------------
*/
*/
PostgresPollingStatusType
PostgresPollingStatusType
PQsetenvPoll
(
PG
setenvHandle
handle
)
PQsetenvPoll
(
PG
conn
*
conn
)
{
{
PGsetenvHandle
handle
=
conn
->
setenv_handle
;
#ifdef MULTIBYTE
#ifdef MULTIBYTE
static
const
char
envname
[]
=
"PGCLIENTENCODING"
;
static
const
char
envname
[]
=
"PGCLIENTENCODING"
;
#endif
#endif
...
@@ -1470,16 +1471,12 @@ PQsetenvPoll(PGsetenvHandle handle)
...
@@ -1470,16 +1471,12 @@ PQsetenvPoll(PGsetenvHandle handle)
encoding
=
PQgetvalue
(
handle
->
res
,
0
,
0
);
encoding
=
PQgetvalue
(
handle
->
res
,
0
,
0
);
if
(
!
encoding
)
/* this should not happen */
if
(
!
encoding
)
/* this should not happen */
encoding
=
pg_encoding_to_char
(
MULTIBYTE
)
;
encoding
=
SQL_ASCII
;
if
(
encoding
)
if
(
encoding
)
{
{
/* set client encoding via environment variable */
/* set client encoding to pg_conn struct */
char
*
envbuf
;
conn
->
client_encoding
=
atoi
(
encoding
);
envbuf
=
(
char
*
)
malloc
(
strlen
(
envname
)
+
strlen
(
encoding
)
+
2
);
sprintf
(
envbuf
,
"%s=%s"
,
envname
,
encoding
);
putenv
(
envbuf
);
}
}
PQclear
(
handle
->
res
);
PQclear
(
handle
->
res
);
/* We have to keep going in order to clear up the query */
/* We have to keep going in order to clear up the query */
...
@@ -1630,7 +1627,7 @@ PQsetenv(PGconn *conn)
...
@@ -1630,7 +1627,7 @@ PQsetenv(PGconn *conn)
return
0
;
return
0
;
for
(;;)
{
for
(;;)
{
flag
=
PQsetenvPoll
(
handle
);
flag
=
PQsetenvPoll
(
conn
);
switch
(
flag
)
switch
(
flag
)
{
{
case
PGRES_POLLING_ACTIVE
:
case
PGRES_POLLING_ACTIVE
:
...
@@ -2355,6 +2352,14 @@ PQbackendPID(const PGconn *conn)
...
@@ -2355,6 +2352,14 @@ PQbackendPID(const PGconn *conn)
return
conn
->
be_pid
;
return
conn
->
be_pid
;
}
}
int
PQclientencoding
(
const
PGconn
*
conn
)
{
if
(
!
conn
||
conn
->
status
!=
CONNECTION_OK
)
return
-
1
;
return
conn
->
client_encoding
;
}
void
void
PQtrace
(
PGconn
*
conn
,
FILE
*
debug_port
)
PQtrace
(
PGconn
*
conn
,
FILE
*
debug_port
)
{
{
...
...
src/interfaces/libpq/fe-print.c
View file @
8fc386a2
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
* didn't really belong there.
* didn't really belong there.
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-print.c,v 1.2
8 1999/11/11 00:10:14 momjian
Exp $
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-print.c,v 1.2
9 2000/01/15 05:37:21 ishii
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -498,27 +498,39 @@ PQprintTuples(const PGresult *res,
...
@@ -498,27 +498,39 @@ PQprintTuples(const PGresult *res,
* the backend is assumed.
* the backend is assumed.
*/
*/
int
int
PQmblen
(
const
unsigned
char
*
s
)
PQmblen
(
const
unsigned
char
*
s
,
int
encoding
)
{
return
(
pg_encoding_mblen
(
encoding
,
s
));
}
/*
* Get encoding id from environment variable PGCLIENTENCODING.
*/
int
PQenv2encoding
(
void
)
{
{
char
*
str
;
char
*
str
;
int
encoding
=
-
1
;
int
encoding
=
SQL_ASCII
;
str
=
getenv
(
"PGCLIENTENCODING"
);
str
=
getenv
(
"PGCLIENTENCODING"
);
if
(
str
&&
*
str
!=
'\0'
)
if
(
str
&&
*
str
!=
'\0'
)
encoding
=
pg_char_to_encoding
(
str
);
encoding
=
pg_char_to_encoding
(
str
);
if
(
encoding
<
0
)
return
(
encoding
);
encoding
=
MULTIBYTE
;
return
(
pg_encoding_mblen
(
encoding
,
s
));
}
}
#else
#else
/* Provide a default definition in case someone calls it anyway */
/* Provide a default definition in case someone calls it anyway */
int
int
PQmblen
(
const
unsigned
char
*
s
)
PQmblen
(
const
unsigned
char
*
s
,
int
encoding
)
{
{
return
1
;
return
1
;
}
}
int
PQenv2encoding
(
void
)
{
return
0
;
}
#endif
/* MULTIBYTE */
#endif
/* MULTIBYTE */
...
@@ -560,7 +572,7 @@ do_field(const PQprintOpt *po, const PGresult *res,
...
@@ -560,7 +572,7 @@ do_field(const PQprintOpt *po, const PGresult *res,
char
ch
=
'0'
;
char
ch
=
'0'
;
#ifdef MULTIBYTE
#ifdef MULTIBYTE
for
(
p
=
pval
;
*
p
;
p
+=
PQmblen
(
p
))
for
(
p
=
pval
;
*
p
;
p
+=
PQmblen
(
p
,
PQclientencoding
(
res
->
conn
)
))
#else
#else
for
(
p
=
pval
;
*
p
;
p
++
)
for
(
p
=
pval
;
*
p
;
p
++
)
#endif
#endif
...
...
src/interfaces/libpq/libpq-fe.h
View file @
8fc386a2
...
@@ -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.5
4 2000/01/14 05:33:15 tgl
Exp $
* $Id: libpq-fe.h,v 1.5
5 2000/01/15 05:37:21 ishii
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -224,6 +224,7 @@ extern "C"
...
@@ -224,6 +224,7 @@ extern "C"
extern
const
char
*
PQerrorMessage
(
const
PGconn
*
conn
);
extern
const
char
*
PQerrorMessage
(
const
PGconn
*
conn
);
extern
int
PQsocket
(
const
PGconn
*
conn
);
extern
int
PQsocket
(
const
PGconn
*
conn
);
extern
int
PQbackendPID
(
const
PGconn
*
conn
);
extern
int
PQbackendPID
(
const
PGconn
*
conn
);
extern
int
PQclientencoding
(
const
PGconn
*
conn
);
/* Enable/disable tracing */
/* Enable/disable tracing */
extern
void
PQtrace
(
PGconn
*
conn
,
FILE
*
debug_port
);
extern
void
PQtrace
(
PGconn
*
conn
,
FILE
*
debug_port
);
...
@@ -235,7 +236,7 @@ extern "C"
...
@@ -235,7 +236,7 @@ extern "C"
/* Passing of environment variables */
/* Passing of environment variables */
/* Asynchronous (non-blocking) */
/* Asynchronous (non-blocking) */
extern
PGsetenvHandle
PQsetenvStart
(
PGconn
*
conn
);
extern
PGsetenvHandle
PQsetenvStart
(
PGconn
*
conn
);
extern
PostgresPollingStatusType
PQsetenvPoll
(
PG
setenvHandle
handle
);
extern
PostgresPollingStatusType
PQsetenvPoll
(
PG
conn
*
conn
);
extern
void
PQsetenvAbort
(
PGsetenvHandle
handle
);
extern
void
PQsetenvAbort
(
PGsetenvHandle
handle
);
/* Synchronous (blocking) */
/* Synchronous (blocking) */
...
@@ -333,7 +334,10 @@ extern "C"
...
@@ -333,7 +334,10 @@ extern "C"
* 0, use variable width */
* 0, use variable width */
/* Determine length of multibyte encoded char at *s */
/* Determine length of multibyte encoded char at *s */
extern
int
PQmblen
(
const
unsigned
char
*
s
);
extern
int
PQmblen
(
const
unsigned
char
*
s
,
int
encoding
);
/* Get encoding id from environment variable PGCLIENTENCODING */
int
PQenv2encoding
(
void
);
/* === in fe-lobj.c === */
/* === in fe-lobj.c === */
...
...
src/interfaces/libpq/libpq-int.h
View file @
8fc386a2
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
*
*
* Copyright (c) 1994, Regents of the University of California
* Copyright (c) 1994, Regents of the University of California
*
*
* $Id: libpq-int.h,v 1.1
5 2000/01/14 05:33:15 tgl
Exp $
* $Id: libpq-int.h,v 1.1
6 2000/01/15 05:37:21 ishii
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -236,6 +236,8 @@ struct pg_conn
...
@@ -236,6 +236,8 @@ struct pg_conn
/* Buffer for receiving various parts of messages */
/* Buffer for receiving various parts of messages */
PQExpBufferData
workBuffer
;
/* expansible string */
PQExpBufferData
workBuffer
;
/* expansible string */
int
client_encoding
;
/* encoding id */
};
};
/* ----------------
/* ----------------
...
...
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