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
b5bcef68
Commit
b5bcef68
authored
May 09, 1999
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix some miscellaneous places that were using raw open() or
fopen(), instead of going through fd.c ... naughty naughty.
parent
71d5d953
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
31 deletions
+56
-31
src/backend/libpq/be-fsstubs.c
src/backend/libpq/be-fsstubs.c
+46
-21
src/backend/libpq/crypt.c
src/backend/libpq/crypt.c
+2
-2
src/backend/libpq/hba.c
src/backend/libpq/hba.c
+4
-4
src/backend/utils/init/miscinit.c
src/backend/utils/init/miscinit.c
+4
-4
No files found.
src/backend/libpq/be-fsstubs.c
View file @
b5bcef68
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/libpq/be-fsstubs.c,v 1.
29 1999/05/03 19:09:39 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/libpq/be-fsstubs.c,v 1.
30 1999/05/09 00:54:30 tgl
Exp $
*
* NOTES
* This should be moved to a more appropriate place. It is here
...
...
@@ -99,7 +99,7 @@ lo_close(int fd)
{
MemoryContext
currentContext
;
if
(
fd
>=
MAX_LOBJ_FDS
)
if
(
fd
<
0
||
fd
>=
MAX_LOBJ_FDS
)
{
elog
(
ERROR
,
"lo_close: large obj descriptor (%d) out of range"
,
fd
);
return
-
2
;
...
...
@@ -131,14 +131,34 @@ lo_close(int fd)
int
lo_read
(
int
fd
,
char
*
buf
,
int
len
)
{
Assert
(
cookies
[
fd
]
!=
NULL
);
if
(
fd
<
0
||
fd
>=
MAX_LOBJ_FDS
)
{
elog
(
ERROR
,
"lo_read: large obj descriptor (%d) out of range"
,
fd
);
return
-
2
;
}
if
(
cookies
[
fd
]
==
NULL
)
{
elog
(
ERROR
,
"lo_read: invalid large obj descriptor (%d)"
,
fd
);
return
-
3
;
}
return
inv_read
(
cookies
[
fd
],
buf
,
len
);
}
int
lo_write
(
int
fd
,
char
*
buf
,
int
len
)
{
Assert
(
cookies
[
fd
]
!=
NULL
);
if
(
fd
<
0
||
fd
>=
MAX_LOBJ_FDS
)
{
elog
(
ERROR
,
"lo_write: large obj descriptor (%d) out of range"
,
fd
);
return
-
2
;
}
if
(
cookies
[
fd
]
==
NULL
)
{
elog
(
ERROR
,
"lo_write: invalid large obj descriptor (%d)"
,
fd
);
return
-
3
;
}
return
inv_write
(
cookies
[
fd
],
buf
,
len
);
}
...
...
@@ -149,11 +169,16 @@ lo_lseek(int fd, int offset, int whence)
MemoryContext
currentContext
;
int
ret
;
if
(
fd
>=
MAX_LOBJ_FDS
)
if
(
fd
<
0
||
fd
>=
MAX_LOBJ_FDS
)
{
elog
(
ERROR
,
"lo_seek: large obj descriptor (%d) out of range"
,
fd
);
elog
(
ERROR
,
"lo_
l
seek: large obj descriptor (%d) out of range"
,
fd
);
return
-
2
;
}
if
(
cookies
[
fd
]
==
NULL
)
{
elog
(
ERROR
,
"lo_lseek: invalid large obj descriptor (%d)"
,
fd
);
return
-
3
;
}
currentContext
=
MemoryContextSwitchTo
((
MemoryContext
)
fscxt
);
...
...
@@ -197,7 +222,7 @@ lo_creat(int mode)
int
lo_tell
(
int
fd
)
{
if
(
fd
>=
MAX_LOBJ_FDS
)
if
(
fd
<
0
||
fd
>=
MAX_LOBJ_FDS
)
{
elog
(
ERROR
,
"lo_tell: large object descriptor (%d) out of range"
,
fd
);
return
-
2
;
...
...
@@ -255,7 +280,7 @@ lowrite(int fd, struct varlena * wbuf)
Oid
lo_import
(
text
*
filename
)
{
int
fd
;
File
fd
;
int
nbytes
,
tmp
;
...
...
@@ -269,13 +294,13 @@ lo_import(text *filename)
*/
StrNCpy
(
fnamebuf
,
VARDATA
(
filename
),
VARSIZE
(
filename
)
-
VARHDRSZ
+
1
);
#ifndef __CYGWIN32__
fd
=
open
(
fnamebuf
,
O_RDONLY
,
0666
);
fd
=
PathNameOpenFile
(
fnamebuf
,
O_RDONLY
,
0666
);
#else
fd
=
open
(
fnamebuf
,
O_RDONLY
|
O_BINARY
,
0666
);
fd
=
PathNameOpenFile
(
fnamebuf
,
O_RDONLY
|
O_BINARY
,
0666
);
#endif
if
(
fd
<
0
)
{
/* error */
elog
(
ERROR
,
"be_lo_import: can't open unix file
\"
%s
\"\n
"
,
elog
(
ERROR
,
"be_lo_import: can't open unix file
\"
%s
\"\n
"
,
fnamebuf
);
}
...
...
@@ -298,7 +323,7 @@ lo_import(text *filename)
/*
* read in from the Unix file and write to the inversion file
*/
while
((
nbytes
=
r
ead
(
fd
,
buf
,
BUFSIZE
))
>
0
)
while
((
nbytes
=
FileR
ead
(
fd
,
buf
,
BUFSIZE
))
>
0
)
{
tmp
=
inv_write
(
lobj
,
buf
,
nbytes
);
if
(
tmp
<
nbytes
)
...
...
@@ -308,7 +333,7 @@ lo_import(text *filename)
}
}
c
lose
(
fd
);
FileC
lose
(
fd
);
inv_close
(
lobj
);
return
lobjOid
;
...
...
@@ -321,7 +346,7 @@ lo_import(text *filename)
int4
lo_export
(
Oid
lobjId
,
text
*
filename
)
{
int
fd
;
File
fd
;
int
nbytes
,
tmp
;
...
...
@@ -331,7 +356,7 @@ lo_export(Oid lobjId, text *filename)
mode_t
oumask
;
/*
*
create an
inversion "object"
*
open the
inversion "object"
*/
lobj
=
inv_open
(
lobjId
,
INV_READ
);
if
(
lobj
==
NULL
)
...
...
@@ -343,17 +368,17 @@ lo_export(Oid lobjId, text *filename)
/*
* open the file to be written to
*/
oumask
=
umask
((
mode_t
)
0
);
StrNCpy
(
fnamebuf
,
VARDATA
(
filename
),
VARSIZE
(
filename
)
-
VARHDRSZ
+
1
);
oumask
=
umask
((
mode_t
)
0
);
#ifndef __CYGWIN32__
fd
=
open
(
fnamebuf
,
O_CREAT
|
O_WRONLY
|
O_TRUNC
,
0666
);
fd
=
PathNameOpenFile
(
fnamebuf
,
O_CREAT
|
O_WRONLY
|
O_TRUNC
,
0666
);
#else
fd
=
open
(
fnamebuf
,
O_CREAT
|
O_WRONLY
|
O_TRUNC
|
O_BINARY
,
0666
);
fd
=
PathNameOpenFile
(
fnamebuf
,
O_CREAT
|
O_WRONLY
|
O_TRUNC
|
O_BINARY
,
0666
);
#endif
umask
(
oumask
);
if
(
fd
<
0
)
{
/* error */
elog
(
ERROR
,
"lo_export: can't open unix file
\"
%s
\"
"
,
elog
(
ERROR
,
"lo_export: can't open unix file
\"
%s
\"
"
,
fnamebuf
);
}
...
...
@@ -362,7 +387,7 @@ lo_export(Oid lobjId, text *filename)
*/
while
((
nbytes
=
inv_read
(
lobj
,
buf
,
BUFSIZE
))
>
0
)
{
tmp
=
w
rite
(
fd
,
buf
,
nbytes
);
tmp
=
FileW
rite
(
fd
,
buf
,
nbytes
);
if
(
tmp
<
nbytes
)
{
elog
(
ERROR
,
"lo_export: error while writing
\"
%s
\"
"
,
...
...
@@ -371,7 +396,7 @@ lo_export(Oid lobjId, text *filename)
}
inv_close
(
lobj
);
c
lose
(
fd
);
FileC
lose
(
fd
);
return
1
;
}
...
...
src/backend/libpq/crypt.c
View file @
b5bcef68
...
...
@@ -9,7 +9,7 @@
* Dec 17, 1997 - Todd A. Brandys
* Orignal Version Completed.
*
* $Id: crypt.c,v 1.1
5 1999/02/13 23:15:42 momjian
Exp $
* $Id: crypt.c,v 1.1
6 1999/05/09 00:54:30 tgl
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -174,7 +174,7 @@ crypt_loadpwdfile()
pwd_cache
=
(
char
**
)
realloc
((
void
*
)
pwd_cache
,
sizeof
(
char
*
)
*
(
pwd_cache_count
+
1
));
pwd_cache
[
pwd_cache_count
++
]
=
pstrdup
(
buffer
);
}
fclos
e
(
pwd_file
);
FreeFil
e
(
pwd_file
);
/*
* Now sort the entries in the cache for faster searching later.
...
...
src/backend/libpq/hba.c
View file @
b5bcef68
...
...
@@ -5,7 +5,7 @@
* wherein you authenticate a user by seeing what IP address the system
* says he comes from and possibly using ident).
*
* $Id: hba.c,v 1.4
0 1999/04/16 04:59:03
tgl Exp $
* $Id: hba.c,v 1.4
1 1999/05/09 00:54:30
tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -966,9 +966,9 @@ GetCharSetByHost(char *TableName, int host, const char *DataDir)
map_file
=
(
char
*
)
palloc
(
bufsize
);
snprintf
(
map_file
,
bufsize
,
"%s/%s"
,
DataDir
,
CHARSET_FILE
);
#ifndef __CYGWIN32__
file
=
fopen
(
map_file
,
"r"
);
file
=
AllocateFile
(
map_file
,
"r"
);
#else
file
=
fopen
(
map_file
,
"rb"
);
file
=
AllocateFile
(
map_file
,
"rb"
);
#endif
if
(
file
==
NULL
)
{
...
...
@@ -1049,7 +1049,7 @@ GetCharSetByHost(char *TableName, int host, const char *DataDir)
}
}
}
fclos
e
(
file
);
FreeFil
e
(
file
);
pfree
(
map_file
);
for
(
i
=
0
;
i
<
ChIndex
;
i
++
)
...
...
src/backend/utils/init/miscinit.c
View file @
b5bcef68
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.2
6 1999/02/13 23:20:01 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.2
7 1999/05/09 00:54:30 tgl
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -339,9 +339,9 @@ SetCharSet()
strlen
(
p
)
+
2
)
*
sizeof
(
char
));
sprintf
(
map_file
,
"%s/%s"
,
DataDir
,
p
);
#ifndef __CYGWIN32__
file
=
fopen
(
map_file
,
"r"
);
file
=
AllocateFile
(
map_file
,
"r"
);
#else
file
=
fopen
(
map_file
,
"rb"
);
file
=
AllocateFile
(
map_file
,
"rb"
);
#endif
if
(
file
==
NULL
)
return
;
...
...
@@ -376,7 +376,7 @@ SetCharSet()
}
}
}
fclos
e
(
file
);
FreeFil
e
(
file
);
free
(
map_file
);
}
}
...
...
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