From 0a97c4a047607708eefef7e925705795c1904ca8 Mon Sep 17 00:00:00 2001
From: Michael Meskes <meskes@postgresql.org>
Date: Tue, 17 Oct 2000 06:15:29 +0000
Subject: [PATCH] Simplified parsing of connect rule.

---
 src/interfaces/ecpg/ChangeLog          | 4 ++++
 src/interfaces/ecpg/preproc/preproc.y  | 9 +++------
 src/interfaces/ecpg/test/test_init.pgc | 3 +++
 3 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/interfaces/ecpg/ChangeLog b/src/interfaces/ecpg/ChangeLog
index 9fe53ee62a9..9a9e9527392 100644
--- a/src/interfaces/ecpg/ChangeLog
+++ b/src/interfaces/ecpg/ChangeLog
@@ -969,5 +969,9 @@ Thu Oct 12 20:13:00 CEST 2000
 Mon Oct 16 21:33:17 CEST 2000
 
 	- Fixed handling of variables in connect rule.
+
+Tue Oct 17 08:09:16 CEST 2000
+
+	- Simplified parsing ofr connect rule.
 	- Set ecpg version to 2.8.0. 
 	- Set library version to 3.2.0.
diff --git a/src/interfaces/ecpg/preproc/preproc.y b/src/interfaces/ecpg/preproc/preproc.y
index 804d3be4579..4c6b6eb2ec5 100644
--- a/src/interfaces/ecpg/preproc/preproc.y
+++ b/src/interfaces/ecpg/preproc/preproc.y
@@ -465,12 +465,7 @@ stmt:  AlterSchemaStmt 			{ output_statement($1, 0, NULL, connection); }
 						if (connection)
 							mmerror(ET_ERROR, "no at option for connect statement.\n");
 
-						fputs("{ ECPGconnect(__LINE__,", yyout);
-
-						if ($1[1] == '?')
-							fprintf(yyout, "%s, %s, %d);", argsinsert->variable->name, $1 + sizeof("\"?\","), autocommit);
-						else				
-							fprintf(yyout, "%s, %d); ", $1, autocommit);
+						fprintf(yyout, "{ ECPGconnect(__LINE__, %s, %d); ", $1, autocommit);
 
 				                reset_variables();
 
@@ -3975,6 +3970,8 @@ connection_target: database_name opt_server opt_port
 		{
 		  if ($1[0] == '\"')
 			$$ = $1;
+		  else if (strcmp($1, "?") == 0)
+			$$ = mm_strdup(argsinsert->variable->name);
 		  else
 			$$ = make3_str(make_str("\""), $1, make_str("\""));
 		}
diff --git a/src/interfaces/ecpg/test/test_init.pgc b/src/interfaces/ecpg/test/test_init.pgc
index 86e6b6da848..980319981c8 100644
--- a/src/interfaces/ecpg/test/test_init.pgc
+++ b/src/interfaces/ecpg/test/test_init.pgc
@@ -34,8 +34,11 @@ int j=1?1:2;
 /*int e=y->member; /* compile error */
 /*int c=10>>2; /* compile error */
 /*bool h=2||1; /* compile error */
+long long  iax;
 exec sql end declare section;
 
+iax = 40000000000LL;
+
 /* not working */
 int f=fa();
 
-- 
GitLab