RE: BUG #15080: ecpg on windows doesn't define HAVE_LONG_LONG_INT

Huong Dangminh <huo-dangminh@ys.jp.nec.com>

From: Huong Dangminh <huo-dangminh@ys.jp.nec.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Jonathan Allen <jallen@americansavingslife.com>, Michael Meskes <meskes@postgresql.org>, Andrew Gierth <andrew@tao11.riddles.org.uk>, "pgsql-bugs@lists.postgresql.org" <pgsql-bugs@lists.postgresql.org>, "Akio Iwaasa" <aki-iwaasa@vt.jp.nec.com>
Date: 2018-05-18T12:40:33Z
Lists: pgsql-bugs
> From: Huong Dangminh [mailto:huo-dangminh@ys.jp.nec.com]
> > something like
> >
> > #if (_MSC_VER > 1200)
> > #define HAVE_LONG_LONG_INT_64 1
> > #endif
> >
> > ...
> >
> > #ifdef HAVE_LONG_LONG_INT_64
> > #define HAVE_STRTOLL 1
> > /* Before VS2013, use Microsoft's nonstandard equivalent function */
> > #if (_MSC_VER < 1800) #define strtoll _strtoi64 #endif #endif
> >
> > and similarly for strtoull.
> >
> > Please check that and see if it works.
> 
> Thanks, as you mentioned the attached works fine for me.
> I think the code is also fine for the before VS2013 but I not yet tested.
> 
> > BTW, is it possible to set up an ecpg test case to verify that this
> > stuff works?
> > It'd have to handle platforms without long long though, so I'm not
> > sure how to deal with that.
> 
> Yes. I was expecting that at least bigint will works fine with sqlda in
> linux system but it seem did not?
> Attached test patch works fine in Windows, but in Linux system the
> sqlda->sqlvar[i].sqltype return ECPGt_long but not ECPGt_long_long (as
> expected) when reference to bigint column.
> Is this another problem in linux? Or am I wrong something?

Look into the code I found that Linux also need define HAVE_LONG_LONG_INT_64 
Flag in order to work with bigint and sqlda.

In the following code,  sqlda_dynamic_type  function return ECPGt_long,
If HAVE_LONG_LONG_INT_64 is not defined.

ecpg/ecpg/typename.c
---
sqlda_dynamic_type function
...
#ifdef HAVE_LONG_LONG_INT_64
			return ECPGt_long_long;
#endif
#ifdef HAVE_LONG_INT_64
			return ECPGt_long;
...
---

Is this fine if We define the above flag in pg_config.h.in like that?

---
/* Define to 1 if the system has the type `long long int'. */
-#undef HAVE_LONG_LONG_INT
+#define HAVE_LONG_LONG_INT 1
 
 /* Define to 1 if `long long int' works and is 64 bits. */
-#undef HAVE_LONG_LONG_INT_64
+#define HAVE_LONG_LONG_INT_64 1
---

I am wondering that "long long int" not supported platform also using pg_config.h.in?


Thanks and best regards,
---
Dang Minh Huong
NEC Solution Innovators, Ltd.
http://www.nec-solutioninnovators.co.jp/en/



Commits

  1. Remove configure's check for nonstandard "long long" printf modifiers.

  2. printf("%lf") is not portable, so omit the "l".

  3. Support platforms where strtoll/strtoull are spelled __strtoll/__strtoull.

  4. Arrange to supply declarations for strtoll/strtoull if needed.

  5. Hot-fix ecpg regression test for missing ecpg_config.h inclusion.

  6. Add some test coverage for ecpg's "long long" support.

  7. Recognize that MSVC can support strtoll() and strtoull().

  8. Fix up ecpg's configuration so it handles "long long int" in MSVC builds.