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
ed7a17dc
Commit
ed7a17dc
authored
Aug 27, 1997
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unneeded stat calls.
parent
75c6c2b6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
52 deletions
+35
-52
src/backend/libpq/hba.c
src/backend/libpq/hba.c
+6
-7
src/backend/utils/init/findbe.c
src/backend/utils/init/findbe.c
+2
-2
src/backend/utils/init/postinit.c
src/backend/utils/init/postinit.c
+7
-15
src/utils/version.c
src/utils/version.c
+20
-28
No files found.
src/backend/libpq/hba.c
View file @
ed7a17dc
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/libpq/hba.c,v 1.1
8 1997/08/18 02:14:37
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/libpq/hba.c,v 1.1
9 1997/08/27 03:48:31
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -15,9 +15,9 @@
...
@@ -15,9 +15,9 @@
#include <string.h>
#include <string.h>
#include <errno.h>
#include <errno.h>
#include <pwd.h>
#include <pwd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <sys/socket.h>
#include <sys/socket.h>
#include <sys/types.h>
/* needed by in.h on Ultrix */
#include <netinet/in.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <unistd.h>
...
@@ -299,8 +299,7 @@ find_hba_entry(const char DataDir[], const struct in_addr ip_addr,
...
@@ -299,8 +299,7 @@ find_hba_entry(const char DataDir[], const struct in_addr ip_addr,
system.
system.
---------------------------------------------------------------------------*/
---------------------------------------------------------------------------*/
int
rc
;
int
fd
;
struct
stat
statbuf
;
FILE
*
file
;
/* The config file we have to read */
FILE
*
file
;
/* The config file we have to read */
...
@@ -315,9 +314,9 @@ find_hba_entry(const char DataDir[], const struct in_addr ip_addr,
...
@@ -315,9 +314,9 @@ find_hba_entry(const char DataDir[], const struct in_addr ip_addr,
strlen
(
OLD_CONF_FILE
)
+
2
)
*
sizeof
(
char
));
strlen
(
OLD_CONF_FILE
)
+
2
)
*
sizeof
(
char
));
sprintf
(
old_conf_file
,
"%s/%s"
,
DataDir
,
OLD_CONF_FILE
);
sprintf
(
old_conf_file
,
"%s/%s"
,
DataDir
,
OLD_CONF_FILE
);
rc
=
stat
(
old_conf_file
,
&
statbuf
);
if
((
fd
=
open
(
old_conf_file
,
O_RDONLY
,
0
))
!=
-
1
)
{
if
(
rc
==
0
)
{
/* Old config file exists. Tell this guy he needs to upgrade. */
/* Old config file exists. Tell this guy he needs to upgrade. */
close
(
fd
);
sprintf
(
PQerrormsg
,
sprintf
(
PQerrormsg
,
"A file exists by the name used for host-based authentication "
"A file exists by the name used for host-based authentication "
"in prior releases of Postgres (%s). The name and format of "
"in prior releases of Postgres (%s). The name and format of "
...
...
src/backend/utils/init/findbe.c
View file @
ed7a17dc
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/init/Attic/findbe.c,v 1.
4 1997/08/12 20:16:12
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/init/Attic/findbe.c,v 1.
5 1997/08/27 03:48:38
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -14,8 +14,8 @@
...
@@ -14,8 +14,8 @@
#include <grp.h>
#include <grp.h>
#include <pwd.h>
#include <pwd.h>
#include <string.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <unistd.h>
#include "postgres.h"
#include "postgres.h"
...
...
src/backend/utils/init/postinit.c
View file @
ed7a17dc
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.1
1 1997/08/19 21:35:50
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.1
2 1997/08/27 03:48:39
momjian Exp $
*
*
* NOTES
* NOTES
* InitPostgres() is the function called from PostgresMain
* InitPostgres() is the function called from PostgresMain
...
@@ -30,7 +30,6 @@
...
@@ -30,7 +30,6 @@
#include <stdio.h>
#include <stdio.h>
#include <string.h>
#include <string.h>
#include <sys/file.h>
#include <sys/file.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/types.h>
#include <math.h>
#include <math.h>
#include <unistd.h>
#include <unistd.h>
...
@@ -79,15 +78,6 @@ static void InitUserid(void);
...
@@ -79,15 +78,6 @@ static void InitUserid(void);
static
IPCKey
PostgresIpcKey
;
static
IPCKey
PostgresIpcKey
;
#ifndef private
#ifndef EBUG
#define private static
#else
/* !defined(EBUG) */
#define private
#endif
/* !defined(EBUG) */
#endif
/* !defined(private) */
/* ----------------------------------------------------------------
/* ----------------------------------------------------------------
* InitPostgres support
* InitPostgres support
* ----------------------------------------------------------------
* ----------------------------------------------------------------
...
@@ -141,7 +131,7 @@ InitMyDatabaseId()
...
@@ -141,7 +131,7 @@ InitMyDatabaseId()
sprintf
(
dbfname
,
"%s%cpg_database"
,
DataDir
,
SEP_CHAR
);
sprintf
(
dbfname
,
"%s%cpg_database"
,
DataDir
,
SEP_CHAR
);
fileflags
=
O_RDONLY
;
fileflags
=
O_RDONLY
;
if
((
dbfd
=
open
(
dbfname
,
O_RDONLY
,
0
666
))
<
0
)
if
((
dbfd
=
open
(
dbfname
,
O_RDONLY
,
0
))
<
0
)
elog
(
FATAL
,
"Cannot open %s"
,
dbfname
);
elog
(
FATAL
,
"Cannot open %s"
,
dbfname
);
pfree
(
dbfname
);
pfree
(
dbfname
);
...
@@ -261,10 +251,10 @@ static void
...
@@ -261,10 +251,10 @@ static void
DoChdirAndInitDatabaseNameAndPath
(
char
*
name
)
{
DoChdirAndInitDatabaseNameAndPath
(
char
*
name
)
{
char
*
reason
;
char
*
reason
;
/* Failure reason returned by some function. NULL if no failure */
/* Failure reason returned by some function. NULL if no failure */
struct
stat
statbuf
;
int
fd
;
char
errormsg
[
1000
];
char
errormsg
[
1000
];
if
(
stat
(
DataDir
,
&
statbuf
)
<
0
)
if
(
(
fd
=
open
(
DataDir
,
O_RDONLY
,
0
))
==
-
1
)
sprintf
(
errormsg
,
"Database system does not exist. "
sprintf
(
errormsg
,
"Database system does not exist. "
"PGDATA directory '%s' not found. Normally, you "
"PGDATA directory '%s' not found. Normally, you "
"create a database system by running initdb."
,
"create a database system by running initdb."
,
...
@@ -272,13 +262,14 @@ DoChdirAndInitDatabaseNameAndPath(char *name) {
...
@@ -272,13 +262,14 @@ DoChdirAndInitDatabaseNameAndPath(char *name) {
else
{
else
{
char
myPath
[
MAXPGPATH
];
/* DatabasePath points here! */
char
myPath
[
MAXPGPATH
];
/* DatabasePath points here! */
close
(
fd
);
if
(
strlen
(
DataDir
)
+
strlen
(
name
)
+
10
>
sizeof
(
myPath
))
if
(
strlen
(
DataDir
)
+
strlen
(
name
)
+
10
>
sizeof
(
myPath
))
sprintf
(
errormsg
,
"Internal error in postinit.c: database "
sprintf
(
errormsg
,
"Internal error in postinit.c: database "
"pathname exceeds maximum allowable length."
);
"pathname exceeds maximum allowable length."
);
else
{
else
{
sprintf
(
myPath
,
"%s/base/%s"
,
DataDir
,
name
);
sprintf
(
myPath
,
"%s/base/%s"
,
DataDir
,
name
);
if
(
stat
(
myPath
,
&
statbuf
)
<
0
)
if
(
(
fd
=
open
(
myPath
,
O_RDONLY
,
0
))
==
-
1
)
sprintf
(
errormsg
,
sprintf
(
errormsg
,
"Database '%s' does not exist. "
"Database '%s' does not exist. "
"(We know this because the directory '%s' "
"(We know this because the directory '%s' "
...
@@ -288,6 +279,7 @@ DoChdirAndInitDatabaseNameAndPath(char *name) {
...
@@ -288,6 +279,7 @@ DoChdirAndInitDatabaseNameAndPath(char *name) {
"of '%s/base/'."
,
"of '%s/base/'."
,
name
,
myPath
,
DataDir
);
name
,
myPath
,
DataDir
);
else
{
else
{
close
(
fd
);
ValidatePgVersion
(
DataDir
,
&
reason
);
ValidatePgVersion
(
DataDir
,
&
reason
);
if
(
reason
!=
NULL
)
if
(
reason
!=
NULL
)
sprintf
(
errormsg
,
sprintf
(
errormsg
,
...
...
src/utils/version.c
View file @
ed7a17dc
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/utils/Attic/version.c,v 1.
5 1997/07/28 00:57:08
momjian Exp $
* $Header: /cvsroot/pgsql/src/utils/Attic/version.c,v 1.
6 1997/08/27 03:48:50
momjian Exp $
*
*
* NOTES
* NOTES
* XXX eventually, should be able to handle version identifiers
* XXX eventually, should be able to handle version identifiers
...
@@ -63,42 +63,34 @@ ValidatePgVersion(const char *path, char **reason_p) {
...
@@ -63,42 +63,34 @@ ValidatePgVersion(const char *path, char **reason_p) {
int
fd
;
int
fd
;
char
version
[
4
];
char
version
[
4
];
char
full_path
[
MAXPGPATH
+
1
];
char
full_path
[
MAXPGPATH
+
1
];
struct
stat
statbuf
;
PathSetVersionFilePath
(
path
,
full_path
);
PathSetVersionFilePath
(
path
,
full_path
);
if
(
stat
(
full_path
,
&
statbuf
)
<
0
)
{
if
(
(
fd
=
open
(
full_path
,
O_RDONLY
,
0
))
==
-
1
)
{
*
reason_p
=
malloc
(
200
);
*
reason_p
=
malloc
(
200
);
sprintf
(
*
reason_p
,
"File '%s' does not exist."
,
full_path
);
sprintf
(
*
reason_p
,
"File '%s' does not exist
or no read permission
."
,
full_path
);
}
else
{
}
else
{
fd
=
open
(
full_path
,
O_RDONLY
,
0
);
if
(
read
(
fd
,
version
,
4
)
<
4
||
if
(
fd
<
0
)
{
!
isascii
(
version
[
0
])
||
!
isdigit
(
version
[
0
])
||
version
[
1
]
!=
'.'
||
!
isascii
(
version
[
2
])
||
!
isdigit
(
version
[
2
])
||
version
[
3
]
!=
'\n'
)
{
*
reason_p
=
malloc
(
200
);
*
reason_p
=
malloc
(
200
);
sprintf
(
*
reason_p
,
"
Unable to open file '%s'. Errno = %s (%d)."
,
sprintf
(
*
reason_p
,
"
File '%s' does not have a valid format "
full_path
,
strerror
(
errno
),
errno
);
"for a PG_VERSION file."
,
full_path
);
}
else
{
}
else
{
if
(
read
(
fd
,
version
,
4
)
<
4
||
if
(
version
[
2
]
!=
'0'
+
PG_VERSION
||
!
isascii
(
version
[
0
])
||
!
isdigit
(
version
[
0
])
||
version
[
0
]
!=
'0'
+
PG_RELEASE
)
{
version
[
1
]
!=
'.'
||
!
isascii
(
version
[
2
])
||
!
isdigit
(
version
[
2
])
||
version
[
3
]
!=
'\n'
)
{
*
reason_p
=
malloc
(
200
);
*
reason_p
=
malloc
(
200
);
sprintf
(
*
reason_p
,
"File '%s' does not have a valid format "
sprintf
(
*
reason_p
,
"for a PG_VERSION file."
,
full_path
);
"Version number in file '%s' should be %d.%d, "
}
else
{
"not %c.%c."
,
if
(
version
[
2
]
!=
'0'
+
PG_VERSION
||
full_path
,
version
[
0
]
!=
'0'
+
PG_RELEASE
)
{
PG_RELEASE
,
PG_VERSION
,
version
[
0
],
version
[
2
]);
*
reason_p
=
malloc
(
200
);
}
else
*
reason_p
=
NULL
;
sprintf
(
*
reason_p
,
"Version number in file '%s' should be %d.%d, "
"not %c.%c."
,
full_path
,
PG_RELEASE
,
PG_VERSION
,
version
[
0
],
version
[
2
]);
}
else
*
reason_p
=
NULL
;
}
close
(
fd
);
}
}
close
(
fd
);
}
}
}
}
...
...
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