Thread: ecpg bug and patch

ecpg bug and patch

From
Adriaan Joubert
Date:
Hi,

    I've been doing some tests with writing int8 to the database using
ecpg. This does not work if the long long variable is in a structure, as
it is not recognised as a simple type.

The patch is attached, but is not very satisfactory. Moving the
definition of

                ECPGt_long_long, ECPGt_unsigned_long_long

up to before ECPGt_varchar causes the resulting application to crash, as
it finds an ECPGt_union, where it should haven found an ECPGt_EOIT (I
think), and I could not figure out where the static offset comes from.

Another problem with ecpg is that it dies on the alpha for long long
variables unless

#define HAVE_LONG_LONG_INT_64

is set in config.h. It is not set by default.

Without fixing these int8 values cannot be written to the database.

Regards,

Adriaandiff -Naur postgresql-7.1RC1/src/interfaces/ecpg/include/ecpgtype.h
postgresql-7.1RC1.orig/src/interfaces/ecpg/include/ecpgtype.h
--- postgresql-7.1RC1/src/interfaces/ecpg/include/ecpgtype.h    Wed Mar 28 12:16:44 2001
+++ postgresql-7.1RC1.orig/src/interfaces/ecpg/include/ecpgtype.h    Sun Jan  7 04:03:39 2001
@@ -70,8 +70,7 @@
         ECPGd_EODT                /* End of descriptor types. */
     };

-#define IS_SIMPLE_TYPE(type) ((type) >= ECPGt_char && (type) <= ECPGt_varchar2 |
-| (type)>=ECPGt_long_long)
+#define IS_SIMPLE_TYPE(type) ((type) >= ECPGt_char && (type) <= ECPGt_varchar2)

 #ifdef __cplusplus
 }

Re: ecpg bug and patch

From
Adriaan Joubert
Date:
Ooops, patch was the wrong way round. Here is a better one.

Sorry,

Adriaandiff -Naur postgresql-7.1RC1.orig/src/interfaces/ecpg/include/ecpgtype.h
postgresql-7.1RC1/src/interfaces/ecpg/include/ecpgtype.h
--- postgresql-7.1RC1.orig/src/interfaces/ecpg/include/ecpgtype.h    Sun Jan  7 04:03:39 2001
+++ postgresql-7.1RC1/src/interfaces/ecpg/include/ecpgtype.h    Wed Mar 28 12:36:05 2001
@@ -70,7 +70,7 @@
         ECPGd_EODT                /* End of descriptor types. */
     };

-#define IS_SIMPLE_TYPE(type) ((type) >= ECPGt_char && (type) <= ECPGt_varchar2)
+#define IS_SIMPLE_TYPE(type) ((type) >= ECPGt_char && (type) <= ECPGt_varchar2 || (type)>=ECPGt_long_long)

 #ifdef __cplusplus
 }

Re: ecpg bug and patch

From
Michael Meskes
Date:
On Wed, Mar 28, 2001 at 12:37:15PM +0300, Adriaan Joubert wrote:
> Ooops, patch was the wrong way round. Here is a better one.

Applied. I did add another set of braces for easier understanding though.
:-)

To be able to move ECPGt_long_long up the list we would have to bump the
soname of the shared library as it would make an incompatible change. So
everyone would have to recompile all their programs. I don't think would be
worth the effort.

Michael

-- 
Michael Meskes
Michael@Fam-Meskes.De
Go SF 49ers! Go Rhein Fire!
Use Debian GNU/Linux! Use PostgreSQL!