mirror of
https://github.com/postgres/postgres.git
synced 2025-05-13 01:13:08 -04:00
Remove configure probes for symlink/readlink, and dead code.
symlink() and readlink() are in SUSv2 and all targeted Unix systems have them. We have partial emulation on Windows. Code that raised runtime errors on systems without it has been dead for years, so we can remove that and also references to such systems in the documentation. Define HAVE_READLINK and HAVE_SYMLINK macros on Unix. Our Windows replacement functions based on junction points can't be used for relative paths or for non-directories, so the macros can be used to check for full symlink support. The places that deal with tablespaces can just use symlink functions without checking the macros. (If they did check the macros, they'd need to provide an #else branch with a runtime or compile time error, and it'd be dead code.) Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Reviewed-by: Andres Freund <andres@anarazel.de> Discussion: https://postgr.es/m/CA+hUKGJ3LHeP9w5Fgzdr4G8AnEtJ=z=p6hGDEm4qYGEUX5B6fQ@mail.gmail.com
This commit is contained in:
parent
adeef67834
commit
2b1f580ee2
5
configure
vendored
5
configure
vendored
@ -16039,7 +16039,7 @@ fi
|
|||||||
LIBS_including_readline="$LIBS"
|
LIBS_including_readline="$LIBS"
|
||||||
LIBS=`echo "$LIBS" | sed -e 's/-ledit//g' -e 's/-lreadline//g'`
|
LIBS=`echo "$LIBS" | sed -e 's/-ledit//g' -e 's/-lreadline//g'`
|
||||||
|
|
||||||
for ac_func in backtrace_symbols clock_gettime copyfile fdatasync getifaddrs getpeerucred inet_pton kqueue mbstowcs_l memset_s poll posix_fallocate ppoll pthread_is_threaded_np readlink readv setproctitle setproctitle_fast strchrnul strsignal symlink syncfs sync_file_range uselocale wcstombs_l writev
|
for ac_func in backtrace_symbols clock_gettime copyfile fdatasync getifaddrs getpeerucred inet_pton kqueue mbstowcs_l memset_s poll posix_fallocate ppoll pthread_is_threaded_np readv setproctitle setproctitle_fast strchrnul strsignal syncfs sync_file_range uselocale wcstombs_l writev
|
||||||
do :
|
do :
|
||||||
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
|
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
|
||||||
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
|
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
|
||||||
@ -17083,9 +17083,6 @@ esac
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
$as_echo "#define HAVE_SYMLINK 1" >>confdefs.h
|
|
||||||
|
|
||||||
ac_fn_c_check_type "$LINENO" "MINIDUMP_TYPE" "ac_cv_type_MINIDUMP_TYPE" "
|
ac_fn_c_check_type "$LINENO" "MINIDUMP_TYPE" "ac_cv_type_MINIDUMP_TYPE" "
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
@ -1805,13 +1805,11 @@ AC_CHECK_FUNCS(m4_normalize([
|
|||||||
posix_fallocate
|
posix_fallocate
|
||||||
ppoll
|
ppoll
|
||||||
pthread_is_threaded_np
|
pthread_is_threaded_np
|
||||||
readlink
|
|
||||||
readv
|
readv
|
||||||
setproctitle
|
setproctitle
|
||||||
setproctitle_fast
|
setproctitle_fast
|
||||||
strchrnul
|
strchrnul
|
||||||
strsignal
|
strsignal
|
||||||
symlink
|
|
||||||
syncfs
|
syncfs
|
||||||
sync_file_range
|
sync_file_range
|
||||||
uselocale
|
uselocale
|
||||||
@ -1963,8 +1961,6 @@ if test "$PORTNAME" = "win32"; then
|
|||||||
AC_LIBOBJ(win32security)
|
AC_LIBOBJ(win32security)
|
||||||
AC_LIBOBJ(win32setlocale)
|
AC_LIBOBJ(win32setlocale)
|
||||||
AC_LIBOBJ(win32stat)
|
AC_LIBOBJ(win32stat)
|
||||||
AC_DEFINE([HAVE_SYMLINK], 1,
|
|
||||||
[Define to 1 if you have the `symlink' function.])
|
|
||||||
AC_CHECK_TYPES(MINIDUMP_TYPE, [pgac_minidump_type=yes], [pgac_minidump_type=no], [
|
AC_CHECK_TYPES(MINIDUMP_TYPE, [pgac_minidump_type=yes], [pgac_minidump_type=no], [
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
@ -530,13 +530,6 @@ SELECT spcname FROM pg_tablespace;
|
|||||||
is also useful for listing the existing tablespaces.
|
is also useful for listing the existing tablespaces.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
|
||||||
<productname>PostgreSQL</productname> makes use of symbolic links
|
|
||||||
to simplify the implementation of tablespaces. This
|
|
||||||
means that tablespaces can be used <emphasis>only</emphasis> on systems
|
|
||||||
that support symbolic links.
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
The directory <filename>$PGDATA/pg_tblspc</filename> contains symbolic links that
|
The directory <filename>$PGDATA/pg_tblspc</filename> contains symbolic links that
|
||||||
point to each of the non-built-in tablespaces defined in the cluster.
|
point to each of the non-built-in tablespaces defined in the cluster.
|
||||||
|
@ -127,10 +127,6 @@ CREATE TABLESPACE <replaceable class="parameter">tablespace_name</replaceable>
|
|||||||
<refsect1>
|
<refsect1>
|
||||||
<title>Notes</title>
|
<title>Notes</title>
|
||||||
|
|
||||||
<para>
|
|
||||||
Tablespaces are only supported on systems that support symbolic links.
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
<command>CREATE TABLESPACE</command> cannot be executed inside a transaction
|
<command>CREATE TABLESPACE</command> cannot be executed inside a transaction
|
||||||
block.
|
block.
|
||||||
|
@ -8305,7 +8305,6 @@ do_pg_backup_start(const char *backupidstr, bool fast, TimeLineID *starttli_p,
|
|||||||
if (get_dirent_type(fullpath, de, false, ERROR) != PGFILETYPE_LNK)
|
if (get_dirent_type(fullpath, de, false, ERROR) != PGFILETYPE_LNK)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
#if defined(HAVE_READLINK) || defined(WIN32)
|
|
||||||
rllen = readlink(fullpath, linkpath, sizeof(linkpath));
|
rllen = readlink(fullpath, linkpath, sizeof(linkpath));
|
||||||
if (rllen < 0)
|
if (rllen < 0)
|
||||||
{
|
{
|
||||||
@ -8358,17 +8357,6 @@ do_pg_backup_start(const char *backupidstr, bool fast, TimeLineID *starttli_p,
|
|||||||
ti->oid, escapedpath.data);
|
ti->oid, escapedpath.data);
|
||||||
|
|
||||||
pfree(escapedpath.data);
|
pfree(escapedpath.data);
|
||||||
#else
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If the platform does not have symbolic links, it should not be
|
|
||||||
* possible to have tablespaces - clearly somebody else created
|
|
||||||
* them. Warn about it and ignore.
|
|
||||||
*/
|
|
||||||
ereport(WARNING,
|
|
||||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
|
||||||
errmsg("tablespaces are not supported on this platform")));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
FreeDir(tblspcdir);
|
FreeDir(tblspcdir);
|
||||||
|
|
||||||
|
@ -213,7 +213,6 @@ TablespaceCreateDbspace(Oid spcOid, Oid dbOid, bool isRedo)
|
|||||||
Oid
|
Oid
|
||||||
CreateTableSpace(CreateTableSpaceStmt *stmt)
|
CreateTableSpace(CreateTableSpaceStmt *stmt)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_SYMLINK
|
|
||||||
Relation rel;
|
Relation rel;
|
||||||
Datum values[Natts_pg_tablespace];
|
Datum values[Natts_pg_tablespace];
|
||||||
bool nulls[Natts_pg_tablespace] = {0};
|
bool nulls[Natts_pg_tablespace] = {0};
|
||||||
@ -391,12 +390,6 @@ CreateTableSpace(CreateTableSpaceStmt *stmt)
|
|||||||
table_close(rel, NoLock);
|
table_close(rel, NoLock);
|
||||||
|
|
||||||
return tablespaceoid;
|
return tablespaceoid;
|
||||||
#else /* !HAVE_SYMLINK */
|
|
||||||
ereport(ERROR,
|
|
||||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
|
||||||
errmsg("tablespaces are not supported on this platform")));
|
|
||||||
return InvalidOid; /* keep compiler quiet */
|
|
||||||
#endif /* HAVE_SYMLINK */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -407,7 +400,6 @@ CreateTableSpace(CreateTableSpaceStmt *stmt)
|
|||||||
void
|
void
|
||||||
DropTableSpace(DropTableSpaceStmt *stmt)
|
DropTableSpace(DropTableSpaceStmt *stmt)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_SYMLINK
|
|
||||||
char *tablespacename = stmt->tablespacename;
|
char *tablespacename = stmt->tablespacename;
|
||||||
TableScanDesc scandesc;
|
TableScanDesc scandesc;
|
||||||
Relation rel;
|
Relation rel;
|
||||||
@ -573,11 +565,6 @@ DropTableSpace(DropTableSpaceStmt *stmt)
|
|||||||
|
|
||||||
/* We keep the lock on pg_tablespace until commit */
|
/* We keep the lock on pg_tablespace until commit */
|
||||||
table_close(rel, NoLock);
|
table_close(rel, NoLock);
|
||||||
#else /* !HAVE_SYMLINK */
|
|
||||||
ereport(ERROR,
|
|
||||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
|
||||||
errmsg("tablespaces are not supported on this platform")));
|
|
||||||
#endif /* HAVE_SYMLINK */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1330,7 +1330,6 @@ sendDir(bbsink *sink, const char *path, int basepathlen, bool sizeonly,
|
|||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
#if defined(HAVE_READLINK) || defined(WIN32)
|
|
||||||
char linkpath[MAXPGPATH];
|
char linkpath[MAXPGPATH];
|
||||||
int rllen;
|
int rllen;
|
||||||
|
|
||||||
@ -1349,18 +1348,6 @@ sendDir(bbsink *sink, const char *path, int basepathlen, bool sizeonly,
|
|||||||
|
|
||||||
size += _tarWriteHeader(sink, pathbuf + basepathlen + 1, linkpath,
|
size += _tarWriteHeader(sink, pathbuf + basepathlen + 1, linkpath,
|
||||||
&statbuf, sizeonly);
|
&statbuf, sizeonly);
|
||||||
#else
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If the platform does not have symbolic links, it should not be
|
|
||||||
* possible to have tablespaces - clearly somebody else created
|
|
||||||
* them. Warn about it and ignore.
|
|
||||||
*/
|
|
||||||
ereport(WARNING,
|
|
||||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
|
||||||
errmsg("tablespaces are not supported on this platform")));
|
|
||||||
continue;
|
|
||||||
#endif /* HAVE_READLINK */
|
|
||||||
}
|
}
|
||||||
else if (S_ISDIR(statbuf.st_mode))
|
else if (S_ISDIR(statbuf.st_mode))
|
||||||
{
|
{
|
||||||
|
@ -302,8 +302,6 @@ pg_tablespace_location(PG_FUNCTION_ARGS)
|
|||||||
tablespaceOid == GLOBALTABLESPACE_OID)
|
tablespaceOid == GLOBALTABLESPACE_OID)
|
||||||
PG_RETURN_TEXT_P(cstring_to_text(""));
|
PG_RETURN_TEXT_P(cstring_to_text(""));
|
||||||
|
|
||||||
#if defined(HAVE_READLINK) || defined(WIN32)
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Find the location of the tablespace by reading the symbolic link that
|
* Find the location of the tablespace by reading the symbolic link that
|
||||||
* is in pg_tblspc/<oid>.
|
* is in pg_tblspc/<oid>.
|
||||||
@ -349,12 +347,6 @@ pg_tablespace_location(PG_FUNCTION_ARGS)
|
|||||||
targetpath[rllen] = '\0';
|
targetpath[rllen] = '\0';
|
||||||
|
|
||||||
PG_RETURN_TEXT_P(cstring_to_text(targetpath));
|
PG_RETURN_TEXT_P(cstring_to_text(targetpath));
|
||||||
#else
|
|
||||||
ereport(ERROR,
|
|
||||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
|
||||||
errmsg("tablespaces are not supported on this platform")));
|
|
||||||
PG_RETURN_NULL();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2646,13 +2646,9 @@ create_xlog_or_symlink(void)
|
|||||||
pg_fatal("could not access directory \"%s\": %m", xlog_dir);
|
pg_fatal("could not access directory \"%s\": %m", xlog_dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_SYMLINK
|
|
||||||
if (symlink(xlog_dir, subdirloc) != 0)
|
if (symlink(xlog_dir, subdirloc) != 0)
|
||||||
pg_fatal("could not create symbolic link \"%s\": %m",
|
pg_fatal("could not create symbolic link \"%s\": %m",
|
||||||
subdirloc);
|
subdirloc);
|
||||||
#else
|
|
||||||
pg_fatal("symlinks are not supported on this platform");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2763,12 +2763,8 @@ main(int argc, char **argv)
|
|||||||
PQserverVersion(conn) < MINIMUM_VERSION_FOR_PG_WAL ?
|
PQserverVersion(conn) < MINIMUM_VERSION_FOR_PG_WAL ?
|
||||||
"pg_xlog" : "pg_wal");
|
"pg_xlog" : "pg_wal");
|
||||||
|
|
||||||
#ifdef HAVE_SYMLINK
|
|
||||||
if (symlink(xlog_dir, linkloc) != 0)
|
if (symlink(xlog_dir, linkloc) != 0)
|
||||||
pg_fatal("could not create symbolic link \"%s\": %m", linkloc);
|
pg_fatal("could not create symbolic link \"%s\": %m", linkloc);
|
||||||
#else
|
|
||||||
pg_fatal("symlinks are not supported on this platform");
|
|
||||||
#endif
|
|
||||||
free(linkloc);
|
free(linkloc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -437,7 +437,6 @@ recurse_dir(const char *datadir, const char *parentpath,
|
|||||||
else if (pgwin32_is_junction(fullpath))
|
else if (pgwin32_is_junction(fullpath))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#if defined(HAVE_READLINK) || defined(WIN32)
|
|
||||||
char link_target[MAXPGPATH];
|
char link_target[MAXPGPATH];
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
@ -460,10 +459,6 @@ recurse_dir(const char *datadir, const char *parentpath,
|
|||||||
if ((parentpath && strcmp(parentpath, "pg_tblspc") == 0) ||
|
if ((parentpath && strcmp(parentpath, "pg_tblspc") == 0) ||
|
||||||
strcmp(path, "pg_wal") == 0)
|
strcmp(path, "pg_wal") == 0)
|
||||||
recurse_dir(datadir, path, callback);
|
recurse_dir(datadir, path, callback);
|
||||||
#else
|
|
||||||
pg_fatal("\"%s\" is a symbolic link, but symbolic links are not supported on this platform",
|
|
||||||
fullpath);
|
|
||||||
#endif /* HAVE_READLINK */
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,6 +250,10 @@ find_my_exec(const char *argv0, char *retpath)
|
|||||||
* Note: we are not particularly tense about producing nice error messages
|
* Note: we are not particularly tense about producing nice error messages
|
||||||
* because we are not really expecting error here; we just determined that
|
* because we are not really expecting error here; we just determined that
|
||||||
* the symlink does point to a valid executable.
|
* the symlink does point to a valid executable.
|
||||||
|
*
|
||||||
|
* Here we test HAVE_READLINK, which excludes Windows. There's no point in
|
||||||
|
* using our junction point-based replacement code for this, because that only
|
||||||
|
* works for directories.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
resolve_symlinks(char *path)
|
resolve_symlinks(char *path)
|
||||||
|
@ -427,9 +427,6 @@
|
|||||||
/* Define to 1 if you have the <readline/readline.h> header file. */
|
/* Define to 1 if you have the <readline/readline.h> header file. */
|
||||||
#undef HAVE_READLINE_READLINE_H
|
#undef HAVE_READLINE_READLINE_H
|
||||||
|
|
||||||
/* Define to 1 if you have the `readlink' function. */
|
|
||||||
#undef HAVE_READLINK
|
|
||||||
|
|
||||||
/* Define to 1 if you have the `readv' function. */
|
/* Define to 1 if you have the `readv' function. */
|
||||||
#undef HAVE_READV
|
#undef HAVE_READV
|
||||||
|
|
||||||
@ -556,9 +553,6 @@
|
|||||||
/* Define to 1 if `tm_zone' is a member of `struct tm'. */
|
/* Define to 1 if `tm_zone' is a member of `struct tm'. */
|
||||||
#undef HAVE_STRUCT_TM_TM_ZONE
|
#undef HAVE_STRUCT_TM_TM_ZONE
|
||||||
|
|
||||||
/* Define to 1 if you have the `symlink' function. */
|
|
||||||
#undef HAVE_SYMLINK
|
|
||||||
|
|
||||||
/* Define to 1 if you have the `syncfs' function. */
|
/* Define to 1 if you have the `syncfs' function. */
|
||||||
#undef HAVE_SYNCFS
|
#undef HAVE_SYNCFS
|
||||||
|
|
||||||
|
@ -522,11 +522,19 @@ extern bool wait_result_is_any_signal(int exit_status, bool include_command_not_
|
|||||||
/*
|
/*
|
||||||
* Interfaces that we assume all Unix system have. We retain individual macros
|
* Interfaces that we assume all Unix system have. We retain individual macros
|
||||||
* for better documentation.
|
* for better documentation.
|
||||||
|
*
|
||||||
|
* For symlink-related functions, there is often no need to test these macros,
|
||||||
|
* because we provided basic support on Windows that can work with absolute
|
||||||
|
* paths to directories. Code that wants to test for complete symlink support
|
||||||
|
* (including relative paths and non-directories) should be conditional on
|
||||||
|
* HAVE_READLINK or HAVE_SYMLINK.
|
||||||
*/
|
*/
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
#define HAVE_GETRLIMIT 1
|
#define HAVE_GETRLIMIT 1
|
||||||
|
#define HAVE_READLINK 1
|
||||||
#define HAVE_SETSID 1
|
#define HAVE_SETSID 1
|
||||||
#define HAVE_SHM_OPEN 1
|
#define HAVE_SHM_OPEN 1
|
||||||
|
#define HAVE_SYMLINK 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* PG_PORT_H */
|
#endif /* PG_PORT_H */
|
||||||
|
@ -337,7 +337,6 @@ sub GenerateFiles
|
|||||||
HAVE_READLINE_H => undef,
|
HAVE_READLINE_H => undef,
|
||||||
HAVE_READLINE_HISTORY_H => undef,
|
HAVE_READLINE_HISTORY_H => undef,
|
||||||
HAVE_READLINE_READLINE_H => undef,
|
HAVE_READLINE_READLINE_H => undef,
|
||||||
HAVE_READLINK => undef,
|
|
||||||
HAVE_READV => undef,
|
HAVE_READV => undef,
|
||||||
HAVE_RL_COMPLETION_MATCHES => undef,
|
HAVE_RL_COMPLETION_MATCHES => undef,
|
||||||
HAVE_RL_COMPLETION_SUPPRESS_QUOTE => undef,
|
HAVE_RL_COMPLETION_SUPPRESS_QUOTE => undef,
|
||||||
@ -380,7 +379,6 @@ sub GenerateFiles
|
|||||||
HAVE_STRUCT_SOCKADDR_UN => undef,
|
HAVE_STRUCT_SOCKADDR_UN => undef,
|
||||||
HAVE_STRUCT_TM_TM_ZONE => undef,
|
HAVE_STRUCT_TM_TM_ZONE => undef,
|
||||||
HAVE_SYNC_FILE_RANGE => undef,
|
HAVE_SYNC_FILE_RANGE => undef,
|
||||||
HAVE_SYMLINK => 1,
|
|
||||||
HAVE_SYNCFS => undef,
|
HAVE_SYNCFS => undef,
|
||||||
HAVE_SYSLOG => undef,
|
HAVE_SYSLOG => undef,
|
||||||
HAVE_SYS_EPOLL_H => undef,
|
HAVE_SYS_EPOLL_H => undef,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user