Subject: Compatibility modes supported in ECPG

From: Ashutosh Sharma <[email-masked]>
Date: Wed, 10 Jan 2018 17:14:26 +0530

Hi All,

As per the documentation of ecpg, currently we support only two types
of compatibility modes with ecpg and they are 1) INFORMIX and 2)
INFORMIX_SE. However, it does accept any compatibility mode option
that starts with INFORMIX*. For e.g. let us say, if i pass
'INFORMIX_BAD_COMPAT_MODE' as a compatibility mode, it still accepts
it.

[ashu@localhost bin]$ ./ecpg -C INFORMIX_BAD_COMPAT_MODE test_compat_modes.pc
[ashu@localhost bin]$

Shouldn't we throw an error for this, instead of accepting it and
assuming it as INFORMIX_SE mode. Thoughts?

--
With Regards,
Ashutosh Sharma
EnterpriseDB:http://www.enterprisedb.com

---

From: Michael Meskes <[email-masked]>
Date: Wed, 10 Jan 2018 13:29:16 +0100

Hi,

> assuming it as INFORMIX_SE mode. Thoughts?

Yes, I'd say that would be better. :)

Michael
-- 
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Meskes at (Debian|Postgresql) dot Org
Jabber: michael at xmpp dot meskes dot org
VfL Borussia! Força Barça! Go SF 49ers! Use Debian GNU/Linux, PostgreSQL

---

From: Ashutosh Sharma <[email-masked]>
Date: Wed, 10 Jan 2018 21:10:20 +0530

> Yes, I'd say that would be better. :)

Thanks Michael. Shall i submit a patch for it. Also, what about making
the compatibility modes case insensitive. Currently, ecpg accepts
compatibility mode only in capital letters. In case if the INFORMIX or
INFORMIX_SE is entered in small or mixed type letter, ecpg throws an
error. Shouldn't that be handled as well?

---

From: Michael Meskes <[email-masked]>
Date: Thu, 11 Jan 2018 12:04:58 +0100

> Thanks Michael. Shall i submit a patch for it. Also, what about 

Yes, please.

> making

Actually I don't mind either way. There is definitely an advantage of
having it case insensitive, but then options are known to be case
sensitive often enough.

Michael
-- 
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Meskes at (Debian|Postgresql) dot Org
Jabber: michael at xmpp dot meskes dot org
VfL Borussia! Força Barça! SF 49ers! Use Debian GNU/Linux, PostgreSQL

---

From: Ashutosh Sharma <[email-masked]>
Date: Thu, 11 Jan 2018 18:13:15 +0530

>> Thanks Michael. Shall i submit a patch for it. Also, what about

Thanks. Attached are the patches
'Allow_ecpg_to_throw_error_for_wrong_compat_modes_v1' and
'Allow_ecpg_to_throw_error_for_wrong_compat_modes_v2' that fixes the
reported issues.

> having it case insensitive, but then options are known to be case

I feel we should make them case insensitive. The reason being, other
embedded SQL programming languages for e.g. Pro*C accepts case
insensitive options. So, why can't we make our ecpg options case
insensitive as well. Thoughts?

> Michael
diff --git a/src/interfaces/ecpg/preproc/ecpg.c b/src/interfaces/ecpg/preproc/ecpg.c
index 8a14572..badf042 100644
--- a/src/interfaces/ecpg/preproc/ecpg.c
+++ b/src/interfaces/ecpg/preproc/ecpg.c
@@ -198,7 +198,7 @@ main(int argc, char *const argv[])
 				system_includes = true;
 				break;
 			case 'C':
-				if (strncmp(optarg, "INFORMIX", strlen("INFORMIX")) == 0)
+				if (strcmp(optarg, "INFORMIX") == 0 || strcmp(optarg, "INFORMIX_SE") == 0)
 				{
 					char		pkginclude_path[MAXPGPATH];
 					char		informix_path[MAXPGPATH];
diff --git a/src/interfaces/ecpg/preproc/ecpg.c b/src/interfaces/ecpg/preproc/ecpg.c
index 8a14572..cd770c8 100644
--- a/src/interfaces/ecpg/preproc/ecpg.c
+++ b/src/interfaces/ecpg/preproc/ecpg.c
@@ -198,12 +198,12 @@ main(int argc, char *const argv[])
 				system_includes = true;
 				break;
 			case 'C':
-				if (strncmp(optarg, "INFORMIX", strlen("INFORMIX")) == 0)
+				if (pg_strcasecmp(optarg, "INFORMIX") == 0 || pg_strcasecmp(optarg, "INFORMIX_SE") == 0)
 				{
 					char		pkginclude_path[MAXPGPATH];
 					char		informix_path[MAXPGPATH];
 
-					compat = (strcmp(optarg, "INFORMIX") == 0) ? ECPG_COMPAT_INFORMIX : ECPG_COMPAT_INFORMIX_SE;
+					compat = (pg_strcasecmp(optarg, "INFORMIX") == 0) ? ECPG_COMPAT_INFORMIX : ECPG_COMPAT_INFORMIX_SE;
 					get_pkginclude_path(my_exec_path, pkginclude_path);
 					snprintf(informix_path, MAXPGPATH, "%s/informix/esql", pkginclude_path);
 					add_include_path(informix_path);

---

From: Michael Meskes <[email-masked]>
Date: Fri, 12 Jan 2018 16:01:26 +0100

> 'Allow_ecpg_to_throw_error_for_wrong_compat_modes_v2' that fixes the

Thanks, I just committed the case insensitive version.

Michael

---

From: Ashutosh Sharma <[email-masked]>
Date: Fri, 12 Jan 2018 20:36:01 +0530

Thank you :)

Michael