6.2 protocol

Started by Bruce Momjianalmost 25 years ago7 messages
#1Bruce Momjian
pgman@candle.pha.pa.us

ODBC still has code to handle 6.2 backends:

/* This startup packet is to support pre-Postgres 6.3 protocol */
typedef struct _StartupPacket6_2
{
unsigned int authtype;
char database[PATH_SIZE];
char user[NAMEDATALEN];
char options[ARGV_SIZE];
char execfile[ARGV_SIZE];
char tty[PATH_SIZE];
} StartupPacket6_2;

Do we still want to carry that code around in ODBC?

-- 
  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
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Bruce Momjian (#1)
Re: 6.2 protocol

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

ODBC still has code to handle 6.2 backends:
Do we still want to carry that code around in ODBC?

I'd suggest retiring the 6.2 *and* 6.3 code from ODBC, so that it only
needs to support one protocol version, and then we can also retire its
"6.2/6.3/6.4" protocol option switch. AFAICS that option switch serves
only to confuse newbies --- I recall a fair number of questions along
the line of "I'm running PG 6.5 (or 7.0), where do I get an ODBC that
will talk to it?" since after all it does not say ">= 6.4".

Besides, anyone still running 6.3 or before needs to be prodded,
none too gently, to upgrade ...

regards, tom lane

#3Bruce Momjian
pgman@candle.pha.pa.us
In reply to: Tom Lane (#2)
1 attachment(s)
Re: [HACKERS] 6.2 protocol

OK, I have applied the following patch to remove ODBC protocol-version
handling. I have kept the protocol-version fields and assignments, in
case it is useful in the future. Comments?

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

ODBC still has code to handle 6.2 backends:
Do we still want to carry that code around in ODBC?

I'd suggest retiring the 6.2 *and* 6.3 code from ODBC, so that it only
needs to support one protocol version, and then we can also retire its
"6.2/6.3/6.4" protocol option switch. AFAICS that option switch serves
only to confuse newbies --- I recall a fair number of questions along
the line of "I'm running PG 6.5 (or 7.0), where do I get an ODBC that
will talk to it?" since after all it does not say ">= 6.4".

Besides, anyone still running 6.3 or before needs to be prodded,
none too gently, to upgrade ...

regards, tom lane

-- 
  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/interfaces/odbc/connection.c
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/interfaces/odbc/connection.c,v
retrieving revision 1.17
diff -c -r1.17 connection.c
*** src/interfaces/odbc/connection.c	2001/02/10 05:50:27	1.17
--- src/interfaces/odbc/connection.c	2001/02/10 06:25:31
***************
*** 461,467 ****
  CC_connect(ConnectionClass *self, char do_password)
  {
  StartupPacket sp;
- StartupPacket6_2 sp62;
  QResultClass *res;
  SocketClass *sock;
  ConnInfo *ci = &(self->connInfo);
--- 461,466 ----
***************
*** 538,573 ****
  		}
  		mylog("connection to the server socket succeeded.\n");
  
! 		if ( PROTOCOL_62(ci)) {
! 			sock->reverse = TRUE;		/* make put_int and get_int work for 6.2 */
  
! 			memset(&sp62, 0, sizeof(StartupPacket6_2));
! 			SOCK_put_int(sock, htonl(4+sizeof(StartupPacket6_2)), 4);
! 			sp62.authtype = htonl(NO_AUTHENTICATION);
! 			strncpy(sp62.database, ci->database, PATH_SIZE);
! 			strncpy(sp62.user, ci->username, NAMEDATALEN);
! 			SOCK_put_n_char(sock, (char *) &sp62, sizeof(StartupPacket6_2));
! 			SOCK_flush_output(sock);
! 		}
! 		else {
! 			memset(&sp, 0, sizeof(StartupPacket));
  
! 			mylog("sizeof startup packet = %d\n", sizeof(StartupPacket));
  
! 			/* Send length of Authentication Block */
! 			SOCK_put_int(sock, 4+sizeof(StartupPacket), 4); 
  
! 			if ( PROTOCOL_63(ci))
! 				sp.protoVersion = (ProtocolVersion) htonl(PG_PROTOCOL_63);
! 			else
! 				sp.protoVersion = (ProtocolVersion) htonl(PG_PROTOCOL_LATEST);
! 
! 			strncpy(sp.database, ci->database, SM_DATABASE);
! 			strncpy(sp.user, ci->username, SM_USER);
  
! 			SOCK_put_n_char(sock, (char *) &sp, sizeof(StartupPacket));
! 			SOCK_flush_output(sock);
! 		}
  
  		mylog("sent the authentication block.\n");
  
--- 537,556 ----
  		}
  		mylog("connection to the server socket succeeded.\n");
  
! 		memset(&sp, 0, sizeof(StartupPacket));
  
! 		mylog("sizeof startup packet = %d\n", sizeof(StartupPacket));
  
! 		/* Send length of Authentication Block */
! 		SOCK_put_int(sock, 4+sizeof(StartupPacket), 4); 
  
! 		sp.protoVersion = (ProtocolVersion) htonl(PG_PROTOCOL_LATEST);
  
! 		strncpy(sp.database, ci->database, SM_DATABASE);
! 		strncpy(sp.user, ci->username, SM_USER);
  
! 		SOCK_put_n_char(sock, (char *) &sp, sizeof(StartupPacket));
! 		SOCK_flush_output(sock);
  
  		mylog("sent the authentication block.\n");
  
***************
*** 588,594 ****
  	/*	Now get the authentication request from backend */
  	/* *************************************************** */
  
! 	if ( ! PROTOCOL_62(ci))	do {
  
  		if (do_password)
  			beresp = 'R';
--- 571,577 ----
  	/*	Now get the authentication request from backend */
  	/* *************************************************** */
  
! 	do {
  
  		if (do_password)
  			beresp = 'R';
***************
*** 1378,1396 ****
  CC_initialize_pg_version(ConnectionClass *self) 
  {
  	strcpy(self->pg_version, self->connInfo.protocol); 
! 	if (PROTOCOL_62(&self->connInfo)) {
! 		self->pg_version_number = (float) 6.2;
! 		self->pg_version_major = 6;
! 		self->pg_version_minor = 2;
! 	} else if (PROTOCOL_63(&self->connInfo)) {
! 		self->pg_version_number = (float) 6.3;
! 		self->pg_version_major = 6;
! 		self->pg_version_minor = 3;
! 	} else {
! 		self->pg_version_number = (float) 6.4;
! 		self->pg_version_major = 6;
! 		self->pg_version_minor = 4;
! 	}
  }
  /*	This function gets the version of PostgreSQL that we're connected to.
      This is used to return the correct info in SQLGetInfo
--- 1361,1369 ----
  CC_initialize_pg_version(ConnectionClass *self) 
  {
  	strcpy(self->pg_version, self->connInfo.protocol); 
! 	self->pg_version_number = (float) 6.4;
! 	self->pg_version_major = 6;
! 	self->pg_version_minor = 4;
  }
  /*	This function gets the version of PostgreSQL that we're connected to.
      This is used to return the correct info in SQLGetInfo
Index: src/interfaces/odbc/connection.h
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/interfaces/odbc/connection.h,v
retrieving revision 1.13
diff -c -r1.13 connection.h
*** src/interfaces/odbc/connection.h	2001/02/06 02:21:12	1.13
--- src/interfaces/odbc/connection.h	2001/02/10 06:25:31
***************
*** 106,115 ****
  
  #define PG_PROTOCOL(major, minor)	(((major) << 16) | (minor))
  #define PG_PROTOCOL_LATEST		PG_PROTOCOL(2, 0)
- #define PG_PROTOCOL_63			PG_PROTOCOL(1, 0)
- #define PG_PROTOCOL_62			PG_PROTOCOL(0, 0)
  
! /*	This startup packet is to support latest Postgres protocol (6.4, 6.3) */
  typedef struct _StartupPacket
  {
  	ProtocolVersion	protoVersion;
--- 106,113 ----
  
  #define PG_PROTOCOL(major, minor)	(((major) << 16) | (minor))
  #define PG_PROTOCOL_LATEST		PG_PROTOCOL(2, 0)
  
! /*	This startup packet is to support latest Postgres protocol */
  typedef struct _StartupPacket
  {
  	ProtocolVersion	protoVersion;
***************
*** 121,138 ****
  } StartupPacket;
  
  
- /*	This startup packet is to support pre-Postgres 6.3 protocol */
- typedef struct _StartupPacket6_2
- {
- 	unsigned int	authtype;
- 	char			database[PATH_SIZE];
- 	char			user[NAMEDATALEN];
- 	char			options[ARGV_SIZE];
- 	char			execfile[ARGV_SIZE];
- 	char			tty[PATH_SIZE];
- } StartupPacket6_2;
- 
- 
  /*	Structure to hold all the connection attributes for a specific
  	connection (used for both registry and file, DSN and DRIVER)
  */
--- 119,124 ----
***************
*** 156,167 ****
  	char    translation_option[SMALL_REGISTRY_LEN];
  	char	focus_password;
  } ConnInfo;
- 
- /*	Macro to determine is the connection using 6.2 protocol? */
- #define PROTOCOL_62(conninfo_)		(strncmp((conninfo_)->protocol, PG62, strlen(PG62)) == 0)
- 
- /*	Macro to determine is the connection using 6.3 protocol? */
- #define PROTOCOL_63(conninfo_)		(strncmp((conninfo_)->protocol, PG63, strlen(PG63)) == 0)
  
  /*
   *	Macros to compare the server's version with a specified version
--- 142,147 ----
Index: src/interfaces/odbc/dlg_specific.c
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/interfaces/odbc/dlg_specific.c,v
retrieving revision 1.18
diff -c -r1.18 dlg_specific.c
*** src/interfaces/odbc/dlg_specific.c	2001/02/10 05:50:28	1.18
--- src/interfaces/odbc/dlg_specific.c	2001/02/10 06:25:31
***************
*** 243,254 ****
  		CheckDlgButton(hdlg, DS_READONLY, atoi(ci->onlyread));
  
  		/*	Protocol */
! 		if (strncmp(ci->protocol, PG62, strlen(PG62)) == 0)
! 			CheckDlgButton(hdlg, DS_PG62, 1);
! 		else if (strncmp(ci->protocol, PG63, strlen(PG63)) == 0)
! 			CheckDlgButton(hdlg, DS_PG63, 1);
! 		else /* latest */
! 			CheckDlgButton(hdlg, DS_PG64, 1);
  
  
  
--- 243,249 ----
  		CheckDlgButton(hdlg, DS_READONLY, atoi(ci->onlyread));
  
  		/*	Protocol */
! 		CheckDlgButton(hdlg, DS_PG64, 1);
  
  
  
***************
*** 281,292 ****
  			sprintf(ci->onlyread, "%d", IsDlgButtonChecked(hdlg, DS_READONLY));
  
  			/*	Protocol */
! 			if ( IsDlgButtonChecked(hdlg, DS_PG62))
! 				strcpy(ci->protocol, PG62);
! 			else if ( IsDlgButtonChecked(hdlg, DS_PG63))
! 				strcpy(ci->protocol, PG63);
! 			else	/* latest */
! 				strcpy(ci->protocol, PG64);
  
  			sprintf(ci->show_system_tables, "%d", IsDlgButtonChecked(hdlg, DS_SHOWSYSTEMTABLES));
  
--- 276,282 ----
  			sprintf(ci->onlyread, "%d", IsDlgButtonChecked(hdlg, DS_READONLY));
  
  			/*	Protocol */
! 			strcpy(ci->protocol, PG64);
  
  			sprintf(ci->show_system_tables, "%d", IsDlgButtonChecked(hdlg, DS_SHOWSYSTEMTABLES));
  
Index: src/interfaces/odbc/psqlodbc.h
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/interfaces/odbc/psqlodbc.h,v
retrieving revision 1.30
diff -c -r1.30 psqlodbc.h
*** src/interfaces/odbc/psqlodbc.h	2001/02/06 02:21:12	1.30
--- src/interfaces/odbc/psqlodbc.h	2001/02/10 06:25:32
***************
*** 91,98 ****
  /* Now that's 0, lets use this instead. DJP 24-1-2001 */
  #define STD_STATEMENT_LEN	MAX_MESSAGE_LEN
  
- #define PG62	"6.2"		/* "Protocol" key setting to force Postgres 6.2 */
- #define PG63	"6.3"		/* "Protocol" key setting to force postgres 6.3 */
  #define PG64	"6.4"
  
  typedef struct ConnectionClass_ ConnectionClass;
--- 91,96 ----
***************
*** 132,139 ****
  	char				cancel_as_freestmt;
  	char				extra_systable_prefixes[MEDIUM_REGISTRY_LEN];
  	char				conn_settings[LARGE_REGISTRY_LEN];
  	char				protocol[SMALL_REGISTRY_LEN];
- 
  	FILE*				mylogFP;
  	FILE*				qlogFP;	
  } GLOBAL_VALUES;
--- 130,139 ----
  	char				cancel_as_freestmt;
  	char				extra_systable_prefixes[MEDIUM_REGISTRY_LEN];
  	char				conn_settings[LARGE_REGISTRY_LEN];
+ 						/* Protocol is not used anymore, but kept in case
+ 						 * it is useful in the future.  bjm 2001-02-10
+ 						 */
  	char				protocol[SMALL_REGISTRY_LEN];
  	FILE*				mylogFP;
  	FILE*				qlogFP;	
  } GLOBAL_VALUES;
Index: src/interfaces/odbc/resource.h
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/interfaces/odbc/resource.h,v
retrieving revision 1.11
diff -c -r1.11 resource.h
*** src/interfaces/odbc/resource.h	2001/01/26 22:41:59	1.11
--- src/interfaces/odbc/resource.h	2001/02/10 06:25:32
***************
*** 19,25 ****
  #define DS_SHOWOIDCOLUMN                1012
  #define DS_FAKEOIDINDEX                 1013
  #define DRV_COMMLOG                     1014
- #define DS_PG62                         1016
  #define IDC_DATASOURCE                  1018
  #define DRV_OPTIMIZER                   1019
  #define DS_CONNSETTINGS                 1020
--- 19,24 ----
***************
*** 48,54 ****
  #define IDC_OPTIONS                     1054
  #define DRV_KSQO                        1055
  #define DS_PG64                         1057
- #define DS_PG63                         1058
  
  /* Next default values for new objects */
  
--- 47,52 ----
#4Hiroshi Inoue
Inoue@tpf.co.jp
In reply to: Bruce Momjian (#3)
RE: [PATCHES] Re: [HACKERS] 6.2 protocol

-----Original Message-----
From: Bruce Momjian

OK, I have applied the following patch to remove ODBC protocol-version
handling. I have kept the protocol-version fields and assignments, in
case it is useful in the future. Comments?

Hmm, could only you 2 decide it so quickly ?
For whom pgsql ODBC driver is ?

Regards,
Hiroshi Inoue

#5Bruce Momjian
pgman@candle.pha.pa.us
In reply to: Hiroshi Inoue (#4)
Re: RE: [PATCHES] Re: [HACKERS] 6.2 protocol

-----Original Message-----
From: Bruce Momjian

OK, I have applied the following patch to remove ODBC protocol-version
handling. I have kept the protocol-version fields and assignments, in
case it is useful in the future. Comments?

Hmm, could only you 2 decide it so quickly ?
For whom pgsql ODBC driver is ?

I can put it back. You want it back?

-- 
  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
#6Hiroshi Inoue
Inoue@tpf.co.jp
In reply to: Bruce Momjian (#5)
RE: RE: [PATCHES] Re: [HACKERS] 6.2 protocol

-----Original Message-----
From: Bruce Momjian [mailto:pgman@candle.pha.pa.us]

-----Original Message-----
From: Bruce Momjian

OK, I have applied the following patch to remove ODBC protocol-version
handling. I have kept the protocol-version fields and assignments, in
case it is useful in the future. Comments?

Hmm, could only you 2 decide it so quickly ?
For whom pgsql ODBC driver is ?

I can put it back. You want it back?

Yes.
ISTM discussion is needed before the change.

Regards,
Hiroshi Inoue

#7Bruce Momjian
pgman@candle.pha.pa.us
In reply to: Hiroshi Inoue (#6)
Re: RE: [PATCHES] Re: [HACKERS] 6.2 protocol

Hmm, could only you 2 decide it so quickly ?
For whom pgsql ODBC driver is ?

I can put it back. You want it back?

Yes.
ISTM discussion is needed before the change.

OK, let's discuss. Why should ODBC still support 6.3 and 6.2 databases?

-- 
  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