Skip to content

Commit e2e0219

Browse files
committed
Clean up some code, comments and docs referring to Windows 2000 and older
This fixes and updates a couple of comments related to outdated Windows versions. Particularly, src/common/exec.c had a fallback implementation to read a file's line from a pipe because stdin/stdout/stderr does not exist in Windows 2000 that is removed to simplify src/common/ as there are unlikely versions of Postgres running on such platforms. Author: Michael Paquier Reviewed-by: Kyotaro Horiguchi, Juan José Santamaría Flecha Discussion: https://postgr.es/m/20191219021526.GC4202@paquier.xyz
1 parent e3ff789 commit e2e0219

File tree

6 files changed

+13
-153
lines changed

6 files changed

+13
-153
lines changed

doc/src/sgml/install-windows.sgml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@
4646
<productname>Cygwin</productname> is not recommended for running a
4747
production server, and it should only be used for running on
4848
older versions of <productname>Windows</productname> where
49-
the native build does not work, such as
50-
<productname>Windows 98</productname>. The official
49+
the native build does not work. The official
5150
binaries are built using <productname>Visual Studio</productname>.
5251
</para>
5352

doc/src/sgml/installation.sgml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2087,7 +2087,7 @@ export MANPATH
20872087

20882088
<para>
20892089
<productname>PostgreSQL</productname> can be expected to work on these operating
2090-
systems: Linux (all recent distributions), Windows (Win2000 SP4 and later),
2090+
systems: Linux (all recent distributions), Windows (XP and later),
20912091
FreeBSD, OpenBSD, NetBSD, macOS, AIX, HP/UX, and Solaris.
20922092
Other Unix-like systems may also work but are not currently
20932093
being tested. In most cases, all CPU architectures supported by

src/backend/libpq/auth.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2503,9 +2503,9 @@ InitializeLDAPConnection(Port *port, LDAP **ldap)
25032503
if (_ldap_start_tls_sA == NULL)
25042504
{
25052505
/*
2506-
* Need to load this function dynamically because it does not
2507-
* exist on Windows 2000, and causes a load error for the whole
2508-
* exe if referenced.
2506+
* Need to load this function dynamically because it may not exist
2507+
* on Windows, and causes a load error for the whole exe if
2508+
* referenced.
25092509
*/
25102510
HANDLE ldaphandle;
25112511

src/bin/initdb/initdb.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2007,7 +2007,7 @@ make_postgres(FILE *cmdfd)
20072007
* signal handler in case we are interrupted.
20082008
*
20092009
* The Windows runtime docs at
2010-
* http://msdn.microsoft.com/library/en-us/vclib/html/_crt_signal.asp
2010+
* https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/signal
20112011
* specifically forbid a number of things being done from a signal handler,
20122012
* including IO, memory allocation and system calls, and only allow jmpbuf
20132013
* if you are handling SIGFPE.
@@ -2016,11 +2016,10 @@ make_postgres(FILE *cmdfd)
20162016
* exit() directly.
20172017
*
20182018
* Also note the behaviour of Windows with SIGINT, which says this:
2019-
* Note SIGINT is not supported for any Win32 application, including
2020-
* Windows 98/Me and Windows NT/2000/XP. When a CTRL+C interrupt occurs,
2021-
* Win32 operating systems generate a new thread to specifically handle
2022-
* that interrupt. This can cause a single-thread application such as UNIX,
2023-
* to become multithreaded, resulting in unexpected behavior.
2019+
* SIGINT is not supported for any Win32 application. When a CTRL+C interrupt
2020+
* occurs, Win32 operating systems generate a new thread to specifically
2021+
* handle that interrupt. This can cause a single-thread application, such as
2022+
* one in UNIX, to become multithreaded and cause unexpected behavior.
20242023
*
20252024
* I have no idea how to handle this. (Strange they call UNIX an application!)
20262025
* So this will need some testing on Windows.

src/common/exec.c

Lines changed: 1 addition & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -354,17 +354,11 @@ find_other_exec(const char *argv0, const char *target,
354354

355355

356356
/*
357-
* The runtime library's popen() on win32 does not work when being
358-
* called from a service when running on windows <= 2000, because
359-
* there is no stdin/stdout/stderr.
360-
*
361-
* Executing a command in a pipe and reading the first line from it
362-
* is all we need.
357+
* Execute a command in a pipe and read the first line from it.
363358
*/
364359
static char *
365360
pipe_read_line(char *cmd, char *line, int maxsize)
366361
{
367-
#ifndef WIN32
368362
FILE *pgver;
369363

370364
/* flush output buffers in case popen does not... */
@@ -393,130 +387,6 @@ pipe_read_line(char *cmd, char *line, int maxsize)
393387
return NULL;
394388

395389
return line;
396-
#else /* WIN32 */
397-
398-
SECURITY_ATTRIBUTES sattr;
399-
HANDLE childstdoutrd,
400-
childstdoutwr,
401-
childstdoutrddup;
402-
PROCESS_INFORMATION pi;
403-
STARTUPINFO si;
404-
char *retval = NULL;
405-
406-
sattr.nLength = sizeof(SECURITY_ATTRIBUTES);
407-
sattr.bInheritHandle = TRUE;
408-
sattr.lpSecurityDescriptor = NULL;
409-
410-
if (!CreatePipe(&childstdoutrd, &childstdoutwr, &sattr, 0))
411-
return NULL;
412-
413-
if (!DuplicateHandle(GetCurrentProcess(),
414-
childstdoutrd,
415-
GetCurrentProcess(),
416-
&childstdoutrddup,
417-
0,
418-
FALSE,
419-
DUPLICATE_SAME_ACCESS))
420-
{
421-
CloseHandle(childstdoutrd);
422-
CloseHandle(childstdoutwr);
423-
return NULL;
424-
}
425-
426-
CloseHandle(childstdoutrd);
427-
428-
ZeroMemory(&pi, sizeof(pi));
429-
ZeroMemory(&si, sizeof(si));
430-
si.cb = sizeof(si);
431-
si.dwFlags = STARTF_USESTDHANDLES;
432-
si.hStdError = childstdoutwr;
433-
si.hStdOutput = childstdoutwr;
434-
si.hStdInput = INVALID_HANDLE_VALUE;
435-
436-
if (CreateProcess(NULL,
437-
cmd,
438-
NULL,
439-
NULL,
440-
TRUE,
441-
0,
442-
NULL,
443-
NULL,
444-
&si,
445-
&pi))
446-
{
447-
/* Successfully started the process */
448-
char *lineptr;
449-
450-
ZeroMemory(line, maxsize);
451-
452-
/* Try to read at least one line from the pipe */
453-
/* This may require more than one wait/read attempt */
454-
for (lineptr = line; lineptr < line + maxsize - 1;)
455-
{
456-
DWORD bytesread = 0;
457-
458-
/* Let's see if we can read */
459-
if (WaitForSingleObject(childstdoutrddup, 10000) != WAIT_OBJECT_0)
460-
break; /* Timeout, but perhaps we got a line already */
461-
462-
if (!ReadFile(childstdoutrddup, lineptr, maxsize - (lineptr - line),
463-
&bytesread, NULL))
464-
break; /* Error, but perhaps we got a line already */
465-
466-
lineptr += strlen(lineptr);
467-
468-
if (!bytesread)
469-
break; /* EOF */
470-
471-
if (strchr(line, '\n'))
472-
break; /* One or more lines read */
473-
}
474-
475-
if (lineptr != line)
476-
{
477-
/* OK, we read some data */
478-
int len;
479-
480-
/* If we got more than one line, cut off after the first \n */
481-
lineptr = strchr(line, '\n');
482-
if (lineptr)
483-
*(lineptr + 1) = '\0';
484-
485-
len = strlen(line);
486-
487-
/*
488-
* If EOL is \r\n, convert to just \n. Because stdout is a
489-
* text-mode stream, the \n output by the child process is
490-
* received as \r\n, so we convert it to \n. The server main.c
491-
* sets setvbuf(stdout, NULL, _IONBF, 0) which has the effect of
492-
* disabling \n to \r\n expansion for stdout.
493-
*/
494-
if (len >= 2 && line[len - 2] == '\r' && line[len - 1] == '\n')
495-
{
496-
line[len - 2] = '\n';
497-
line[len - 1] = '\0';
498-
len--;
499-
}
500-
501-
/*
502-
* We emulate fgets() behaviour. So if there is no newline at the
503-
* end, we add one...
504-
*/
505-
if (len == 0 || line[len - 1] != '\n')
506-
strcat(line, "\n");
507-
508-
retval = line;
509-
}
510-
511-
CloseHandle(pi.hProcess);
512-
CloseHandle(pi.hThread);
513-
}
514-
515-
CloseHandle(childstdoutwr);
516-
CloseHandle(childstdoutrddup);
517-
518-
return retval;
519-
#endif /* WIN32 */
520390
}
521391

522392

src/port/getaddrinfo.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,9 @@ haveNativeWindowsIPv6routines(void)
6969
return (getaddrinfo_ptr != NULL);
7070

7171
/*
72-
* For Windows XP and Windows 2003 (and longhorn/vista), the IPv6 routines
73-
* are present in the WinSock 2 library (ws2_32.dll). Try that first
72+
* For Windows XP and later versions, the IPv6 routines are present in the
73+
* WinSock 2 library (ws2_32.dll).
7474
*/
75-
7675
hLibrary = LoadLibraryA("ws2_32");
7776

7877
if (hLibrary == NULL || GetProcAddress(hLibrary, "getaddrinfo") == NULL)
@@ -83,13 +82,6 @@ haveNativeWindowsIPv6routines(void)
8382
*/
8483
if (hLibrary != NULL)
8584
FreeLibrary(hLibrary);
86-
87-
/*
88-
* In Windows 2000, there was only the IPv6 Technology Preview look in
89-
* the IPv6 WinSock library (wship6.dll).
90-
*/
91-
92-
hLibrary = LoadLibraryA("wship6");
9385
}
9486

9587
/* If hLibrary is null, we couldn't find a dll with functions */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy