libpq.dll & psql.exe on Win32

Started by Mikhail Terekhovover 24 years ago6 messages
#1Mikhail Terekhov
terekhov@emc.com

Hi,

There are two problems when compiling libpq.dll and psql.exe
on Windows. I'm not sure it is the best way to fix them
(see patch below.) Comments?

Regards,
Mikhail Terekhov

Index: bin/psql/prompt.c
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/bin/psql/prompt.c,v
retrieving revision 1.19
diff -C3 -r1.19 prompt.c
*** bin/psql/prompt.c	2001/05/06 17:21:11	1.19
--- bin/psql/prompt.c	2001/08/22 18:27:26
***************
*** 129,134 ****
--- 129,135 ----
  							if (*p == 'm')
  								buf[strcspn(buf, ".")] = '\0';
  						}
+ #ifndef WIN32
  						/* UNIX socket */
  						else
  						{
***************
*** 139,144 ****
--- 140,146 ----
  							else
  								snprintf(buf, MAX_PROMPT_SIZE, "[local:%s]", host);
  						}
+ #endif
  					}
  					break;
  					/* DB server port number */
Index: include/libpq/hba.h
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/include/libpq/hba.h,v
retrieving revision 1.24
diff -C3 -r1.24 hba.h
*** include/libpq/hba.h	2001/08/16 16:24:16	1.24
--- include/libpq/hba.h	2001/08/22 18:27:26
***************
*** 11,17 ****
--- 11,19 ----
  #ifndef HBA_H
  #define HBA_H
+ #ifndef WIN32
  #include <netinet/in.h>
+ #endif

#define CONF_FILE "pg_hba.conf"
/* Name of the config file */

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Mikhail Terekhov (#1)
Re: libpq.dll & psql.exe on Win32

Mikhail Terekhov <terekhov@emc.com> writes:

There are two problems when compiling libpq.dll and psql.exe
on Windows. I'm not sure it is the best way to fix them
(see patch below.) Comments?

The first should probably be conditional on HAVE_UNIX_SOCKETS,
not on WIN32. The second change looks okay to me.

regards, tom lane

Show quoted text
Index: bin/psql/prompt.c
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/bin/psql/prompt.c,v
retrieving revision 1.19
diff -C3 -r1.19 prompt.c
*** bin/psql/prompt.c	2001/05/06 17:21:11	1.19
--- bin/psql/prompt.c	2001/08/22 18:27:26
***************
*** 129,134 ****
--- 129,135 ----
if (*p == 'm')
buf[strcspn(buf, ".")] = '\0';
}
+ #ifndef WIN32
/* UNIX socket */
else
{
***************
*** 139,144 ****
--- 140,146 ----
else
snprintf(buf, MAX_PROMPT_SIZE, "[local:%s]", host);
}
+ #endif
}
break;
/* DB server port number */
Index: include/libpq/hba.h
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/include/libpq/hba.h,v
retrieving revision 1.24
diff -C3 -r1.24 hba.h
*** include/libpq/hba.h	2001/08/16 16:24:16	1.24
--- include/libpq/hba.h	2001/08/22 18:27:26
***************
*** 11,17 ****
--- 11,19 ----
#ifndef HBA_H
#define HBA_H
+ #ifndef WIN32
#include <netinet/in.h>
+ #endif

#define CONF_FILE "pg_hba.conf"
/* Name of the config file */

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://www.postgresql.org/search.mpl

#3Bruce Momjian
pgman@candle.pha.pa.us
In reply to: Mikhail Terekhov (#1)
Re: libpq.dll & psql.exe on Win32

Approved with Tom's suggested changes.

Your patch has been added to the PostgreSQL unapplied patches list at:

http://candle.pha.pa.us/cgi-bin/pgpatches

I will try to apply it within the next 48 hours.

Hi,

There are two problems when compiling libpq.dll and psql.exe
on Windows. I'm not sure it is the best way to fix them
(see patch below.) Comments?

Regards,
Mikhail Terekhov

Index: bin/psql/prompt.c
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/bin/psql/prompt.c,v
retrieving revision 1.19
diff -C3 -r1.19 prompt.c
*** bin/psql/prompt.c	2001/05/06 17:21:11	1.19
--- bin/psql/prompt.c	2001/08/22 18:27:26
***************
*** 129,134 ****
--- 129,135 ----
if (*p == 'm')
buf[strcspn(buf, ".")] = '\0';
}
+ #ifndef WIN32
/* UNIX socket */
else
{
***************
*** 139,144 ****
--- 140,146 ----
else
snprintf(buf, MAX_PROMPT_SIZE, "[local:%s]", host);
}
+ #endif
}
break;
/* DB server port number */
Index: include/libpq/hba.h
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/include/libpq/hba.h,v
retrieving revision 1.24
diff -C3 -r1.24 hba.h
*** include/libpq/hba.h	2001/08/16 16:24:16	1.24
--- include/libpq/hba.h	2001/08/22 18:27:26
***************
*** 11,17 ****
--- 11,19 ----
#ifndef HBA_H
#define HBA_H
+ #ifndef WIN32
#include <netinet/in.h>
+ #endif

#define CONF_FILE "pg_hba.conf"
/* Name of the config file */

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://www.postgresql.org/search.mpl

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
#4Bruce Momjian
pgman@candle.pha.pa.us
In reply to: Mikhail Terekhov (#1)
1 attachment(s)
Re: libpq.dll & psql.exe on Win32

I have applied the attached patch that is basically your patch with
Tom's suggestion to use HAVE_UNIX_SOCKETS.

Hi,

There are two problems when compiling libpq.dll and psql.exe
on Windows. I'm not sure it is the best way to fix them
(see patch below.) Comments?

Regards,
Mikhail Terekhov

Index: bin/psql/prompt.c
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/bin/psql/prompt.c,v
retrieving revision 1.19
diff -C3 -r1.19 prompt.c
*** bin/psql/prompt.c	2001/05/06 17:21:11	1.19
--- bin/psql/prompt.c	2001/08/22 18:27:26
***************
*** 129,134 ****
--- 129,135 ----
if (*p == 'm')
buf[strcspn(buf, ".")] = '\0';
}
+ #ifndef WIN32
/* UNIX socket */
else
{
***************
*** 139,144 ****
--- 140,146 ----
else
snprintf(buf, MAX_PROMPT_SIZE, "[local:%s]", host);
}
+ #endif
}
break;
/* DB server port number */
Index: include/libpq/hba.h
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/include/libpq/hba.h,v
retrieving revision 1.24
diff -C3 -r1.24 hba.h
*** include/libpq/hba.h	2001/08/16 16:24:16	1.24
--- include/libpq/hba.h	2001/08/22 18:27:26
***************
*** 11,17 ****
--- 11,19 ----
#ifndef HBA_H
#define HBA_H
+ #ifndef WIN32
#include <netinet/in.h>
+ #endif

#define CONF_FILE "pg_hba.conf"
/* Name of the config file */

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://www.postgresql.org/search.mpl

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Attachments:

/bjm/difftext/plainDownload
Index: src/bin/psql/prompt.c
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/bin/psql/prompt.c,v
retrieving revision 1.19
diff -c -r1.19 prompt.c
*** src/bin/psql/prompt.c	2001/05/06 17:21:11	1.19
--- src/bin/psql/prompt.c	2001/08/24 16:55:13
***************
*** 129,134 ****
--- 129,135 ----
  							if (*p == 'm')
  								buf[strcspn(buf, ".")] = '\0';
  						}
+ #ifndef HAVE_UNIX_SOCKETS
  						/* UNIX socket */
  						else
  						{
***************
*** 139,144 ****
--- 140,146 ----
  							else
  								snprintf(buf, MAX_PROMPT_SIZE, "[local:%s]", host);
  						}
+ #endif
  					}
  					break;
  					/* DB server port number */
Index: src/include/libpq/hba.h
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/include/libpq/hba.h,v
retrieving revision 1.24
diff -c -r1.24 hba.h
*** src/include/libpq/hba.h	2001/08/16 16:24:16	1.24
--- src/include/libpq/hba.h	2001/08/24 16:55:13
***************
*** 11,17 ****
--- 11,19 ----
  #ifndef HBA_H
  #define HBA_H
  
+ #ifndef WIN32
  #include <netinet/in.h>
+ #endif
  
  #define CONF_FILE "pg_hba.conf"
   /* Name of the config file  */
#5Tom Lane
tgl@sss.pgh.pa.us
In reply to: Bruce Momjian (#4)
Re: libpq.dll & psql.exe on Win32

Bruce Momjian <pgman@candle.pha.pa.us> writes:

}
+ #ifndef HAVE_UNIX_SOCKETS
/* UNIX socket */
else
{
***************

Uh, that test is backwards.

regards, tom lane

#6Bruce Momjian
pgman@candle.pha.pa.us
In reply to: Tom Lane (#5)
Re: libpq.dll & psql.exe on Win32

Bruce Momjian <pgman@candle.pha.pa.us> writes:

}
+ #ifndef HAVE_UNIX_SOCKETS
/* UNIX socket */
else
{
***************

Uh, that test is backwards.

Thanks. Fixed and committed.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026