Added just another compatibility level for Informix.
authorMichael Meskes <meskes@postgresql.org>
Thu, 26 Jun 2003 11:37:05 +0000 (11:37 +0000)
committerMichael Meskes <meskes@postgresql.org>
Thu, 26 Jun 2003 11:37:05 +0000 (11:37 +0000)
src/interfaces/ecpg/ChangeLog
src/interfaces/ecpg/ecpglib/connect.c
src/interfaces/ecpg/ecpglib/data.c
src/interfaces/ecpg/ecpglib/execute.c
src/interfaces/ecpg/ecpglib/extern.h
src/interfaces/ecpg/ecpglib/prepare.c
src/interfaces/ecpg/preproc/ecpg.c
src/interfaces/ecpg/preproc/extern.h
src/interfaces/ecpg/preproc/pgc.l
src/interfaces/ecpg/preproc/preproc.y
src/interfaces/ecpg/test/test_informix.pgc

index a8daf97af747ad9dae5e6f39178ddbbb4e0c18f3..67629d5bea9bf410d2dbec7b6ae5bb1f9af0ef4a 100644 (file)
@@ -1514,6 +1514,16 @@ Fri Jun 20 15:34:29 CEST 2003
 Sun Jun 22 11:20:29 CEST 2003
 
        - Fixed missing '\0' in output char pointer.
+       
+Wed Jun 25 09:29:34 CEST 2003
+
+       - Synced keyword.x and preproc.y/gram.y.
+       - Implemented Informix special way to treat NULLs.
+       
+Thu Jun 26 13:26:13 CEST 2003
+
+       - Added another compatibility level INFORMIX_SE.
+       - Synced again.
        - Set ecpg version to 3.0.0
        - Set ecpg library to 4.0.0
        - Set pgtypes library to 1.0.0
index cda4bbd15bfb06f70482284a6e9d9cd5e112978e..77505f1184a788d0058abb67f299ef4eaf1723df 100644 (file)
@@ -1,4 +1,4 @@
-/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.8 2003/06/25 10:44:21 meskes Exp $ */
+/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.9 2003/06/26 11:37:05 meskes Exp $ */
 
 #define POSTGRES_ECPG_INTERNAL
 #include "postgres_fe.h"
@@ -304,7 +304,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
 
        ECPGinit_sqlca(sqlca);
        
-       if (compat == ECPG_COMPAT_INFORMIX)
+       if (INFORMIX_MODE(compat))
        {
                char *envname;
                
index 8e0138d527ddeed0f910a8c89645bb2196825794..77f35e639e02b526942f5bab365ae127a3919cf5 100644 (file)
@@ -1,4 +1,4 @@
-/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.8 2003/06/25 10:44:21 meskes Exp $ */
+/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.9 2003/06/26 11:37:05 meskes Exp $ */
 
 #define POSTGRES_ECPG_INTERNAL
 #include "postgres_fe.h"
@@ -78,7 +78,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
                                break;
 #endif   /* HAVE_LONG_LONG_INT_64 */
                        case ECPGt_NO_INDICATOR:
-                               if (force_indicator == false && compat == ECPG_COMPAT_INFORMIX)
+                               if (force_indicator == false)
                                {
                                        /* Informix has an additional way to specify NULLs
                                         * note that this uses special values to denote NULL */
index af4d23b7e79b5811774ca02344463697fd1e4d7b..ad5ab5d1f02e6607121cdc9365f1e4495af47fc0 100644 (file)
@@ -1,4 +1,4 @@
-/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.12 2003/06/25 10:44:21 meskes Exp $ */
+/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.13 2003/06/26 11:37:05 meskes Exp $ */
 
 /*
  * The aim is to get a simpler inteface to the database routines.
@@ -508,7 +508,7 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
                        break;
 #endif   /* HAVE_LONG_LONG_INT_64 */
                case ECPGt_NO_INDICATOR:
-                       if (stmt->force_indicator == false && stmt->compat == ECPG_COMPAT_INFORMIX)
+                       if (stmt->force_indicator == false)
                        {
                                if (ECPGis_informix_null(var->type, var->value))
                                        *tobeinserted_p = "null";
@@ -1186,7 +1186,9 @@ ECPGexecute(struct statement * stmt)
                                sqlca->sqlerrd[1] = PQoidValue(results);
                                sqlca->sqlerrd[2] = atol(PQcmdTuples(results));
                                ECPGlog("ECPGexecute line %d Ok: %s\n", stmt->lineno, cmdstat);
-                               if (!sqlca->sqlerrd[2] && (   !strncmp(cmdstat, "UPDATE", 6)
+                               if (stmt->compat != ECPG_COMPAT_INFORMIX_SE &&
+                                               !sqlca->sqlerrd[2] &&
+                                                       ( !strncmp(cmdstat, "UPDATE", 6)
                                                          || !strncmp(cmdstat, "INSERT", 6)
                                                          || !strncmp(cmdstat, "DELETE", 6)))
                                        ECPGraise(stmt->lineno, ECPG_NOT_FOUND, NULL);
index a7f37491da862dd4a0afe1e4159686298bb7c608..b6b25b8328a926709b0e3bffd765aba3f71f247f 100644 (file)
@@ -5,7 +5,8 @@
 #include "libpq-fe.h"
 #include "sqlca.h"
 
-enum COMPAT_MODE { ECPG_COMPAT_PGSQL = 0, ECPG_COMPAT_INFORMIX};
+enum COMPAT_MODE { ECPG_COMPAT_PGSQL = 0, ECPG_COMPAT_INFORMIX, ECPG_COMPAT_INFORMIX_SE};
+#define INFORMIX_MODE(X) ((X) == ECPG_COMPAT_INFORMIX || (X) == ECPG_COMPAT_INFORMIX_SE)
 
 /* Here are some methods used by the lib. */
 
index a10f386fc8c31687bda594cfc53678481391cfa6..63d7afac7013ac635e76d2f2687e4b314a6bf8ec 100644 (file)
@@ -1,4 +1,4 @@
-/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/prepare.c,v 1.4 2003/06/25 10:44:21 meskes Exp $ */
+/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/prepare.c,v 1.5 2003/06/26 11:37:05 meskes Exp $ */
 
 #define POSTGRES_ECPG_INTERNAL
 #include "postgres_fe.h"
@@ -110,7 +110,7 @@ ECPGdeallocate(int lineno, int c, char *name)
        bool ret = ECPGdeallocate_one(lineno, name);
        enum COMPAT_MODE compat = c;
 
-       if (compat == ECPG_COMPAT_INFORMIX)
+       if (INFORMIX_MODE(compat))
        {
                /* Just ignore all errors since we do not know the list of cursors we
                 * are allowed to free. We have to trust that the software. */
index 0256080a50a9d3ca7512ea20e8559b34325e9136..42f278057ce31a822b9bce026b3101a266f086cb 100644 (file)
@@ -1,4 +1,4 @@
-/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.74 2003/06/25 10:44:21 meskes Exp $ */
+/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.75 2003/06/26 11:37:05 meskes Exp $ */
 
 /* New main for ecpg, the PostgreSQL embedded SQL precompiler. */
 /* (C) Michael Meskes <meskes@postgresql.org> Feb 5th, 1998 */
@@ -45,7 +45,9 @@ help(const char *progname)
        printf("  -d             generate parser debug output\n");
 #endif
        printf("  -C <mode>      set compatibility mode\n"
-                  "                 mode may be \"INFORMIX\" only at the moment\n");
+                  "                 mode may be one of\n"
+                  "                 \"INFORMIX\"\n"
+                  "                 \"INFORMIX_SE\"\n");
        printf("  -r <option>    specify runtime behaviour\n"
                   "                 option may be only \"no_indicator\" at the moment\n");     
        printf("  -D SYMBOL      define SYMBOL\n");
@@ -165,9 +167,9 @@ main(int argc, char *const argv[])
                                system_includes = true;
                                break;
                        case 'C':
-                               if (strcmp(optarg, "INFORMIX") == 0)
+                               if (strncmp(optarg, "INFORMIX", strlen("INFORMIX")) == 0)
                                {
-                                       compat = ECPG_COMPAT_INFORMIX;
+                                       compat = (strcmp(optarg, "INFORMIX") == 0) ? ECPG_COMPAT_INFORMIX : ECPG_COMPAT_INFORMIX_SE;
                                        /* system_includes = true; */
                                        add_preprocessor_define("dec_t=Numeric");
                                        add_preprocessor_define("intrvl_t=Interval");
@@ -383,7 +385,7 @@ main(int argc, char *const argv[])
                                fprintf(yyout, "/* Processed by ecpg (%d.%d.%d) */\n/* These four include files are added by the preprocessor */\n#include <ecpgtype.h>\n#include <ecpglib.h>\n#include <ecpgerrno.h>\n#include <sqlca.h>\n#line 1 \"%s\"\n", MAJOR_VERSION, MINOR_VERSION, PATCHLEVEL, input_filename);
 
                                /* add some compatibility headers */
-                               if (compat == ECPG_COMPAT_INFORMIX)
+                               if (INFORMIX_MODE)
                                        fprintf(yyout, "/* Needed for informix compatibility */\n#include <ecpg_informix.h>\n");
 
                                /* and parse the source */
index f38cb244ae91b6bbed4a027f683132ab78444c7a..aa76930e7c7eb0e799fd4881aadafbbb9e40c6d6 100644 (file)
@@ -96,7 +96,8 @@ extern ScanKeyword *ScanKeywordLookup(char *text);
 #define INDICATOR_NOT_STRUCT   6
 #define INDICATOR_NOT_SIMPLE   7
 
-enum COMPAT_MODE { ECPG_COMPAT_PGSQL = 0, ECPG_COMPAT_INFORMIX};
+enum COMPAT_MODE { ECPG_COMPAT_PGSQL = 0, ECPG_COMPAT_INFORMIX, ECPG_COMPAT_INFORMIX_SE};
 extern enum COMPAT_MODE compat;
+#define INFORMIX_MODE  (compat == ECPG_COMPAT_INFORMIX || compat == ECPG_COMPAT_INFORMIX_SE)
 
 #endif /* _ECPG_PREPROC_EXTERN_H */
index f4a1f6cbfd02940772407cb264fd0b82ea683b45..57d201b798ba52f6698c4fdeec735f9f6ef7eaf7 100644 (file)
@@ -12,7 +12,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.117 2003/06/20 15:16:06 meskes Exp $
+ *       $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.118 2003/06/26 11:37:05 meskes Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -420,7 +420,7 @@ cppline                     {space}*#(.*\\{space})+.*
 <SQL>{typecast}                { return TYPECAST; }
 <SQL>{informix_special}        {
                          /* are we simulating Informix? */
-                          if (compat == ECPG_COMPAT_INFORMIX)
+                          if (INFORMIX_MODE)
                          {
                                unput(':');
                          }
@@ -605,7 +605,7 @@ cppline                     {space}*#(.*\\{space})+.*
 <C>{exec_sql}          { BEGIN SQL; return SQL_START; }
 <C>{informix_special}  { 
                          /* are we simulating Informix? */
-                         if (compat == ECPG_COMPAT_INFORMIX)
+                         if (INFORMIX_MODE)
                          {
                                BEGIN SQL;
                                return SQL_START;
@@ -715,7 +715,7 @@ cppline                     {space}*#(.*\\{space})+.*
 <C>{exec_sql}{define}{space}*  { BEGIN(def_ident); }
 <C>{informix_special}{define}{space}*  {
                                                /* are we simulating Informix? */
-                                               if (compat == ECPG_COMPAT_INFORMIX)
+                                               if (INFORMIX_MODE)
                                                {
                                                        BEGIN(def_ident);
                                                }
@@ -730,7 +730,7 @@ cppline                     {space}*#(.*\\{space})+.*
 <C>{exec_sql}{include}{space}* { BEGIN(incl); }
 <C>{informix_special}{include}{space}* { 
                                          /* are we simulating Informix? */
-                                         if (compat == ECPG_COMPAT_INFORMIX)
+                                         if (INFORMIX_MODE)
                                          {
                                                BEGIN(incl);
                                          }
@@ -745,7 +745,7 @@ cppline                     {space}*#(.*\\{space})+.*
 <C,xskip>{exec_sql}{ifdef}{space}*     { ifcond = TRUE; BEGIN(xcond); }
 <C,xskip>{informix_special}{ifdef}{space}* { 
                                          /* are we simulating Informix? */
-                                         if (compat == ECPG_COMPAT_INFORMIX)
+                                         if (INFORMIX_MODE)
                                          {
                                                ifcond = TRUE;
                                                BEGIN(xcond);
@@ -761,7 +761,7 @@ cppline                     {space}*#(.*\\{space})+.*
 <C,xskip>{exec_sql}{ifndef}{space}* { ifcond = FALSE; BEGIN(xcond); }
 <C,xskip>{informix_special}{ifndef}{space}* { 
                                          /* are we simulating Informix? */
-                                         if (compat == ECPG_COMPAT_INFORMIX)
+                                         if (INFORMIX_MODE)
                                          {
                                                ifcond = FALSE;
                                                BEGIN(xcond);
@@ -787,7 +787,7 @@ cppline                     {space}*#(.*\\{space})+.*
                                        }
 <C,xskip>{informix_special}{elif}{space}* { 
                                          /* are we simulating Informix? */
-                                         if (compat == ECPG_COMPAT_INFORMIX)
+                                         if (INFORMIX_MODE)
                                          {
                                                if ( preproc_tos == 0 ) {
                                                        mmerror(PARSE_ERROR, ET_FATAL, "Missing matching 'EXEC SQL IFDEF / EXEC SQL IFNDEF'");
@@ -826,7 +826,7 @@ cppline                     {space}*#(.*\\{space})+.*
                                        }
 <C,xskip>{informix_special}{else}{space}*      {
                                          /* are we simulating Informix? */
-                                         if (compat == ECPG_COMPAT_INFORMIX)
+                                         if (INFORMIX_MODE)
                                          {
                                                if ( stacked_if_value[preproc_tos].else_branch ) {
                                                        mmerror(PARSE_ERROR, ET_FATAL, "Duplicated 'EXEC SQL ELSE;'");
@@ -864,7 +864,7 @@ cppline                     {space}*#(.*\\{space})+.*
                                        }
 <C,xskip>{informix_special}{endif}{space}*";"  {
                                          /* are we simulating Informix? */
-                                         if (compat == ECPG_COMPAT_INFORMIX)
+                                         if (INFORMIX_MODE)
                                          {
                                                if ( preproc_tos == 0 )
                                                        mmerror(PARSE_ERROR, ET_FATAL, "Unmatched 'EXEC SQL ENDIF;'");
index ffa849045a83d1ed94a8f4341be9782b30c3f954..2d799705edc92eba5af01bc3f1253ca99f2af121 100644 (file)
@@ -1,4 +1,4 @@
-/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Attic/preproc.y,v 1.239 2003/06/25 21:30:33 momjian Exp $ */
+/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Attic/preproc.y,v 1.240 2003/06/26 11:37:05 meskes Exp $ */
 
 /* Copyright comment */
 %{
@@ -2674,7 +2674,7 @@ DeclareCursorStmt:  DECLARE name cursor_options CURSOR opt_hold FOR SelectStmt
                        argsinsert = argsresult = NULL;
                        cur = this;
 
-                       if (compat == ECPG_COMPAT_INFORMIX)
+                       if (INFORMIX_MODE)
                                $$ = cat_str(5, adjust_informix(this->argsinsert), adjust_informix(this->argsresult), make_str("/*"), mm_strdup(this->command), make_str("*/"));
                        else
                                $$ = cat_str(3, make_str("/*"), mm_strdup(this->command), make_str("*/"));
@@ -3476,8 +3476,6 @@ a_expr:  c_expr
                        { $$ = cat_str(3, $1, make_str("not in"), $4); }
                | a_expr qual_all_Op sub_type select_with_parens %prec Op
                        { $$ = cat_str(4, $1, $2, $3, $4); }
-               | a_expr qual_all_Op sub_type '(' a_expr ')' %prec Op
-                       { $$ = cat_str(6, $1, $2, $3, make_str("("), $5, make_str(")")); }
                | UNIQUE select_with_parens %prec Op
                        { $$ = cat2_str(make_str("unique"), $2); }
                | r_expr
index fd0512c7cde3799a85d4e3bfd5303f5739bf287a..fdc9a97954fd6f47d394e4c2c9fc5560459854f9 100644 (file)
@@ -34,8 +34,13 @@ int main()
                else
                        printf("%d %d\n", i, j);
        }
-       
+
+       $delete from test where i=87;
+       printf("delete: %ld\n", sqlca.sqlcode);
+
+       $commit;
        $drop table test;
+       $commit;
 
        $disconnect;