Thread: ECPG patchset

ECPG patchset

From
Boszormenyi Zoltan
Date:
Hi,

we have updated our patchset to current 8.5 CVS.
The actual patches will be in emails coming as
answers to this one. As two patches were already included,
the remaining patches are as follows:

1. dynamic cursorname
2. sqlda support
3. describe support
4. proper out-of-scope declare/open/fetch for cursors in compat mode

Changes (the numbers indicate the patch it was made in):

1. ECPG auto-generated grammar couldn't deal with  grammar objects having both an "addon" and a "rule"  extension,
emittingan extra '{' between the "addon"  and the original rule code blocks. Fix was needed for parse.pl  and now the
grammarlooks nicer, my previous question was  solved by it.
 

2. No more ecpg_compare_sqlda_with_PGresult() function, it triggered  most of the time anyway, it's cheaper to
unconditionallyfree() and
 
malloc().  No more realloc(), it ruined the internal pointers inside the sqlda
structure.  A small leak fix for FETCH when a decimal or numeric was used:

> diff -durpN pgsql.dyncursor/src/interfaces/ecpg/ecpglib/data.c
> pgsql.sqlda/src/interfaces/ecpg/ecpglib/data.c
> --- pgsql.dyncursor/src/interfaces/ecpg/ecpglib/data.c  2009-08-08
> 17:19:45.000000000 +0200
> +++ pgsql.sqlda/src/interfaces/ecpg/ecpglib/data.c      2009-09-03
> 12:56:36.000000000 +0200
> @@ -554,7 +554,7 @@ ecpg_get_data(const PGresult *results, i
>                                         else
>                                                
> PGTYPESnumeric_to_decimal(nres, (decimal *) (var + offset * act_tuple));
>  
> -                                       free(nres);
> +                                       PGTYPESnumeric_free(nres);
>                                         break;
>  
>                                 case ECPGt_interval:
  Now sqlda usage is valgrind-clean.  We added the possibility to extend SQLDA for multi-row FETCH,  using the
->desc_nextpointer, but not implemented. Multi-row  FETCH is not available in Informix.
 

3. Only updated to current CVS.

4. Fixed uninitialized pointers that were discovered by valgrind and  were causing problems on HP-UX. (Small malloc()s
seemto be  zeroed out by Fedora 9's glibc, but not on HP-UX.)
 

Best regards,
Zoltán Böszörményi

-- 
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
http://www.postgresql.at/



Re: ECPG patchset

From
Boszormenyi Zoltan
Date:
Dynamic cursorname

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
http://www.postgresql.at/

diff -dcrpN pgsql.orig/src/backend/parser/gram.y pgsql.dyncursor/src/backend/parser/gram.y
*** pgsql.orig/src/backend/parser/gram.y    2009-08-19 11:31:07.000000000 +0200
--- pgsql.dyncursor/src/backend/parser/gram.y    2009-09-03 12:29:27.000000000 +0200
*************** static TypeName *TableFuncTypeName(List
*** 253,259 ****

  %type <str>        relation_name copy_file_name
                  database_name access_method_clause access_method attr_name
!                 index_name name file_name cluster_index_specification

  %type <list>    func_name handler_name qual_Op qual_all_Op subquery_Op
                  opt_class opt_validator validator_clause
--- 253,259 ----

  %type <str>        relation_name copy_file_name
                  database_name access_method_clause access_method attr_name
!                 index_name name cursor_name file_name cluster_index_specification

  %type <list>    func_name handler_name qual_Op qual_all_Op subquery_Op
                  opt_class opt_validator validator_clause
*************** static TypeName *TableFuncTypeName(List
*** 331,337 ****
  %type <ival>    opt_column event cursor_options opt_hold opt_set_data
  %type <objtype>    reindex_type drop_type comment_type

! %type <node>    fetch_direction limit_clause select_limit_value
                  offset_clause select_offset_value
                  select_offset_value2 opt_select_fetch_first_value
  %type <ival>    row_or_rows first_or_next
--- 331,337 ----
  %type <ival>    opt_column event cursor_options opt_hold opt_set_data
  %type <objtype>    reindex_type drop_type comment_type

! %type <node>    fetch_args limit_clause select_limit_value
                  offset_clause select_offset_value
                  select_offset_value2 opt_select_fetch_first_value
  %type <ival>    row_or_rows first_or_next
*************** reloption_elem:
*** 1916,1922 ****
   *****************************************************************************/

  ClosePortalStmt:
!             CLOSE name
                  {
                      ClosePortalStmt *n = makeNode(ClosePortalStmt);
                      n->portalname = $2;
--- 1916,1922 ----
   *****************************************************************************/

  ClosePortalStmt:
!             CLOSE cursor_name
                  {
                      ClosePortalStmt *n = makeNode(ClosePortalStmt);
                      n->portalname = $2;
*************** comment_text:
*** 4083,4224 ****
   *
   *****************************************************************************/

! FetchStmt:    FETCH fetch_direction from_in name
                  {
                      FetchStmt *n = (FetchStmt *) $2;
-                     n->portalname = $4;
-                     n->ismove = FALSE;
-                     $$ = (Node *)n;
-                 }
-             | FETCH name
-                 {
-                     FetchStmt *n = makeNode(FetchStmt);
-                     n->direction = FETCH_FORWARD;
-                     n->howMany = 1;
-                     n->portalname = $2;
                      n->ismove = FALSE;
                      $$ = (Node *)n;
                  }
!             | MOVE fetch_direction from_in name
                  {
                      FetchStmt *n = (FetchStmt *) $2;
-                     n->portalname = $4;
                      n->ismove = TRUE;
                      $$ = (Node *)n;
                  }
!             | MOVE name
                  {
                      FetchStmt *n = makeNode(FetchStmt);
                      n->direction = FETCH_FORWARD;
                      n->howMany = 1;
-                     n->portalname = $2;
-                     n->ismove = TRUE;
                      $$ = (Node *)n;
                  }
!         ;
!
! fetch_direction:
!             /*EMPTY*/
                  {
                      FetchStmt *n = makeNode(FetchStmt);
                      n->direction = FETCH_FORWARD;
                      n->howMany = 1;
                      $$ = (Node *)n;
                  }
!             | NEXT
                  {
                      FetchStmt *n = makeNode(FetchStmt);
                      n->direction = FETCH_FORWARD;
                      n->howMany = 1;
                      $$ = (Node *)n;
                  }
!             | PRIOR
                  {
                      FetchStmt *n = makeNode(FetchStmt);
                      n->direction = FETCH_BACKWARD;
                      n->howMany = 1;
                      $$ = (Node *)n;
                  }
!             | FIRST_P
                  {
                      FetchStmt *n = makeNode(FetchStmt);
                      n->direction = FETCH_ABSOLUTE;
                      n->howMany = 1;
                      $$ = (Node *)n;
                  }
!             | LAST_P
                  {
                      FetchStmt *n = makeNode(FetchStmt);
                      n->direction = FETCH_ABSOLUTE;
                      n->howMany = -1;
                      $$ = (Node *)n;
                  }
!             | ABSOLUTE_P SignedIconst
                  {
                      FetchStmt *n = makeNode(FetchStmt);
                      n->direction = FETCH_ABSOLUTE;
                      n->howMany = $2;
                      $$ = (Node *)n;
                  }
!             | RELATIVE_P SignedIconst
                  {
                      FetchStmt *n = makeNode(FetchStmt);
                      n->direction = FETCH_RELATIVE;
                      n->howMany = $2;
                      $$ = (Node *)n;
                  }
!             | SignedIconst
                  {
                      FetchStmt *n = makeNode(FetchStmt);
                      n->direction = FETCH_FORWARD;
                      n->howMany = $1;
                      $$ = (Node *)n;
                  }
!             | ALL
                  {
                      FetchStmt *n = makeNode(FetchStmt);
                      n->direction = FETCH_FORWARD;
                      n->howMany = FETCH_ALL;
                      $$ = (Node *)n;
                  }
!             | FORWARD
                  {
                      FetchStmt *n = makeNode(FetchStmt);
                      n->direction = FETCH_FORWARD;
                      n->howMany = 1;
                      $$ = (Node *)n;
                  }
!             | FORWARD SignedIconst
                  {
                      FetchStmt *n = makeNode(FetchStmt);
                      n->direction = FETCH_FORWARD;
                      n->howMany = $2;
                      $$ = (Node *)n;
                  }
!             | FORWARD ALL
                  {
                      FetchStmt *n = makeNode(FetchStmt);
                      n->direction = FETCH_FORWARD;
                      n->howMany = FETCH_ALL;
                      $$ = (Node *)n;
                  }
!             | BACKWARD
                  {
                      FetchStmt *n = makeNode(FetchStmt);
                      n->direction = FETCH_BACKWARD;
                      n->howMany = 1;
                      $$ = (Node *)n;
                  }
!             | BACKWARD SignedIconst
                  {
                      FetchStmt *n = makeNode(FetchStmt);
                      n->direction = FETCH_BACKWARD;
                      n->howMany = $2;
                      $$ = (Node *)n;
                  }
!             | BACKWARD ALL
                  {
                      FetchStmt *n = makeNode(FetchStmt);
                      n->direction = FETCH_BACKWARD;
                      n->howMany = FETCH_ALL;
                      $$ = (Node *)n;
--- 4083,4227 ----
   *
   *****************************************************************************/

! FetchStmt:    FETCH fetch_args
                  {
                      FetchStmt *n = (FetchStmt *) $2;
                      n->ismove = FALSE;
                      $$ = (Node *)n;
                  }
!             | MOVE fetch_args
                  {
                      FetchStmt *n = (FetchStmt *) $2;
                      n->ismove = TRUE;
                      $$ = (Node *)n;
                  }
!         ;
!
! fetch_args:
!             cursor_name
                  {
                      FetchStmt *n = makeNode(FetchStmt);
+                     n->portalname = $1;
                      n->direction = FETCH_FORWARD;
                      n->howMany = 1;
                      $$ = (Node *)n;
                  }
!             | from_in cursor_name
                  {
                      FetchStmt *n = makeNode(FetchStmt);
+                     n->portalname = $2;
                      n->direction = FETCH_FORWARD;
                      n->howMany = 1;
                      $$ = (Node *)n;
                  }
!             | NEXT opt_from_in cursor_name
                  {
                      FetchStmt *n = makeNode(FetchStmt);
+                     n->portalname = $3;
                      n->direction = FETCH_FORWARD;
                      n->howMany = 1;
                      $$ = (Node *)n;
                  }
!             | PRIOR opt_from_in cursor_name
                  {
                      FetchStmt *n = makeNode(FetchStmt);
+                     n->portalname = $3;
                      n->direction = FETCH_BACKWARD;
                      n->howMany = 1;
                      $$ = (Node *)n;
                  }
!             | FIRST_P opt_from_in cursor_name
                  {
                      FetchStmt *n = makeNode(FetchStmt);
+                     n->portalname = $3;
                      n->direction = FETCH_ABSOLUTE;
                      n->howMany = 1;
                      $$ = (Node *)n;
                  }
!             | LAST_P opt_from_in cursor_name
                  {
                      FetchStmt *n = makeNode(FetchStmt);
+                     n->portalname = $3;
                      n->direction = FETCH_ABSOLUTE;
                      n->howMany = -1;
                      $$ = (Node *)n;
                  }
!             | ABSOLUTE_P SignedIconst opt_from_in cursor_name
                  {
                      FetchStmt *n = makeNode(FetchStmt);
+                     n->portalname = $4;
                      n->direction = FETCH_ABSOLUTE;
                      n->howMany = $2;
                      $$ = (Node *)n;
                  }
!             | RELATIVE_P SignedIconst opt_from_in cursor_name
                  {
                      FetchStmt *n = makeNode(FetchStmt);
+                     n->portalname = $4;
                      n->direction = FETCH_RELATIVE;
                      n->howMany = $2;
                      $$ = (Node *)n;
                  }
!             | SignedIconst opt_from_in cursor_name
                  {
                      FetchStmt *n = makeNode(FetchStmt);
+                     n->portalname = $3;
                      n->direction = FETCH_FORWARD;
                      n->howMany = $1;
                      $$ = (Node *)n;
                  }
!             | ALL opt_from_in cursor_name
                  {
                      FetchStmt *n = makeNode(FetchStmt);
+                     n->portalname = $3;
                      n->direction = FETCH_FORWARD;
                      n->howMany = FETCH_ALL;
                      $$ = (Node *)n;
                  }
!             | FORWARD opt_from_in cursor_name
                  {
                      FetchStmt *n = makeNode(FetchStmt);
+                     n->portalname = $3;
                      n->direction = FETCH_FORWARD;
                      n->howMany = 1;
                      $$ = (Node *)n;
                  }
!             | FORWARD SignedIconst opt_from_in cursor_name
                  {
                      FetchStmt *n = makeNode(FetchStmt);
+                     n->portalname = $4;
                      n->direction = FETCH_FORWARD;
                      n->howMany = $2;
                      $$ = (Node *)n;
                  }
!             | FORWARD ALL opt_from_in cursor_name
                  {
                      FetchStmt *n = makeNode(FetchStmt);
+                     n->portalname = $4;
                      n->direction = FETCH_FORWARD;
                      n->howMany = FETCH_ALL;
                      $$ = (Node *)n;
                  }
!             | BACKWARD opt_from_in cursor_name
                  {
                      FetchStmt *n = makeNode(FetchStmt);
+                     n->portalname = $3;
                      n->direction = FETCH_BACKWARD;
                      n->howMany = 1;
                      $$ = (Node *)n;
                  }
!             | BACKWARD SignedIconst opt_from_in cursor_name
                  {
                      FetchStmt *n = makeNode(FetchStmt);
+                     n->portalname = $4;
                      n->direction = FETCH_BACKWARD;
                      n->howMany = $2;
                      $$ = (Node *)n;
                  }
!             | BACKWARD ALL opt_from_in cursor_name
                  {
                      FetchStmt *n = makeNode(FetchStmt);
+                     n->portalname = $4;
                      n->direction = FETCH_BACKWARD;
                      n->howMany = FETCH_ALL;
                      $$ = (Node *)n;
*************** from_in:    FROM                                    {}
*** 4229,4234 ****
--- 4232,4242 ----
              | IN_P                                    {}
          ;

+ opt_from_in:    FROM                                    {}
+             | IN_P                                    {}
+             | /* EMPTY */                                {}
+         ;
+

  /*****************************************************************************
   *
*************** set_target_list:
*** 6848,6854 ****
   *                CURSOR STATEMENTS
   *
   *****************************************************************************/
! DeclareCursorStmt: DECLARE name cursor_options CURSOR opt_hold FOR SelectStmt
                  {
                      DeclareCursorStmt *n = makeNode(DeclareCursorStmt);
                      n->portalname = $2;
--- 6856,6862 ----
   *                CURSOR STATEMENTS
   *
   *****************************************************************************/
! DeclareCursorStmt: DECLARE cursor_name cursor_options CURSOR opt_hold FOR SelectStmt
                  {
                      DeclareCursorStmt *n = makeNode(DeclareCursorStmt);
                      n->portalname = $2;
*************** DeclareCursorStmt: DECLARE name cursor_o
*** 6859,6864 ****
--- 6867,6875 ----
                  }
          ;

+ cursor_name:    name                        { $$ = $1; }
+         ;
+
  cursor_options: /*EMPTY*/                    { $$ = 0; }
              | cursor_options NO SCROLL        { $$ = $1 | CURSOR_OPT_NO_SCROLL; }
              | cursor_options SCROLL            { $$ = $1 | CURSOR_OPT_SCROLL; }
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/ecpg.addons pgsql.dyncursor/src/interfaces/ecpg/preproc/ecpg.addons
*** pgsql.orig/src/interfaces/ecpg/preproc/ecpg.addons    2009-08-14 16:27:41.000000000 +0200
--- pgsql.dyncursor/src/interfaces/ecpg/preproc/ecpg.addons    2009-09-03 12:31:30.000000000 +0200
*************** ECPG: ConstraintAttributeSpecConstraintT
*** 206,226 ****
              if (strcmp($2, "deferrable") != 0 && strcmp($1, "initially deferrable") == 0 )
                  mmerror(PARSE_ERROR, ET_ERROR, "constraint declared INITIALLY DEFERRED must be DEFERRABLE");
  ECPG: var_valueNumericOnly addon
- ECPG: fetch_directionSignedIconst addon
          if ($1[0] == '$')
          {
              free($1);
              $1 = make_str("$0");
          }
! ECPG: fetch_directionABSOLUTE_PSignedIconst addon
! ECPG: fetch_directionRELATIVE_PSignedIconst addon
! ECPG: fetch_directionFORWARDSignedIconst addon
! ECPG: fetch_directionBACKWARDSignedIconst addon
          if ($2[0] == '$')
          {
              free($2);
              $2 = make_str("$0");
          }
  ECPG: PrepareStmtPREPAREprepared_nameprep_type_clauseASPreparableStmt block
      {
          $$.name = $2;
--- 206,290 ----
              if (strcmp($2, "deferrable") != 0 && strcmp($1, "initially deferrable") == 0 )
                  mmerror(PARSE_ERROR, ET_ERROR, "constraint declared INITIALLY DEFERRED must be DEFERRABLE");
  ECPG: var_valueNumericOnly addon
          if ($1[0] == '$')
          {
              free($1);
              $1 = make_str("$0");
          }
! ECPG: FetchStmtFETCHfetch_args addon
! ECPG: FetchStmtMOVEfetch_args addon
!         add_additional_variables(current_cursor, false);
!         free(current_cursor);
!         current_cursor = NULL;
! ECPG: fetch_argscursor_name addon
!         current_cursor = mm_strdup($1);
!         if ($1[0] == ':')
!         {
!             free($1);
!             $1 = make_str("$0");
!         }
! ECPG: fetch_argsfrom_incursor_name addon
!         current_cursor = mm_strdup($2);
!         if ($2[0] == ':')
!         {
!             free($2);
!             $2 = make_str("$0");
!         }
! ECPG: fetch_argsNEXTopt_from_incursor_name addon
! ECPG: fetch_argsPRIORopt_from_incursor_name addon
! ECPG: fetch_argsFIRST_Popt_from_incursor_name addon
! ECPG: fetch_argsLAST_Popt_from_incursor_name addon
! ECPG: fetch_argsALLopt_from_incursor_name addon
!         current_cursor = mm_strdup($3);
!         if ($3[0] == ':')
!         {
!             free($3);
!             $3 = make_str("$0");
!         }
! ECPG: fetch_argsSignedIconstopt_from_incursor_name addon
!         if ($1[0] == '$')
!         {
!             free($1);
!             $1 = make_str("$0");
!         }
!         current_cursor = mm_strdup($3);
!         if ($3[0] == ':')
!         {
!             free($3);
!             $3 = make_str("$0");
!         }
! ECPG: fetch_argsFORWARDALLopt_from_incursor_name addon
! ECPG: fetch_argsBACKWARDALLopt_from_incursor_name addon
!         current_cursor = mm_strdup($4);
!         if ($4[0] == ':')
!         {
!             free($4);
!             $4 = make_str("$0");
!         }
! ECPG: fetch_argsABSOLUTE_PSignedIconstopt_from_incursor_name addon
! ECPG: fetch_argsRELATIVE_PSignedIconstopt_from_incursor_name addon
! ECPG: fetch_argsFORWARDSignedIconstopt_from_incursor_name addon
! ECPG: fetch_argsBACKWARDSignedIconstopt_from_incursor_name addon
          if ($2[0] == '$')
          {
              free($2);
              $2 = make_str("$0");
          }
+         current_cursor = mm_strdup($4);
+         if ($4[0] == ':')
+         {
+             free($4);
+             $4 = make_str("$0");
+         }
+ ECPG: cursor_namename rule
+     | char_civar
+         {
+             char *curname = mm_alloc(strlen($1) + 2);
+             sprintf(curname, ":%s", $1);
+             free($1);
+             $1 = curname;
+             $$ = $1;
+         }
  ECPG: PrepareStmtPREPAREprepared_nameprep_type_clauseASPreparableStmt block
      {
          $$.name = $2;
*************** ECPG: PrepareStmtPREPAREprepared_namepre
*** 235,243 ****
      }
  ECPG: ExecuteStmtEXECUTEprepared_nameexecute_param_clauseexecute_rest block
      { $$ = $2; }
! ECPG: DeclareCursorStmtDECLAREnamecursor_optionsCURSORopt_holdFORSelectStmt block
      {
          struct cursor *ptr, *this;
          char *comment;

          for (ptr = cur; ptr != NULL; ptr = ptr->next)
--- 299,308 ----
      }
  ECPG: ExecuteStmtEXECUTEprepared_nameexecute_param_clauseexecute_rest block
      { $$ = $2; }
! ECPG: DeclareCursorStmtDECLAREcursor_namecursor_optionsCURSORopt_holdFORSelectStmt block
      {
          struct cursor *ptr, *this;
+         char *cursor_marker = $2[0] == ':' ? make_str("$0") : mm_strdup($2);
          char *comment;

          for (ptr = cur; ptr != NULL; ptr = ptr->next)
*************** ECPG: DeclareCursorStmtDECLAREnamecursor
*** 252,258 ****
          this->name = $2;
          this->connection = connection;
          this->opened = false;
!         this->command =  cat_str(7, make_str("declare"), mm_strdup($2), $3, make_str("cursor"), $5, make_str("for"),
$7);
          this->argsinsert = argsinsert;
          this->argsresult = argsresult;
          argsinsert = argsresult = NULL;
--- 317,323 ----
          this->name = $2;
          this->connection = connection;
          this->opened = false;
!         this->command =  cat_str(7, make_str("declare"), cursor_marker, $3, make_str("cursor"), $5, make_str("for"),
$7);
          this->argsinsert = argsinsert;
          this->argsresult = argsresult;
          argsinsert = argsresult = NULL;
*************** ECPG: DeclareCursorStmtDECLAREnamecursor
*** 272,277 ****
--- 337,347 ----
          else
              $$ = comment;
      }
+ ECPG: ClosePortalStmtCLOSEcursor_name block
+     {
+         char *cursor_marker = $2[0] == ':' ? make_str("$0") : $2;
+         $$ = cat2_str(make_str("close"), cursor_marker);
+     }
  ECPG: opt_hold block
      {
          if (compat == ECPG_COMPAT_INFORMIX_SE && autocommit == true)
*************** ECPG: VariableShowStmtSHOWALL block
*** 336,382 ****
          mmerror(PARSE_ERROR, ET_ERROR, "SHOW ALL is not implemented");
          $$ = EMPTY;
      }
! ECPG: FetchStmtFETCHfetch_directionfrom_inname block
      {
          add_additional_variables($4, false);
!         $$ = cat_str(4, make_str("fetch"), $2, $3, $4);
      }
! ECPG: FetchStmtFETCHname block
      {
!         add_additional_variables($2, false);
!         $$ = cat_str(2, make_str("fetch"), $2);
      }
- ECPG: FetchStmtMOVEname rule
-     | FETCH fetch_direction from_in name ecpg_into
-         {
-             add_additional_variables($4, false);
-             $$ = cat_str(4, make_str("fetch"), $2, $3, $4);
-         }
-     | FETCH fetch_direction name ecpg_into
-         {
-             add_additional_variables($3, false);
-             $$ = cat_str(4, make_str("fetch"), $2, make_str("from"), $3);
-         }
-     | FETCH from_in name ecpg_into
-         {
-             add_additional_variables($3, false);
-             $$ = cat_str(3, make_str("fetch"), $2, $3);
-         }
-     | FETCH name ecpg_into
-         {
-             add_additional_variables($2, false);
-             $$ = cat2_str(make_str("fetch"), $2);
-         }
-     | FETCH fetch_direction name
-         {
-             add_additional_variables($3, false);
-             $$ = cat_str(4, make_str("fetch"), $2, make_str("from"), $3);
-         }
-     | FETCH from_in name
-         {
-             add_additional_variables($3, false);
-             $$ = cat_str(3, make_str("fetch"), $2, $3);
-         }
  ECPG: SpecialRuleRelationOLD addon
          if (!QueryIsRule)
              mmerror(PARSE_ERROR, ET_ERROR, "OLD used in query that is not in a rule");
--- 406,443 ----
          mmerror(PARSE_ERROR, ET_ERROR, "SHOW ALL is not implemented");
          $$ = EMPTY;
      }
! ECPG: FetchStmtMOVEfetch_args rule
!     | FETCH fetch_args ecpg_into
      {
+         add_additional_variables(current_cursor, false);
+         free(current_cursor);
+         current_cursor = NULL;
+         $$ = cat2_str(make_str("fetch"), $2);
+     }
+     | FETCH FORWARD cursor_name opt_ecpg_into
+     {
+         char *cursor_marker = $3[0] == ':' ? make_str("$0") : $3;
+         add_additional_variables($3, false);
+         $$ = cat_str(2, make_str("fetch forward"), cursor_marker);
+     }
+     | FETCH FORWARD from_in cursor_name opt_ecpg_into
+     {
+         char *cursor_marker = $4[0] == ':' ? make_str("$0") : $4;
          add_additional_variables($4, false);
!         $$ = cat_str(2, make_str("fetch forward from"), cursor_marker);
      }
!     | MOVE FORWARD cursor_name
      {
!         char *cursor_marker = $3[0] == ':' ? make_str("$0") : $3;
!         add_additional_variables($3, false);
!         $$ = cat_str(2, make_str("move forward"), cursor_marker);
!     }
!     | MOVE FORWARD from_in cursor_name
!     {
!         char *cursor_marker = $4[0] == ':' ? make_str("$0") : $4;
!         add_additional_variables($4, false);
!         $$ = cat_str(2, make_str("move forward from"), cursor_marker);
      }
  ECPG: SpecialRuleRelationOLD addon
          if (!QueryIsRule)
              mmerror(PARSE_ERROR, ET_ERROR, "OLD used in query that is not in a rule");
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/ecpg.c pgsql.dyncursor/src/interfaces/ecpg/preproc/ecpg.c
*** pgsql.orig/src/interfaces/ecpg/preproc/ecpg.c    2009-08-07 13:06:28.000000000 +0200
--- pgsql.dyncursor/src/interfaces/ecpg/preproc/ecpg.c    2009-09-03 12:28:03.000000000 +0200
*************** enum COMPAT_MODE compat = ECPG_COMPAT_PG
*** 26,31 ****
--- 26,32 ----

  struct _include_path *include_paths = NULL;
  struct cursor *cur = NULL;
+ char *current_cursor = NULL;
  struct typedefs *types = NULL;
  struct _defines *defines = NULL;

diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/ecpg.trailer
pgsql.dyncursor/src/interfaces/ecpg/preproc/ecpg.trailer
*** pgsql.orig/src/interfaces/ecpg/preproc/ecpg.trailer    2009-08-14 16:27:41.000000000 +0200
--- pgsql.dyncursor/src/interfaces/ecpg/preproc/ecpg.trailer    2009-09-03 12:28:03.000000000 +0200
*************** char_variable: cvariable
*** 228,233 ****
--- 228,265 ----
          }
          ;

+ cursor_char_variable: cvariable
+         {
+             /* check if we have a string variable */
+             struct variable *p = find_variable($1);
+             enum ECPGttype type = p->type->type;
+
+             /* If we have just one character this is not a string */
+             if (atol(p->type->size) == 1)
+                     mmerror(PARSE_ERROR, ET_ERROR, "invalid data type");
+             else
+             {
+                 /* if array see what's inside */
+                 if (type == ECPGt_array)
+                     type = p->type->u.element->type;
+
+                 switch (type)
+                 {
+                     case ECPGt_char:
+                     case ECPGt_unsigned_char:
+                     case ECPGt_string:
+                     case ECPGt_varchar:
+                         $$ = $1;
+                         break;
+                     default:
+                         mmerror(PARSE_ERROR, ET_ERROR, "invalid data type");
+                         $$ = $1;
+                         break;
+                 }
+             }
+         }
+         ;
+
  opt_options: Op connect_options
          {
              if (strlen($1) == 0)
*************** prepared_name: name             {
*** 285,293 ****
   * Declare a prepared cursor. The syntax is different from the standard
   * declare statement, so we create a new rule.
   */
! ECPGCursorStmt:  DECLARE name cursor_options CURSOR opt_hold FOR prepared_name
          {
              struct cursor *ptr, *this;
              struct variable *thisquery = (struct variable *)mm_alloc(sizeof(struct variable));
              const char *con = connection ? connection : "NULL";

--- 317,326 ----
   * Declare a prepared cursor. The syntax is different from the standard
   * declare statement, so we create a new rule.
   */
! ECPGCursorStmt:  DECLARE cursor_name cursor_options CURSOR opt_hold FOR prepared_name
          {
              struct cursor *ptr, *this;
+             char *cursor_marker = $2[0] == ':' ? make_str("$0") : mm_strdup($2);
              struct variable *thisquery = (struct variable *)mm_alloc(sizeof(struct variable));
              const char *con = connection ? connection : "NULL";

*************** ECPGCursorStmt:  DECLARE name cursor_opt
*** 304,310 ****
              this->next = cur;
              this->name = $2;
              this->connection = connection;
!             this->command =  cat_str(6, make_str("declare"), mm_strdup($2), $3, make_str("cursor"), $5, make_str("for
$1"));
              this->argsresult = NULL;

              thisquery->type = &ecpg_query;
--- 337,343 ----
              this->next = cur;
              this->name = $2;
              this->connection = connection;
!             this->command =  cat_str(6, make_str("declare"), cursor_marker, $3, make_str("cursor"), $5, make_str("for
$1"));
              this->argsresult = NULL;

              thisquery->type = &ecpg_query;
*************** ECPGCursorStmt:  DECLARE name cursor_opt
*** 314,319 ****
--- 347,358 ----
              sprintf(thisquery->name, "ECPGprepared_statement(%s, %s, __LINE__)", con, $7);

              this->argsinsert = NULL;
+             if ($2[0] == ':')
+             {
+                 struct variable *var = find_variable($2 + 1);
+                 remove_variable_from_list(&argsinsert, var);
+                 add_variable_to_head(&(this->argsinsert), var, &no_indicator);
+             }
              add_variable_to_head(&(this->argsinsert), thisquery, &no_indicator);

              cur = this;
*************** ECPGFree:    SQL_FREE name    { $$ = $2; }
*** 957,963 ****
  /*
   * open is an open cursor, at the moment this has to be removed
   */
! ECPGOpen: SQL_OPEN name opt_ecpg_using { $$ = $2; };

  opt_ecpg_using: /*EMPTY*/    { $$ = EMPTY; }
          | ecpg_using        { $$ = $1; }
--- 996,1011 ----
  /*
   * open is an open cursor, at the moment this has to be removed
   */
! ECPGOpen: SQL_OPEN cursor_name opt_ecpg_using
!         {
!             if ($2[0] == ':')
!             {
!                 struct variable *var = find_variable($2 + 1);
!                 remove_variable_from_list(&argsinsert, var);
!             }
!             $$ = $2;
!         }
!         ;

  opt_ecpg_using: /*EMPTY*/    { $$ = EMPTY; }
          | ecpg_using        { $$ = $1; }
*************** civarind: cvariable indicator
*** 1782,1787 ****
--- 1830,1842 ----
          }
          ;

+ char_civar: cursor_char_variable
+         {
+             add_variable_to_head(&argsinsert, find_variable($1), &no_indicator);
+             $$ = $1;
+         }
+         ;
+
  civar: cvariable
          {
              add_variable_to_head(&argsinsert, find_variable($1), &no_indicator);
*************** ecpg_into: INTO into_list    { $$ = EMPTY;
*** 1997,2002 ****
--- 2052,2061 ----
          | into_descriptor    { $$ = $1; }
      ;

+
+ opt_ecpg_into:    /* EMPTY */    { $$ = EMPTY; }
+     | ecpg_into        { $$ = $1; }
+
  %%

  void base_yyerror(const char *error)
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/ecpg.type pgsql.dyncursor/src/interfaces/ecpg/preproc/ecpg.type
*** pgsql.orig/src/interfaces/ecpg/preproc/ecpg.type    2008-11-14 11:03:33.000000000 +0100
--- pgsql.dyncursor/src/interfaces/ecpg/preproc/ecpg.type    2009-09-03 12:28:03.000000000 +0200
***************
*** 43,50 ****
--- 43,52 ----
  %type <str> c_term
  %type <str> c_thing
  %type <str> char_variable
+ %type <str> char_civar
  %type <str> civar
  %type <str> civarind
+ %type <str> cursor_char_variable
  %type <str> ColLabel
  %type <str> connect_options
  %type <str> connection_object
***************
*** 75,80 ****
--- 77,83 ----
  %type <str> opt_bit_field
  %type <str> opt_connection_name
  %type <str> opt_database_name
+ %type <str> opt_ecpg_into
  %type <str> opt_ecpg_using
  %type <str> opt_initializer
  %type <str> opt_options
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/extern.h pgsql.dyncursor/src/interfaces/ecpg/preproc/extern.h
*** pgsql.orig/src/interfaces/ecpg/preproc/extern.h    2009-07-17 07:50:56.000000000 +0200
--- pgsql.dyncursor/src/interfaces/ecpg/preproc/extern.h    2009-09-03 12:28:03.000000000 +0200
*************** extern char *output_filename;
*** 47,52 ****
--- 47,53 ----

  extern struct _include_path *include_paths;
  extern struct cursor *cur;
+ extern char *current_cursor;
  extern struct typedefs *types;
  extern struct _defines *defines;
  extern struct ECPGtype ecpg_no_indicator;
*************** extern struct descriptor *lookup_descrip
*** 91,96 ****
--- 92,98 ----
  extern struct variable *descriptor_variable(const char *name, int input);
  extern void add_variable_to_head(struct arguments **, struct variable *, struct variable *);
  extern void add_variable_to_tail(struct arguments **, struct variable *, struct variable *);
+ extern void remove_variable_from_list(struct arguments ** list, struct variable * var);
  extern void dump_variables(struct arguments *, int);
  extern struct typedefs *get_typedef(char *);
  extern void adjust_array(enum ECPGttype, char **, char **, char *, char *, int, bool);
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/parse.pl pgsql.dyncursor/src/interfaces/ecpg/preproc/parse.pl
*** pgsql.orig/src/interfaces/ecpg/preproc/parse.pl    2009-01-30 17:28:46.000000000 +0100
--- pgsql.dyncursor/src/interfaces/ecpg/preproc/parse.pl    2009-09-03 12:28:03.000000000 +0200
*************** $replace_types{'unreserved_keyword'} = '
*** 57,63 ****
  $replace_types{'Sconst'} = 'ignore';

  # some production rules have to be ignored or replaced
! $replace_line{'fetch_direction'} = 'ignore';
  $replace_line{"opt_array_boundsopt_array_bounds'['Iconst']'"} = 'ignore';
  $replace_line{'col_name_keywordCHAR_P'} = 'ignore';
  $replace_line{'col_name_keywordINT_P'} = 'ignore';
--- 57,65 ----
  $replace_types{'Sconst'} = 'ignore';

  # some production rules have to be ignored or replaced
! $replace_line{'fetch_args'} = 'ignore';
! $replace_line{'fetch_argsFORWARDopt_from_incursor_name'} = 'ignore';
! $replace_line{'fetch_argsBACKWARDopt_from_incursor_name'} = 'ignore';
  $replace_line{"opt_array_boundsopt_array_bounds'['Iconst']'"} = 'ignore';
  $replace_line{'col_name_keywordCHAR_P'} = 'ignore';
  $replace_line{'col_name_keywordINT_P'} = 'ignore';
*************** sub include_stuff {
*** 311,316 ****
--- 313,319 ----
      local($includestream, $includefilename, $includeblock, $copy, $field_count) = @_;
      $copied = 0;
      $inblock = 0;
+     $have_addon = 0;
      $filename = $path . "/" . $includefilename;
      while (($_ = &Getline2($filename),$getline_ok)) {
      if ($includeblock ne '' && $Fld[1] eq 'ECPG:' && $inblock == 0) {
*************** sub include_stuff {
*** 319,327 ****
          $inblock = 1;
          $includetype = $Fld[3];
          if ($includetype eq 'rule') {
!             &dump_fields($stmt_mode, *fields, $field_count, ' { ');
          }
          elsif ($includetype eq 'addon') {
              &add_to_buffer('rules', ' { ');
          }
          }
--- 322,336 ----
          $inblock = 1;
          $includetype = $Fld[3];
          if ($includetype eq 'rule') {
!             if ($have_addon == 0) {
!             &dump_fields($stmt_mode, *fields, $field_count, ' { ');
!             }
!             else {
!             &dump_fields($stmt_mode, *fields, $field_count, '');
!             }
          }
          elsif ($includetype eq 'addon') {
+             $have_addon  = 1;
              &add_to_buffer('rules', ' { ');
          }
          }
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/variable.c pgsql.dyncursor/src/interfaces/ecpg/preproc/variable.c
*** pgsql.orig/src/interfaces/ecpg/preproc/variable.c    2009-08-07 13:06:28.000000000 +0200
--- pgsql.dyncursor/src/interfaces/ecpg/preproc/variable.c    2009-09-03 12:28:03.000000000 +0200
*************** add_variable_to_tail(struct arguments **
*** 401,406 ****
--- 401,430 ----
          *list = new;
  }

+ void
+ remove_variable_from_list(struct arguments ** list, struct variable * var)
+ {
+     struct arguments *p, *prev = NULL;
+     bool found = false;
+
+     for (p = *list; p; p = p->next)
+     {
+         if (p->variable == var)
+         {
+             found = true;
+             break;
+         }
+         prev = p;
+     }
+     if (found)
+     {
+         if (prev)
+             prev->next = p->next;
+         else
+             *list = p->next;
+     }
+ }
+
  /* Dump out a list of all the variable on this list.
     This is a recursive function that works from the end of the list and
     deletes the list as we go on.
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/compat_informix/cursor.pgc
pgsql.dyncursor/src/interfaces/ecpg/test/compat_informix/cursor.pgc
*** pgsql.orig/src/interfaces/ecpg/test/compat_informix/cursor.pgc    1970-01-01 01:00:00.000000000 +0100
--- pgsql.dyncursor/src/interfaces/ecpg/test/compat_informix/cursor.pgc    2009-09-03 12:28:03.000000000 +0200
***************
*** 0 ****
--- 1,245 ----
+ #include <stdlib.h>
+ #include <string.h>
+
+ exec sql include ../regression;
+
+ exec sql whenever sqlerror stop;
+
+ exec sql type c is char reference;
+ typedef char* c;
+
+ exec sql type ind is union { int integer; short smallint; };
+ typedef union { int integer; short smallint; } ind;
+
+ #define BUFFERSIZ 8
+ exec sql type str is varchar[BUFFERSIZ];
+
+ #define CURNAME "mycur"
+
+ int
+ main (void)
+ {
+ exec sql begin declare section;
+     char    *stmt1 = "SELECT id, t FROM t1";
+     char    *curname1 = CURNAME;
+     char    *curname2 = CURNAME;
+     char    *curname3 = CURNAME;
+     varchar    curname4[50];
+     int    count;
+     int    id;
+     char    t[64];
+ exec sql end declare section;
+
+     char msg[128];
+
+     ECPGdebug(1, stderr);
+
+     strcpy(msg, "connect");
+     exec sql connect to REGRESSDB1;
+
+     strcpy(msg, "set");
+     exec sql set datestyle to iso;
+
+     strcpy(msg, "create");
+     exec sql create table t1(id serial primary key, t text);
+
+     strcpy(msg, "insert");
+     exec sql insert into t1(id, t) values (default, 'a');
+     exec sql insert into t1(id, t) values (default, 'b');
+     exec sql insert into t1(id, t) values (default, 'c');
+     exec sql insert into t1(id, t) values (default, 'd');
+
+     strcpy(msg, "commit");
+     exec sql commit;
+
+     /* Dynamic cursorname test with INTO list in FETCH stmts */
+
+     strcpy(msg, "declare");
+     exec sql declare :curname1 cursor for
+         select id, t from t1;
+
+     strcpy(msg, "open");
+     exec sql open :curname1;
+
+     strcpy(msg, "fetch from");
+     exec sql fetch from :curname1 into :id, :t;
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch");
+     exec sql fetch :curname1 into :id, :t;
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch 1 from");
+     exec sql fetch 1 from :curname1 into :id, :t;
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch :count from");
+     count = 1;
+     exec sql fetch :count from :curname1 into :id, :t;
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "move in");
+     exec sql move absolute 0 in :curname1;
+
+     strcpy(msg, "fetch 1");
+     exec sql fetch 1 :curname1 into :id, :t;
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch :count");
+     count = 1;
+     exec sql fetch :count :curname1 into :id, :t;
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "close");
+     exec sql close :curname1;
+
+     /* Dynamic cursorname test with INTO list in DECLARE stmt */
+
+     strcpy(msg, "declare");
+     exec sql declare :curname2 cursor for
+         select id, t into :id, :t from t1;
+
+     strcpy(msg, "open");
+     exec sql open :curname2;
+
+     strcpy(msg, "fetch from");
+     exec sql fetch from :curname2;
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch");
+     exec sql fetch :curname2;
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch 1 from");
+     exec sql fetch 1 from :curname2;
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch :count from");
+     count = 1;
+     exec sql fetch :count from :curname2;
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "move");
+     exec sql move absolute 0 :curname2;
+
+     strcpy(msg, "fetch 1");
+     exec sql fetch 1 :curname2;
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch :count");
+     count = 1;
+     exec sql fetch :count :curname2;
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "close");
+     exec sql close :curname2;
+
+     /* Dynamic cursorname test with PREPARED stmt */
+
+     strcpy(msg, "prepare");
+     exec sql prepare st_id1 from :stmt1;
+
+     strcpy(msg, "declare");
+     exec sql declare :curname3 cursor for st_id1;
+
+     strcpy(msg, "open");
+     exec sql open :curname3;
+
+     strcpy(msg, "fetch from");
+     exec sql fetch from :curname3 into :id, :t;
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch");
+     exec sql fetch :curname3 into :id, :t;
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch 1 from");
+     exec sql fetch 1 from :curname3 into :id, :t;
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch :count from");
+     count = 1;
+     exec sql fetch :count from :curname3 into :id, :t;
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "move");
+     exec sql move absolute 0 :curname3;
+
+     strcpy(msg, "fetch 1");
+     exec sql fetch 1 :curname3 into :id, :t;
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch :count");
+     count = 1;
+     exec sql fetch :count :curname3 into :id, :t;
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "close");
+     exec sql close :curname3;
+
+     strcpy(msg, "deallocate prepare");
+     exec sql deallocate prepare st_id1;
+
+     /* Dynamic cursorname test with PREPARED stmt,
+        cursor name in varchar */
+
+     curname4.len = strlen(CURNAME);
+     strcpy(curname4.arr, CURNAME);
+
+     strcpy(msg, "prepare");
+     exec sql prepare st_id2 from :stmt1;
+
+     strcpy(msg, "declare");
+     exec sql declare :curname4 cursor for st_id2;
+
+     strcpy(msg, "open");
+     exec sql open :curname4;
+
+     strcpy(msg, "fetch from");
+     exec sql fetch from :curname4 into :id, :t;
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch");
+     exec sql fetch :curname4 into :id, :t;
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch 1 from");
+     exec sql fetch 1 from :curname4 into :id, :t;
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch :count from");
+     count = 1;
+     exec sql fetch :count from :curname4 into :id, :t;
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "move");
+     exec sql move absolute 0 :curname4;
+
+     strcpy(msg, "fetch 1");
+     exec sql fetch 1 :curname4 into :id, :t;
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch :count");
+     count = 1;
+     exec sql fetch :count :curname4 into :id, :t;
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "close");
+     exec sql close :curname4;
+
+     strcpy(msg, "deallocate prepare");
+     exec sql deallocate prepare st_id2;
+
+     /* End test */
+
+     strcpy(msg, "drop");
+     exec sql drop table t1;
+
+     strcpy(msg, "commit");
+     exec sql commit;
+
+     strcpy(msg, "disconnect");
+     exec sql disconnect;
+
+     return (0);
+ }
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/compat_informix/Makefile
pgsql.dyncursor/src/interfaces/ecpg/test/compat_informix/Makefile
*** pgsql.orig/src/interfaces/ecpg/test/compat_informix/Makefile    2006-09-19 17:36:08.000000000 +0200
--- pgsql.dyncursor/src/interfaces/ecpg/test/compat_informix/Makefile    2009-09-03 12:28:03.000000000 +0200
*************** override LIBS := -lecpg_compat $(LIBS)
*** 12,17 ****
--- 12,18 ----

  TESTS = test_informix test_informix.c \
          test_informix2 test_informix2.c \
+         cursor cursor.c \
          dec_test dec_test.c \
          rfmtdate rfmtdate.c \
          rfmtlong rfmtlong.c \
*************** test_informix.c: test_informix.pgc ../re
*** 26,31 ****
--- 27,35 ----
  test_informix2.c: test_informix2.pgc ../regression.h
      $(ECPG) -o $@ -I$(srcdir) $<

+ cursor.c: cursor.pgc ../regression.h
+     $(ECPG) -o $@ -I$(srcdir) $<
+
  dec_test.c: dec_test.pgc ../regression.h
      $(ECPG) -o $@ -I$(srcdir) $<

diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/ecpg_schedule pgsql.dyncursor/src/interfaces/ecpg/test/ecpg_schedule
*** pgsql.orig/src/interfaces/ecpg/test/ecpg_schedule    2008-10-29 11:40:29.000000000 +0100
--- pgsql.dyncursor/src/interfaces/ecpg/test/ecpg_schedule    2009-09-03 12:28:03.000000000 +0200
*************** test: compat_informix/charfuncs
*** 3,8 ****
--- 3,9 ----
  test: compat_informix/rfmtdate
  test: compat_informix/rfmtlong
  test: compat_informix/rnull
+ test: compat_informix/cursor
  test: compat_informix/test_informix
  test: compat_informix/test_informix2
  test: connect/test2
*************** test: pgtypeslib/num_test2
*** 16,21 ****
--- 17,23 ----
  test: preproc/array_of_struct
  test: preproc/autoprep
  test: preproc/comment
+ test: preproc/cursor
  test: preproc/define
  test: preproc/init
  test: preproc/strings
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/ecpg_schedule_tcp
pgsql.dyncursor/src/interfaces/ecpg/test/ecpg_schedule_tcp
*** pgsql.orig/src/interfaces/ecpg/test/ecpg_schedule_tcp    2008-10-29 11:40:29.000000000 +0100
--- pgsql.dyncursor/src/interfaces/ecpg/test/ecpg_schedule_tcp    2009-09-03 12:28:03.000000000 +0200
*************** test: compat_informix/charfuncs
*** 3,8 ****
--- 3,9 ----
  test: compat_informix/rfmtdate
  test: compat_informix/rfmtlong
  test: compat_informix/rnull
+ test: compat_informix/cursor
  test: compat_informix/test_informix
  test: compat_informix/test_informix2
  test: connect/test2
*************** test: pgtypeslib/num_test2
*** 16,21 ****
--- 17,23 ----
  test: preproc/array_of_struct
  test: preproc/autoprep
  test: preproc/comment
+ test: preproc/cursor
  test: preproc/define
  test: preproc/init
  test: preproc/strings
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-cursor.c
pgsql.dyncursor/src/interfaces/ecpg/test/expected/compat_informix-cursor.c
*** pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-cursor.c    1970-01-01 01:00:00.000000000 +0100
--- pgsql.dyncursor/src/interfaces/ecpg/test/expected/compat_informix-cursor.c    2009-09-03 12:47:24.000000000 +0200
***************
*** 0 ****
--- 1,766 ----
+ /* Processed by ecpg (regression mode) */
+ /* These include files are added by the preprocessor */
+ #include <ecpglib.h>
+ #include <ecpgerrno.h>
+ #include <sqlca.h>
+ /* Needed for informix compatibility */
+ #include <ecpg_informix.h>
+ /* End of automatic include section */
+ #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+
+ #line 1 "cursor.pgc"
+ #include <stdlib.h>
+ #include <string.h>
+
+
+ #line 1 "regression.h"
+
+
+
+
+
+
+ #line 4 "cursor.pgc"
+
+
+ /* exec sql whenever sqlerror  stop ; */
+ #line 6 "cursor.pgc"
+
+
+ /* exec sql type c is char reference */
+ #line 8 "cursor.pgc"
+
+ typedef char* c;
+
+ /* exec sql type ind is union {
+ #line 11 "cursor.pgc"
+  int integer ;
+
+ #line 11 "cursor.pgc"
+  short smallint ;
+  } */
+ #line 11 "cursor.pgc"
+
+ typedef union { int integer; short smallint; } ind;
+
+ #define BUFFERSIZ 8
+ /* exec sql type str is [ BUFFERSIZ ] */
+ #line 15 "cursor.pgc"
+
+
+ #define CURNAME "mycur"
+
+ int
+ main (void)
+ {
+ /* exec sql begin declare section */
+
+
+
+
+
+
+
+
+
+ #line 23 "cursor.pgc"
+  char * stmt1 = "SELECT id, t FROM t1" ;
+
+ #line 24 "cursor.pgc"
+  char * curname1 = CURNAME ;
+
+ #line 25 "cursor.pgc"
+  char * curname2 = CURNAME ;
+
+ #line 26 "cursor.pgc"
+  char * curname3 = CURNAME ;
+
+ #line 27 "cursor.pgc"
+   struct varchar_curname4_27  { int len; char arr[ 50 ]; }  curname4 ;
+
+ #line 28 "cursor.pgc"
+  int count ;
+
+ #line 29 "cursor.pgc"
+  int id ;
+
+ #line 30 "cursor.pgc"
+  char t [ 64 ] ;
+ /* exec sql end declare section */
+ #line 31 "cursor.pgc"
+
+
+     char msg[128];
+
+     ECPGdebug(1, stderr);
+
+     strcpy(msg, "connect");
+     { ECPGconnect(__LINE__, 1, "regress1" , NULL, NULL , NULL, 0);
+ #line 38 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 38 "cursor.pgc"
+
+
+     strcpy(msg, "set");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
+ #line 41 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 41 "cursor.pgc"
+
+
+     strcpy(msg, "create");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "create table t1 ( id serial primary key , t text )",
ECPGt_EOIT,ECPGt_EORT); 
+ #line 44 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 44 "cursor.pgc"
+
+
+     strcpy(msg, "insert");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'a' )",
ECPGt_EOIT,ECPGt_EORT); 
+ #line 47 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 47 "cursor.pgc"
+
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'b' )",
ECPGt_EOIT,ECPGt_EORT); 
+ #line 48 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 48 "cursor.pgc"
+
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'c' )",
ECPGt_EOIT,ECPGt_EORT); 
+ #line 49 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 49 "cursor.pgc"
+
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'd' )",
ECPGt_EOIT,ECPGt_EORT); 
+ #line 50 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 50 "cursor.pgc"
+
+
+     strcpy(msg, "commit");
+     { ECPGtrans(__LINE__, NULL, "commit");
+ #line 53 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 53 "cursor.pgc"
+
+
+     /* Dynamic cursorname test with INTO list in FETCH stmts */
+
+     strcpy(msg, "declare");
+     ECPG_informix_set_var( 0, &( curname1 ), __LINE__);\
+  ECPG_informix_reset_sqlca(); /* declare $0 cursor for select id , t from t1 */
+ #line 59 "cursor.pgc"
+
+
+     strcpy(msg, "open");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare $0 cursor for select id , t from t1",
+     ECPGt_char,&(*( char  *)(ECPG_informix_get_var( 0))),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 62 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 62 "cursor.pgc"
+
+
+     strcpy(msg, "fetch from");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch from $0",
+     ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 65 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 65 "cursor.pgc"
+
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch $0",
+     ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 69 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 69 "cursor.pgc"
+
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch 1 from");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch 1 from $0",
+     ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 73 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 73 "cursor.pgc"
+
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch :count from");
+     count = 1;
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch $0 from $0",
+     ECPGt_int,&(count),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 78 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 78 "cursor.pgc"
+
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "move in");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "move absolute 0 in $0",
+     ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 82 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 82 "cursor.pgc"
+
+
+     strcpy(msg, "fetch 1");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch 1 $0",
+     ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 85 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 85 "cursor.pgc"
+
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch :count");
+     count = 1;
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch $0 $0",
+     ECPGt_int,&(count),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 90 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 90 "cursor.pgc"
+
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "close");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "close $0",
+     ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 94 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 94 "cursor.pgc"
+
+
+     /* Dynamic cursorname test with INTO list in DECLARE stmt */
+
+     strcpy(msg, "declare");
+     ECPG_informix_set_var( 3, &( curname2 ), __LINE__);\
+  ECPG_informix_set_var( 1, ( t ), __LINE__);\
+  ECPG_informix_set_var( 2, &( id ), __LINE__);\
+  ECPG_informix_reset_sqlca(); /* declare $0 cursor for select id , t from t1 */
+ #line 100 "cursor.pgc"
+
+
+     strcpy(msg, "open");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare $0 cursor for select id , t from t1",
+     ECPGt_char,&(*( char  *)(ECPG_informix_get_var( 3))),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_int,&(*( int  *)(ECPG_informix_get_var( 2))),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,(( char  *)(ECPG_informix_get_var( 1))),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 103 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 103 "cursor.pgc"
+
+
+     strcpy(msg, "fetch from");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch from $0",
+     ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_int,&(*( int  *)(ECPG_informix_get_var( 2))),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,(( char  *)(ECPG_informix_get_var( 1))),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 106 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 106 "cursor.pgc"
+
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch $0",
+     ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_int,&(*( int  *)(ECPG_informix_get_var( 2))),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,(( char  *)(ECPG_informix_get_var( 1))),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 110 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 110 "cursor.pgc"
+
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch 1 from");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch 1 from $0",
+     ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_int,&(*( int  *)(ECPG_informix_get_var( 2))),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,(( char  *)(ECPG_informix_get_var( 1))),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 114 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 114 "cursor.pgc"
+
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch :count from");
+     count = 1;
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch $0 from $0",
+     ECPGt_int,&(count),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_int,&(*( int  *)(ECPG_informix_get_var( 2))),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,(( char  *)(ECPG_informix_get_var( 1))),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 119 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 119 "cursor.pgc"
+
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "move");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "move absolute 0 $0",
+     ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_int,&(*( int  *)(ECPG_informix_get_var( 2))),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,(( char  *)(ECPG_informix_get_var( 1))),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 123 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 123 "cursor.pgc"
+
+
+     strcpy(msg, "fetch 1");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch 1 $0",
+     ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_int,&(*( int  *)(ECPG_informix_get_var( 2))),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,(( char  *)(ECPG_informix_get_var( 1))),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 126 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 126 "cursor.pgc"
+
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch :count");
+     count = 1;
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch $0 $0",
+     ECPGt_int,&(count),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_int,&(*( int  *)(ECPG_informix_get_var( 2))),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,(( char  *)(ECPG_informix_get_var( 1))),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 131 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 131 "cursor.pgc"
+
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "close");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "close $0",
+     ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 135 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 135 "cursor.pgc"
+
+
+     /* Dynamic cursorname test with PREPARED stmt */
+
+     strcpy(msg, "prepare");
+     { ECPGprepare(__LINE__, NULL, 0, "st_id1", stmt1);
+ #line 140 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 140 "cursor.pgc"
+
+
+     strcpy(msg, "declare");
+     ECPG_informix_reset_sqlca(); /* declare $0 cursor for $1 */
+ #line 143 "cursor.pgc"
+
+
+     strcpy(msg, "open");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare $0 cursor for $1",
+     ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id1", __LINE__)),(long)1,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 146 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 146 "cursor.pgc"
+
+
+     strcpy(msg, "fetch from");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch from $0",
+     ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 149 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 149 "cursor.pgc"
+
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch $0",
+     ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 153 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 153 "cursor.pgc"
+
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch 1 from");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch 1 from $0",
+     ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 157 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 157 "cursor.pgc"
+
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch :count from");
+     count = 1;
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch $0 from $0",
+     ECPGt_int,&(count),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 162 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 162 "cursor.pgc"
+
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "move");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "move absolute 0 $0",
+     ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 166 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 166 "cursor.pgc"
+
+
+     strcpy(msg, "fetch 1");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch 1 $0",
+     ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 169 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 169 "cursor.pgc"
+
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch :count");
+     count = 1;
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch $0 $0",
+     ECPGt_int,&(count),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 174 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 174 "cursor.pgc"
+
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "close");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "close $0",
+     ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 178 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 178 "cursor.pgc"
+
+
+     strcpy(msg, "deallocate prepare");
+     { ECPGdeallocate(__LINE__, 1, NULL, "st_id1");
+ #line 181 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 181 "cursor.pgc"
+
+
+     /* Dynamic cursorname test with PREPARED stmt,
+        cursor name in varchar */
+
+     curname4.len = strlen(CURNAME);
+     strcpy(curname4.arr, CURNAME);
+
+     strcpy(msg, "prepare");
+     { ECPGprepare(__LINE__, NULL, 0, "st_id2", stmt1);
+ #line 190 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 190 "cursor.pgc"
+
+
+     strcpy(msg, "declare");
+     ECPG_informix_reset_sqlca(); /* declare $0 cursor for $1 */
+ #line 193 "cursor.pgc"
+
+
+     strcpy(msg, "open");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare $0 cursor for $1",
+     ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id2", __LINE__)),(long)1,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 196 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 196 "cursor.pgc"
+
+
+     strcpy(msg, "fetch from");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch from $0",
+     ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 199 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 199 "cursor.pgc"
+
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch $0",
+     ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 203 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 203 "cursor.pgc"
+
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch 1 from");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch 1 from $0",
+     ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 207 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 207 "cursor.pgc"
+
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch :count from");
+     count = 1;
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch $0 from $0",
+     ECPGt_int,&(count),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 212 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 212 "cursor.pgc"
+
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "move");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "move absolute 0 $0",
+     ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 216 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 216 "cursor.pgc"
+
+
+     strcpy(msg, "fetch 1");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch 1 $0",
+     ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 219 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 219 "cursor.pgc"
+
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch :count");
+     count = 1;
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch $0 $0",
+     ECPGt_int,&(count),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 224 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 224 "cursor.pgc"
+
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "close");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "close $0",
+     ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 228 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 228 "cursor.pgc"
+
+
+     strcpy(msg, "deallocate prepare");
+     { ECPGdeallocate(__LINE__, 1, NULL, "st_id2");
+ #line 231 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 231 "cursor.pgc"
+
+
+     /* End test */
+
+     strcpy(msg, "drop");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT);
+ #line 236 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 236 "cursor.pgc"
+
+
+     strcpy(msg, "commit");
+     { ECPGtrans(__LINE__, NULL, "commit");
+ #line 239 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 239 "cursor.pgc"
+
+
+     strcpy(msg, "disconnect");
+     { ECPGdisconnect(__LINE__, "CURRENT");
+ #line 242 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 242 "cursor.pgc"
+
+
+     return (0);
+ }
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-cursor.stderr
pgsql.dyncursor/src/interfaces/ecpg/test/expected/compat_informix-cursor.stderr
*** pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-cursor.stderr    1970-01-01 01:00:00.000000000 +0100
--- pgsql.dyncursor/src/interfaces/ecpg/test/expected/compat_informix-cursor.stderr    2009-09-03 12:28:03.000000000
+0200
***************
*** 0 ****
--- 1,372 ----
+ [NO_PID]: ECPGdebug: set to 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 41: query: set datestyle to iso; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 41: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 41: OK: SET
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 44: query: create table t1 ( id serial primary key , t text ); with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 44: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 44: OK: CREATE TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 47: query: insert into t1 ( id , t ) values ( default , 'a' ); with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 47: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 47: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 48: query: insert into t1 ( id , t ) values ( default , 'b' ); with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 48: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 48: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 49: query: insert into t1 ( id , t ) values ( default , 'c' ); with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 49: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 49: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: query: insert into t1 ( id , t ) values ( default , 'd' ); with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 53: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 62: query: declare mycur cursor for select id , t from t1; with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 62: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 62: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 65: query: fetch from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 65: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 65: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 65: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 65: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 69: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 69: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 69: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 69: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 69: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 73: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 73: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 73: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 73: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 73: RESULT: c offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 78: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 78: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 78: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 78: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 78: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 82: query: move absolute 0 in mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 82: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 82: OK: MOVE 0
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 85: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 85: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 85: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 85: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 85: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 90: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 90: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 90: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 90: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 90: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 94: query: close mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 94: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 94: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 103: query: declare mycur cursor for select id , t from t1; with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 103: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 103: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 106: query: fetch from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 106: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 106: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 106: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 106: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 110: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 110: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 110: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 110: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 110: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 114: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 114: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 114: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 114: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 114: RESULT: c offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 119: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 119: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 119: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 119: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 119: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 123: query: move absolute 0 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 123: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 123: OK: MOVE 0
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 126: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 126: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 126: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 126: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 126: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 131: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 131: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 131: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 131: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 131: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 135: query: close mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 135: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 135: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 140: name st_id1; query: "SELECT id, t FROM t1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 146: query: declare mycur cursor for SELECT id, t FROM t1; with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 146: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 146: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 149: query: fetch from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 149: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 149: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 149: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 149: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 153: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 153: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 153: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 153: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 153: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 157: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 157: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 157: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 157: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 157: RESULT: c offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 162: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 162: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 162: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 162: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 162: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 166: query: move absolute 0 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 166: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 166: OK: MOVE 0
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 169: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 169: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 169: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 169: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 169: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 174: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 174: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 174: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 174: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 174: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 178: query: close mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 178: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 178: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 181: name st_id1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 190: name st_id2; query: "SELECT id, t FROM t1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 196: query: declare mycur cursor for SELECT id, t FROM t1; with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 196: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 196: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 199: query: fetch from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 199: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 199: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 199: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 199: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 203: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 203: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 203: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 203: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 203: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 207: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 207: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 207: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 207: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 207: RESULT: c offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 212: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 212: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 212: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 212: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 212: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 216: query: move absolute 0 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 216: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 216: OK: MOVE 0
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 219: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 219: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 219: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 219: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 219: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 224: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 224: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 224: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 224: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 224: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 228: query: close mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 228: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 228: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 231: name st_id2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 236: query: drop table t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 236: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 236: OK: DROP TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 239: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection regress1 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-cursor.stdout
pgsql.dyncursor/src/interfaces/ecpg/test/expected/compat_informix-cursor.stdout
*** pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-cursor.stdout    1970-01-01 01:00:00.000000000 +0100
--- pgsql.dyncursor/src/interfaces/ecpg/test/expected/compat_informix-cursor.stdout    2009-09-03 12:28:03.000000000
+0200
***************
*** 0 ****
--- 1,24 ----
+ 1 a
+ 2 b
+ 3 c
+ 4 d
+ 1 a
+ 2 b
+ 1 a
+ 2 b
+ 3 c
+ 4 d
+ 1 a
+ 2 b
+ 1 a
+ 2 b
+ 3 c
+ 4 d
+ 1 a
+ 2 b
+ 1 a
+ 2 b
+ 3 c
+ 4 d
+ 1 a
+ 2 b
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c
pgsql.dyncursor/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c
*** pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c    2009-08-14 16:27:41.000000000 +0200
--- pgsql.dyncursor/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c    2009-09-03 12:28:03.000000000
+0200
*************** if (sqlca.sqlcode < 0) dosqlprint ( );}
*** 158,164 ****

      while (1)
      {
!         { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch forward from c", ECPGt_EOIT,
      ECPGt_int,&(i),(long)1,(long)1,sizeof(int),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
      ECPGt_decimal,&(j),(long)1,(long)1,sizeof(decimal),
--- 158,164 ----

      while (1)
      {
!         { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch forward c", ECPGt_EOIT,
      ECPGt_int,&(i),(long)1,(long)1,sizeof(int),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
      ECPGt_decimal,&(j),(long)1,(long)1,sizeof(decimal),
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-test_informix.stderr
pgsql.dyncursor/src/interfaces/ecpg/test/expected/compat_informix-test_informix.stderr
*** pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-test_informix.stderr    2009-08-14 16:27:41.000000000
+0200
--- pgsql.dyncursor/src/interfaces/ecpg/test/expected/compat_informix-test_informix.stderr    2009-09-03
12:47:45.000000000+0200 
*************** DETAIL:  Key (i)=(7) already exists.
*** 63,69 ****
  [NO_PID]: sqlca: code: 0, state: 00000
  [NO_PID]: ecpg_execute on line 95: OK: DECLARE CURSOR
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 57: query: fetch forward from c; with 0 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
  [NO_PID]: ecpg_execute on line 57: using PQexec
  [NO_PID]: sqlca: code: 0, state: 00000
--- 63,69 ----
  [NO_PID]: sqlca: code: 0, state: 00000
  [NO_PID]: ecpg_execute on line 95: OK: DECLARE CURSOR
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 57: query: fetch forward c; with 0 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
  [NO_PID]: ecpg_execute on line 57: using PQexec
  [NO_PID]: sqlca: code: 0, state: 00000
*************** DETAIL:  Key (i)=(7) already exists.
*** 75,81 ****
  [NO_PID]: sqlca: code: 0, state: 00000
  [NO_PID]: ecpg_get_data on line 57: RESULT: test    offset: -1; array: yes
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 57: query: fetch forward from c; with 0 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
  [NO_PID]: ecpg_execute on line 57: using PQexec
  [NO_PID]: sqlca: code: 0, state: 00000
--- 75,81 ----
  [NO_PID]: sqlca: code: 0, state: 00000
  [NO_PID]: ecpg_get_data on line 57: RESULT: test    offset: -1; array: yes
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 57: query: fetch forward c; with 0 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
  [NO_PID]: ecpg_execute on line 57: using PQexec
  [NO_PID]: sqlca: code: 0, state: 00000
*************** DETAIL:  Key (i)=(7) already exists.
*** 87,93 ****
  [NO_PID]: sqlca: code: 0, state: 00000
  [NO_PID]: ecpg_get_data on line 57: RESULT: a       offset: -1; array: yes
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 57: query: fetch forward from c; with 0 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
  [NO_PID]: ecpg_execute on line 57: using PQexec
  [NO_PID]: sqlca: code: 0, state: 00000
--- 87,93 ----
  [NO_PID]: sqlca: code: 0, state: 00000
  [NO_PID]: ecpg_get_data on line 57: RESULT: a       offset: -1; array: yes
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 57: query: fetch forward c; with 0 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
  [NO_PID]: ecpg_execute on line 57: using PQexec
  [NO_PID]: sqlca: code: 0, state: 00000
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/preproc-cursor.c
pgsql.dyncursor/src/interfaces/ecpg/test/expected/preproc-cursor.c
*** pgsql.orig/src/interfaces/ecpg/test/expected/preproc-cursor.c    1970-01-01 01:00:00.000000000 +0100
--- pgsql.dyncursor/src/interfaces/ecpg/test/expected/preproc-cursor.c    2009-09-03 12:28:03.000000000 +0200
***************
*** 0 ****
--- 1,760 ----
+ /* Processed by ecpg (regression mode) */
+ /* These include files are added by the preprocessor */
+ #include <ecpglib.h>
+ #include <ecpgerrno.h>
+ #include <sqlca.h>
+ /* End of automatic include section */
+ #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+
+ #line 1 "cursor.pgc"
+ #include <stdlib.h>
+ #include <string.h>
+
+
+ #line 1 "regression.h"
+
+
+
+
+
+
+ #line 4 "cursor.pgc"
+
+
+ /* exec sql whenever sqlerror  stop ; */
+ #line 6 "cursor.pgc"
+
+
+ /* exec sql type c is char reference */
+ #line 8 "cursor.pgc"
+
+ typedef char* c;
+
+ /* exec sql type ind is union {
+ #line 11 "cursor.pgc"
+  int integer ;
+
+ #line 11 "cursor.pgc"
+  short smallint ;
+  } */
+ #line 11 "cursor.pgc"
+
+ typedef union { int integer; short smallint; } ind;
+
+ #define BUFFERSIZ 8
+ /* exec sql type str is [ BUFFERSIZ ] */
+ #line 15 "cursor.pgc"
+
+
+ #define CURNAME "mycur"
+
+ int
+ main (void)
+ {
+ /* exec sql begin declare section */
+
+
+
+
+
+
+
+
+
+ #line 23 "cursor.pgc"
+  char * stmt1 = "SELECT id, t FROM t1" ;
+
+ #line 24 "cursor.pgc"
+  char * curname1 = CURNAME ;
+
+ #line 25 "cursor.pgc"
+  char * curname2 = CURNAME ;
+
+ #line 26 "cursor.pgc"
+  char * curname3 = CURNAME ;
+
+ #line 27 "cursor.pgc"
+   struct varchar_curname4_27  { int len; char arr[ 50 ]; }  curname4 ;
+
+ #line 28 "cursor.pgc"
+  int count ;
+
+ #line 29 "cursor.pgc"
+  int id ;
+
+ #line 30 "cursor.pgc"
+  char t [ 64 ] ;
+ /* exec sql end declare section */
+ #line 31 "cursor.pgc"
+
+
+     char msg[128];
+
+     ECPGdebug(1, stderr);
+
+     strcpy(msg, "connect");
+     { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0);
+ #line 38 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 38 "cursor.pgc"
+
+
+     strcpy(msg, "set");
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
+ #line 41 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 41 "cursor.pgc"
+
+
+     strcpy(msg, "create");
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table t1 ( id serial primary key , t text )",
ECPGt_EOIT,ECPGt_EORT); 
+ #line 44 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 44 "cursor.pgc"
+
+
+     strcpy(msg, "insert");
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'a' )",
ECPGt_EOIT,ECPGt_EORT); 
+ #line 47 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 47 "cursor.pgc"
+
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'b' )",
ECPGt_EOIT,ECPGt_EORT); 
+ #line 48 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 48 "cursor.pgc"
+
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'c' )",
ECPGt_EOIT,ECPGt_EORT); 
+ #line 49 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 49 "cursor.pgc"
+
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'd' )",
ECPGt_EOIT,ECPGt_EORT); 
+ #line 50 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 50 "cursor.pgc"
+
+
+     strcpy(msg, "commit");
+     { ECPGtrans(__LINE__, NULL, "commit");
+ #line 53 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 53 "cursor.pgc"
+
+
+     /* Dynamic cursorname test with INTO list in FETCH stmts */
+
+     strcpy(msg, "declare");
+     /* declare $0 cursor for select id , t from t1 */
+ #line 59 "cursor.pgc"
+
+
+     strcpy(msg, "open");
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare $0 cursor for select id , t from t1",
+     ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 62 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 62 "cursor.pgc"
+
+
+     strcpy(msg, "fetch from");
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch from $0",
+     ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 65 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 65 "cursor.pgc"
+
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch");
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0",
+     ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 69 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 69 "cursor.pgc"
+
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch 1 from");
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 from $0",
+     ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 73 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 73 "cursor.pgc"
+
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch :count from");
+     count = 1;
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0 from $0",
+     ECPGt_int,&(count),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 78 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 78 "cursor.pgc"
+
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "move in");
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "move absolute 0 in $0",
+     ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 82 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 82 "cursor.pgc"
+
+
+     strcpy(msg, "fetch 1");
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 $0",
+     ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 85 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 85 "cursor.pgc"
+
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch :count");
+     count = 1;
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0 $0",
+     ECPGt_int,&(count),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 90 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 90 "cursor.pgc"
+
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "close");
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close $0",
+     ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 94 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 94 "cursor.pgc"
+
+
+     /* Dynamic cursorname test with INTO list in DECLARE stmt */
+
+     strcpy(msg, "declare");
+     /* declare $0 cursor for select id , t from t1 */
+ #line 100 "cursor.pgc"
+
+
+     strcpy(msg, "open");
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare $0 cursor for select id , t from t1",
+     ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 103 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 103 "cursor.pgc"
+
+
+     strcpy(msg, "fetch from");
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch from $0",
+     ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 106 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 106 "cursor.pgc"
+
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch");
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0",
+     ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 110 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 110 "cursor.pgc"
+
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch 1 from");
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 from $0",
+     ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 114 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 114 "cursor.pgc"
+
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch :count from");
+     count = 1;
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0 from $0",
+     ECPGt_int,&(count),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 119 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 119 "cursor.pgc"
+
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "move");
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "move absolute 0 $0",
+     ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 123 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 123 "cursor.pgc"
+
+
+     strcpy(msg, "fetch 1");
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 $0",
+     ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 126 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 126 "cursor.pgc"
+
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch :count");
+     count = 1;
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0 $0",
+     ECPGt_int,&(count),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 131 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 131 "cursor.pgc"
+
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "close");
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close $0",
+     ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 135 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 135 "cursor.pgc"
+
+
+     /* Dynamic cursorname test with PREPARED stmt */
+
+     strcpy(msg, "prepare");
+     { ECPGprepare(__LINE__, NULL, 0, "st_id1", stmt1);
+ #line 140 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 140 "cursor.pgc"
+
+
+     strcpy(msg, "declare");
+     /* declare $0 cursor for $1 */
+ #line 143 "cursor.pgc"
+
+
+     strcpy(msg, "open");
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare $0 cursor for $1",
+     ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id1", __LINE__)),(long)1,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 146 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 146 "cursor.pgc"
+
+
+     strcpy(msg, "fetch from");
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch from $0",
+     ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 149 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 149 "cursor.pgc"
+
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch");
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0",
+     ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 153 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 153 "cursor.pgc"
+
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch 1 from");
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 from $0",
+     ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 157 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 157 "cursor.pgc"
+
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch :count from");
+     count = 1;
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0 from $0",
+     ECPGt_int,&(count),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 162 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 162 "cursor.pgc"
+
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "move");
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "move absolute 0 $0",
+     ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 166 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 166 "cursor.pgc"
+
+
+     strcpy(msg, "fetch 1");
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 $0",
+     ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 169 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 169 "cursor.pgc"
+
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch :count");
+     count = 1;
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0 $0",
+     ECPGt_int,&(count),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 174 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 174 "cursor.pgc"
+
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "close");
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close $0",
+     ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 178 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 178 "cursor.pgc"
+
+
+     strcpy(msg, "deallocate prepare");
+     { ECPGdeallocate(__LINE__, 0, NULL, "st_id1");
+ #line 181 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 181 "cursor.pgc"
+
+
+     /* Dynamic cursorname test with PREPARED stmt,
+        cursor name in varchar */
+
+     curname4.len = strlen(CURNAME);
+     strcpy(curname4.arr, CURNAME);
+
+     strcpy(msg, "prepare");
+     { ECPGprepare(__LINE__, NULL, 0, "st_id2", stmt1);
+ #line 190 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 190 "cursor.pgc"
+
+
+     strcpy(msg, "declare");
+     /* declare $0 cursor for $1 */
+ #line 193 "cursor.pgc"
+
+
+     strcpy(msg, "open");
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare $0 cursor for $1",
+     ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id2", __LINE__)),(long)1,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 196 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 196 "cursor.pgc"
+
+
+     strcpy(msg, "fetch from");
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch from $0",
+     ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 199 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 199 "cursor.pgc"
+
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch");
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0",
+     ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 203 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 203 "cursor.pgc"
+
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch 1 from");
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 from $0",
+     ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 207 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 207 "cursor.pgc"
+
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch :count from");
+     count = 1;
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0 from $0",
+     ECPGt_int,&(count),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 212 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 212 "cursor.pgc"
+
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "move");
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "move absolute 0 $0",
+     ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 216 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 216 "cursor.pgc"
+
+
+     strcpy(msg, "fetch 1");
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 $0",
+     ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 219 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 219 "cursor.pgc"
+
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch :count");
+     count = 1;
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0 $0",
+     ECPGt_int,&(count),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 224 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 224 "cursor.pgc"
+
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "close");
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close $0",
+     ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 228 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 228 "cursor.pgc"
+
+
+     strcpy(msg, "deallocate prepare");
+     { ECPGdeallocate(__LINE__, 0, NULL, "st_id2");
+ #line 231 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 231 "cursor.pgc"
+
+
+     /* End test */
+
+     strcpy(msg, "drop");
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT);
+ #line 236 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 236 "cursor.pgc"
+
+
+     strcpy(msg, "commit");
+     { ECPGtrans(__LINE__, NULL, "commit");
+ #line 239 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 239 "cursor.pgc"
+
+
+     strcpy(msg, "disconnect");
+     { ECPGdisconnect(__LINE__, "CURRENT");
+ #line 242 "cursor.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 242 "cursor.pgc"
+
+
+     return (0);
+ }
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/preproc-cursor.stderr
pgsql.dyncursor/src/interfaces/ecpg/test/expected/preproc-cursor.stderr
*** pgsql.orig/src/interfaces/ecpg/test/expected/preproc-cursor.stderr    1970-01-01 01:00:00.000000000 +0100
--- pgsql.dyncursor/src/interfaces/ecpg/test/expected/preproc-cursor.stderr    2009-09-03 12:28:03.000000000 +0200
***************
*** 0 ****
--- 1,372 ----
+ [NO_PID]: ECPGdebug: set to 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 41: query: set datestyle to iso; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 41: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 41: OK: SET
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 44: query: create table t1 ( id serial primary key , t text ); with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 44: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 44: OK: CREATE TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 47: query: insert into t1 ( id , t ) values ( default , 'a' ); with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 47: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 47: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 48: query: insert into t1 ( id , t ) values ( default , 'b' ); with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 48: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 48: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 49: query: insert into t1 ( id , t ) values ( default , 'c' ); with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 49: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 49: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: query: insert into t1 ( id , t ) values ( default , 'd' ); with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 53: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 62: query: declare mycur cursor for select id , t from t1; with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 62: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 62: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 65: query: fetch from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 65: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 65: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 65: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 65: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 69: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 69: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 69: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 69: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 69: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 73: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 73: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 73: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 73: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 73: RESULT: c offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 78: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 78: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 78: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 78: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 78: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 82: query: move absolute 0 in mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 82: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 82: OK: MOVE 0
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 85: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 85: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 85: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 85: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 85: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 90: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 90: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 90: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 90: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 90: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 94: query: close mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 94: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 94: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 103: query: declare mycur cursor for select id , t from t1; with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 103: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 103: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 106: query: fetch from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 106: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 106: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 106: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 106: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 110: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 110: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 110: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 110: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 110: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 114: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 114: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 114: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 114: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 114: RESULT: c offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 119: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 119: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 119: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 119: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 119: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 123: query: move absolute 0 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 123: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 123: OK: MOVE 0
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 126: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 126: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 126: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 126: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 126: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 131: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 131: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 131: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 131: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 131: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 135: query: close mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 135: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 135: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 140: name st_id1; query: "SELECT id, t FROM t1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 146: query: declare mycur cursor for SELECT id, t FROM t1; with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 146: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 146: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 149: query: fetch from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 149: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 149: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 149: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 149: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 153: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 153: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 153: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 153: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 153: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 157: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 157: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 157: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 157: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 157: RESULT: c offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 162: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 162: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 162: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 162: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 162: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 166: query: move absolute 0 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 166: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 166: OK: MOVE 0
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 169: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 169: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 169: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 169: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 169: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 174: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 174: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 174: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 174: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 174: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 178: query: close mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 178: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 178: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 181: name st_id1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 190: name st_id2; query: "SELECT id, t FROM t1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 196: query: declare mycur cursor for SELECT id, t FROM t1; with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 196: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 196: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 199: query: fetch from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 199: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 199: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 199: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 199: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 203: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 203: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 203: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 203: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 203: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 207: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 207: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 207: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 207: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 207: RESULT: c offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 212: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 212: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 212: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 212: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 212: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 216: query: move absolute 0 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 216: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 216: OK: MOVE 0
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 219: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 219: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 219: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 219: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 219: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 224: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 224: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 224: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 224: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 224: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 228: query: close mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 228: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 228: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 231: name st_id2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 236: query: drop table t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 236: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 236: OK: DROP TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 239: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection regress1 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/preproc-cursor.stdout
pgsql.dyncursor/src/interfaces/ecpg/test/expected/preproc-cursor.stdout
*** pgsql.orig/src/interfaces/ecpg/test/expected/preproc-cursor.stdout    1970-01-01 01:00:00.000000000 +0100
--- pgsql.dyncursor/src/interfaces/ecpg/test/expected/preproc-cursor.stdout    2009-09-03 12:28:03.000000000 +0200
***************
*** 0 ****
--- 1,24 ----
+ 1 a
+ 2 b
+ 3 c
+ 4 d
+ 1 a
+ 2 b
+ 1 a
+ 2 b
+ 3 c
+ 4 d
+ 1 a
+ 2 b
+ 1 a
+ 2 b
+ 3 c
+ 4 d
+ 1 a
+ 2 b
+ 1 a
+ 2 b
+ 3 c
+ 4 d
+ 1 a
+ 2 b
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/preproc/cursor.pgc
pgsql.dyncursor/src/interfaces/ecpg/test/preproc/cursor.pgc
*** pgsql.orig/src/interfaces/ecpg/test/preproc/cursor.pgc    1970-01-01 01:00:00.000000000 +0100
--- pgsql.dyncursor/src/interfaces/ecpg/test/preproc/cursor.pgc    2009-09-03 12:28:03.000000000 +0200
***************
*** 0 ****
--- 1,245 ----
+ #include <stdlib.h>
+ #include <string.h>
+
+ exec sql include ../regression;
+
+ exec sql whenever sqlerror stop;
+
+ exec sql type c is char reference;
+ typedef char* c;
+
+ exec sql type ind is union { int integer; short smallint; };
+ typedef union { int integer; short smallint; } ind;
+
+ #define BUFFERSIZ 8
+ exec sql type str is varchar[BUFFERSIZ];
+
+ #define CURNAME "mycur"
+
+ int
+ main (void)
+ {
+ exec sql begin declare section;
+     char    *stmt1 = "SELECT id, t FROM t1";
+     char    *curname1 = CURNAME;
+     char    *curname2 = CURNAME;
+     char    *curname3 = CURNAME;
+     varchar    curname4[50];
+     int    count;
+     int    id;
+     char    t[64];
+ exec sql end declare section;
+
+     char msg[128];
+
+     ECPGdebug(1, stderr);
+
+     strcpy(msg, "connect");
+     exec sql connect to REGRESSDB1;
+
+     strcpy(msg, "set");
+     exec sql set datestyle to iso;
+
+     strcpy(msg, "create");
+     exec sql create table t1(id serial primary key, t text);
+
+     strcpy(msg, "insert");
+     exec sql insert into t1(id, t) values (default, 'a');
+     exec sql insert into t1(id, t) values (default, 'b');
+     exec sql insert into t1(id, t) values (default, 'c');
+     exec sql insert into t1(id, t) values (default, 'd');
+
+     strcpy(msg, "commit");
+     exec sql commit;
+
+     /* Dynamic cursorname test with INTO list in FETCH stmts */
+
+     strcpy(msg, "declare");
+     exec sql declare :curname1 cursor for
+         select id, t from t1;
+
+     strcpy(msg, "open");
+     exec sql open :curname1;
+
+     strcpy(msg, "fetch from");
+     exec sql fetch from :curname1 into :id, :t;
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch");
+     exec sql fetch :curname1 into :id, :t;
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch 1 from");
+     exec sql fetch 1 from :curname1 into :id, :t;
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch :count from");
+     count = 1;
+     exec sql fetch :count from :curname1 into :id, :t;
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "move in");
+     exec sql move absolute 0 in :curname1;
+
+     strcpy(msg, "fetch 1");
+     exec sql fetch 1 :curname1 into :id, :t;
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch :count");
+     count = 1;
+     exec sql fetch :count :curname1 into :id, :t;
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "close");
+     exec sql close :curname1;
+
+     /* Dynamic cursorname test with INTO list in DECLARE stmt */
+
+     strcpy(msg, "declare");
+     exec sql declare :curname2 cursor for
+         select id, t into :id, :t from t1;
+
+     strcpy(msg, "open");
+     exec sql open :curname2;
+
+     strcpy(msg, "fetch from");
+     exec sql fetch from :curname2;
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch");
+     exec sql fetch :curname2;
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch 1 from");
+     exec sql fetch 1 from :curname2;
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch :count from");
+     count = 1;
+     exec sql fetch :count from :curname2;
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "move");
+     exec sql move absolute 0 :curname2;
+
+     strcpy(msg, "fetch 1");
+     exec sql fetch 1 :curname2;
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch :count");
+     count = 1;
+     exec sql fetch :count :curname2;
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "close");
+     exec sql close :curname2;
+
+     /* Dynamic cursorname test with PREPARED stmt */
+
+     strcpy(msg, "prepare");
+     exec sql prepare st_id1 from :stmt1;
+
+     strcpy(msg, "declare");
+     exec sql declare :curname3 cursor for st_id1;
+
+     strcpy(msg, "open");
+     exec sql open :curname3;
+
+     strcpy(msg, "fetch from");
+     exec sql fetch from :curname3 into :id, :t;
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch");
+     exec sql fetch :curname3 into :id, :t;
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch 1 from");
+     exec sql fetch 1 from :curname3 into :id, :t;
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch :count from");
+     count = 1;
+     exec sql fetch :count from :curname3 into :id, :t;
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "move");
+     exec sql move absolute 0 :curname3;
+
+     strcpy(msg, "fetch 1");
+     exec sql fetch 1 :curname3 into :id, :t;
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch :count");
+     count = 1;
+     exec sql fetch :count :curname3 into :id, :t;
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "close");
+     exec sql close :curname3;
+
+     strcpy(msg, "deallocate prepare");
+     exec sql deallocate prepare st_id1;
+
+     /* Dynamic cursorname test with PREPARED stmt,
+        cursor name in varchar */
+
+     curname4.len = strlen(CURNAME);
+     strcpy(curname4.arr, CURNAME);
+
+     strcpy(msg, "prepare");
+     exec sql prepare st_id2 from :stmt1;
+
+     strcpy(msg, "declare");
+     exec sql declare :curname4 cursor for st_id2;
+
+     strcpy(msg, "open");
+     exec sql open :curname4;
+
+     strcpy(msg, "fetch from");
+     exec sql fetch from :curname4 into :id, :t;
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch");
+     exec sql fetch :curname4 into :id, :t;
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch 1 from");
+     exec sql fetch 1 from :curname4 into :id, :t;
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch :count from");
+     count = 1;
+     exec sql fetch :count from :curname4 into :id, :t;
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "move");
+     exec sql move absolute 0 :curname4;
+
+     strcpy(msg, "fetch 1");
+     exec sql fetch 1 :curname4 into :id, :t;
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "fetch :count");
+     count = 1;
+     exec sql fetch :count :curname4 into :id, :t;
+     printf("%d %s\n", id, t);
+
+     strcpy(msg, "close");
+     exec sql close :curname4;
+
+     strcpy(msg, "deallocate prepare");
+     exec sql deallocate prepare st_id2;
+
+     /* End test */
+
+     strcpy(msg, "drop");
+     exec sql drop table t1;
+
+     strcpy(msg, "commit");
+     exec sql commit;
+
+     strcpy(msg, "disconnect");
+     exec sql disconnect;
+
+     return (0);
+ }
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/preproc/Makefile
pgsql.dyncursor/src/interfaces/ecpg/test/preproc/Makefile
*** pgsql.orig/src/interfaces/ecpg/test/preproc/Makefile    2008-10-29 11:40:29.000000000 +0100
--- pgsql.dyncursor/src/interfaces/ecpg/test/preproc/Makefile    2009-09-03 12:28:03.000000000 +0200
*************** include $(top_srcdir)/$(subdir)/../Makef
*** 7,12 ****
--- 7,13 ----
  TESTS = array_of_struct array_of_struct.c \
      autoprep autoprep.c \
      comment comment.c \
+     cursor cursor.c \
      define define.c \
      init init.c \
      strings strings.c \

Re: ECPG patchset

From
Boszormenyi Zoltan
Date:
SQLDA support

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
http://www.postgresql.at/

diff -dcrpN pgsql.dyncursor/src/interfaces/ecpg/ecpglib/data.c pgsql.sqlda/src/interfaces/ecpg/ecpglib/data.c
*** pgsql.dyncursor/src/interfaces/ecpg/ecpglib/data.c    2009-08-08 17:19:45.000000000 +0200
--- pgsql.sqlda/src/interfaces/ecpg/ecpglib/data.c    2009-09-03 12:56:36.000000000 +0200
*************** ecpg_get_data(const PGresult *results, i
*** 554,560 ****
                      else
                          PGTYPESnumeric_to_decimal(nres, (decimal *) (var + offset * act_tuple));

!                     free(nres);
                      break;

                  case ECPGt_interval:
--- 554,560 ----
                      else
                          PGTYPESnumeric_to_decimal(nres, (decimal *) (var + offset * act_tuple));

!                     PGTYPESnumeric_free(nres);
                      break;

                  case ECPGt_interval:
diff -dcrpN pgsql.dyncursor/src/interfaces/ecpg/ecpglib/execute.c pgsql.sqlda/src/interfaces/ecpg/ecpglib/execute.c
*** pgsql.dyncursor/src/interfaces/ecpg/ecpglib/execute.c    2009-08-07 13:06:28.000000000 +0200
--- pgsql.sqlda/src/interfaces/ecpg/ecpglib/execute.c    2009-09-03 13:30:07.000000000 +0200
***************
*** 25,30 ****
--- 25,31 ----
  #include "ecpgerrno.h"
  #include "extern.h"
  #include "sqlca.h"
+ #include "sqlda.h"
  #include "sql3types.h"
  #include "pgtypes_numeric.h"
  #include "pgtypes_date.h"
*************** ecpg_store_input(const int lineno, const
*** 1033,1038 ****
--- 1034,1040 ----
                  break;

              case ECPGt_descriptor:
+             case ECPGt_sqlda:
                  break;

              default:
*************** ecpg_execute(struct statement * stmt)
*** 1172,1177 ****
--- 1174,1235 ----
              if (desc->count == desc_counter)
                  desc_counter = 0;
          }
+         else if (var->type == ECPGt_sqlda)
+         {
+             pg_sqlda_t      **_sqlda = (pg_sqlda_t **)var->pointer;
+             pg_sqlda_t       *sqlda = *_sqlda;
+             struct variable    desc_inlist;
+             int        i;
+
+             if (sqlda == NULL)
+                 return false;
+
+             desc_counter++;
+             for (i = 0; i < sqlda->sqld; i++)
+             {
+                 if (i + 1 == desc_counter)
+                 {
+                     desc_inlist.type = ecpg_sqlda_type(sqlda->sqlvar[i].sqltype);
+                     desc_inlist.value = sqlda->sqlvar[i].sqldata;
+                     desc_inlist.pointer = &(sqlda->sqlvar[i].sqldata);
+                     switch (desc_inlist.type)
+                     {
+                         case ECPGt_char:
+                         case ECPGt_varchar:
+                             desc_inlist.varcharsize = strlen(sqlda->sqlvar[i].sqldata);
+                             break;
+                         default:
+                             desc_inlist.varcharsize = 0;
+                             break;
+                     }
+                     desc_inlist.arrsize = 1;
+                     desc_inlist.offset = 0;
+                     if (sqlda->sqlvar[i].sqlind)
+                     {
+                         desc_inlist.ind_type = ECPGt_short;
+                         /* ECPG expects indicator value < 0 */
+                         if (*(sqlda->sqlvar[i].sqlind))
+                             *(sqlda->sqlvar[i].sqlind) = -1;
+                         desc_inlist.ind_value = sqlda->sqlvar[i].sqlind;
+                         desc_inlist.ind_pointer = &(sqlda->sqlvar[i].sqlind);
+                         desc_inlist.ind_varcharsize = desc_inlist.ind_arrsize = 1;
+                         desc_inlist.ind_offset = 0;
+                     }
+                     else
+                     {
+                         desc_inlist.ind_type = ECPGt_NO_INDICATOR;
+                         desc_inlist.ind_value = desc_inlist.ind_pointer = NULL;
+                         desc_inlist.ind_varcharsize = desc_inlist.ind_arrsize = desc_inlist.ind_offset = 0;
+                     }
+                     if (!ecpg_store_input(stmt->lineno, stmt->force_indicator, &desc_inlist, &tobeinserted, false))
+                         return false;
+
+                     break;
+                 }
+             }
+             if (sqlda->sqld == desc_counter)
+                 desc_counter = 0;
+         }
          else
          {
              if (!ecpg_store_input(stmt->lineno, stmt->force_indicator, var, &tobeinserted, false))
*************** ecpg_execute(struct statement * stmt)
*** 1353,1358 ****
--- 1411,1450 ----
                  }
                  var = var->next;
              }
+             else if (var != NULL && var->type == ECPGt_sqlda)
+             {
+                 pg_sqlda_t      **_sqlda = (pg_sqlda_t **)var->pointer;
+                 pg_sqlda_t       *sqlda = *_sqlda;
+                 pg_sqlda_t       *sqlda_new;
+
+                 /* Build a new sqlda structure. Note that only fetching 1 record is supported */
+                 sqlda_new = ecpg_build_sqlda_for_PGresult(stmt->lineno, results, 0);
+
+                 if (!sqlda_new)
+                 {
+                     ecpg_log("ecpg_execute on line %d: out of memory allocating a new sqlda\n", stmt->lineno);
+                     status = false;
+                 }
+                 else
+                 {
+                     ecpg_log("ecpg_execute on line %d: new sqlda was built\n", stmt->lineno);
+
+                     /* If we are passed in a previously existing sqlda then free it. */
+                     if (sqlda)
+                     {
+                         free(sqlda);
+                         sqlda = NULL;
+                     }
+
+                     *_sqlda = sqlda_new;
+
+                     ecpg_set_sqlda_from_PGresult(stmt->lineno, _sqlda, results, 0);
+                     ecpg_log("ecpg_execute on line %d: putting result (1 tuple %d fields) into sqlda descriptor\n",
+                             stmt->lineno, PQnfields(results));
+                 }
+
+                 var = var->next;
+             }
              else
                  for (act_field = 0; act_field < nfields && status; act_field++)
                  {
diff -dcrpN pgsql.dyncursor/src/interfaces/ecpg/ecpglib/extern.h pgsql.sqlda/src/interfaces/ecpg/ecpglib/extern.h
*** pgsql.dyncursor/src/interfaces/ecpg/ecpglib/extern.h    2009-05-25 12:08:48.000000000 +0200
--- pgsql.sqlda/src/interfaces/ecpg/ecpglib/extern.h    2009-09-03 13:02:55.000000000 +0200
***************
*** 6,11 ****
--- 6,12 ----
  #include "postgres_fe.h"
  #include "libpq-fe.h"
  #include "sqlca.h"
+ #include "sqlda.h"
  #include "ecpg_config.h"
  #ifndef CHAR_BIT
  #include <limits.h>
*************** bool        ecpg_init(const struct connection
*** 129,134 ****
--- 130,137 ----
  char       *ecpg_strdup(const char *, int);
  const char *ecpg_type_name(enum ECPGttype);
  int            ecpg_dynamic_type(Oid);
+ int            ecpg_sqlda_type(int);
+ int            ecpg_to_sqlda_type(Oid);
  void        ecpg_free_auto_mem(void);
  void        ecpg_clear_auto_mem(void);

*************** void        ecpg_log(const char *format,...);
*** 149,154 ****
--- 152,160 ----
  bool        ecpg_auto_prepare(int, const char *, const int, char **, const char *);
  void        ecpg_init_sqlca(struct sqlca_t * sqlca);

+ pg_sqlda_t *ecpg_build_sqlda_for_PGresult(int, PGresult *, int);
+ void        ecpg_set_sqlda_from_PGresult(int, pg_sqlda_t **, const PGresult *, int);
+
  /* SQLSTATE values generated or processed by ecpglib (intentionally
   * not exported -- users should refer to the codes directly) */

diff -dcrpN pgsql.dyncursor/src/interfaces/ecpg/ecpglib/Makefile pgsql.sqlda/src/interfaces/ecpg/ecpglib/Makefile
*** pgsql.dyncursor/src/interfaces/ecpg/ecpglib/Makefile    2009-07-13 11:16:41.000000000 +0200
--- pgsql.sqlda/src/interfaces/ecpg/ecpglib/Makefile    2009-09-03 12:56:36.000000000 +0200
*************** override CFLAGS += $(PTHREAD_CFLAGS)
*** 24,30 ****
  # Need to recompile any libpgport object files
  LIBS := $(filter-out -lpgport, $(LIBS))

! OBJS= execute.o typename.o descriptor.o data.o error.o prepare.o memory.o \
      connect.o misc.o path.o pgstrcasecmp.o \
      $(filter snprintf.o strlcpy.o, $(LIBOBJS))

--- 24,30 ----
  # Need to recompile any libpgport object files
  LIBS := $(filter-out -lpgport, $(LIBS))

! OBJS= execute.o typename.o descriptor.o sqlda.o data.o error.o prepare.o memory.o \
      connect.o misc.o path.o pgstrcasecmp.o \
      $(filter snprintf.o strlcpy.o, $(LIBOBJS))

diff -dcrpN pgsql.dyncursor/src/interfaces/ecpg/ecpglib/sqlda.c pgsql.sqlda/src/interfaces/ecpg/ecpglib/sqlda.c
*** pgsql.dyncursor/src/interfaces/ecpg/ecpglib/sqlda.c    1970-01-01 01:00:00.000000000 +0100
--- pgsql.sqlda/src/interfaces/ecpg/ecpglib/sqlda.c    2009-09-03 13:03:56.000000000 +0200
***************
*** 0 ****
--- 1,277 ----
+ /*
+  * Crude SQLDA support routines
+  * Only supports fetching 1 record at a time
+  *
+  * The allocated memory area pointed by an sqlda pointer
+  * contains both the metadata and the data, so freeing up
+  * is a simple free(sqlda) as expected by the ESQL/C examples.
+  */
+
+ #define POSTGRES_ECPG_INTERNAL
+ #include "postgres_fe.h"
+ #include "pg_type.h"
+
+ #include <inttypes.h>
+ #include <dlfcn.h>
+
+ #include "ecpg-pthread-win32.h"
+ #include "decimal.h"
+ #include "ecpgtype.h"
+ #include "ecpglib.h"
+ #include "ecpgerrno.h"
+ #include "extern.h"
+ #include "sqlca.h"
+ #include "sqlda.h"
+ #include "sqltypes.h"
+
+ /*
+  * Compute the next variable's offset with
+  * the current variable's size and alignment.
+  */
+ static long
+ ecpg_sqlda_size_round_align(long offset, int alignment, int size)
+ {
+     if (offset % alignment)
+         offset += alignment - (offset % alignment);
+     offset += size;
+     return offset;
+ }
+
+ /*
+  * Compute the current variable's offset with alignment.
+  */
+ static long
+ ecpg_sqlda_size_align(long offset, int alignment)
+ {
+     if (offset % alignment)
+         offset += alignment - (offset % alignment);
+     return offset;
+ }
+
+ static long
+ ecpg_sqlda_empty_size(const PGresult *res)
+ {
+     long    size;
+     int    i;
+     int    sqld = PQnfields(res);
+
+
+     /* Initial size to store main structure and field structures */
+     size = sizeof(pg_sqlda_t) + sqld * sizeof(pg_sqlvar_t);
+
+     /* Add space for field names */
+     for (i = 0; i < sqld; i++)
+         size += strlen(PQfname(res, i)) + 1;
+
+     /* Add padding to the first field value */
+     size = ecpg_sqlda_size_align(size, sizeof(int));
+
+     return size;
+ }
+
+ static long
+ ecpg_sqlda_total_size(const PGresult *res, int row)
+ {
+     int    i;
+     int    sqld = PQnfields(res);
+     long    size;
+
+     size = ecpg_sqlda_empty_size(res);
+
+     if (row < 0)
+         return size;
+
+     /* Add space for the field values */
+     for (i = 0; i < sqld; i++)
+     {
+         switch (ecpg_to_sqlda_type(PQftype(res, i)))
+         {
+             case SQLSMINT:
+                 size = ecpg_sqlda_size_round_align(size, sizeof(short), sizeof(short));
+                 break;
+             case SQLINT:
+             case SQLSERIAL:
+                 size = ecpg_sqlda_size_round_align(size, sizeof(int), sizeof(int));
+                 break;
+             case SQLFLOAT:
+                 size = ecpg_sqlda_size_round_align(size, sizeof(double), sizeof(double));
+                 break;
+             case SQLSMFLOAT:
+                 size = ecpg_sqlda_size_round_align(size, sizeof(float), sizeof(float));
+                 break;
+             case SQLDECIMAL:
+                 size = ecpg_sqlda_size_round_align(size, sizeof(int), sizeof(decimal));
+                 break;
+             case SQLINT8:
+             case SQLSERIAL8:
+                 size = ecpg_sqlda_size_round_align(size, sizeof(int64_t), sizeof(int64_t));
+                 break;
+
+             /*
+              * These types will be passed as character strings
+              * copied as is from the PGresult until we know
+              * what to do with them.
+              */
+             case SQLCHAR:
+             case SQLTEXT:
+             case SQLVCHAR:
+             case SQLNCHAR:
+             case SQLNVCHAR:
+             case SQLMONEY:
+             case SQLDATE:
+             case SQLDTIME:
+             case SQLINTERVAL:
+             default:
+                 size += strlen(PQgetvalue(res, row, i)) + 1;
+                 break;
+         }
+     }
+     return size;
+ }
+
+ /*
+  * Build pg_sqlda_t (metadata only) from PGresult
+  * leaving enough space for the field values in
+  * the given row number
+  */
+ pg_sqlda_t *
+ ecpg_build_sqlda_for_PGresult(int line, PGresult *res, int row)
+ {
+     pg_sqlda_t *sqlda;
+     pg_sqlvar_t*sqlvar;
+     char       *fname;
+     long        size;
+     int        sqld;
+     int        i;
+
+     size = ecpg_sqlda_total_size(res, row);
+     sqlda = (pg_sqlda_t *)ecpg_alloc(size, line);
+     if (!sqlda)
+         return NULL;
+
+     memset(sqlda, 0, size);
+     sqlvar = (pg_sqlvar_t *)(sqlda + 1);
+     sqld = PQnfields(res);
+     fname = (char *)(sqlvar + sqld);
+
+     sqlda->sqld = sqld;
+     sqlda->desc_occ = size; /* cheat here, keep the full allocated size */
+     sqlda->sqlvar = sqlvar;
+
+     for (i = 0; i < sqlda->sqld; i++)
+     {
+         sqlda->sqlvar[i].sqltype = ecpg_to_sqlda_type(PQftype(res, i));
+         strcpy(fname, PQfname(res, i));
+         sqlda->sqlvar[i].sqlname = fname;
+         fname += strlen(sqlda->sqlvar[i].sqlname) + 1;
+         sqlda->sqlvar[i].sqlformat = (char *)(long)PQfformat(res, i);
+         sqlda->sqlvar[i].sqlxid = PQftype(res, i);
+         sqlda->sqlvar[i].sqltypelen = PQfsize(res, i);
+     }
+
+     return sqlda;
+ }
+
+ /*
+  * Sets values from PGresult.
+  */
+ void
+ ecpg_set_sqlda_from_PGresult(int lineno, pg_sqlda_t **_sqlda, const PGresult *res, int row)
+ {
+     pg_sqlda_t *sqlda = (*_sqlda);
+     int        i;
+     long        size;
+     static    int2    value_is_null = -1;
+     static    int2    value_is_not_null = 0;
+
+     /* Offset for the first field value */
+     size = ecpg_sqlda_empty_size(res);
+
+     /*
+      * Set sqlvar[i]->sqldata pointers and convert values to correct format
+      */
+     for (i = 0; i < sqlda->sqld; i++)
+     {
+         int type = -1, isnull;
+         int use_getdata = true;
+
+         switch (sqlda->sqlvar[i].sqltype)
+         {
+             case SQLSMINT:
+                 size = ecpg_sqlda_size_align(size, sizeof(short));
+                 sqlda->sqlvar[i].sqldata = (char *)sqlda + size;
+                 size += sizeof(short);
+                 type = ECPGt_short;
+                 break;
+             case SQLINT:
+             case SQLSERIAL:
+                 size = ecpg_sqlda_size_align(size, sizeof(int));
+                 sqlda->sqlvar[i].sqldata = (char *)sqlda + size;
+                 size += sizeof(int);
+                 type = ECPGt_int;
+                 break;
+             case SQLFLOAT:
+                 size = ecpg_sqlda_size_align(size, sizeof(double));
+                 sqlda->sqlvar[i].sqldata = (char *)sqlda + size;
+                 size += sizeof(double);
+                 type = ECPGt_double;
+                 break;
+             case SQLSMFLOAT:
+                 size = ecpg_sqlda_size_align(size, sizeof(float));
+                 sqlda->sqlvar[i].sqldata = (char *)sqlda + size;
+                 size += sizeof(float);
+                 type = ECPGt_float;
+                 break;
+             case SQLDECIMAL:
+             {
+                 size = ecpg_sqlda_size_align(size, sizeof(int));
+                 sqlda->sqlvar[i].sqldata = (char *)sqlda + size;
+                 size += sizeof(decimal);
+                 type = ECPGt_decimal;
+                 break;
+             }
+             case SQLINT8:
+             case SQLSERIAL8:
+                 size = ecpg_sqlda_size_align(size, sizeof(int64_t));
+                 sqlda->sqlvar[i].sqldata = (char *)sqlda + size;
+                 size += sizeof(int64_t);
+                 type = ECPGt_long_long;
+                 break;
+
+             /*
+              * These types will be passed as character strings until
+              * it's known what to do with them. We use sqlvar->sqldata
+              * in all cases regardless of length, don't care about
+              * sqlvar->sqlilongdata.
+              */
+             case SQLCHAR:
+             case SQLTEXT:
+             case SQLVCHAR:
+             case SQLNCHAR:
+             case SQLNVCHAR:
+             case SQLMONEY:
+             case SQLDATE:
+             case SQLDTIME:
+             case SQLINTERVAL:
+             default:
+                 sqlda->sqlvar[i].sqldata = (char *)sqlda + size;
+                 size += strlen(PQgetvalue(res, row, i)) + 1;
+                 use_getdata = false;
+                 break;
+         }
+
+         isnull = PQgetisnull(res, 0, i);
+         sqlda->sqlvar[i].sqlind = isnull ? &value_is_null : &value_is_not_null;
+         if (!isnull)
+         {
+             if (use_getdata)
+                 ecpg_get_data(res, row, i, lineno,
+                         type, ECPGt_NO_INDICATOR,
+                         sqlda->sqlvar[i].sqldata, NULL, 0, 0, 0,
+                         ECPG_ARRAY_NONE, ECPG_COMPAT_INFORMIX, false);
+             else
+                 strcpy(sqlda->sqlvar[i].sqldata, PQgetvalue(res, row, i));
+         }
+     }
+ }
+
diff -dcrpN pgsql.dyncursor/src/interfaces/ecpg/ecpglib/typename.c pgsql.sqlda/src/interfaces/ecpg/ecpglib/typename.c
*** pgsql.dyncursor/src/interfaces/ecpg/ecpglib/typename.c    2009-08-07 13:06:28.000000000 +0200
--- pgsql.sqlda/src/interfaces/ecpg/ecpglib/typename.c    2009-09-03 12:56:36.000000000 +0200
***************
*** 7,12 ****
--- 7,13 ----
  #include "ecpgtype.h"
  #include "ecpglib.h"
  #include "extern.h"
+ #include "sqltypes.h"
  #include "sql3types.h"
  #include "pg_type.h"

*************** ecpg_dynamic_type(Oid type)
*** 100,102 ****
--- 101,190 ----
              return -(int) type;
      }
  }
+
+ int
+ ecpg_sqlda_type(int type)
+ {
+     switch (type)
+     {
+         case SQLCHAR:
+         case SQLNCHAR:
+             return ECPGt_char;
+         case SQLSMINT:
+             return ECPGt_short;
+         case SQLINT:
+             return ECPGt_int;
+         case SQLFLOAT:
+             return ECPGt_double;
+         case SQLSMFLOAT:
+             return ECPGt_float;
+         case SQLDECIMAL:
+             return ECPGt_decimal;
+         case SQLSERIAL:
+             return ECPGt_int;
+         case SQLDATE:
+             return ECPGt_date;
+ #if 0
+         case SQLMONEY:
+             return ???;
+         case SQLNULL:
+             return ???;
+ #endif
+         case SQLDTIME:
+             return ECPGt_timestamp;
+ #if 0
+         case SQLBYTES:
+             return ???;
+ #endif
+         case SQLTEXT:
+             return ECPGt_char;
+         case SQLVCHAR:
+         case SQLNVCHAR:
+             return ECPGt_varchar;
+         case SQLINTERVAL:
+             return ECPGt_interval;
+         case SQLINT8:
+         case SQLSERIAL8:
+             return ECPGt_long_long;
+         default:
+             return (-type);
+     }
+ }
+
+ int
+ ecpg_to_sqlda_type(Oid type)
+ {
+     switch (type)
+     {
+         case CHAROID:
+         case BPCHAROID:
+             return SQLCHAR;
+         case INT2OID:
+             return SQLSMINT;
+         case INT4OID:
+             return SQLINT;
+         case FLOAT8OID:
+             return SQLFLOAT;
+         case FLOAT4OID:
+             return SQLSMFLOAT;
+         case NUMERICOID:
+             return SQLDECIMAL;
+         case DATEOID:
+             return SQLDATE;
+         case CASHOID:
+             return SQLMONEY;
+         case TIMESTAMPOID:
+         case TIMESTAMPTZOID:
+             return SQLDTIME;
+         case TEXTOID:
+             return SQLTEXT;
+         case VARCHAROID:
+             return SQLVCHAR;
+         case INTERVALOID:
+             return SQLINTERVAL;
+         case INT8OID:
+             return SQLINT8;
+         default:
+             return (-type);
+     }
+ }
diff -dcrpN pgsql.dyncursor/src/interfaces/ecpg/include/ecpgtype.h pgsql.sqlda/src/interfaces/ecpg/include/ecpgtype.h
*** pgsql.dyncursor/src/interfaces/ecpg/include/ecpgtype.h    2009-08-07 13:06:28.000000000 +0200
--- pgsql.sqlda/src/interfaces/ecpg/include/ecpgtype.h    2009-09-03 12:56:36.000000000 +0200
*************** enum ECPGttype
*** 62,68 ****
      ECPGt_EOIT,                    /* End of insert types. */
      ECPGt_EORT,                    /* End of result types. */
      ECPGt_NO_INDICATOR,            /* no indicator */
!     ECPGt_string                            /* trimmed (char *) type */
  };

   /* descriptor items */
--- 62,69 ----
      ECPGt_EOIT,                    /* End of insert types. */
      ECPGt_EORT,                    /* End of result types. */
      ECPGt_NO_INDICATOR,            /* no indicator */
!     ECPGt_string,                /* trimmed (char *) type */
!     ECPGt_sqlda                /* C struct descriptor */
  };

   /* descriptor items */
diff -dcrpN pgsql.dyncursor/src/interfaces/ecpg/include/sqlda.h pgsql.sqlda/src/interfaces/ecpg/include/sqlda.h
*** pgsql.dyncursor/src/interfaces/ecpg/include/sqlda.h    2009-06-13 18:25:05.000000000 +0200
--- pgsql.sqlda/src/interfaces/ecpg/include/sqlda.h    2009-09-03 12:56:36.000000000 +0200
***************
*** 1,3 ****
--- 1,74 ----
  /*
   * $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqlda.h,v 1.4 2009/06/11 14:49:13 momjian Exp $
   */
+
+ #ifndef POSTGRES_SQLDA_H
+ #define POSTGRES_SQLDA_H
+
+ /* Define Informix "standard" types */
+ #ifndef C_H
+ typedef int        int4;
+ typedef    short        int2;
+ #endif
+ typedef    char        int1;
+
+ typedef    int        mint;
+ typedef    long        mlong;
+
+ typedef    short        MSHORT;
+ typedef    char        MCHAR;
+
+ typedef    unsigned int    uint4;
+ typedef    unsigned short    uint2;
+ typedef    unsigned char    uint1;
+
+ typedef    unsigned int    muint;
+ typedef    unsigned long    mulong;
+
+ typedef    unsigned short    MUSHORT;
+ typedef    unsigned char    MUCHAR;
+
+ #define MI_INT_SIZE     (sizeof(int)    * 8)
+ #define MI_LONG_SIZE    (sizeof(long)   * 8)
+ #define MI_PTR_SIZE     (sizeof(char *) * 8)
+
+ typedef struct sqlvar_struct
+ {
+     int2    sqltype;        /* variable type                */
+     int4    sqllen;            /* length in bytes              */
+     char       *sqldata;        /* pointer to data              */
+     int2       *sqlind;        /* pointer to indicator         */
+     char       *sqlname;        /* variable name                */
+     char       *sqlformat;        /* reserved for future use      */
+     int2    sqlitype;        /* ind variable type            */
+     int2    sqlilen;        /* ind length in bytes          */
+     char       *sqlidata;        /* ind data pointer             */
+     int4    sqlxid;            /* extended id type             */
+     char       *sqltypename;    /* extended type name           */
+     int2    sqltypelen;        /* length of extended type name */
+     int2    sqlownerlen;        /* length of owner name         */
+     int2    sqlsourcetype;        /* source type for distinct of built-ins */
+     char       *sqlownername;    /* owner name                   */
+     int4    sqlsourceid;        /* extended id of source type   */
+
+     /*
+      * sqlilongdata is new.  It supports data that exceeds the 32k
+      * limit.  sqlilen and sqlidata are for backward compatibility
+      * and they have maximum value of <32K.
+      */
+     char       *sqlilongdata;    /* for data field beyond 32K    */
+     int4    sqlflags;        /* for internal use only        */
+     void       *sqlreserved;    /* reserved for future use      */
+ } pg_sqlvar_t;
+
+ typedef struct sqlda
+ {
+     int2        sqld;
+     pg_sqlvar_t       *sqlvar;
+     char        desc_name[19];    /* descriptor name              */
+     int2        desc_occ;    /* size of sqlda structure      */
+     struct sqlda       *desc_next;    /* pointer to next sqlda struct */
+     void           *reserved;    /* reserved for future use */
+ } pg_sqlda_t;
+
+ #endif /* POSTGRES_SQLDA_H */
diff -dcrpN pgsql.dyncursor/src/interfaces/ecpg/include/sqltypes.h pgsql.sqlda/src/interfaces/ecpg/include/sqltypes.h
*** pgsql.dyncursor/src/interfaces/ecpg/include/sqltypes.h    2009-06-13 18:25:05.000000000 +0200
--- pgsql.sqlda/src/interfaces/ecpg/include/sqltypes.h    2009-09-03 12:56:36.000000000 +0200
***************
*** 30,33 ****
--- 30,55 ----
  #define CLVCHARPTRTYPE    124
  #define CTYPEMAX    25

+ /*
+  * Values used in sqlda->sqlvar[i]->sqltype
+  */
+ #define    SQLCHAR        0
+ #define    SQLSMINT    1
+ #define    SQLINT        2
+ #define    SQLFLOAT    3
+ #define    SQLSMFLOAT    4
+ #define    SQLDECIMAL    5
+ #define    SQLSERIAL    6
+ #define    SQLDATE        7
+ #define    SQLMONEY    8
+ #define    SQLDTIME    10
+ #define    SQLBYTES    11
+ #define    SQLTEXT        12
+ #define    SQLVCHAR    13
+ #define    SQLINTERVAL    14
+ #define    SQLNCHAR    15
+ #define    SQLNVCHAR    16
+ #define    SQLINT8        17
+ #define    SQLSERIAL8    18
+
  #endif   /* ndef ECPG_SQLTYPES_H */
diff -dcrpN pgsql.dyncursor/src/interfaces/ecpg/preproc/descriptor.c
pgsql.sqlda/src/interfaces/ecpg/preproc/descriptor.c
*** pgsql.dyncursor/src/interfaces/ecpg/preproc/descriptor.c    2009-01-30 17:28:46.000000000 +0100
--- pgsql.sqlda/src/interfaces/ecpg/preproc/descriptor.c    2009-09-03 12:56:36.000000000 +0200
*************** descriptor_variable(const char *name, in
*** 326,328 ****
--- 326,347 ----
      strlcpy(descriptor_names[input], name, sizeof(descriptor_names[input]));
      return (struct variable *) & varspace[input];
  }
+
+ struct variable *
+ sqlda_variable(const char *name)
+ {
+     struct variable *p = (struct variable *) mm_alloc(sizeof(struct variable));
+
+     p->name = mm_strdup(name);
+     p->type = (struct ECPGtype *) mm_alloc(sizeof(struct ECPGtype));
+     p->type->type = ECPGt_sqlda;
+     p->type->size = NULL;
+     p->type->struct_sizeof = NULL;
+     p->type->u.element = NULL;
+     p->type->lineno = 0;
+     p->brace_level = 0;
+     p->next = NULL;
+
+     return p;
+ }
+
diff -dcrpN pgsql.dyncursor/src/interfaces/ecpg/preproc/ecpg.addons pgsql.sqlda/src/interfaces/ecpg/preproc/ecpg.addons
*** pgsql.dyncursor/src/interfaces/ecpg/preproc/ecpg.addons    2009-09-03 12:31:30.000000000 +0200
--- pgsql.sqlda/src/interfaces/ecpg/preproc/ecpg.addons    2009-09-03 12:58:29.000000000 +0200
*************** ECPG: VariableShowStmtSHOWALL block
*** 407,426 ****
          $$ = EMPTY;
      }
  ECPG: FetchStmtMOVEfetch_args rule
!     | FETCH fetch_args ecpg_into
      {
          add_additional_variables(current_cursor, false);
          free(current_cursor);
          current_cursor = NULL;
          $$ = cat2_str(make_str("fetch"), $2);
      }
!     | FETCH FORWARD cursor_name opt_ecpg_into
      {
          char *cursor_marker = $3[0] == ':' ? make_str("$0") : $3;
          add_additional_variables($3, false);
          $$ = cat_str(2, make_str("fetch forward"), cursor_marker);
      }
!     | FETCH FORWARD from_in cursor_name opt_ecpg_into
      {
          char *cursor_marker = $4[0] == ':' ? make_str("$0") : $4;
          add_additional_variables($4, false);
--- 407,426 ----
          $$ = EMPTY;
      }
  ECPG: FetchStmtMOVEfetch_args rule
!     | FETCH fetch_args ecpg_fetch_into
      {
          add_additional_variables(current_cursor, false);
          free(current_cursor);
          current_cursor = NULL;
          $$ = cat2_str(make_str("fetch"), $2);
      }
!     | FETCH FORWARD cursor_name opt_ecpg_fetch_into
      {
          char *cursor_marker = $3[0] == ':' ? make_str("$0") : $3;
          add_additional_variables($3, false);
          $$ = cat_str(2, make_str("fetch forward"), cursor_marker);
      }
!     | FETCH FORWARD from_in cursor_name opt_ecpg_fetch_into
      {
          char *cursor_marker = $4[0] == ':' ? make_str("$0") : $4;
          add_additional_variables($4, false);
diff -dcrpN pgsql.dyncursor/src/interfaces/ecpg/preproc/ecpg.trailer
pgsql.sqlda/src/interfaces/ecpg/preproc/ecpg.trailer
*** pgsql.dyncursor/src/interfaces/ecpg/preproc/ecpg.trailer    2009-09-03 12:28:03.000000000 +0200
--- pgsql.sqlda/src/interfaces/ecpg/preproc/ecpg.trailer    2009-09-03 12:56:36.000000000 +0200
*************** ecpg_using:    USING using_list     { $$ = EMP
*** 1017,1035 ****

  using_descriptor: USING opt_sql SQL_DESCRIPTOR quoted_ident_stringvar
          {
!             add_variable_to_head(&argsinsert, descriptor_variable($4,0), &no_indicator);
              $$ = EMPTY;
          }
          ;

  into_descriptor: INTO opt_sql SQL_DESCRIPTOR quoted_ident_stringvar
          {
!             add_variable_to_head(&argsresult, descriptor_variable($4,1), &no_indicator);
              $$ = EMPTY;
          }
          ;

! opt_sql: /*EMPTY*/ | SQL_SQL;

  using_list: UsingValue | UsingValue ',' using_list;

--- 1017,1065 ----

  using_descriptor: USING opt_sql SQL_DESCRIPTOR quoted_ident_stringvar
          {
!             if (strlen($2) || !(INFORMIX_MODE))
!                 add_variable_to_head(&argsinsert, descriptor_variable($4,0), &no_indicator);
!             else
!             {
!                 if ($4[0] == '\"')
!                 {
!                     char *pos;
!
!                     $4[0] = ' ';
!                     for (pos = $4; *pos; pos++)
!                         if (*pos == '\"')
!                             *pos = ' ';
!                 }
!                 add_variable_to_head(&argsinsert, sqlda_variable($4), &no_indicator);
!             }
              $$ = EMPTY;
          }
          ;

  into_descriptor: INTO opt_sql SQL_DESCRIPTOR quoted_ident_stringvar
          {
!             if (strlen($2) || !(INFORMIX_MODE))
!                 add_variable_to_head(&argsresult, descriptor_variable($4,1), &no_indicator);
!             else
!             {
!                 if ($4[0] == '\"')
!                 {
!                     char *pos;
!
!                     $4[0] = ' ';
!                     for (pos = $4; *pos; pos++)
!                         if (*pos == '\"')
!                             *pos = ' ';
!                 }
!                 add_variable_to_head(&argsresult, sqlda_variable($4), &no_indicator);
!             }
              $$ = EMPTY;
          }
          ;

! opt_sql: /*EMPTY*/        { $$ = EMPTY; }
!         | SQL_SQL    { $$ = make_str("sql"); }
!         ;

  using_list: UsingValue | UsingValue ',' using_list;

*************** ecpg_into: INTO into_list    { $$ = EMPTY;
*** 2053,2060 ****
      ;


! opt_ecpg_into:    /* EMPTY */    { $$ = EMPTY; }
!     | ecpg_into        { $$ = $1; }

  %%

--- 2083,2106 ----
      ;


! ecpg_fetch_into: ecpg_into    { $$ = $1; }
!     | using_descriptor
!     {
!         struct variable *var;
!
!         if (!INFORMIX_MODE)
!             mmerror(PARSE_ERROR, ET_ERROR, "Not in Informix compatibility mode");
!
!         var = argsinsert->variable;
!         remove_variable_from_list(&argsinsert, var);
!         add_variable_to_head(&argsresult, var, &no_indicator);
!         $$ = $1;
!     }
!     ;
!
! opt_ecpg_fetch_into: /* EMPTY */    { $$ = EMPTY; }
!     | ecpg_fetch_into        { $$ = $1; }
!     ;

  %%

diff -dcrpN pgsql.dyncursor/src/interfaces/ecpg/preproc/ecpg.type pgsql.sqlda/src/interfaces/ecpg/preproc/ecpg.type
*** pgsql.dyncursor/src/interfaces/ecpg/preproc/ecpg.type    2009-09-03 12:28:03.000000000 +0200
--- pgsql.sqlda/src/interfaces/ecpg/preproc/ecpg.type    2009-09-03 12:56:36.000000000 +0200
***************
*** 62,67 ****
--- 62,68 ----
  %type <str> ecpg_ident
  %type <str> ecpg_interval
  %type <str> ecpg_into
+ %type <str> ecpg_fetch_into
  %type <str> ecpg_param
  %type <str> ecpg_sconst
  %type <str> ecpg_using
***************
*** 77,83 ****
  %type <str> opt_bit_field
  %type <str> opt_connection_name
  %type <str> opt_database_name
! %type <str> opt_ecpg_into
  %type <str> opt_ecpg_using
  %type <str> opt_initializer
  %type <str> opt_options
--- 78,84 ----
  %type <str> opt_bit_field
  %type <str> opt_connection_name
  %type <str> opt_database_name
! %type <str> opt_ecpg_fetch_into
  %type <str> opt_ecpg_using
  %type <str> opt_initializer
  %type <str> opt_options
***************
*** 87,92 ****
--- 88,94 ----
  %type <str> opt_reference
  %type <str> opt_scale
  %type <str> opt_server
+ %type <str> opt_sql
  %type <str> opt_user
  %type <str> opt_opt_value
  %type <str> ora_user
diff -dcrpN pgsql.dyncursor/src/interfaces/ecpg/preproc/extern.h pgsql.sqlda/src/interfaces/ecpg/preproc/extern.h
*** pgsql.dyncursor/src/interfaces/ecpg/preproc/extern.h    2009-09-03 12:28:03.000000000 +0200
--- pgsql.sqlda/src/interfaces/ecpg/preproc/extern.h    2009-09-03 12:56:36.000000000 +0200
*************** extern void add_descriptor(char *, char
*** 90,95 ****
--- 90,96 ----
  extern void drop_descriptor(char *, char *);
  extern struct descriptor *lookup_descriptor(char *, char *);
  extern struct variable *descriptor_variable(const char *name, int input);
+ extern struct variable *sqlda_variable(const char *name);
  extern void add_variable_to_head(struct arguments **, struct variable *, struct variable *);
  extern void add_variable_to_tail(struct arguments **, struct variable *, struct variable *);
  extern void remove_variable_from_list(struct arguments ** list, struct variable * var);
diff -dcrpN pgsql.dyncursor/src/interfaces/ecpg/preproc/type.c pgsql.sqlda/src/interfaces/ecpg/preproc/type.c
*** pgsql.dyncursor/src/interfaces/ecpg/preproc/type.c    2009-09-03 12:25:47.000000000 +0200
--- pgsql.sqlda/src/interfaces/ecpg/preproc/type.c    2009-09-03 12:56:36.000000000 +0200
*************** get_type(enum ECPGttype type)
*** 194,199 ****
--- 194,202 ----
          case ECPGt_descriptor:
              return ("ECPGt_descriptor");
              break;
+         case ECPGt_sqlda:
+             return ("ECPGt_sqlda");
+             break;
          case ECPGt_date:
              return ("ECPGt_date");
              break;
*************** ECPGdump_a_simple(FILE *o, const char *n
*** 328,333 ****
--- 331,338 ----
      else if (type == ECPGt_descriptor)
          /* remember that name here already contains quotes (if needed) */
          fprintf(o, "\n\tECPGt_descriptor, %s, 0L, 0L, 0L, ", name);
+     else if (type == ECPGt_sqlda)
+         fprintf(o, "\n\tECPGt_sqlda, &%s, 0L, 0L, 0L, ", name);
      else
      {
          char       *variable = (char *) mm_alloc(strlen(name) + ((prefix == NULL) ? 0 : strlen(prefix)) + 4);
diff -dcrpN pgsql.dyncursor/src/interfaces/ecpg/test/compat_informix/Makefile
pgsql.sqlda/src/interfaces/ecpg/test/compat_informix/Makefile
*** pgsql.dyncursor/src/interfaces/ecpg/test/compat_informix/Makefile    2009-09-03 12:28:03.000000000 +0200
--- pgsql.sqlda/src/interfaces/ecpg/test/compat_informix/Makefile    2009-09-03 12:56:36.000000000 +0200
*************** TESTS = test_informix test_informix.c \
*** 17,22 ****
--- 17,23 ----
          rfmtdate rfmtdate.c \
          rfmtlong rfmtlong.c \
          rnull rnull.c \
+         sqlda sqlda.c \
          charfuncs charfuncs.c

  all: $(TESTS)
*************** test_informix2.c: test_informix2.pgc ../
*** 30,35 ****
--- 31,39 ----
  cursor.c: cursor.pgc ../regression.h
      $(ECPG) -o $@ -I$(srcdir) $<

+ sqlda.c: sqlda.pgc ../regression.h
+     $(ECPG) -o $@ -I$(srcdir) $<
+
  dec_test.c: dec_test.pgc ../regression.h
      $(ECPG) -o $@ -I$(srcdir) $<

diff -dcrpN pgsql.dyncursor/src/interfaces/ecpg/test/compat_informix/sqlda.pgc
pgsql.sqlda/src/interfaces/ecpg/test/compat_informix/sqlda.pgc
*** pgsql.dyncursor/src/interfaces/ecpg/test/compat_informix/sqlda.pgc    1970-01-01 01:00:00.000000000 +0100
--- pgsql.sqlda/src/interfaces/ecpg/test/compat_informix/sqlda.pgc    2009-09-03 12:56:36.000000000 +0200
***************
*** 0 ****
--- 1,207 ----
+ #include <stdlib.h>
+ #include <string.h>
+ #include <inttypes.h>
+
+ exec sql include ../regression;
+
+ exec sql include sqlda.h;
+ exec sql include sqltypes.h;
+
+ exec sql whenever sqlerror stop;
+
+ /* These shouldn't be under DECLARE SECTION */
+ pg_sqlda_t    *inp_sqlda, *outp_sqlda;
+
+ static void
+ dump_sqlda(pg_sqlda_t *sqlda)
+ {
+     int    i;
+
+     for (i = 0; i < sqlda->sqld; i++)
+     {
+         if (outp_sqlda->sqlvar[i].sqlind && *(outp_sqlda->sqlvar[i].sqlind) == -1)
+             printf("name sqlda descriptor: '%s' value NULL'\n", outp_sqlda->sqlvar[i].sqlname);
+         else
+         switch (sqlda->sqlvar[i].sqltype)
+         {
+         case SQLCHAR:
+         case SQLVCHAR:
+         case SQLTEXT:
+             printf("name sqlda descriptor: '%s' value '%s'\n", sqlda->sqlvar[i].sqlname, sqlda->sqlvar[i].sqldata);
+             break;
+         case SQLSERIAL:
+         case SQLINT:
+             printf("name sqlda descriptor: '%s' value %d\n", sqlda->sqlvar[i].sqlname, *(int
*)sqlda->sqlvar[i].sqldata);
+             break;
+         case SQLSERIAL8:
+         case SQLINT8:
+             printf("name sqlda descriptor: '%s' value %" PRId64 "\n", sqlda->sqlvar[i].sqlname, *(int64_t
*)sqlda->sqlvar[i].sqldata);
+             break;
+         case SQLFLOAT:
+             printf("name sqlda descriptor: '%s' value %lf\n", sqlda->sqlvar[i].sqlname, *(double
*)sqlda->sqlvar[i].sqldata);
+             break;
+         case SQLDECIMAL:
+             {
+                 char    val[64];
+                 dectoasc((dec_t *)sqlda->sqlvar[i].sqldata, val, 64, -1);
+                 printf("name sqlda descriptor: '%s' value DECIMAL '%s'\n", sqlda->sqlvar[i].sqlname, val);
+                 break;
+             }
+         }
+     }
+ }
+
+ int
+ main (void)
+ {
+ exec sql begin declare section;
+     char    *stmt1 = "SELECT * FROM t1";
+     char    *stmt2 = "SELECT * FROM t1 WHERE id = ?";
+     int    rec;
+     int    id;
+ exec sql end declare section;
+
+     char msg[128];
+
+     ECPGdebug(1, stderr);
+
+     strcpy(msg, "connect");
+     exec sql connect to REGRESSDB1;
+
+     strcpy(msg, "set");
+     exec sql set datestyle to iso;
+
+     strcpy(msg, "create");
+     exec sql create table t1(
+         id integer,
+         t text,
+         d1 numeric,
+         d2 float8,
+         c char(10));
+
+     strcpy(msg, "insert");
+     exec sql insert into t1 values
+         (1, 'a', 1.0, 1, 'a'),
+         (2, null, null, null, null),
+         (3, '"c"', -3, 'nan'::float8, 'c'),
+         (4, 'd', 4.0, 4, 'd');
+
+     strcpy(msg, "commit");
+     exec sql commit;
+
+     /* SQLDA test for getting all records from a table */
+
+     outp_sqlda = NULL;
+
+     strcpy(msg, "prepare");
+     exec sql prepare st_id1 from :stmt1;
+
+     strcpy(msg, "declare");
+     exec sql declare mycur1 cursor for st_id1;
+
+     strcpy(msg, "open");
+     exec sql open mycur1;
+
+     exec sql whenever not found do break;
+
+     rec = 0;
+     while (1)
+     {
+         strcpy(msg, "fetch");
+         exec sql fetch 1 from mycur1 into descriptor outp_sqlda;
+
+         printf("FETCH RECORD %d\n", ++rec);
+         dump_sqlda(outp_sqlda);
+     }
+
+     exec sql whenever not found continue;
+
+     strcpy(msg, "close");
+     exec sql close mycur1;
+
+     strcpy(msg, "deallocate");
+     exec sql deallocate prepare st_id1;
+
+     free(outp_sqlda);
+
+     /* SQLDA test for getting all records from a table
+        using the Informix-specific FETCH ... USING DESCRIPTOR
+      */
+
+     outp_sqlda = NULL;
+
+     strcpy(msg, "prepare");
+     exec sql prepare st_id2 from :stmt1;
+
+     strcpy(msg, "declare");
+     exec sql declare mycur2 cursor for st_id2;
+
+     strcpy(msg, "open");
+     exec sql open mycur2;
+
+     exec sql whenever not found do break;
+
+     rec = 0;
+     while (1)
+     {
+         strcpy(msg, "fetch");
+         exec sql fetch from mycur2 using descriptor outp_sqlda;
+
+         printf("FETCH RECORD %d\n", ++rec);
+         dump_sqlda(outp_sqlda);
+     }
+
+     exec sql whenever not found continue;
+
+     strcpy(msg, "close");
+     exec sql close mycur2;
+
+     strcpy(msg, "deallocate");
+     exec sql deallocate prepare st_id2;
+
+     free(outp_sqlda);
+
+     /* SQLDA test for getting one record using an input descriptor */
+
+     /* Input sqlda has to be built manually */
+     inp_sqlda = (pg_sqlda_t *)malloc(sizeof(pg_sqlda_t));
+     memset(inp_sqlda, 0, sizeof(pg_sqlda_t));
+     inp_sqlda->sqld = 1;
+     inp_sqlda->sqlvar = malloc(sizeof(pg_sqlvar_t));
+     memset(inp_sqlda->sqlvar, 0, sizeof(pg_sqlvar_t));
+
+     inp_sqlda->sqlvar[0].sqltype = SQLINT;
+     inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+
+     printf("EXECUTE RECORD 4\n");
+
+     id = 4;
+
+     outp_sqlda = NULL;
+
+     strcpy(msg, "prepare");
+     exec sql prepare st_id3 FROM :stmt2;
+
+     strcpy(msg, "execute");
+     exec sql execute st_id3 using descriptor inp_sqlda into descriptor outp_sqlda;
+
+     dump_sqlda(outp_sqlda);
+
+     strcpy(msg, "deallocate");
+     exec sql deallocate prepare st_id3;
+
+     free(outp_sqlda);
+
+     /* End test */
+
+     strcpy(msg, "drop");
+     exec sql drop table t1;
+
+     strcpy(msg, "commit");
+     exec sql commit;
+
+     strcpy(msg, "disconnect");
+     exec sql disconnect;
+
+     return (0);
+ }
diff -dcrpN pgsql.dyncursor/src/interfaces/ecpg/test/ecpg_schedule pgsql.sqlda/src/interfaces/ecpg/test/ecpg_schedule
*** pgsql.dyncursor/src/interfaces/ecpg/test/ecpg_schedule    2009-09-03 12:28:03.000000000 +0200
--- pgsql.sqlda/src/interfaces/ecpg/test/ecpg_schedule    2009-09-03 12:56:36.000000000 +0200
*************** test: compat_informix/rfmtdate
*** 4,9 ****
--- 4,10 ----
  test: compat_informix/rfmtlong
  test: compat_informix/rnull
  test: compat_informix/cursor
+ test: compat_informix/sqlda
  test: compat_informix/test_informix
  test: compat_informix/test_informix2
  test: connect/test2
diff -dcrpN pgsql.dyncursor/src/interfaces/ecpg/test/ecpg_schedule_tcp
pgsql.sqlda/src/interfaces/ecpg/test/ecpg_schedule_tcp
*** pgsql.dyncursor/src/interfaces/ecpg/test/ecpg_schedule_tcp    2009-09-03 12:28:03.000000000 +0200
--- pgsql.sqlda/src/interfaces/ecpg/test/ecpg_schedule_tcp    2009-09-03 12:56:36.000000000 +0200
*************** test: compat_informix/rfmtdate
*** 4,9 ****
--- 4,10 ----
  test: compat_informix/rfmtlong
  test: compat_informix/rnull
  test: compat_informix/cursor
+ test: compat_informix/sqlda
  test: compat_informix/test_informix
  test: compat_informix/test_informix2
  test: connect/test2
diff -dcrpN pgsql.dyncursor/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c
pgsql.sqlda/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c
*** pgsql.dyncursor/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c    1970-01-01 01:00:00.000000000 +0100
--- pgsql.sqlda/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c    2009-09-03 13:09:00.000000000 +0200
***************
*** 0 ****
--- 1,506 ----
+ /* Processed by ecpg (regression mode) */
+ /* These include files are added by the preprocessor */
+ #include <ecpglib.h>
+ #include <ecpgerrno.h>
+ #include <sqlca.h>
+ /* Needed for informix compatibility */
+ #include <ecpg_informix.h>
+ /* End of automatic include section */
+ #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+
+ #line 1 "sqlda.pgc"
+ #include <stdlib.h>
+ #include <string.h>
+ #include <inttypes.h>
+
+
+ #line 1 "regression.h"
+
+
+
+
+
+
+ #line 5 "sqlda.pgc"
+
+
+
+ #line 1 "sqlda.h"
+ /*
+  * $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqlda.h,v 1.4 2009/06/11 14:49:13 momjian Exp $
+  */
+
+ #ifndef POSTGRES_SQLDA_H
+ #define POSTGRES_SQLDA_H
+
+ /* Define Informix "standard" types */
+ #ifndef C_H
+ typedef int        int4;
+ typedef    short        int2;
+ #endif
+ typedef    char        int1;
+
+ typedef    int        mint;
+ typedef    long        mlong;
+
+ typedef    short        MSHORT;
+ typedef    char        MCHAR;
+
+ typedef    unsigned int    uint4;
+ typedef    unsigned short    uint2;
+ typedef    unsigned char    uint1;
+
+ typedef    unsigned int    muint;
+ typedef    unsigned long    mulong;
+
+ typedef    unsigned short    MUSHORT;
+ typedef    unsigned char    MUCHAR;
+
+ #define MI_INT_SIZE     (sizeof(int)    * 8)
+ #define MI_LONG_SIZE    (sizeof(long)   * 8)
+ #define MI_PTR_SIZE     (sizeof(char *) * 8)
+
+ typedef struct sqlvar_struct
+ {
+     int2    sqltype;        /* variable type                */
+     int4    sqllen;            /* length in bytes              */
+     char       *sqldata;        /* pointer to data              */
+     int2       *sqlind;        /* pointer to indicator         */
+     char       *sqlname;        /* variable name                */
+     char       *sqlformat;        /* reserved for future use      */
+     int2    sqlitype;        /* ind variable type            */
+     int2    sqlilen;        /* ind length in bytes          */
+     char       *sqlidata;        /* ind data pointer             */
+     int4    sqlxid;            /* extended id type             */
+     char       *sqltypename;    /* extended type name           */
+     int2    sqltypelen;        /* length of extended type name */
+     int2    sqlownerlen;        /* length of owner name         */
+     int2    sqlsourcetype;        /* source type for distinct of built-ins */
+     char       *sqlownername;    /* owner name                   */
+     int4    sqlsourceid;        /* extended id of source type   */
+
+     /*
+      * sqlilongdata is new.  It supports data that exceeds the 32k
+      * limit.  sqlilen and sqlidata are for backward compatibility
+      * and they have maximum value of <32K.
+      */
+     char       *sqlilongdata;    /* for data field beyond 32K    */
+     int4    sqlflags;        /* for internal use only        */
+     void       *sqlreserved;    /* reserved for future use      */
+ } pg_sqlvar_t;
+
+ typedef struct sqlda
+ {
+     int2        sqld;
+     pg_sqlvar_t       *sqlvar;
+     char        desc_name[19];    /* descriptor name              */
+     int2        desc_occ;    /* size of sqlda structure      */
+     struct sqlda       *desc_next;    /* pointer to next sqlda struct */
+     void           *reserved;    /* reserved for future use */
+ } pg_sqlda_t;
+
+ #endif /* POSTGRES_SQLDA_H */
+
+ #line 7 "sqlda.pgc"
+
+
+ #line 1 "sqltypes.h"
+ /*
+  * $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqltypes.h,v 1.9 2009/06/11 14:49:13 momjian Exp $
+  */
+ #ifndef ECPG_SQLTYPES_H
+ #define ECPG_SQLTYPES_H
+
+ #define CCHARTYPE    ECPGt_char
+ #define CSHORTTYPE    ECPGt_short
+ #define CINTTYPE    ECPGt_int
+ #define CLONGTYPE    ECPGt_long
+ #define CFLOATTYPE    ECPGt_float
+ #define CDOUBLETYPE ECPGt_double
+ #define CDECIMALTYPE    ECPGt_decimal
+ #define CFIXCHARTYPE    108
+ #define CSTRINGTYPE ECPGt_char
+ #define CDATETYPE    ECPGt_date
+ #define CMONEYTYPE    111
+ #define CDTIMETYPE    ECPGt_timestamp
+ #define CLOCATORTYPE    113
+ #define CVCHARTYPE    ECPGt_varchar
+ #define CINVTYPE    115
+ #define CFILETYPE    116
+ #define CINT8TYPE    ECPGt_long_long
+ #define CCOLLTYPE        118
+ #define CLVCHARTYPE        119
+ #define CFIXBINTYPE        120
+ #define CVARBINTYPE        121
+ #define CBOOLTYPE        ECPGt_bool
+ #define CROWTYPE        123
+ #define CLVCHARPTRTYPE    124
+ #define CTYPEMAX    25
+
+ /*
+  * Values used in sqlda->sqlvar[i]->sqltype
+  */
+ #define    SQLCHAR        0
+ #define    SQLSMINT    1
+ #define    SQLINT        2
+ #define    SQLFLOAT    3
+ #define    SQLSMFLOAT    4
+ #define    SQLDECIMAL    5
+ #define    SQLSERIAL    6
+ #define    SQLDATE        7
+ #define    SQLMONEY    8
+ #define    SQLDTIME    10
+ #define    SQLBYTES    11
+ #define    SQLTEXT        12
+ #define    SQLVCHAR    13
+ #define    SQLINTERVAL    14
+ #define    SQLNCHAR    15
+ #define    SQLNVCHAR    16
+ #define    SQLINT8        17
+ #define    SQLSERIAL8    18
+
+ #endif   /* ndef ECPG_SQLTYPES_H */
+
+ #line 8 "sqlda.pgc"
+
+
+ /* exec sql whenever sqlerror  stop ; */
+ #line 10 "sqlda.pgc"
+
+
+ /* These shouldn't be under DECLARE SECTION */
+ pg_sqlda_t    *inp_sqlda, *outp_sqlda;
+
+ static void
+ dump_sqlda(pg_sqlda_t *sqlda)
+ {
+     int    i;
+
+     for (i = 0; i < sqlda->sqld; i++)
+     {
+         if (outp_sqlda->sqlvar[i].sqlind && *(outp_sqlda->sqlvar[i].sqlind) == -1)
+             printf("name sqlda descriptor: '%s' value NULL'\n", outp_sqlda->sqlvar[i].sqlname);
+         else
+         switch (sqlda->sqlvar[i].sqltype)
+         {
+         case SQLCHAR:
+         case SQLVCHAR:
+         case SQLTEXT:
+             printf("name sqlda descriptor: '%s' value '%s'\n", sqlda->sqlvar[i].sqlname, sqlda->sqlvar[i].sqldata);
+             break;
+         case SQLSERIAL:
+         case SQLINT:
+             printf("name sqlda descriptor: '%s' value %d\n", sqlda->sqlvar[i].sqlname, *(int
*)sqlda->sqlvar[i].sqldata);
+             break;
+         case SQLSERIAL8:
+         case SQLINT8:
+             printf("name sqlda descriptor: '%s' value %" PRId64 "\n", sqlda->sqlvar[i].sqlname, *(int64_t
*)sqlda->sqlvar[i].sqldata);
+             break;
+         case SQLFLOAT:
+             printf("name sqlda descriptor: '%s' value %lf\n", sqlda->sqlvar[i].sqlname, *(double
*)sqlda->sqlvar[i].sqldata);
+             break;
+         case SQLDECIMAL:
+             {
+                 char    val[64];
+                 dectoasc((decimal *)sqlda->sqlvar[i].sqldata, val, 64, -1);
+                 printf("name sqlda descriptor: '%s' value DECIMAL '%s'\n", sqlda->sqlvar[i].sqlname, val);
+                 break;
+             }
+         }
+     }
+ }
+
+ int
+ main (void)
+ {
+ /* exec sql begin declare section */
+
+
+
+
+
+ #line 58 "sqlda.pgc"
+  char * stmt1 = "SELECT * FROM t1" ;
+
+ #line 59 "sqlda.pgc"
+  char * stmt2 = "SELECT * FROM t1 WHERE id = ?" ;
+
+ #line 60 "sqlda.pgc"
+  int rec ;
+
+ #line 61 "sqlda.pgc"
+  int id ;
+ /* exec sql end declare section */
+ #line 62 "sqlda.pgc"
+
+
+     char msg[128];
+
+     ECPGdebug(1, stderr);
+
+     strcpy(msg, "connect");
+     { ECPGconnect(__LINE__, 1, "regress1" , NULL, NULL , NULL, 0);
+ #line 69 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 69 "sqlda.pgc"
+
+
+     strcpy(msg, "set");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
+ #line 72 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 72 "sqlda.pgc"
+
+
+     strcpy(msg, "create");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "create table t1 ( id integer , t text , d1 numeric , d2 float8
,c char ( 10 ) )", ECPGt_EOIT, ECPGt_EORT); 
+ #line 80 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 80 "sqlda.pgc"
+
+
+     strcpy(msg, "insert");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into t1 values ( 1 , 'a' , 1.0 , 1 , 'a' ) , ( 2 , null
,null , null , null ) , ( 3 , '\"c\"' , - 3 , 'nan' :: float8 , 'c' ) , ( 4 , 'd' , 4.0 , 4 , 'd' )", ECPGt_EOIT,
ECPGt_EORT);
+ #line 87 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 87 "sqlda.pgc"
+
+
+     strcpy(msg, "commit");
+     { ECPGtrans(__LINE__, NULL, "commit");
+ #line 90 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 90 "sqlda.pgc"
+
+
+     /* SQLDA test for getting all records from a table */
+
+     outp_sqlda = NULL;
+
+     strcpy(msg, "prepare");
+     { ECPGprepare(__LINE__, NULL, 0, "st_id1", stmt1);
+ #line 97 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 97 "sqlda.pgc"
+
+
+     strcpy(msg, "declare");
+     ECPG_informix_reset_sqlca(); /* declare mycur1 cursor for $1 */
+ #line 100 "sqlda.pgc"
+
+
+     strcpy(msg, "open");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare mycur1 cursor for $1",
+     ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id1", __LINE__)),(long)1,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 103 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 103 "sqlda.pgc"
+
+
+     /* exec sql whenever not found  break ; */
+ #line 105 "sqlda.pgc"
+
+
+     rec = 0;
+     while (1)
+     {
+         strcpy(msg, "fetch");
+         { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch 1 from mycur1", ECPGt_EOIT,
+     ECPGt_sqlda, & outp_sqlda , 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 111 "sqlda.pgc"
+
+ if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
+ #line 111 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 111 "sqlda.pgc"
+
+
+         printf("FETCH RECORD %d\n", ++rec);
+         dump_sqlda(outp_sqlda);
+     }
+
+     /* exec sql whenever not found  continue ; */
+ #line 117 "sqlda.pgc"
+
+
+     strcpy(msg, "close");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "close mycur1", ECPGt_EOIT, ECPGt_EORT);
+ #line 120 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 120 "sqlda.pgc"
+
+
+     strcpy(msg, "deallocate");
+     { ECPGdeallocate(__LINE__, 1, NULL, "st_id1");
+ #line 123 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 123 "sqlda.pgc"
+
+
+     free(outp_sqlda);
+
+     /* SQLDA test for getting all records from a table
+        using the Informix-specific FETCH ... USING DESCRIPTOR
+      */
+
+     outp_sqlda = NULL;
+
+     strcpy(msg, "prepare");
+     { ECPGprepare(__LINE__, NULL, 0, "st_id2", stmt1);
+ #line 134 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 134 "sqlda.pgc"
+
+
+     strcpy(msg, "declare");
+     ECPG_informix_reset_sqlca(); /* declare mycur2 cursor for $1 */
+ #line 137 "sqlda.pgc"
+
+
+     strcpy(msg, "open");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare mycur2 cursor for $1",
+     ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id2", __LINE__)),(long)1,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 140 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 140 "sqlda.pgc"
+
+
+     /* exec sql whenever not found  break ; */
+ #line 142 "sqlda.pgc"
+
+
+     rec = 0;
+     while (1)
+     {
+         strcpy(msg, "fetch");
+         { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch from mycur2", ECPGt_EOIT,
+     ECPGt_sqlda, & outp_sqlda , 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 148 "sqlda.pgc"
+
+ if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
+ #line 148 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 148 "sqlda.pgc"
+
+
+         printf("FETCH RECORD %d\n", ++rec);
+         dump_sqlda(outp_sqlda);
+     }
+
+     /* exec sql whenever not found  continue ; */
+ #line 154 "sqlda.pgc"
+
+
+     strcpy(msg, "close");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "close mycur2", ECPGt_EOIT, ECPGt_EORT);
+ #line 157 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 157 "sqlda.pgc"
+
+
+     strcpy(msg, "deallocate");
+     { ECPGdeallocate(__LINE__, 1, NULL, "st_id2");
+ #line 160 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 160 "sqlda.pgc"
+
+
+     free(outp_sqlda);
+
+     /* SQLDA test for getting one record using an input descriptor */
+
+     /* Input sqlda has to be built manually */
+     inp_sqlda = (pg_sqlda_t *)malloc(sizeof(pg_sqlda_t));
+     memset(inp_sqlda, 0, sizeof(pg_sqlda_t));
+     inp_sqlda->sqld = 1;
+     inp_sqlda->sqlvar = malloc(sizeof(pg_sqlvar_t));
+     memset(inp_sqlda->sqlvar, 0, sizeof(pg_sqlvar_t));
+
+     inp_sqlda->sqlvar[0].sqltype = SQLINT;
+     inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+
+     printf("EXECUTE RECORD 4\n");
+
+     id = 4;
+
+     outp_sqlda = NULL;
+
+     strcpy(msg, "prepare");
+     { ECPGprepare(__LINE__, NULL, 0, "st_id3", stmt2);
+ #line 183 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 183 "sqlda.pgc"
+
+
+     strcpy(msg, "execute");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, 1, "st_id3",
+     ECPGt_sqlda, & inp_sqlda , 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_sqlda, & outp_sqlda , 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 186 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 186 "sqlda.pgc"
+
+
+     dump_sqlda(outp_sqlda);
+
+     strcpy(msg, "deallocate");
+     { ECPGdeallocate(__LINE__, 1, NULL, "st_id3");
+ #line 191 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 191 "sqlda.pgc"
+
+
+     free(outp_sqlda);
+
+     /* End test */
+
+     strcpy(msg, "drop");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT);
+ #line 198 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 198 "sqlda.pgc"
+
+
+     strcpy(msg, "commit");
+     { ECPGtrans(__LINE__, NULL, "commit");
+ #line 201 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 201 "sqlda.pgc"
+
+
+     strcpy(msg, "disconnect");
+     { ECPGdisconnect(__LINE__, "CURRENT");
+ #line 204 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 204 "sqlda.pgc"
+
+
+     return (0);
+ }
diff -dcrpN pgsql.dyncursor/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stderr
pgsql.sqlda/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stderr
*** pgsql.dyncursor/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stderr    1970-01-01 01:00:00.000000000
+0100
--- pgsql.sqlda/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stderr    2009-09-03 13:08:49.000000000 +0200
***************
*** 0 ****
--- 1,224 ----
+ [NO_PID]: ECPGdebug: set to 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 72: query: set datestyle to iso; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 72: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 72: OK: SET
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 75: query: create table t1 ( id integer , t text , d1 numeric , d2 float8 , c char (
10) ); with 0 parameter(s) on connection regress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 75: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 75: OK: CREATE TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 83: query: insert into t1 values ( 1 , 'a' , 1.0 , 1 , 'a' ) , ( 2 , null , null ,
null, null ) , ( 3 , '"c"' , - 3 , 'nan' :: float8 , 'c' ) , ( 4 , 'd' , 4.0 , 4 , 'd' ); with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 83: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 83: OK: INSERT 0 4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 90: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 97: name st_id1; query: "SELECT * FROM t1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 103: query: declare mycur1 cursor for SELECT * FROM t1; with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 103: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 103: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 111: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 111: RESULT: 1.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 111: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 111: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 111: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 111: RESULT: -3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 111: RESULT: NaN offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 111: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 111: RESULT: 4.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 111: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: correctly got 0 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: raising sqlcode 100 on line 111: no data found on line 111
+ [NO_PID]: sqlca: code: 100, state: 02000
+ [NO_PID]: ecpg_execute on line 120: query: close mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 120: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 120: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 123: name st_id1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 134: name st_id2; query: "SELECT * FROM t1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 140: query: declare mycur2 cursor for SELECT * FROM t1; with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 140: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 140: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: query: fetch from mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: 1.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: query: fetch from mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: query: fetch from mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: -3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: NaN offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: query: fetch from mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: 4.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: query: fetch from mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: correctly got 0 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: raising sqlcode 100 on line 148: no data found on line 148
+ [NO_PID]: sqlca: code: 100, state: 02000
+ [NO_PID]: ecpg_execute on line 157: query: close mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 157: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 157: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 160: name st_id2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 183: name st_id3; query: "SELECT * FROM t1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 186: query: SELECT * FROM t1 WHERE id = $1; with 1 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 186: using PQexecPrepared for "SELECT * FROM t1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: free_params on line 186: parameter 1 = 4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 186: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 186: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 186: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 186: RESULT: 4.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 186: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 186: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 191: name st_id3
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 198: query: drop table t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 198: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 198: OK: DROP TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 201: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection regress1 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
diff -dcrpN pgsql.dyncursor/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stdout
pgsql.sqlda/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stdout
*** pgsql.dyncursor/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stdout    1970-01-01 01:00:00.000000000
+0100
--- pgsql.sqlda/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stdout    2009-09-03 12:56:36.000000000 +0200
***************
*** 0 ****
--- 1,54 ----
+ FETCH RECORD 1
+ name sqlda descriptor: 'id' value 1
+ name sqlda descriptor: 't' value 'a'
+ name sqlda descriptor: 'd1' value DECIMAL '1.0'
+ name sqlda descriptor: 'd2' value 1.000000
+ name sqlda descriptor: 'c' value 'a         '
+ FETCH RECORD 2
+ name sqlda descriptor: 'id' value 2
+ name sqlda descriptor: 't' value NULL'
+ name sqlda descriptor: 'd1' value NULL'
+ name sqlda descriptor: 'd2' value NULL'
+ name sqlda descriptor: 'c' value NULL'
+ FETCH RECORD 3
+ name sqlda descriptor: 'id' value 3
+ name sqlda descriptor: 't' value '"c"'
+ name sqlda descriptor: 'd1' value DECIMAL '-3'
+ name sqlda descriptor: 'd2' value nan
+ name sqlda descriptor: 'c' value 'c         '
+ FETCH RECORD 4
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'd'
+ name sqlda descriptor: 'd1' value DECIMAL '4.0'
+ name sqlda descriptor: 'd2' value 4.000000
+ name sqlda descriptor: 'c' value 'd         '
+ FETCH RECORD 1
+ name sqlda descriptor: 'id' value 1
+ name sqlda descriptor: 't' value 'a'
+ name sqlda descriptor: 'd1' value DECIMAL '1.0'
+ name sqlda descriptor: 'd2' value 1.000000
+ name sqlda descriptor: 'c' value 'a         '
+ FETCH RECORD 2
+ name sqlda descriptor: 'id' value 2
+ name sqlda descriptor: 't' value NULL'
+ name sqlda descriptor: 'd1' value NULL'
+ name sqlda descriptor: 'd2' value NULL'
+ name sqlda descriptor: 'c' value NULL'
+ FETCH RECORD 3
+ name sqlda descriptor: 'id' value 3
+ name sqlda descriptor: 't' value '"c"'
+ name sqlda descriptor: 'd1' value DECIMAL '-3'
+ name sqlda descriptor: 'd2' value nan
+ name sqlda descriptor: 'c' value 'c         '
+ FETCH RECORD 4
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'd'
+ name sqlda descriptor: 'd1' value DECIMAL '4.0'
+ name sqlda descriptor: 'd2' value 4.000000
+ name sqlda descriptor: 'c' value 'd         '
+ EXECUTE RECORD 4
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'd'
+ name sqlda descriptor: 'd1' value DECIMAL '4.0'
+ name sqlda descriptor: 'd2' value 4.000000
+ name sqlda descriptor: 'c' value 'd         '

Re: ECPG patchset

From
Boszormenyi Zoltan
Date:
DESCRIBE [OUTPUT] support

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
http://www.postgresql.at/

diff -dcrpN pgsql.sqlda/src/interfaces/ecpg/ecpglib/descriptor.c
pgsql.describe/src/interfaces/ecpg/ecpglib/descriptor.c
*** pgsql.sqlda/src/interfaces/ecpg/ecpglib/descriptor.c    2009-08-07 13:06:28.000000000 +0200
--- pgsql.describe/src/interfaces/ecpg/ecpglib/descriptor.c    2009-09-03 13:19:41.000000000 +0200
***************
*** 13,18 ****
--- 13,19 ----
  #include "ecpgerrno.h"
  #include "extern.h"
  #include "sqlca.h"
+ #include "sqlda.h"
  #include "sql3types.h"

  static void descriptor_free(struct descriptor * desc);
*************** get_char_item(int lineno, void *var, enu
*** 226,231 ****
--- 227,238 ----
      return (true);
  }

+ #define RETURN_IF_NO_DATA    if (ntuples < 1) \
+                 { \
+                     ecpg_raise(lineno, ECPG_NOT_FOUND, ECPG_SQLSTATE_NO_DATA, NULL); \
+                     return (false); \
+                 }
+
  bool
  ECPGget_desc(int lineno, const char *desc_name, int index,...)
  {
*************** ECPGget_desc(int lineno, const char *des
*** 244,254 ****
          return (false);

      ntuples = PQntuples(ECPGresult);
-     if (ntuples < 1)
-     {
-         ecpg_raise(lineno, ECPG_NOT_FOUND, ECPG_SQLSTATE_NO_DATA, NULL);
-         return (false);
-     }

      if (index < 1 || index > PQnfields(ECPGresult))
      {
--- 251,256 ----
*************** ECPGget_desc(int lineno, const char *des
*** 283,288 ****
--- 285,291 ----
          switch (type)
          {
              case (ECPGd_indicator):
+                 RETURN_IF_NO_DATA;
                  data_var.ind_type = vartype;
                  data_var.ind_pointer = var;
                  data_var.ind_varcharsize = varcharsize;
*************** ECPGget_desc(int lineno, const char *des
*** 295,300 ****
--- 298,304 ----
                  break;

              case ECPGd_data:
+                 RETURN_IF_NO_DATA;
                  data_var.type = vartype;
                  data_var.pointer = var;
                  data_var.varcharsize = varcharsize;
*************** ECPGget_desc(int lineno, const char *des
*** 377,382 ****
--- 381,387 ----
              case ECPGd_ret_length:
              case ECPGd_ret_octet:

+                 RETURN_IF_NO_DATA;
                  /*
                   * this is like ECPGstore_result
                   */
*************** ECPGget_desc(int lineno, const char *des
*** 480,485 ****
--- 485,491 ----
      sqlca->sqlerrd[2] = ntuples;
      return (true);
  }
+ #undef RETURN_IF_NO_DATA

  bool
  ECPGset_desc_header(int lineno, const char *desc_name, int count)
*************** ecpg_find_desc(int line, const char *nam
*** 722,730 ****
      return NULL;                /* not found */
  }

  bool
! ECPGdescribe(int line, bool input, const char *statement,...)
  {
!     ecpg_log("ECPGdescribe called on line %d for %s: %s\n", line, input ? "input" : "output", statement);
!     return false;
  }
--- 728,841 ----
      return NULL;                /* not found */
  }

+ static pg_sqlda_t*
+ build_sqlda(int lineno, bool input, const char *connection_name, const char *stmt_name)
+ {
+     struct connection *con;
+     PGresult    *res;
+     pg_sqlda_t    *sqlda = NULL;
+
+     con = ecpg_get_connection(connection_name);
+     res = PQdescribePrepared(con->connection, stmt_name);
+     if (!ecpg_check_PQresult(res, lineno, con->connection, ECPG_COMPAT_INFORMIX))
+         return NULL;
+
+     sqlda = ecpg_build_sqlda_for_PGresult(lineno, res, -1);
+
+     PQclear(res);
+     return sqlda;
+ }
+
  bool
! ECPGdescribe(int line, bool input, const char *connection_name, const char *stmt_name, ...)
  {
!     bool        ret = false;
!     va_list        args;
!
!     /* DESCRIBE INPUT is not yet supported */
!     if (input)
!         return false;
!
!     va_start(args, stmt_name);
!
!     for (;;)
!     {
!         enum ECPGttype    type, dummy_type;
!         void        *ptr, *dummy_ptr;
!         long        dummy;
!
!         /* variable type */
!         type = va_arg(args, enum ECPGttype);
!
!         if (type == ECPGt_EORT)
!             break;
!
!         /* rest of variable parameters*/
!         ptr = va_arg(args, void *);
!         dummy = va_arg(args, long);
!         dummy = va_arg(args, long);
!         dummy = va_arg(args, long);
!
!         /* variable indicator */
!         dummy_type = va_arg(args, enum ECPGttype);
!         dummy_ptr = va_arg(args, void *);
!         dummy = va_arg(args, long);
!         dummy = va_arg(args, long);
!         dummy = va_arg(args, long);
!
!         switch (type)
!         {
!             case ECPGt_descriptor:
!             {
!                 char    *name = ptr;
!                 struct connection *con = ecpg_get_connection(connection_name);
!                 struct descriptor *desc = ecpg_find_desc(line, name);
!                 PGresult    *res;
!                 ExecStatusType  ret;
!
!                 if (con == NULL)
!                     break;
!                 if (desc == NULL)
!                     break;
!
!                 res = PQdescribePrepared(con->connection, stmt_name);
!                 ret = PQresultStatus(res);
!                 if (ecpg_check_PQresult(res, line, con->connection, ECPG_COMPAT_PGSQL))
!                 {
!                     if (desc->result != NULL)
!                         PQclear(desc->result);
!                     desc->result = res;
!                     ret = true;
!                 }
!                 break;
!             }
!             case ECPGt_sqlda:
!             {
!                 pg_sqlda_t **sqlda_ptr = ptr;
!                 pg_sqlda_t *sqlda_new;
!
!                 sqlda_new = build_sqlda(line, input, connection_name, stmt_name);
!                 if (sqlda_new)
!                 {
! #if 0
!                     /*
!                      * We should free the old pointer but we can't be sure
!                      * if the pointer is valid. Only the calling application can.
!                      */
!                     pg_sqlda_t *sqlda_old = *sqlda_ptr;
!                     if (sqlda_old)
!                         free(sqlda_old);
! #endif
!                     *sqlda_ptr = sqlda_new;
!                     ret = true;
!                 }
!                 break;
!             }
!             default:
!                 /* nothing else may come */
!                 ;
!         }
!     }
!
!     return ret;
  }
diff -dcrpN pgsql.sqlda/src/interfaces/ecpg/include/ecpglib.h pgsql.describe/src/interfaces/ecpg/include/ecpglib.h
*** pgsql.sqlda/src/interfaces/ecpg/include/ecpglib.h    2009-06-13 18:25:05.000000000 +0200
--- pgsql.describe/src/interfaces/ecpg/include/ecpglib.h    2009-09-03 13:14:28.000000000 +0200
*************** bool        ECPGset_desc(int, const char *, in
*** 83,89 ****

  void        ECPGset_noind_null(enum ECPGttype, void *);
  bool        ECPGis_noind_null(enum ECPGttype, void *);
! bool        ECPGdescribe(int, bool, const char *,...);

  /* dynamic result allocation */
  void        ECPGfree_auto_mem(void);
--- 83,89 ----

  void        ECPGset_noind_null(enum ECPGttype, void *);
  bool        ECPGis_noind_null(enum ECPGttype, void *);
! bool        ECPGdescribe(int, bool, const char *, const char *, ...);

  /* dynamic result allocation */
  void        ECPGfree_auto_mem(void);
diff -dcrpN pgsql.sqlda/src/interfaces/ecpg/preproc/ecpg.trailer
pgsql.describe/src/interfaces/ecpg/preproc/ecpg.trailer
*** pgsql.sqlda/src/interfaces/ecpg/preproc/ecpg.trailer    2009-09-03 12:56:36.000000000 +0200
--- pgsql.describe/src/interfaces/ecpg/preproc/ecpg.trailer    2009-09-03 13:14:28.000000000 +0200
*************** ECPGCursorStmt:  DECLARE cursor_name cur
*** 354,360 ****
                  add_variable_to_head(&(this->argsinsert), var, &no_indicator);
              }
              add_variable_to_head(&(this->argsinsert), thisquery, &no_indicator);
-
              cur = this;

              if (INFORMIX_MODE && braces_open > 0) /* we're in a function */
--- 354,359 ----
*************** into_descriptor: INTO opt_sql SQL_DESCRI
*** 1057,1062 ****
--- 1056,1068 ----
          }
          ;

+ into_sqlda: INTO name
+         {
+             add_variable_to_head(&argsresult, sqlda_variable($2), &no_indicator);
+             $$ = EMPTY;
+         }
+         ;
+
  opt_sql: /*EMPTY*/        { $$ = EMPTY; }
          | SQL_SQL    { $$ = make_str("sql"); }
          ;
*************** ECPGDescribe: SQL_DESCRIBE INPUT_P name
*** 1092,1113 ****
      {
          const char *con = connection ? connection : "NULL";
          mmerror(PARSE_ERROR, ET_WARNING, "using unsupported DESCRIBE statement");
!         $$ = (char *) mm_alloc(sizeof("1, ECPGprepared_statement(, \"\", __LINE__)") + strlen(con) + strlen($3));
!         sprintf($$, "1, ECPGprepared_statement(%s, \"%s\", __LINE__)", con, $3);
      }
      | SQL_DESCRIBE opt_output name using_descriptor
      {
          const char *con = connection ? connection : "NULL";
!         mmerror(PARSE_ERROR, ET_WARNING, "using unsupported DESCRIBE statement");
!         $$ = (char *) mm_alloc(sizeof("0, ECPGprepared_statement(, \"\", __LINE__)") + strlen(con) + strlen($3));
!         sprintf($$, "0, ECPGprepared_statement(%s, \"%s\", __LINE__)", con, $3);
      }
      | SQL_DESCRIBE opt_output name into_descriptor
      {
          const char *con = connection ? connection : "NULL";
          mmerror(PARSE_ERROR, ET_WARNING, "using unsupported DESCRIBE statement");
!         $$ = (char *) mm_alloc(sizeof("0, ECPGprepared_statement(, \"\", __LINE__)") + strlen(con) + strlen($3));
!         sprintf($$, "0, ECPGprepared_statement(%s, \"%s\", __LINE__)", con, $3);
      }
      ;

--- 1098,1140 ----
      {
          const char *con = connection ? connection : "NULL";
          mmerror(PARSE_ERROR, ET_WARNING, "using unsupported DESCRIBE statement");
!         $$ = (char *) mm_alloc(sizeof("1, , \"\"") + strlen(con) + strlen($3));
!         sprintf($$, "1, %s, \"%s\"", con, $3);
      }
      | SQL_DESCRIBE opt_output name using_descriptor
      {
          const char *con = connection ? connection : "NULL";
!         struct variable *var;
!
!         var = argsinsert->variable;
!         remove_variable_from_list(&argsinsert, var);
!         add_variable_to_head(&argsresult, var, &no_indicator);
!
!         $$ = (char *) mm_alloc(sizeof("0, , \"\"") + strlen(con) + strlen($3));
!         sprintf($$, "0, %s, \"%s\"", con, $3);
      }
      | SQL_DESCRIBE opt_output name into_descriptor
      {
          const char *con = connection ? connection : "NULL";
+         $$ = (char *) mm_alloc(sizeof("0, , \"\"") + strlen(con) + strlen($3));
+         sprintf($$, "0, %s, \"%s\"", con, $3);
+     }
+     | SQL_DESCRIBE INPUT_P name into_sqlda
+     {
+         const char *con = connection ? connection : "NULL";
          mmerror(PARSE_ERROR, ET_WARNING, "using unsupported DESCRIBE statement");
!         if (!INFORMIX_MODE)
!             mmerror(PARSE_ERROR, ET_ERROR, "Not in Informix compatibility mode");
!         $$ = (char *) mm_alloc(sizeof("1, , \"\"") + strlen(con) + strlen($3));
!         sprintf($$, "1, %s, \"%s\"", con, $3);
!     }
!     | SQL_DESCRIBE opt_output name into_sqlda
!     {
!         const char *con = connection ? connection : "NULL";
!         if (!INFORMIX_MODE)
!             mmerror(PARSE_ERROR, ET_ERROR, "Not in Informix compatibility mode");
!         $$ = (char *) mm_alloc(sizeof("0, , \"\"") + strlen(con) + strlen($3));
!         sprintf($$, "0, %s, \"%s\"", con, $3);
      }
      ;

diff -dcrpN pgsql.sqlda/src/interfaces/ecpg/preproc/ecpg.type pgsql.describe/src/interfaces/ecpg/preproc/ecpg.type
*** pgsql.sqlda/src/interfaces/ecpg/preproc/ecpg.type    2009-09-03 12:56:36.000000000 +0200
--- pgsql.describe/src/interfaces/ecpg/preproc/ecpg.type    2009-09-03 13:14:28.000000000 +0200
***************
*** 73,78 ****
--- 73,79 ----
  %type <str> execute_rest
  %type <str> indicator
  %type <str> into_descriptor
+ %type <str> into_sqlda
  %type <str> Iresult
  %type <str> on_off
  %type <str> opt_bit_field
***************
*** 88,94 ****
  %type <str> opt_reference
  %type <str> opt_scale
  %type <str> opt_server
! %type <str> opt_sql
  %type <str> opt_user
  %type <str> opt_opt_value
  %type <str> ora_user
--- 89,95 ----
  %type <str> opt_reference
  %type <str> opt_scale
  %type <str> opt_server
! %type <str> opt_sql
  %type <str> opt_user
  %type <str> opt_opt_value
  %type <str> ora_user
diff -dcrpN pgsql.sqlda/src/interfaces/ecpg/test/compat_informix/describe.pgc
pgsql.describe/src/interfaces/ecpg/test/compat_informix/describe.pgc
*** pgsql.sqlda/src/interfaces/ecpg/test/compat_informix/describe.pgc    1970-01-01 01:00:00.000000000 +0100
--- pgsql.describe/src/interfaces/ecpg/test/compat_informix/describe.pgc    2009-09-03 13:14:28.000000000 +0200
***************
*** 0 ****
--- 1,166 ----
+ #include <stdlib.h>
+ #include <string.h>
+
+ exec sql include ../regression;
+ exec sql include sqlda.h;
+
+ exec sql whenever sqlerror stop;
+
+ pg_sqlda_t    *sqlda1, *sqlda2, *sqlda3;
+
+ int
+ main (void)
+ {
+ exec sql begin declare section;
+     char    *stmt1 = "SELECT id, t FROM t1";
+     char    *stmt2 = "SELECT id, t FROM t1 WHERE id = -1";
+     int    i, count1, count2;
+     char    field_name1[30] = "not set";
+     char    field_name2[30] = "not set";
+ exec sql end declare section;
+
+     char msg[128];
+
+     ECPGdebug(1, stderr);
+
+     strcpy(msg, "connect");
+     exec sql connect to REGRESSDB1;
+
+     strcpy(msg, "set");
+     exec sql set datestyle to iso;
+
+     strcpy(msg, "create");
+     exec sql create table t1(id serial primary key, t text);
+
+     strcpy(msg, "insert");
+     exec sql insert into t1(id, t) values (default, 'a');
+     exec sql insert into t1(id, t) values (default, 'b');
+     exec sql insert into t1(id, t) values (default, 'c');
+     exec sql insert into t1(id, t) values (default, 'd');
+
+     strcpy(msg, "commit");
+     exec sql commit;
+
+     /*
+      * Test DESCRIBE with a query producing tuples.
+      * DESCRIPTOR and SQL DESCRIPTOR are NOT the same in
+      * Informix-compat mode.
+      */
+
+     strcpy(msg, "allocate");
+     exec sql allocate descriptor desc1;
+     exec sql allocate descriptor desc2;
+
+     strcpy(msg, "prepare");
+     exec sql prepare st_id1 FROM :stmt1;
+
+     sqlda1 = sqlda2 = sqlda3 = NULL;
+
+     strcpy(msg, "describe");
+     exec sql describe st_id1 into sql descriptor desc1;
+     exec sql describe st_id1 using sql descriptor desc2;
+
+     exec sql describe st_id1 into descriptor sqlda1;
+     exec sql describe st_id1 using descriptor sqlda2;
+     exec sql describe st_id1 into sqlda3;
+
+     if (sqlda1 == NULL || sqlda1 == NULL || sqlda2 == NULL)
+         exit(1);
+
+     strcpy(msg, "get descriptor");
+     exec sql get descriptor desc1 :count1 = count;
+     exec sql get descriptor desc1 :count2 = count;
+
+     if (!(    count1 == count2 &&
+         count1 == sqlda1->sqld &&
+         count1 == sqlda2->sqld &&
+         count1 == sqlda3->sqld))
+         exit(1);
+
+     for (i = 1; i <= count1; i++)
+     {
+         exec sql get descriptor desc1 value :i :field_name1 = name;
+         exec sql get descriptor desc2 value :i :field_name2 = name;
+         printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
+             "sqlda1 '%s'\n\tsqlda2 '%s'\n\tsqlda3 '%s'\n",
+             i, field_name1, field_name2,
+             sqlda1->sqlvar[i-1].sqlname,
+             sqlda2->sqlvar[i-1].sqlname,
+             sqlda3->sqlvar[i-1].sqlname);
+     }
+
+     strcpy(msg, "deallocate");
+     exec sql deallocate descriptor desc1;
+     exec sql deallocate descriptor desc2;
+     free(sqlda1);
+     free(sqlda2);
+     free(sqlda3);
+
+     exec sql deallocate prepare st_id1;
+
+     /* Test DESCRIBE with a query not producing tuples */
+
+     strcpy(msg, "allocate");
+     exec sql allocate descriptor desc1;
+     exec sql allocate descriptor desc2;
+
+     strcpy(msg, "prepare");
+     exec sql prepare st_id2 FROM :stmt2;
+
+     sqlda1 = sqlda2 = sqlda3 = NULL;
+
+     strcpy(msg, "describe");
+     exec sql describe st_id2 into sql descriptor desc1;
+     exec sql describe st_id2 using sql descriptor desc2;
+
+     exec sql describe st_id2 into descriptor sqlda1;
+     exec sql describe st_id2 using descriptor sqlda2;
+     exec sql describe st_id2 into sqlda3;
+
+     if (sqlda1 == NULL || sqlda1 == NULL || sqlda2 == NULL)
+         exit(1);
+
+     strcpy(msg, "get descriptor");
+     exec sql get descriptor desc1 :count1 = count;
+     exec sql get descriptor desc1 :count2 = count;
+
+     if (!(    count1 == count2 &&
+         count1 == sqlda1->sqld &&
+         count1 == sqlda2->sqld &&
+         count1 == sqlda3->sqld))
+         exit(1);
+
+     for (i = 1; i <= count1; i++)
+     {
+         exec sql get descriptor desc1 value :i :field_name1 = name;
+         exec sql get descriptor desc2 value :i :field_name2 = name;
+         printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
+             "sqlda1 '%s'\n\tsqlda2 '%s'\n\tsqlda3 '%s'\n",
+             i, field_name1, field_name2,
+             sqlda1->sqlvar[i-1].sqlname,
+             sqlda2->sqlvar[i-1].sqlname,
+             sqlda3->sqlvar[i-1].sqlname);
+     }
+
+     strcpy(msg, "deallocate");
+     exec sql deallocate descriptor desc1;
+     exec sql deallocate descriptor desc2;
+     free(sqlda1);
+     free(sqlda2);
+     free(sqlda3);
+
+     exec sql deallocate prepare st_id2;
+
+     /* End test */
+
+     strcpy(msg, "drop");
+     exec sql drop table t1;
+
+     strcpy(msg, "commit");
+     exec sql commit;
+
+     strcpy(msg, "disconnect");
+     exec sql disconnect;
+
+     return (0);
+ }
diff -dcrpN pgsql.sqlda/src/interfaces/ecpg/test/compat_informix/Makefile
pgsql.describe/src/interfaces/ecpg/test/compat_informix/Makefile
*** pgsql.sqlda/src/interfaces/ecpg/test/compat_informix/Makefile    2009-09-03 12:56:36.000000000 +0200
--- pgsql.describe/src/interfaces/ecpg/test/compat_informix/Makefile    2009-09-03 13:14:28.000000000 +0200
*************** override LIBS := -lecpg_compat $(LIBS)
*** 13,18 ****
--- 13,19 ----
  TESTS = test_informix test_informix.c \
          test_informix2 test_informix2.c \
          cursor cursor.c \
+         describe describe.c \
          dec_test dec_test.c \
          rfmtdate rfmtdate.c \
          rfmtlong rfmtlong.c \
*************** test_informix2.c: test_informix2.pgc ../
*** 31,36 ****
--- 32,40 ----
  cursor.c: cursor.pgc ../regression.h
      $(ECPG) -o $@ -I$(srcdir) $<

+ describe.c: describe.pgc ../regression.h
+     $(ECPG) -o $@ -I$(srcdir) $<
+
  sqlda.c: sqlda.pgc ../regression.h
      $(ECPG) -o $@ -I$(srcdir) $<

diff -dcrpN pgsql.sqlda/src/interfaces/ecpg/test/ecpg_schedule pgsql.describe/src/interfaces/ecpg/test/ecpg_schedule
*** pgsql.sqlda/src/interfaces/ecpg/test/ecpg_schedule    2009-09-03 12:56:36.000000000 +0200
--- pgsql.describe/src/interfaces/ecpg/test/ecpg_schedule    2009-09-03 13:14:28.000000000 +0200
*************** test: compat_informix/rfmtlong
*** 5,10 ****
--- 5,11 ----
  test: compat_informix/rnull
  test: compat_informix/cursor
  test: compat_informix/sqlda
+ test: compat_informix/describe
  test: compat_informix/test_informix
  test: compat_informix/test_informix2
  test: connect/test2
*************** test: preproc/array_of_struct
*** 19,24 ****
--- 20,26 ----
  test: preproc/autoprep
  test: preproc/comment
  test: preproc/cursor
+ test: preproc/describe
  test: preproc/define
  test: preproc/init
  test: preproc/strings
diff -dcrpN pgsql.sqlda/src/interfaces/ecpg/test/ecpg_schedule_tcp
pgsql.describe/src/interfaces/ecpg/test/ecpg_schedule_tcp
*** pgsql.sqlda/src/interfaces/ecpg/test/ecpg_schedule_tcp    2009-09-03 12:56:36.000000000 +0200
--- pgsql.describe/src/interfaces/ecpg/test/ecpg_schedule_tcp    2009-09-03 13:14:28.000000000 +0200
*************** test: compat_informix/rfmtlong
*** 5,10 ****
--- 5,11 ----
  test: compat_informix/rnull
  test: compat_informix/cursor
  test: compat_informix/sqlda
+ test: compat_informix/describe
  test: compat_informix/test_informix
  test: compat_informix/test_informix2
  test: connect/test2
*************** test: preproc/array_of_struct
*** 19,24 ****
--- 20,26 ----
  test: preproc/autoprep
  test: preproc/comment
  test: preproc/cursor
+ test: preproc/describe
  test: preproc/define
  test: preproc/init
  test: preproc/strings
diff -dcrpN pgsql.sqlda/src/interfaces/ecpg/test/expected/compat_informix-describe.c
pgsql.describe/src/interfaces/ecpg/test/expected/compat_informix-describe.c
*** pgsql.sqlda/src/interfaces/ecpg/test/expected/compat_informix-describe.c    1970-01-01 01:00:00.000000000 +0100
--- pgsql.describe/src/interfaces/ecpg/test/expected/compat_informix-describe.c    2009-09-03 13:14:28.000000000 +0200
***************
*** 0 ****
--- 1,490 ----
+ /* Processed by ecpg (regression mode) */
+ /* These include files are added by the preprocessor */
+ #include <ecpglib.h>
+ #include <ecpgerrno.h>
+ #include <sqlca.h>
+ /* Needed for informix compatibility */
+ #include <ecpg_informix.h>
+ /* End of automatic include section */
+ #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+
+ #line 1 "describe.pgc"
+ #include <stdlib.h>
+ #include <string.h>
+
+
+ #line 1 "regression.h"
+
+
+
+
+
+
+ #line 4 "describe.pgc"
+
+
+ #line 1 "sqlda.h"
+ /*
+  * $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqlda.h,v 1.4 2009/06/11 14:49:13 momjian Exp $
+  */
+
+ #ifndef POSTGRES_SQLDA_H
+ #define POSTGRES_SQLDA_H
+
+ /* Define Informix "standard" types */
+ #ifndef C_H
+ typedef int        int4;
+ typedef    short        int2;
+ #endif
+ typedef    char        int1;
+
+ typedef    int        mint;
+ typedef    long        mlong;
+
+ typedef    short        MSHORT;
+ typedef    char        MCHAR;
+
+ typedef    unsigned int    uint4;
+ typedef    unsigned short    uint2;
+ typedef    unsigned char    uint1;
+
+ typedef    unsigned int    muint;
+ typedef    unsigned long    mulong;
+
+ typedef    unsigned short    MUSHORT;
+ typedef    unsigned char    MUCHAR;
+
+ #define MI_INT_SIZE     (sizeof(int)    * 8)
+ #define MI_LONG_SIZE    (sizeof(long)   * 8)
+ #define MI_PTR_SIZE     (sizeof(char *) * 8)
+
+ typedef struct sqlvar_struct
+ {
+     int2    sqltype;        /* variable type                */
+     int4    sqllen;            /* length in bytes              */
+     char       *sqldata;        /* pointer to data              */
+     int2       *sqlind;        /* pointer to indicator         */
+     char       *sqlname;        /* variable name                */
+     char       *sqlformat;        /* reserved for future use      */
+     int2    sqlitype;        /* ind variable type            */
+     int2    sqlilen;        /* ind length in bytes          */
+     char       *sqlidata;        /* ind data pointer             */
+     int4    sqlxid;            /* extended id type             */
+     char       *sqltypename;    /* extended type name           */
+     int2    sqltypelen;        /* length of extended type name */
+     int2    sqlownerlen;        /* length of owner name         */
+     int2    sqlsourcetype;        /* source type for distinct of built-ins */
+     char       *sqlownername;    /* owner name                   */
+     int4    sqlsourceid;        /* extended id of source type   */
+
+     /*
+      * sqlilongdata is new.  It supports data that exceeds the 32k
+      * limit.  sqlilen and sqlidata are for backward compatibility
+      * and they have maximum value of <32K.
+      */
+     char       *sqlilongdata;    /* for data field beyond 32K    */
+     int4    sqlflags;        /* for internal use only        */
+     void       *sqlreserved;    /* reserved for future use      */
+ } pg_sqlvar_t;
+
+ typedef struct sqlda
+ {
+     int2        sqld;
+     pg_sqlvar_t       *sqlvar;
+     char        desc_name[19];    /* descriptor name              */
+     int2        desc_occ;    /* size of sqlda structure      */
+     struct sqlda       *desc_next;    /* pointer to next sqlda struct */
+     void           *reserved;    /* reserved for future use */
+ } pg_sqlda_t;
+
+ #endif /* POSTGRES_SQLDA_H */
+
+ #line 5 "describe.pgc"
+
+
+ /* exec sql whenever sqlerror  stop ; */
+ #line 7 "describe.pgc"
+
+
+ pg_sqlda_t    *sqlda1, *sqlda2, *sqlda3;
+
+ int
+ main (void)
+ {
+ /* exec sql begin declare section */
+
+
+
+
+
+
+ #line 15 "describe.pgc"
+  char * stmt1 = "SELECT id, t FROM t1" ;
+
+ #line 16 "describe.pgc"
+  char * stmt2 = "SELECT id, t FROM t1 WHERE id = -1" ;
+
+ #line 17 "describe.pgc"
+  int i , count1 , count2 ;
+
+ #line 18 "describe.pgc"
+  char field_name1 [ 30 ] = "not set" ;
+
+ #line 19 "describe.pgc"
+  char field_name2 [ 30 ] = "not set" ;
+ /* exec sql end declare section */
+ #line 20 "describe.pgc"
+
+
+     char msg[128];
+
+     ECPGdebug(1, stderr);
+
+     strcpy(msg, "connect");
+     { ECPGconnect(__LINE__, 1, "regress1" , NULL, NULL , NULL, 0);
+ #line 27 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 27 "describe.pgc"
+
+
+     strcpy(msg, "set");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
+ #line 30 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 30 "describe.pgc"
+
+
+     strcpy(msg, "create");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "create table t1 ( id serial primary key , t text )",
ECPGt_EOIT,ECPGt_EORT); 
+ #line 33 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 33 "describe.pgc"
+
+
+     strcpy(msg, "insert");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'a' )",
ECPGt_EOIT,ECPGt_EORT); 
+ #line 36 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 36 "describe.pgc"
+
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'b' )",
ECPGt_EOIT,ECPGt_EORT); 
+ #line 37 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 37 "describe.pgc"
+
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'c' )",
ECPGt_EOIT,ECPGt_EORT); 
+ #line 38 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 38 "describe.pgc"
+
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'd' )",
ECPGt_EOIT,ECPGt_EORT); 
+ #line 39 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 39 "describe.pgc"
+
+
+     strcpy(msg, "commit");
+     { ECPGtrans(__LINE__, NULL, "commit");
+ #line 42 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 42 "describe.pgc"
+
+
+     /*
+      * Test DESCRIBE with a query producing tuples.
+      * DESCRIPTOR and SQL DESCRIPTOR are NOT the same in
+      * Informix-compat mode.
+      */
+
+     strcpy(msg, "allocate");
+     ECPGallocate_desc(__LINE__, "desc1");
+ #line 51 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 51 "describe.pgc"
+
+     ECPGallocate_desc(__LINE__, "desc2");
+ #line 52 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 52 "describe.pgc"
+
+
+     strcpy(msg, "prepare");
+     { ECPGprepare(__LINE__, NULL, 0, "st_id1", stmt1);
+ #line 55 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 55 "describe.pgc"
+
+
+     sqlda1 = sqlda2 = sqlda3 = NULL;
+
+     strcpy(msg, "describe");
+     { ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+     ECPGt_descriptor, "desc1", 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 60 "describe.pgc"
+
+     { ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+     ECPGt_descriptor, "desc2", 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 61 "describe.pgc"
+
+
+     { ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+     ECPGt_sqlda, & sqlda1 , 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 63 "describe.pgc"
+
+     { ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+     ECPGt_sqlda, & sqlda2 , 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 64 "describe.pgc"
+
+     { ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+     ECPGt_sqlda, &sqlda3, 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 65 "describe.pgc"
+
+
+     if (sqlda1 == NULL || sqlda1 == NULL || sqlda2 == NULL)
+         exit(1);
+
+     strcpy(msg, "get descriptor");
+     { ECPGget_desc_header(__LINE__, "desc1", &(count1));
+
+ #line 71 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 71 "describe.pgc"
+
+     { ECPGget_desc_header(__LINE__, "desc1", &(count2));
+
+ #line 72 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 72 "describe.pgc"
+
+
+     if (!(    count1 == count2 &&
+         count1 == sqlda1->sqld &&
+         count1 == sqlda2->sqld &&
+         count1 == sqlda3->sqld))
+         exit(1);
+
+     for (i = 1; i <= count1; i++)
+     {
+         { ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
+     ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+
+ #line 82 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 82 "describe.pgc"
+
+         { ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
+     ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+
+ #line 83 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 83 "describe.pgc"
+
+         printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
+             "sqlda1 '%s'\n\tsqlda2 '%s'\n\tsqlda3 '%s'\n",
+             i, field_name1, field_name2,
+             sqlda1->sqlvar[i-1].sqlname,
+             sqlda2->sqlvar[i-1].sqlname,
+             sqlda3->sqlvar[i-1].sqlname);
+     }
+
+     strcpy(msg, "deallocate");
+     ECPGdeallocate_desc(__LINE__, "desc1");
+ #line 93 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 93 "describe.pgc"
+
+     ECPGdeallocate_desc(__LINE__, "desc2");
+ #line 94 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 94 "describe.pgc"
+
+     free(sqlda1);
+     free(sqlda2);
+     free(sqlda3);
+
+     { ECPGdeallocate(__LINE__, 1, NULL, "st_id1");
+ #line 99 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 99 "describe.pgc"
+
+
+     /* Test DESCRIBE with a query not producing tuples */
+
+     strcpy(msg, "allocate");
+     ECPGallocate_desc(__LINE__, "desc1");
+ #line 104 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 104 "describe.pgc"
+
+     ECPGallocate_desc(__LINE__, "desc2");
+ #line 105 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 105 "describe.pgc"
+
+
+     strcpy(msg, "prepare");
+     { ECPGprepare(__LINE__, NULL, 0, "st_id2", stmt2);
+ #line 108 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 108 "describe.pgc"
+
+
+     sqlda1 = sqlda2 = sqlda3 = NULL;
+
+     strcpy(msg, "describe");
+     { ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+     ECPGt_descriptor, "desc1", 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 113 "describe.pgc"
+
+     { ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+     ECPGt_descriptor, "desc2", 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 114 "describe.pgc"
+
+
+     { ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+     ECPGt_sqlda, & sqlda1 , 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 116 "describe.pgc"
+
+     { ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+     ECPGt_sqlda, & sqlda2 , 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 117 "describe.pgc"
+
+     { ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+     ECPGt_sqlda, &sqlda3, 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 118 "describe.pgc"
+
+
+     if (sqlda1 == NULL || sqlda1 == NULL || sqlda2 == NULL)
+         exit(1);
+
+     strcpy(msg, "get descriptor");
+     { ECPGget_desc_header(__LINE__, "desc1", &(count1));
+
+ #line 124 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 124 "describe.pgc"
+
+     { ECPGget_desc_header(__LINE__, "desc1", &(count2));
+
+ #line 125 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 125 "describe.pgc"
+
+
+     if (!(    count1 == count2 &&
+         count1 == sqlda1->sqld &&
+         count1 == sqlda2->sqld &&
+         count1 == sqlda3->sqld))
+         exit(1);
+
+     for (i = 1; i <= count1; i++)
+     {
+         { ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
+     ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+
+ #line 135 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 135 "describe.pgc"
+
+         { ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
+     ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+
+ #line 136 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 136 "describe.pgc"
+
+         printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
+             "sqlda1 '%s'\n\tsqlda2 '%s'\n\tsqlda3 '%s'\n",
+             i, field_name1, field_name2,
+             sqlda1->sqlvar[i-1].sqlname,
+             sqlda2->sqlvar[i-1].sqlname,
+             sqlda3->sqlvar[i-1].sqlname);
+     }
+
+     strcpy(msg, "deallocate");
+     ECPGdeallocate_desc(__LINE__, "desc1");
+ #line 146 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 146 "describe.pgc"
+
+     ECPGdeallocate_desc(__LINE__, "desc2");
+ #line 147 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 147 "describe.pgc"
+
+     free(sqlda1);
+     free(sqlda2);
+     free(sqlda3);
+
+     { ECPGdeallocate(__LINE__, 1, NULL, "st_id2");
+ #line 152 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 152 "describe.pgc"
+
+
+     /* End test */
+
+     strcpy(msg, "drop");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT);
+ #line 157 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 157 "describe.pgc"
+
+
+     strcpy(msg, "commit");
+     { ECPGtrans(__LINE__, NULL, "commit");
+ #line 160 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 160 "describe.pgc"
+
+
+     strcpy(msg, "disconnect");
+     { ECPGdisconnect(__LINE__, "CURRENT");
+ #line 163 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 163 "describe.pgc"
+
+
+     return (0);
+ }
diff -dcrpN pgsql.sqlda/src/interfaces/ecpg/test/expected/compat_informix-describe.stderr
pgsql.describe/src/interfaces/ecpg/test/expected/compat_informix-describe.stderr
*** pgsql.sqlda/src/interfaces/ecpg/test/expected/compat_informix-describe.stderr    1970-01-01 01:00:00.000000000
+0100
--- pgsql.describe/src/interfaces/ecpg/test/expected/compat_informix-describe.stderr    2009-09-03 13:14:28.000000000
+0200
***************
*** 0 ****
--- 1,100 ----
+ [NO_PID]: ECPGdebug: set to 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 30: query: set datestyle to iso; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 30: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 30: OK: SET
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 33: query: create table t1 ( id serial primary key , t text ); with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 33: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 33: OK: CREATE TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: query: insert into t1 ( id , t ) values ( default , 'a' ); with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: query: insert into t1 ( id , t ) values ( default , 'b' ); with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: query: insert into t1 ( id , t ) values ( default , 'c' ); with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 39: query: insert into t1 ( id , t ) values ( default , 'd' ); with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 39: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 39: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 42: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 55: name st_id1; query: "SELECT id, t FROM t1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 99: name st_id1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 108: name st_id2; query: "SELECT id, t FROM t1 WHERE id = -1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 152: name st_id2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 157: query: drop table t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 157: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 157: OK: DROP TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 160: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection regress1 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
diff -dcrpN pgsql.sqlda/src/interfaces/ecpg/test/expected/compat_informix-describe.stdout
pgsql.describe/src/interfaces/ecpg/test/expected/compat_informix-describe.stdout
*** pgsql.sqlda/src/interfaces/ecpg/test/expected/compat_informix-describe.stdout    1970-01-01 01:00:00.000000000
+0100
--- pgsql.describe/src/interfaces/ecpg/test/expected/compat_informix-describe.stdout    2009-09-03 13:14:28.000000000
+0200
***************
*** 0 ****
--- 1,24 ----
+ 1
+     field_name1 'id'
+     field_name2 'id'
+     sqlda1 'id'
+     sqlda2 'id'
+     sqlda3 'id'
+ 2
+     field_name1 't'
+     field_name2 't'
+     sqlda1 't'
+     sqlda2 't'
+     sqlda3 't'
+ 1
+     field_name1 'id'
+     field_name2 'id'
+     sqlda1 'id'
+     sqlda2 'id'
+     sqlda3 'id'
+ 2
+     field_name1 't'
+     field_name2 't'
+     sqlda1 't'
+     sqlda2 't'
+     sqlda3 't'
diff -dcrpN pgsql.sqlda/src/interfaces/ecpg/test/expected/preproc-describe.c
pgsql.describe/src/interfaces/ecpg/test/expected/preproc-describe.c
*** pgsql.sqlda/src/interfaces/ecpg/test/expected/preproc-describe.c    1970-01-01 01:00:00.000000000 +0100
--- pgsql.describe/src/interfaces/ecpg/test/expected/preproc-describe.c    2009-09-03 13:14:28.000000000 +0200
***************
*** 0 ****
--- 1,481 ----
+ /* Processed by ecpg (regression mode) */
+ /* These include files are added by the preprocessor */
+ #include <ecpglib.h>
+ #include <ecpgerrno.h>
+ #include <sqlca.h>
+ /* End of automatic include section */
+ #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+
+ #line 1 "describe.pgc"
+ #include <stdlib.h>
+ #include <string.h>
+
+
+ #line 1 "regression.h"
+
+
+
+
+
+
+ #line 4 "describe.pgc"
+
+
+ /* exec sql whenever sqlerror  stop ; */
+ #line 6 "describe.pgc"
+
+
+ int
+ main (void)
+ {
+ /* exec sql begin declare section */
+
+
+
+
+
+
+
+
+ #line 12 "describe.pgc"
+  char * stmt1 = "SELECT id, t FROM t1" ;
+
+ #line 13 "describe.pgc"
+  char * stmt2 = "SELECT id, t FROM t1 WHERE id = -1" ;
+
+ #line 14 "describe.pgc"
+  int i , count1 , count2 , count3 , count4 ;
+
+ #line 15 "describe.pgc"
+  char field_name1 [ 30 ] = "not set" ;
+
+ #line 16 "describe.pgc"
+  char field_name2 [ 30 ] = "not set" ;
+
+ #line 17 "describe.pgc"
+  char field_name3 [ 30 ] = "not set" ;
+
+ #line 18 "describe.pgc"
+  char field_name4 [ 30 ] = "not set" ;
+ /* exec sql end declare section */
+ #line 19 "describe.pgc"
+
+
+     char msg[128];
+
+     ECPGdebug(1, stderr);
+
+     strcpy(msg, "connect");
+     { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0);
+ #line 26 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 26 "describe.pgc"
+
+
+     strcpy(msg, "set");
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
+ #line 29 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 29 "describe.pgc"
+
+
+     strcpy(msg, "create");
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table t1 ( id serial primary key , t text )",
ECPGt_EOIT,ECPGt_EORT); 
+ #line 32 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 32 "describe.pgc"
+
+
+     strcpy(msg, "insert");
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'a' )",
ECPGt_EOIT,ECPGt_EORT); 
+ #line 35 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 35 "describe.pgc"
+
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'b' )",
ECPGt_EOIT,ECPGt_EORT); 
+ #line 36 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 36 "describe.pgc"
+
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'c' )",
ECPGt_EOIT,ECPGt_EORT); 
+ #line 37 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 37 "describe.pgc"
+
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'd' )",
ECPGt_EOIT,ECPGt_EORT); 
+ #line 38 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 38 "describe.pgc"
+
+
+     strcpy(msg, "commit");
+     { ECPGtrans(__LINE__, NULL, "commit");
+ #line 41 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 41 "describe.pgc"
+
+
+     /*
+      * Test DESCRIBE with a query producing tuples.
+      * DESCRIPTOR and SQL DESCRIPTOR are the same in native mode.
+      */
+
+     strcpy(msg, "allocate");
+     ECPGallocate_desc(__LINE__, "desc1");
+ #line 49 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 49 "describe.pgc"
+
+     ECPGallocate_desc(__LINE__, "desc2");
+ #line 50 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 50 "describe.pgc"
+
+     ECPGallocate_desc(__LINE__, "desc3");
+ #line 51 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 51 "describe.pgc"
+
+     ECPGallocate_desc(__LINE__, "desc4");
+ #line 52 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 52 "describe.pgc"
+
+
+     strcpy(msg, "prepare");
+     { ECPGprepare(__LINE__, NULL, 0, "st_id1", stmt1);
+ #line 55 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 55 "describe.pgc"
+
+
+     strcpy(msg, "describe");
+     { ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+     ECPGt_descriptor, "desc1", 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 58 "describe.pgc"
+
+     { ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+     ECPGt_descriptor, "desc2", 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 59 "describe.pgc"
+
+     { ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+     ECPGt_descriptor, "desc3", 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 60 "describe.pgc"
+
+     { ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+     ECPGt_descriptor, "desc4", 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 61 "describe.pgc"
+
+
+     strcpy(msg, "get descriptor");
+     { ECPGget_desc_header(__LINE__, "desc1", &(count1));
+
+ #line 64 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 64 "describe.pgc"
+
+     { ECPGget_desc_header(__LINE__, "desc2", &(count2));
+
+ #line 65 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 65 "describe.pgc"
+
+     { ECPGget_desc_header(__LINE__, "desc3", &(count3));
+
+ #line 66 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 66 "describe.pgc"
+
+     { ECPGget_desc_header(__LINE__, "desc4", &(count4));
+
+ #line 67 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 67 "describe.pgc"
+
+
+     if (!(count1 == count2 && count1 == count3 && count1 == count4))
+         exit(1);
+
+     for (i = 1; i <= count1; i++)
+     {
+         { ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
+     ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+
+ #line 74 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 74 "describe.pgc"
+
+         { ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
+     ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+
+ #line 75 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 75 "describe.pgc"
+
+         { ECPGget_desc(__LINE__, "desc3", i,ECPGd_name,
+     ECPGt_char,(field_name3),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+
+ #line 76 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 76 "describe.pgc"
+
+         { ECPGget_desc(__LINE__, "desc4", i,ECPGd_name,
+     ECPGt_char,(field_name4),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+
+ #line 77 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 77 "describe.pgc"
+
+         printf("field_name 1 '%s' 2 '%s' 3 '%s' 4 '%s'\n",
+             field_name1, field_name2, field_name3, field_name4);
+     }
+
+     strcpy(msg, "deallocate");
+     ECPGdeallocate_desc(__LINE__, "desc1");
+ #line 83 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 83 "describe.pgc"
+
+     ECPGdeallocate_desc(__LINE__, "desc2");
+ #line 84 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 84 "describe.pgc"
+
+     ECPGdeallocate_desc(__LINE__, "desc3");
+ #line 85 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 85 "describe.pgc"
+
+     ECPGdeallocate_desc(__LINE__, "desc4");
+ #line 86 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 86 "describe.pgc"
+
+
+     { ECPGdeallocate(__LINE__, 0, NULL, "st_id1");
+ #line 88 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 88 "describe.pgc"
+
+
+     /* Test DESCRIBE with a query not producing tuples */
+
+     strcpy(msg, "allocate");
+     ECPGallocate_desc(__LINE__, "desc1");
+ #line 93 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 93 "describe.pgc"
+
+     ECPGallocate_desc(__LINE__, "desc2");
+ #line 94 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 94 "describe.pgc"
+
+     ECPGallocate_desc(__LINE__, "desc3");
+ #line 95 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 95 "describe.pgc"
+
+     ECPGallocate_desc(__LINE__, "desc4");
+ #line 96 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 96 "describe.pgc"
+
+
+     strcpy(msg, "prepare");
+     { ECPGprepare(__LINE__, NULL, 0, "st_id2", stmt2);
+ #line 99 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 99 "describe.pgc"
+
+
+     strcpy(msg, "describe");
+     { ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+     ECPGt_descriptor, "desc1", 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 102 "describe.pgc"
+
+     { ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+     ECPGt_descriptor, "desc2", 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 103 "describe.pgc"
+
+     { ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+     ECPGt_descriptor, "desc3", 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 104 "describe.pgc"
+
+     { ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+     ECPGt_descriptor, "desc4", 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 105 "describe.pgc"
+
+
+     strcpy(msg, "get descriptor");
+     { ECPGget_desc_header(__LINE__, "desc1", &(count1));
+
+ #line 108 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 108 "describe.pgc"
+
+     { ECPGget_desc_header(__LINE__, "desc2", &(count2));
+
+ #line 109 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 109 "describe.pgc"
+
+     { ECPGget_desc_header(__LINE__, "desc3", &(count3));
+
+ #line 110 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 110 "describe.pgc"
+
+     { ECPGget_desc_header(__LINE__, "desc4", &(count4));
+
+ #line 111 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 111 "describe.pgc"
+
+
+     if (!(count1 == count2 && count1 == count3 && count1 == count4))
+         exit(1);
+
+     for (i = 1; i <= count1; i++)
+     {
+         { ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
+     ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+
+ #line 118 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 118 "describe.pgc"
+
+         { ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
+     ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+
+ #line 119 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 119 "describe.pgc"
+
+         { ECPGget_desc(__LINE__, "desc3", i,ECPGd_name,
+     ECPGt_char,(field_name3),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+
+ #line 120 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 120 "describe.pgc"
+
+         { ECPGget_desc(__LINE__, "desc4", i,ECPGd_name,
+     ECPGt_char,(field_name4),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+
+ #line 121 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 121 "describe.pgc"
+
+         printf("field_name 1 '%s' 2 '%s' 3 '%s' 4 '%s'\n",
+             field_name1, field_name2, field_name3, field_name4);
+     }
+
+     strcpy(msg, "deallocate");
+     ECPGdeallocate_desc(__LINE__, "desc1");
+ #line 127 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 127 "describe.pgc"
+
+     ECPGdeallocate_desc(__LINE__, "desc2");
+ #line 128 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 128 "describe.pgc"
+
+     ECPGdeallocate_desc(__LINE__, "desc3");
+ #line 129 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 129 "describe.pgc"
+
+     ECPGdeallocate_desc(__LINE__, "desc4");
+ #line 130 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 130 "describe.pgc"
+
+
+     { ECPGdeallocate(__LINE__, 0, NULL, "st_id2");
+ #line 132 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 132 "describe.pgc"
+
+
+
+     /* End test */
+
+     strcpy(msg, "drop");
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT);
+ #line 138 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 138 "describe.pgc"
+
+
+     strcpy(msg, "commit");
+     { ECPGtrans(__LINE__, NULL, "commit");
+ #line 141 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 141 "describe.pgc"
+
+
+     strcpy(msg, "disconnect");
+     { ECPGdisconnect(__LINE__, "CURRENT");
+ #line 144 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 144 "describe.pgc"
+
+
+     return (0);
+ }
diff -dcrpN pgsql.sqlda/src/interfaces/ecpg/test/expected/preproc-describe.stderr
pgsql.describe/src/interfaces/ecpg/test/expected/preproc-describe.stderr
*** pgsql.sqlda/src/interfaces/ecpg/test/expected/preproc-describe.stderr    1970-01-01 01:00:00.000000000 +0100
--- pgsql.describe/src/interfaces/ecpg/test/expected/preproc-describe.stderr    2009-09-03 13:14:28.000000000 +0200
***************
*** 0 ****
--- 1,140 ----
+ [NO_PID]: ECPGdebug: set to 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 29: query: set datestyle to iso; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 29: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 29: OK: SET
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 32: query: create table t1 ( id serial primary key , t text ); with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 32: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 32: OK: CREATE TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 35: query: insert into t1 ( id , t ) values ( default , 'a' ); with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 35: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 35: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: query: insert into t1 ( id , t ) values ( default , 'b' ); with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: query: insert into t1 ( id , t ) values ( default , 'c' ); with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: query: insert into t1 ( id , t ) values ( default , 'd' ); with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 41: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 55: name st_id1; query: "SELECT id, t FROM t1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 88: name st_id1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 99: name st_id2; query: "SELECT id, t FROM t1 WHERE id = -1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 132: name st_id2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 138: query: drop table t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 138: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 138: OK: DROP TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 141: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection regress1 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
diff -dcrpN pgsql.sqlda/src/interfaces/ecpg/test/expected/preproc-describe.stdout
pgsql.describe/src/interfaces/ecpg/test/expected/preproc-describe.stdout
*** pgsql.sqlda/src/interfaces/ecpg/test/expected/preproc-describe.stdout    1970-01-01 01:00:00.000000000 +0100
--- pgsql.describe/src/interfaces/ecpg/test/expected/preproc-describe.stdout    2009-09-03 13:14:28.000000000 +0200
***************
*** 0 ****
--- 1,4 ----
+ field_name 1 'id' 2 'id' 3 'id' 4 'id'
+ field_name 1 't' 2 't' 3 't' 4 't'
+ field_name 1 'id' 2 'id' 3 'id' 4 'id'
+ field_name 1 't' 2 't' 3 't' 4 't'
diff -dcrpN pgsql.sqlda/src/interfaces/ecpg/test/preproc/describe.pgc
pgsql.describe/src/interfaces/ecpg/test/preproc/describe.pgc
*** pgsql.sqlda/src/interfaces/ecpg/test/preproc/describe.pgc    1970-01-01 01:00:00.000000000 +0100
--- pgsql.describe/src/interfaces/ecpg/test/preproc/describe.pgc    2009-09-03 13:14:28.000000000 +0200
***************
*** 0 ****
--- 1,147 ----
+ #include <stdlib.h>
+ #include <string.h>
+
+ exec sql include ../regression;
+
+ exec sql whenever sqlerror stop;
+
+ int
+ main (void)
+ {
+ exec sql begin declare section;
+     char    *stmt1 = "SELECT id, t FROM t1";
+     char    *stmt2 = "SELECT id, t FROM t1 WHERE id = -1";
+     int    i, count1, count2, count3, count4;
+     char    field_name1[30] = "not set";
+     char    field_name2[30] = "not set";
+     char    field_name3[30] = "not set";
+     char    field_name4[30] = "not set";
+ exec sql end declare section;
+
+     char msg[128];
+
+     ECPGdebug(1, stderr);
+
+     strcpy(msg, "connect");
+     exec sql connect to REGRESSDB1;
+
+     strcpy(msg, "set");
+     exec sql set datestyle to iso;
+
+     strcpy(msg, "create");
+     exec sql create table t1(id serial primary key, t text);
+
+     strcpy(msg, "insert");
+     exec sql insert into t1(id, t) values (default, 'a');
+     exec sql insert into t1(id, t) values (default, 'b');
+     exec sql insert into t1(id, t) values (default, 'c');
+     exec sql insert into t1(id, t) values (default, 'd');
+
+     strcpy(msg, "commit");
+     exec sql commit;
+
+     /*
+      * Test DESCRIBE with a query producing tuples.
+      * DESCRIPTOR and SQL DESCRIPTOR are the same in native mode.
+      */
+
+     strcpy(msg, "allocate");
+     exec sql allocate descriptor desc1;
+     exec sql allocate descriptor desc2;
+     exec sql allocate descriptor desc3;
+     exec sql allocate descriptor desc4;
+
+     strcpy(msg, "prepare");
+     exec sql prepare st_id1 FROM :stmt1;
+
+     strcpy(msg, "describe");
+     exec sql describe st_id1 into descriptor desc1;
+     exec sql describe st_id1 into sql descriptor desc2;
+     exec sql describe st_id1 using descriptor desc3;
+     exec sql describe st_id1 using sql descriptor desc4;
+
+     strcpy(msg, "get descriptor");
+     exec sql get descriptor desc1 :count1 = count;
+     exec sql get descriptor desc2 :count2 = count;
+     exec sql get descriptor desc3 :count3 = count;
+     exec sql get descriptor desc4 :count4 = count;
+
+     if (!(count1 == count2 && count1 == count3 && count1 == count4))
+         exit(1);
+
+     for (i = 1; i <= count1; i++)
+     {
+         exec sql get descriptor desc1 value :i :field_name1 = name;
+         exec sql get descriptor desc2 value :i :field_name2 = name;
+         exec sql get descriptor desc3 value :i :field_name3 = name;
+         exec sql get descriptor desc4 value :i :field_name4 = name;
+         printf("field_name 1 '%s' 2 '%s' 3 '%s' 4 '%s'\n",
+             field_name1, field_name2, field_name3, field_name4);
+     }
+
+     strcpy(msg, "deallocate");
+     exec sql deallocate descriptor desc1;
+     exec sql deallocate descriptor desc2;
+     exec sql deallocate descriptor desc3;
+     exec sql deallocate descriptor desc4;
+
+     exec sql deallocate prepare st_id1;
+
+     /* Test DESCRIBE with a query not producing tuples */
+
+     strcpy(msg, "allocate");
+     exec sql allocate descriptor desc1;
+     exec sql allocate descriptor desc2;
+     exec sql allocate descriptor desc3;
+     exec sql allocate descriptor desc4;
+
+     strcpy(msg, "prepare");
+     exec sql prepare st_id2 FROM :stmt2;
+
+     strcpy(msg, "describe");
+     exec sql describe st_id2 into descriptor desc1;
+     exec sql describe st_id2 into sql descriptor desc2;
+     exec sql describe st_id2 using descriptor desc3;
+     exec sql describe st_id2 using sql descriptor desc4;
+
+     strcpy(msg, "get descriptor");
+     exec sql get descriptor desc1 :count1 = count;
+     exec sql get descriptor desc2 :count2 = count;
+     exec sql get descriptor desc3 :count3 = count;
+     exec sql get descriptor desc4 :count4 = count;
+
+     if (!(count1 == count2 && count1 == count3 && count1 == count4))
+         exit(1);
+
+     for (i = 1; i <= count1; i++)
+     {
+         exec sql get descriptor desc1 value :i :field_name1 = name;
+         exec sql get descriptor desc2 value :i :field_name2 = name;
+         exec sql get descriptor desc3 value :i :field_name3 = name;
+         exec sql get descriptor desc4 value :i :field_name4 = name;
+         printf("field_name 1 '%s' 2 '%s' 3 '%s' 4 '%s'\n",
+             field_name1, field_name2, field_name3, field_name4);
+     }
+
+     strcpy(msg, "deallocate");
+     exec sql deallocate descriptor desc1;
+     exec sql deallocate descriptor desc2;
+     exec sql deallocate descriptor desc3;
+     exec sql deallocate descriptor desc4;
+
+     exec sql deallocate prepare st_id2;
+
+
+     /* End test */
+
+     strcpy(msg, "drop");
+     exec sql drop table t1;
+
+     strcpy(msg, "commit");
+     exec sql commit;
+
+     strcpy(msg, "disconnect");
+     exec sql disconnect;
+
+     return (0);
+ }
diff -dcrpN pgsql.sqlda/src/interfaces/ecpg/test/preproc/Makefile
pgsql.describe/src/interfaces/ecpg/test/preproc/Makefile
*** pgsql.sqlda/src/interfaces/ecpg/test/preproc/Makefile    2009-09-03 12:28:03.000000000 +0200
--- pgsql.describe/src/interfaces/ecpg/test/preproc/Makefile    2009-09-03 13:14:28.000000000 +0200
*************** TESTS = array_of_struct array_of_struct.
*** 8,13 ****
--- 8,14 ----
      autoprep autoprep.c \
      comment comment.c \
      cursor cursor.c \
+     describe describe.c \
      define define.c \
      init init.c \
      strings strings.c \

Re: ECPG patchset

From
Boszormenyi Zoltan
Date:
Out of scope cursor usage

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
http://www.postgresql.at/

diff -dcrpN pgsql.describe/src/interfaces/ecpg/preproc/descriptor.c
pgsql.ooscur/src/interfaces/ecpg/preproc/descriptor.c
*** pgsql.describe/src/interfaces/ecpg/preproc/descriptor.c    2009-09-03 12:56:36.000000000 +0200
--- pgsql.ooscur/src/interfaces/ecpg/preproc/descriptor.c    2009-09-03 13:57:48.000000000 +0200
*************** struct variable *
*** 317,323 ****
  descriptor_variable(const char *name, int input)
  {
      static char descriptor_names[2][MAX_DESCRIPTOR_NAMELEN];
!     static const struct ECPGtype descriptor_type = {ECPGt_descriptor, NULL, NULL, {NULL}, 0};
      static const struct variable varspace[2] = {
          {descriptor_names[0], (struct ECPGtype *) & descriptor_type, 0, NULL},
          {descriptor_names[1], (struct ECPGtype *) & descriptor_type, 0, NULL}
--- 317,323 ----
  descriptor_variable(const char *name, int input)
  {
      static char descriptor_names[2][MAX_DESCRIPTOR_NAMELEN];
!     static const struct ECPGtype descriptor_type = {ECPGt_descriptor, NULL, NULL, NULL, {NULL}, 0};
      static const struct variable varspace[2] = {
          {descriptor_names[0], (struct ECPGtype *) & descriptor_type, 0, NULL},
          {descriptor_names[1], (struct ECPGtype *) & descriptor_type, 0, NULL}
diff -dcrpN pgsql.describe/src/interfaces/ecpg/preproc/ecpg.addons pgsql.ooscur/src/interfaces/ecpg/preproc/ecpg.addons
*** pgsql.describe/src/interfaces/ecpg/preproc/ecpg.addons    2009-09-03 12:58:29.000000000 +0200
--- pgsql.ooscur/src/interfaces/ecpg/preproc/ecpg.addons    2009-09-03 14:34:41.000000000 +0200
*************** ECPG: DeclareCursorStmtDECLAREcursor_nam
*** 315,325 ****
--- 315,328 ----

          this->next = cur;
          this->name = $2;
+         this->function = (current_function ? mm_strdup(current_function) : NULL);
          this->connection = connection;
          this->opened = false;
          this->command =  cat_str(7, make_str("declare"), cursor_marker, $3, make_str("cursor"), $5, make_str("for"),
$7);
          this->argsinsert = argsinsert;
+         this->argsinsert_oos = NULL;
          this->argsresult = argsresult;
+         this->argsresult_oos = NULL;
          argsinsert = argsresult = NULL;
          cur = this;

*************** ECPG: DeclareCursorStmtDECLAREcursor_nam
*** 329,338 ****
          {
              if (braces_open > 0) /* we're in a function */
              {
!                 $$ = cat_str(4, adjust_informix(this->argsinsert), adjust_informix(this->argsresult),
make_str("ECPG_informix_reset_sqlca();"),comment); 
              }
              else
!                 $$ = cat_str(3, adjust_informix(this->argsinsert), adjust_informix(this->argsresult), comment);
          }
          else
              $$ = comment;
--- 332,341 ----
          {
              if (braces_open > 0) /* we're in a function */
              {
!                 $$ = cat_str(4, adjust_informix(this, true), adjust_informix(this, false),
make_str("ECPG_informix_reset_sqlca();"),comment); 
              }
              else
!                 $$ = cat_str(3, adjust_informix(this, true), adjust_informix(this, false), comment);
          }
          else
              $$ = comment;
diff -dcrpN pgsql.describe/src/interfaces/ecpg/preproc/ecpg.header pgsql.ooscur/src/interfaces/ecpg/preproc/ecpg.header
*** pgsql.describe/src/interfaces/ecpg/preproc/ecpg.header    2009-08-07 13:06:28.000000000 +0200
--- pgsql.ooscur/src/interfaces/ecpg/preproc/ecpg.header    2009-09-03 13:57:48.000000000 +0200
***************
*** 33,38 ****
--- 33,39 ----
   */
  int struct_level = 0;
  int braces_open; /* brace level counter */
+ char *current_function;
  int ecpg_informix_var = 0;
  char    *connection = NULL;
  char    *input_filename = NULL;
*************** static char *ECPGstruct_sizeof = NULL;
*** 53,62 ****
  /* for forward declarations we have to store some data as well */
  static char *forward_name = NULL;

! struct ECPGtype ecpg_no_indicator = {ECPGt_NO_INDICATOR, NULL, NULL, {NULL}, 0};
  struct variable no_indicator = {"no_indicator", &ecpg_no_indicator, 0, NULL};

! struct ECPGtype ecpg_query = {ECPGt_char_variable, NULL, NULL, {NULL}, 0};

  /*
   * Handle parsing errors and warnings
--- 54,63 ----
  /* for forward declarations we have to store some data as well */
  static char *forward_name = NULL;

! struct ECPGtype ecpg_no_indicator = {ECPGt_NO_INDICATOR, NULL, NULL, NULL, {NULL}, 0};
  struct variable no_indicator = {"no_indicator", &ecpg_no_indicator, 0, NULL};

! struct ECPGtype ecpg_query = {ECPGt_char_variable, NULL, NULL, NULL, {NULL}, 0};

  /*
   * Handle parsing errors and warnings
*************** create_questionmarks(char *name, bool ar
*** 230,236 ****
  }

  static char *
! adjust_informix(struct arguments *list)
  {
      /* Informix accepts DECLARE with variables that are out of scope when OPEN is called.
        * for instance you can declare variables in a function, and then subsequently use them
--- 231,237 ----
  }

  static char *
! adjust_informix(struct cursor *cur, bool insert)
  {
      /* Informix accepts DECLARE with variables that are out of scope when OPEN is called.
        * for instance you can declare variables in a function, and then subsequently use them
*************** adjust_informix(struct arguments *list)
*** 244,252 ****
--- 245,275 ----
       * We have to change the variables to our own struct and just store the pointer instead of the variable
       */

+      struct arguments *list;
       struct arguments *ptr;
+      struct arguments *newlist = NULL;
+      struct variable *newvar, *newind;
       char *result = make_str("");

+ /*
+  * This only needed if the out-of-scope DECLARE is
+  * decided to be useful for non-compat mode, too.
+  * DECLARE has just been proved to be a non-declarative
+  * statement in Informix.
+  */
+ #if 0
+     /*
+      * If we're outside of a function, then DECLARE can only reference
+      * variables in the global scope. They don't need transforming.
+      * This also prevents emitting ECPGinformix_set_var() calls
+      * outside of functions.
+      */
+      if (cur->function == NULL) /* same as checking for (braces_open == 0) */
+         return result;
+ #endif
+
+      list = (insert ? cur->argsinsert : cur->argsresult);
+
       for (ptr = list; ptr != NULL; ptr = ptr->next)
       {
           char temp[20]; /* this should be sufficient unless you have 8 byte integers */
*************** adjust_informix(struct arguments *list)
*** 258,274 ****

          if ((ptr->variable->type->type != ECPGt_varchar && ptr->variable->type->type != ECPGt_char &&
ptr->variable->type->type!= ECPGt_unsigned_char && ptr->variable->type->type != ECPGt_string) &&
atoi(ptr->variable->type->size)> 1) 
          {
!             ptr->variable = new_variable(cat_str(4, make_str("("),
mm_strdup(ecpg_type_name(ptr->variable->type->u.element->type)),make_str(" *)(ECPG_informix_get_var("),
mm_strdup(temp)),ECPGmake_array_type(ECPGmake_simple_type(ptr->variable->type->u.element->type, make_str("1"),
ptr->variable->type->u.element->lineno),ptr->variable->type->size), 0); 
              sprintf(temp, "%d, (", ecpg_informix_var++);
          }
          else if ((ptr->variable->type->type == ECPGt_varchar || ptr->variable->type->type == ECPGt_char ||
ptr->variable->type->type== ECPGt_unsigned_char || ptr->variable->type->type == ECPGt_string) &&
atoi(ptr->variable->type->size)> 1) 
          {
!             ptr->variable = new_variable(cat_str(4, make_str("("),
mm_strdup(ecpg_type_name(ptr->variable->type->type)),make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)),
ECPGmake_simple_type(ptr->variable->type->type,ptr->variable->type->size, ptr->variable->type->lineno), 0); 
              sprintf(temp, "%d, (", ecpg_informix_var++);
          }
          else
          {
!             ptr->variable = new_variable(cat_str(4, make_str("*("),
mm_strdup(ecpg_type_name(ptr->variable->type->type)),make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)),
ECPGmake_simple_type(ptr->variable->type->type,ptr->variable->type->size, ptr->variable->type->lineno), 0); 
              sprintf(temp, "%d, &(", ecpg_informix_var++);
          }

--- 281,317 ----

          if ((ptr->variable->type->type != ECPGt_varchar && ptr->variable->type->type != ECPGt_char &&
ptr->variable->type->type!= ECPGt_unsigned_char && ptr->variable->type->type != ECPGt_string) &&
atoi(ptr->variable->type->size)> 1) 
          {
!             newvar = new_variable(cat_str(4, make_str("("),
mm_strdup(ecpg_type_name(ptr->variable->type->u.element->type)),make_str(" *)(ECPG_informix_get_var("),
mm_strdup(temp)),ECPGmake_array_type(ECPGmake_simple_type(ptr->variable->type->u.element->type, make_str("1"),
ptr->variable->type->u.element->lineno),ptr->variable->type->size), 0); 
              sprintf(temp, "%d, (", ecpg_informix_var++);
          }
          else if ((ptr->variable->type->type == ECPGt_varchar || ptr->variable->type->type == ECPGt_char ||
ptr->variable->type->type== ECPGt_unsigned_char || ptr->variable->type->type == ECPGt_string) &&
atoi(ptr->variable->type->size)> 1) 
          {
!             newvar = new_variable(cat_str(4, make_str("("), mm_strdup(ecpg_type_name(ptr->variable->type->type)),
make_str("*)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->variable->type->type,
ptr->variable->type->size,ptr->variable->type->lineno), 0); 
              sprintf(temp, "%d, (", ecpg_informix_var++);
          }
+         else if (ptr->variable->type->type == ECPGt_struct || ptr->variable->type->type == ECPGt_union)
+         {
+             sprintf(temp, "%d)))", ecpg_informix_var);
+             newvar = new_variable(cat_str(4, make_str("(*("), mm_strdup(ptr->variable->type->type_name), make_str("
*)(ECPG_informix_get_var("),mm_strdup(temp)), ECPGmake_struct_type(ptr->variable->type->u.members,
ptr->variable->type->type,ptr->variable->type->type_name, ptr->variable->type->struct_sizeof), 0); 
+             sprintf(temp, "%d, &(", ecpg_informix_var++);
+         }
+         else if (ptr->variable->type->type == ECPGt_array)
+         {
+             if (ptr->variable->type->u.element->type == ECPGt_struct || ptr->variable->type->u.element->type ==
ECPGt_union)
+             {
+                 sprintf(temp, "%d)))", ecpg_informix_var);
+                 newvar = new_variable(cat_str(4, make_str("(*("),
mm_strdup(ptr->variable->type->u.element->type_name),make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)),
ECPGmake_struct_type(ptr->variable->type->u.element->u.members,ptr->variable->type->u.element->type,
ptr->variable->type->u.element->type_name,ptr->variable->type->u.element->struct_sizeof), 0); 
+                 sprintf(temp, "%d, (", ecpg_informix_var++);
+             }
+             else
+             {
+                 newvar = new_variable(cat_str(4, make_str("("), mm_strdup(ecpg_type_name(ptr->variable->type->type)),
make_str("*)(ECPG_informix_get_var("), mm_strdup(temp)),
ECPGmake_array_type(ECPGmake_simple_type(ptr->variable->type->u.element->type,ptr->variable->type->u.element->size,
ptr->variable->type->u.element->lineno),ptr->variable->type->size), 0); 
+                 sprintf(temp, "%d, &(", ecpg_informix_var++);
+             }
+         }
          else
          {
!             newvar = new_variable(cat_str(4, make_str("*("), mm_strdup(ecpg_type_name(ptr->variable->type->type)),
make_str("*)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->variable->type->type,
ptr->variable->type->size,ptr->variable->type->lineno), 0); 
              sprintf(temp, "%d, &(", ecpg_informix_var++);
          }

*************** adjust_informix(struct arguments *list)
*** 276,305 ****
          result = cat_str(5, result, make_str("ECPG_informix_set_var("), mm_strdup(temp), mm_strdup(original_var),
make_str("),__LINE__);\n")); 

          /* now the indicator if there is one */
!         if (ptr->indicator->type->type != ECPGt_NO_INDICATOR)
          {
              /* change variable name to "ECPG_informix_get_var(<counter>)" */
              original_var = ptr->indicator->name;
              sprintf(temp, "%d))", ecpg_informix_var);

              /* create call to "ECPG_informix_set_var(<counter>, <pointer>. <linen number>)" */
!             if (atoi(ptr->indicator->type->size) > 1)
              {
!                 ptr->indicator = new_variable(cat_str(4, make_str("("),
mm_strdup(ecpg_type_name(ptr->indicator->type->type)),make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)),
ECPGmake_simple_type(ptr->indicator->type->type,ptr->indicator->type->size, ptr->variable->type->lineno), 0); 
                  sprintf(temp, "%d, (", ecpg_informix_var++);
              }
              else
              {
!                 ptr->indicator = new_variable(cat_str(4, make_str("*("),
mm_strdup(ecpg_type_name(ptr->indicator->type->type)),make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)),
ECPGmake_simple_type(ptr->indicator->type->type,ptr->indicator->type->size, ptr->variable->type->lineno), 0); 
                  sprintf(temp, "%d, &(", ecpg_informix_var++);
              }
              result = cat_str(5, result, make_str("ECPG_informix_set_var("), mm_strdup(temp), mm_strdup(original_var),
make_str("),__LINE__);\n")); 
          }
       }

       return result;
  }

  static struct cursor *
  add_additional_variables(char *name, bool insert)
  {
--- 319,384 ----
          result = cat_str(5, result, make_str("ECPG_informix_set_var("), mm_strdup(temp), mm_strdup(original_var),
make_str("),__LINE__);\n")); 

          /* now the indicator if there is one */
!         if (ptr->indicator->type->type == ECPGt_NO_INDICATOR)
!         {
!             newind = ptr->indicator;
!         }
!         else
          {
              /* change variable name to "ECPG_informix_get_var(<counter>)" */
              original_var = ptr->indicator->name;
              sprintf(temp, "%d))", ecpg_informix_var);

              /* create call to "ECPG_informix_set_var(<counter>, <pointer>. <linen number>)" */
!             if (ptr->indicator->type->type == ECPGt_struct || ptr->indicator->type->type == ECPGt_union)
              {
!                 sprintf(temp, "%d)))", ecpg_informix_var);
!                 newind = new_variable(cat_str(4, make_str("(*("), mm_strdup(ptr->indicator->type->type_name),
make_str("*)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_struct_type(ptr->indicator->type->u.members,
ptr->indicator->type->type,ptr->indicator->type->type_name, ptr->indicator->type->struct_sizeof), 0); 
!                 sprintf(temp, "%d, &(", ecpg_informix_var++);
!             }
!             else if (ptr->indicator->type->type == ECPGt_array)
!             {
!                 if (ptr->indicator->type->u.element->type == ECPGt_struct || ptr->indicator->type->u.element->type ==
ECPGt_union)
!                 {
!                     sprintf(temp, "%d)))", ecpg_informix_var);
!                     newind = new_variable(cat_str(4, make_str("(*("),
mm_strdup(ptr->indicator->type->u.element->type_name),make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)),
ECPGmake_struct_type(ptr->indicator->type->u.element->u.members,ptr->indicator->type->u.element->type,
ptr->indicator->type->u.element->type_name,ptr->indicator->type->u.element->struct_sizeof), 0); 
!                     sprintf(temp, "%d, (", ecpg_informix_var++);
!                 }
!                 else
!                 {
!                     newind = new_variable(cat_str(4, make_str("("),
mm_strdup(ecpg_type_name(ptr->indicator->type->u.element->type)),make_str(" *)(ECPG_informix_get_var("),
mm_strdup(temp)),ECPGmake_array_type(ECPGmake_simple_type(ptr->indicator->type->u.element->type,
ptr->indicator->type->u.element->size,ptr->indicator->type->u.element->lineno), ptr->indicator->type->size), 0); 
!                     sprintf(temp, "%d, &(", ecpg_informix_var++);
!                 }
!             }
!             else if (atoi(ptr->indicator->type->size) > 1)
!             {
!                 newind = new_variable(cat_str(4, make_str("("),
mm_strdup(ecpg_type_name(ptr->indicator->type->type)),make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)),
ECPGmake_simple_type(ptr->indicator->type->type,ptr->indicator->type->size, ptr->variable->type->lineno), 0); 
                  sprintf(temp, "%d, (", ecpg_informix_var++);
              }
              else
              {
!                 newind = new_variable(cat_str(4, make_str("*("),
mm_strdup(ecpg_type_name(ptr->indicator->type->type)),make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)),
ECPGmake_simple_type(ptr->indicator->type->type,ptr->indicator->type->size, ptr->variable->type->lineno), 0); 
                  sprintf(temp, "%d, &(", ecpg_informix_var++);
              }
              result = cat_str(5, result, make_str("ECPG_informix_set_var("), mm_strdup(temp), mm_strdup(original_var),
make_str("),__LINE__);\n")); 
          }
+
+         add_variable_to_tail(&newlist, newvar, newind);
       }

+      if (insert)
+         cur->argsinsert_oos = newlist;
+      else
+         cur->argsresult_oos = newlist;
+
       return result;
  }

+ /* This tests whether the cursor was declared and opened in the same function. */
+ #define SAMEFUNC(cur)    \
+     ((cur->function == NULL) ||        \
+      (cur->function != NULL && !strcmp(cur->function, current_function)))
+
  static struct cursor *
  add_additional_variables(char *name, bool insert)
  {
*************** add_additional_variables(char *name, boo
*** 322,333 ****
      {
          /* add all those input variables that were given earlier
           * note that we have to append here but have to keep the existing order */
!         for (p = ptr->argsinsert; p; p = p->next)
              add_variable_to_tail(&argsinsert, p->variable, p->indicator);
      }

      /* add all those output variables that were given earlier */
!     for (p = ptr->argsresult; p; p = p->next)
          add_variable_to_tail(&argsresult, p->variable, p->indicator);

      return ptr;
--- 401,412 ----
      {
          /* add all those input variables that were given earlier
           * note that we have to append here but have to keep the existing order */
!         for (p = (SAMEFUNC(ptr) ? ptr->argsinsert : ptr->argsinsert_oos); p; p = p->next)
              add_variable_to_tail(&argsinsert, p->variable, p->indicator);
      }

      /* add all those output variables that were given earlier */
!     for (p = (SAMEFUNC(ptr) ? ptr->argsresult : ptr->argsresult_oos); p; p = p->next)
          add_variable_to_tail(&argsresult, p->variable, p->indicator);

      return ptr;
diff -dcrpN pgsql.describe/src/interfaces/ecpg/preproc/ecpg.trailer
pgsql.ooscur/src/interfaces/ecpg/preproc/ecpg.trailer
*** pgsql.describe/src/interfaces/ecpg/preproc/ecpg.trailer    2009-09-03 13:14:28.000000000 +0200
--- pgsql.ooscur/src/interfaces/ecpg/preproc/ecpg.trailer    2009-09-03 14:36:36.000000000 +0200
*************** statement: ecpgstart at stmt ';'
*** 16,22 ****
                  | c_thing               { fprintf(yyout, "%s", $1); free($1); }
                  | CPP_LINE              { fprintf(yyout, "%s", $1); free($1); }
                  | '{'                   { braces_open++; fputs("{", yyout); }
!                 | '}'                   { remove_typedefs(braces_open); remove_variables(braces_open--); fputs("}",
yyout);} 
                  ;

  CreateAsStmt: CREATE OptTemp TABLE create_as_target AS {FoundInto = 0;} SelectStmt opt_with_data
--- 16,32 ----
                  | c_thing               { fprintf(yyout, "%s", $1); free($1); }
                  | CPP_LINE              { fprintf(yyout, "%s", $1); free($1); }
                  | '{'                   { braces_open++; fputs("{", yyout); }
!                 | '}'
!         {
!             remove_typedefs(braces_open);
!             remove_variables(braces_open--);
!             if (braces_open == 0)
!             {
!                 free(current_function);
!                 current_function = NULL;
!             }
!             fputs("}", yyout);
!         }
                  ;

  CreateAsStmt: CREATE OptTemp TABLE create_as_target AS {FoundInto = 0;} SelectStmt opt_with_data
*************** ECPGCursorStmt:  DECLARE cursor_name cur
*** 336,344 ****
--- 346,356 ----
              /* initial definition */
              this->next = cur;
              this->name = $2;
+             this->function = (current_function ? mm_strdup(current_function) : NULL);
              this->connection = connection;
              this->command =  cat_str(6, make_str("declare"), cursor_marker, $3, make_str("cursor"), $5, make_str("for
$1"));
              this->argsresult = NULL;
+             this->argsresult_oos = NULL;

              thisquery->type = &ecpg_query;
              thisquery->brace_level = 0;
*************** ECPGCursorStmt:  DECLARE cursor_name cur
*** 347,352 ****
--- 359,365 ----
              sprintf(thisquery->name, "ECPGprepared_statement(%s, %s, __LINE__)", con, $7);

              this->argsinsert = NULL;
+             this->argsinsert_oos = NULL;
              if ($2[0] == ':')
              {
                  struct variable *var = find_variable($2 + 1);
*************** var_declaration: storage_declaration
*** 443,448 ****
--- 456,462 ----
          var_type
          {
              actual_type[struct_level].type_enum = $2.type_enum;
+             actual_type[struct_level].type_str = $2.type_str;
              actual_type[struct_level].type_dimension = $2.type_dimension;
              actual_type[struct_level].type_index = $2.type_index;
              actual_type[struct_level].type_sizeof = $2.type_sizeof;
*************** var_declaration: storage_declaration
*** 456,461 ****
--- 470,476 ----
          | var_type
          {
              actual_type[struct_level].type_enum = $1.type_enum;
+             actual_type[struct_level].type_str = $1.type_str;
              actual_type[struct_level].type_dimension = $1.type_dimension;
              actual_type[struct_level].type_index = $1.type_index;
              actual_type[struct_level].type_sizeof = $1.type_sizeof;
*************** variable: opt_pointer ECPGColLabel opt_a
*** 867,875 ****
                  case ECPGt_struct:
                  case ECPGt_union:
                      if (atoi(dimension) < 0)
!                         type = ECPGmake_struct_type(struct_member_list[struct_level],
actual_type[struct_level].type_enum,actual_type[struct_level].type_sizeof); 
                      else
!                         type = ECPGmake_array_type(ECPGmake_struct_type(struct_member_list[struct_level],
actual_type[struct_level].type_enum,actual_type[struct_level].type_sizeof), dimension); 

                      $$ = cat_str(5, $1, mm_strdup($2), $3.str, $4, $5);
                      break;
--- 882,890 ----
                  case ECPGt_struct:
                  case ECPGt_union:
                      if (atoi(dimension) < 0)
!                         type = ECPGmake_struct_type(struct_member_list[struct_level],
actual_type[struct_level].type_enum,actual_type[struct_level].type_str, actual_type[struct_level].type_sizeof); 
                      else
!                         type = ECPGmake_array_type(ECPGmake_struct_type(struct_member_list[struct_level],
actual_type[struct_level].type_enum,actual_type[struct_level].type_str, actual_type[struct_level].type_sizeof),
dimension);

                      $$ = cat_str(5, $1, mm_strdup($2), $3.str, $4, $5);
                      break;
*************** ECPGVar: SQL_VAR
*** 1373,1381 ****
                      case ECPGt_struct:
                      case ECPGt_union:
                          if (atoi(dimension) < 0)
!                             type = ECPGmake_struct_type(struct_member_list[struct_level], $5.type_enum,
$5.type_sizeof);
                          else
!                             type = ECPGmake_array_type(ECPGmake_struct_type(struct_member_list[struct_level],
$5.type_enum,$5.type_sizeof),dimension); 
                          break;

                      case ECPGt_varchar:
--- 1388,1396 ----
                      case ECPGt_struct:
                      case ECPGt_union:
                          if (atoi(dimension) < 0)
!                             type = ECPGmake_struct_type(struct_member_list[struct_level], $5.type_enum, $5.type_str,
$5.type_sizeof);
                          else
!                             type = ECPGmake_array_type(ECPGmake_struct_type(struct_member_list[struct_level],
$5.type_enum,$5.type_str, $5.type_sizeof), dimension); 
                          break;

                      case ECPGt_varchar:
diff -dcrpN pgsql.describe/src/interfaces/ecpg/preproc/extern.h pgsql.ooscur/src/interfaces/ecpg/preproc/extern.h
*** pgsql.describe/src/interfaces/ecpg/preproc/extern.h    2009-09-03 12:56:36.000000000 +0200
--- pgsql.ooscur/src/interfaces/ecpg/preproc/extern.h    2009-09-03 13:57:48.000000000 +0200
*************** extern int    braces_open,
*** 29,34 ****
--- 29,35 ----
              ecpg_informix_var,
              regression_mode,
              auto_prepare;
+ extern char *current_function;
  extern char *descriptor_index;
  extern char *descriptor_name;
  extern char *connection;
diff -dcrpN pgsql.describe/src/interfaces/ecpg/preproc/pgc.l pgsql.ooscur/src/interfaces/ecpg/preproc/pgc.l
*** pgsql.describe/src/interfaces/ecpg/preproc/pgc.l    2009-01-30 17:28:46.000000000 +0100
--- pgsql.ooscur/src/interfaces/ecpg/preproc/pgc.l    2009-09-03 13:57:48.000000000 +0200
*************** static char    *literalbuf = NULL;        /* e
*** 41,46 ****
--- 41,49 ----
  static int        literallen;                /* actual current length */
  static int        literalalloc;            /* current allocated buffer size */

+ /* Used for detecting global state together with braces_open */
+ static int        parenths_open;
+
  #define startlit()    (literalbuf[0] = '\0', literallen = 0)
  static void addlit(char *ytext, int yleng);
  static void addlitchar (unsigned char);
*************** cppline            {space}*#(.*\\{space})*.*{newl
*** 788,794 ****
                      }
  <C>{identifier}     {
                          const ScanKeyword        *keyword;
!
                          /* Informix uses SQL defines only in SQL space */
                          /* however, some defines have to be taken care of for compatibility */
                          if ((!INFORMIX_MODE || !isinformixdefine()) && !isdefine())
--- 791,807 ----
                      }
  <C>{identifier}     {
                          const ScanKeyword        *keyword;
!
!                         /*
!                          * Try to detect a function name:
!                          * look for identifiers at the global scope
!                          * keep the last identifier before the first '(' and '{' */
!                         if (braces_open == 0 && parenths_open == 0)
!                         {
!                             if (current_function)
!                                 free(current_function);
!                             current_function = mm_strdup(yytext);
!                         }
                          /* Informix uses SQL defines only in SQL space */
                          /* however, some defines have to be taken care of for compatibility */
                          if ((!INFORMIX_MODE || !isinformixdefine()) && !isdefine())
*************** cppline            {space}*#(.*\\{space})*.*{newl
*** 811,818 ****
  <C>"/"                { return('/'); }
  <C>"+"                { return('+'); }
  <C>"-"                { return('-'); }
! <C>"("                { return('('); }
! <C>")"                { return(')'); }
  <C,xskip>{space}        { ECHO; }
  <C>\{                { return('{'); }
  <C>\}                { return('}'); }
--- 824,831 ----
  <C>"/"                { return('/'); }
  <C>"+"                { return('+'); }
  <C>"-"                { return('-'); }
! <C>"("                { parenths_open++; return('('); }
! <C>")"                { parenths_open--; return(')'); }
  <C,xskip>{space}        { ECHO; }
  <C>\{                { return('{'); }
  <C>\}                { return('}'); }
*************** void
*** 1178,1183 ****
--- 1191,1198 ----
  lex_init(void)
  {
      braces_open = 0;
+     parenths_open = 0;
+     current_function = NULL;

      preproc_tos = 0;
      yylineno = 1;
diff -dcrpN pgsql.describe/src/interfaces/ecpg/preproc/type.c pgsql.ooscur/src/interfaces/ecpg/preproc/type.c
*** pgsql.describe/src/interfaces/ecpg/preproc/type.c    2009-09-03 12:56:36.000000000 +0200
--- pgsql.ooscur/src/interfaces/ecpg/preproc/type.c    2009-09-03 13:57:48.000000000 +0200
*************** ECPGstruct_member_dup(struct ECPGstruct_
*** 46,52 ****
          {
              case ECPGt_struct:
              case ECPGt_union:
!                 type = ECPGmake_struct_type(rm->type->u.members, rm->type->type, rm->type->struct_sizeof);
                  break;
              case ECPGt_array:

--- 46,52 ----
          {
              case ECPGt_struct:
              case ECPGt_union:
!                 type = ECPGmake_struct_type(rm->type->u.members, rm->type->type, rm->type->type_name,
rm->type->struct_sizeof);
                  break;
              case ECPGt_array:

*************** ECPGstruct_member_dup(struct ECPGstruct_
*** 55,61 ****
                   * create the struct too
                   */
                  if (rm->type->u.element->type == ECPGt_struct)
!                     type = ECPGmake_struct_type(rm->type->u.element->u.members, rm->type->u.element->type,
rm->type->u.element->struct_sizeof);
                  else
                      type = ECPGmake_array_type(ECPGmake_simple_type(rm->type->u.element->type,
rm->type->u.element->size,rm->type->u.element->lineno), rm->type->size); 
                  break;
--- 55,61 ----
                   * create the struct too
                   */
                  if (rm->type->u.element->type == ECPGt_struct)
!                     type = ECPGmake_struct_type(rm->type->u.element->u.members, rm->type->u.element->type,
rm->type->u.element->type_name,rm->type->u.element->struct_sizeof); 
                  else
                      type = ECPGmake_array_type(ECPGmake_simple_type(rm->type->u.element->type,
rm->type->u.element->size,rm->type->u.element->lineno), rm->type->size); 
                  break;
*************** ECPGmake_simple_type(enum ECPGttype type
*** 98,103 ****
--- 98,104 ----
      struct ECPGtype *ne = (struct ECPGtype *) mm_alloc(sizeof(struct ECPGtype));

      ne->type = type;
+     ne->type_name = NULL;
      ne->size = size;
      ne->u.element = NULL;
      ne->struct_sizeof = NULL;
*************** ECPGmake_array_type(struct ECPGtype * ty
*** 117,126 ****
  }

  struct ECPGtype *
! ECPGmake_struct_type(struct ECPGstruct_member * rm, enum ECPGttype type, char *struct_sizeof)
  {
      struct ECPGtype *ne = ECPGmake_simple_type(type, make_str("1"), 0);

      ne->u.members = ECPGstruct_member_dup(rm);
      ne->struct_sizeof = struct_sizeof;

--- 118,128 ----
  }

  struct ECPGtype *
! ECPGmake_struct_type(struct ECPGstruct_member * rm, enum ECPGttype type, char *type_name, char *struct_sizeof)
  {
      struct ECPGtype *ne = ECPGmake_simple_type(type, make_str("1"), 0);

+     ne->type_name = mm_strdup(type_name);
      ne->u.members = ECPGstruct_member_dup(rm);
      ne->struct_sizeof = struct_sizeof;

diff -dcrpN pgsql.describe/src/interfaces/ecpg/preproc/type.h pgsql.ooscur/src/interfaces/ecpg/preproc/type.h
*** pgsql.describe/src/interfaces/ecpg/preproc/type.h    2009-06-13 18:25:05.000000000 +0200
--- pgsql.ooscur/src/interfaces/ecpg/preproc/type.h    2009-09-03 13:57:48.000000000 +0200
*************** struct ECPGstruct_member
*** 17,22 ****
--- 17,23 ----
  struct ECPGtype
  {
      enum ECPGttype type;
+     char       *type_name;            /* For struct and union types it is the struct name */
      char       *size;            /* For array it is the number of elements. For
                                   * varchar it is the maxsize of the area. */
      char       *struct_sizeof;    /* For a struct this is the sizeof() type as
*************** void        ECPGmake_struct_member(char *, str
*** 36,42 ****
  struct ECPGtype *ECPGmake_simple_type(enum ECPGttype, char *, int);
  struct ECPGtype *ECPGmake_varchar_type(enum ECPGttype, long);
  struct ECPGtype *ECPGmake_array_type(struct ECPGtype *, char *);
! struct ECPGtype *ECPGmake_struct_type(struct ECPGstruct_member *, enum ECPGttype, char *);
  struct ECPGstruct_member *ECPGstruct_member_dup(struct ECPGstruct_member *);

  /* Frees a type. */
--- 37,43 ----
  struct ECPGtype *ECPGmake_simple_type(enum ECPGttype, char *, int);
  struct ECPGtype *ECPGmake_varchar_type(enum ECPGttype, long);
  struct ECPGtype *ECPGmake_array_type(struct ECPGtype *, char *);
! struct ECPGtype *ECPGmake_struct_type(struct ECPGstruct_member *, enum ECPGttype, char *, char *);
  struct ECPGstruct_member *ECPGstruct_member_dup(struct ECPGstruct_member *);

  /* Frees a type. */
*************** struct _include_path
*** 123,133 ****
--- 124,137 ----
  struct cursor
  {
      char       *name;
+     char       *function;
      char       *command;
      char       *connection;
      bool        opened;
      struct arguments *argsinsert;
+     struct arguments *argsinsert_oos;
      struct arguments *argsresult;
+     struct arguments *argsresult_oos;
      struct cursor *next;
  };

diff -dcrpN pgsql.describe/src/interfaces/ecpg/preproc/variable.c pgsql.ooscur/src/interfaces/ecpg/preproc/variable.c
*** pgsql.describe/src/interfaces/ecpg/preproc/variable.c    2009-09-03 12:28:03.000000000 +0200
--- pgsql.ooscur/src/interfaces/ecpg/preproc/variable.c    2009-09-03 13:57:48.000000000 +0200
*************** find_struct_member(char *name, char *str
*** 47,53 ****
                          return (new_variable(name,
ECPGmake_array_type(ECPGmake_simple_type(members->type->u.element->type,members->type->u.element->size,
members->type->u.element->lineno),members->type->size), brace_level)); 
                      case ECPGt_struct:
                      case ECPGt_union:
!                         return (new_variable(name, ECPGmake_struct_type(members->type->u.members,
members->type->type,members->type->struct_sizeof), brace_level)); 
                      default:
                          return (new_variable(name, ECPGmake_simple_type(members->type->type, members->type->size,
members->type->lineno),brace_level)); 
                  }
--- 47,53 ----
                          return (new_variable(name,
ECPGmake_array_type(ECPGmake_simple_type(members->type->u.element->type,members->type->u.element->size,
members->type->u.element->lineno),members->type->size), brace_level)); 
                      case ECPGt_struct:
                      case ECPGt_union:
!                         return (new_variable(name, ECPGmake_struct_type(members->type->u.members,
members->type->type,members->type->type_name, members->type->struct_sizeof), brace_level)); 
                      default:
                          return (new_variable(name, ECPGmake_simple_type(members->type->type, members->type->size,
members->type->lineno),brace_level)); 
                  }
*************** find_struct_member(char *name, char *str
*** 94,100 ****
                                  return (new_variable(name,
ECPGmake_array_type(ECPGmake_simple_type(members->type->u.element->u.element->type,
members->type->u.element->u.element->size,members->type->u.element->u.element->lineno),
members->type->u.element->size),brace_level)); 
                              case ECPGt_struct:
                              case ECPGt_union:
!                                 return (new_variable(name, ECPGmake_struct_type(members->type->u.element->u.members,
members->type->u.element->type,members->type->u.element->struct_sizeof), brace_level)); 
                              default:
                                  return (new_variable(name, ECPGmake_simple_type(members->type->u.element->type,
members->type->u.element->size,members->type->u.element->lineno), brace_level)); 
                          }
--- 94,100 ----
                                  return (new_variable(name,
ECPGmake_array_type(ECPGmake_simple_type(members->type->u.element->u.element->type,
members->type->u.element->u.element->size,members->type->u.element->u.element->lineno),
members->type->u.element->size),brace_level)); 
                              case ECPGt_struct:
                              case ECPGt_union:
!                                 return (new_variable(name, ECPGmake_struct_type(members->type->u.element->u.members,
members->type->u.element->type,members->type->u.element->type_name, members->type->u.element->struct_sizeof),
brace_level));
                              default:
                                  return (new_variable(name, ECPGmake_simple_type(members->type->u.element->type,
members->type->u.element->size,members->type->u.element->lineno), brace_level)); 
                          }
*************** find_variable(char *name)
*** 235,241 ****
                          return (new_variable(name,
ECPGmake_array_type(ECPGmake_simple_type(p->type->u.element->u.element->type,p->type->u.element->u.element->size,
p->type->u.element->u.element->lineno),p->type->u.element->size), p->brace_level)); 
                      case ECPGt_struct:
                      case ECPGt_union:
!                         return (new_variable(name, ECPGmake_struct_type(p->type->u.element->u.members,
p->type->u.element->type,p->type->u.element->struct_sizeof), p->brace_level)); 
                      default:
                          return (new_variable(name, ECPGmake_simple_type(p->type->u.element->type,
p->type->u.element->size,p->type->u.element->lineno), p->brace_level)); 
                  }
--- 235,241 ----
                          return (new_variable(name,
ECPGmake_array_type(ECPGmake_simple_type(p->type->u.element->u.element->type,p->type->u.element->u.element->size,
p->type->u.element->u.element->lineno),p->type->u.element->size), p->brace_level)); 
                      case ECPGt_struct:
                      case ECPGt_union:
!                         return (new_variable(name, ECPGmake_struct_type(p->type->u.element->u.members,
p->type->u.element->type,p->type->u.element->type_name, p->type->u.element->struct_sizeof), p->brace_level)); 
                      default:
                          return (new_variable(name, ECPGmake_simple_type(p->type->u.element->type,
p->type->u.element->size,p->type->u.element->lineno), p->brace_level)); 
                  }
diff -dcrpN pgsql.describe/src/interfaces/ecpg/test/compat_informix/Makefile
pgsql.ooscur/src/interfaces/ecpg/test/compat_informix/Makefile
*** pgsql.describe/src/interfaces/ecpg/test/compat_informix/Makefile    2009-09-03 13:14:28.000000000 +0200
--- pgsql.ooscur/src/interfaces/ecpg/test/compat_informix/Makefile    2009-09-03 13:57:48.000000000 +0200
*************** TESTS = test_informix test_informix.c \
*** 14,19 ****
--- 14,21 ----
          test_informix2 test_informix2.c \
          cursor cursor.c \
          describe describe.c \
+         struct struct.c \
+         outofscope outofscope.c \
          dec_test dec_test.c \
          rfmtdate rfmtdate.c \
          rfmtlong rfmtlong.c \
*************** describe.c: describe.pgc ../regression.h
*** 38,43 ****
--- 40,51 ----
  sqlda.c: sqlda.pgc ../regression.h
      $(ECPG) -o $@ -I$(srcdir) $<

+ struct.c: struct.pgc ../regression.h
+     $(ECPG) -o $@ -I$(srcdir) $<
+
+ outofscope.c: outofscope.pgc ../regression.h
+     $(ECPG) -o $@ -I$(srcdir) $<
+
  dec_test.c: dec_test.pgc ../regression.h
      $(ECPG) -o $@ -I$(srcdir) $<

diff -dcrpN pgsql.describe/src/interfaces/ecpg/test/compat_informix/outofscope.pgc
pgsql.ooscur/src/interfaces/ecpg/test/compat_informix/outofscope.pgc
*** pgsql.describe/src/interfaces/ecpg/test/compat_informix/outofscope.pgc    1970-01-01 01:00:00.000000000 +0100
--- pgsql.ooscur/src/interfaces/ecpg/test/compat_informix/outofscope.pgc    2009-09-03 13:57:48.000000000 +0200
***************
*** 0 ****
--- 1,122 ----
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+
+ exec sql include ../regression;
+
+ exec sql begin declare section;
+ exec sql include struct.h;
+ exec sql end declare section;
+
+ exec sql whenever sqlerror stop;
+
+ static void
+ get_var(MYTYPE **myvar0, MYNULLTYPE **mynullvar0)
+ {
+     exec sql begin declare section;
+     MYTYPE        *myvar = malloc(sizeof(MYTYPE));
+     MYNULLTYPE    *mynullvar = malloc(sizeof(MYNULLTYPE));
+     exec sql end declare section;
+
+     /* Test DECLARE ... SELECT ... INTO with pointers */
+
+     exec sql declare mycur cursor for select * INTO :myvar :mynullvar from a1;
+
+     if (sqlca.sqlcode != 0)
+         exit(1);
+
+     *myvar0 = myvar;
+     *mynullvar0 = mynullvar;
+ }
+
+ static void
+ open_cur(void)
+ {
+     exec sql open mycur;
+
+     if (sqlca.sqlcode != 0)
+         exit(1);
+ }
+
+ static void
+ get_record(void)
+ {
+     exec sql fetch mycur;
+
+     if (sqlca.sqlcode != 0 && sqlca.sqlcode != SQLNOTFOUND)
+         exit(1);
+ }
+
+ static void
+ close_cur(void)
+ {
+     exec sql close mycur;
+
+     if (sqlca.sqlcode != 0)
+         exit(1);
+ }
+
+ int
+ main (void)
+ {
+     MYTYPE        *myvar;
+     MYNULLTYPE    *mynullvar;
+
+     char msg[128];
+
+     ECPGdebug(1, stderr);
+
+     strcpy(msg, "connect");
+     exec sql connect to REGRESSDB1;
+
+     strcpy(msg, "set");
+     exec sql set datestyle to iso;
+
+     strcpy(msg, "create");
+     exec sql create table a1(id serial primary key, t text, d1 numeric, d2 float8, c character(10));
+
+     strcpy(msg, "insert");
+     exec sql insert into a1(id, t, d1, d2, c) values (default, 'a', 1.0, 2, 'a');
+     exec sql insert into a1(id, t, d1, d2, c) values (default, null, null, null, null);
+     exec sql insert into a1(id, t, d1, d2, c) values (default, '"a"', -1.0, 'nan'::float8, 'a');
+     exec sql insert into a1(id, t, d1, d2, c) values (default, 'b', 2.0, 3, 'b');
+
+     strcpy(msg, "commit");
+     exec sql commit;
+
+     /* Test out-of-scope DECLARE/OPEN/FETCH/CLOSE */
+
+     get_var(&myvar, &mynullvar);
+     open_cur();
+
+     exec sql whenever not found do break;
+
+     while (1)
+     {
+         memset(myvar, 0, sizeof(MYTYPE));
+         get_record();
+         if (sqlca.sqlcode == SQLNOTFOUND)
+             break;
+         printf("id=%d%s t='%s'%s d1=%lf%s d2=%lf%s c = '%s'%s\n",
+             myvar->id, mynullvar->id ? " (NULL)" : "",
+             myvar->t, mynullvar->t ? " (NULL)" : "",
+             myvar->d1, mynullvar->d1 ? " (NULL)" : "",
+             myvar->d2, mynullvar->d2 ? " (NULL)" : "",
+             myvar->c, mynullvar->c ? " (NULL)" : "");
+     }
+
+     close_cur();
+
+     /* End test */
+
+     strcpy(msg, "drop");
+     exec sql drop table a1;
+
+     strcpy(msg, "commit");
+     exec sql commit;
+
+     strcpy(msg, "disconnect");
+     exec sql disconnect;
+
+     return (0);
+ }
diff -dcrpN pgsql.describe/src/interfaces/ecpg/test/compat_informix/struct.h
pgsql.ooscur/src/interfaces/ecpg/test/compat_informix/struct.h
*** pgsql.describe/src/interfaces/ecpg/test/compat_informix/struct.h    1970-01-01 01:00:00.000000000 +0100
--- pgsql.ooscur/src/interfaces/ecpg/test/compat_informix/struct.h    2009-09-03 13:57:48.000000000 +0200
***************
*** 0 ****
--- 1,18 ----
+
+ struct mytype {
+     int    id;
+     char    t[64];
+     double    d1; /* dec_t */
+     double    d2;
+     char    c[30];
+ };
+ typedef struct mytype MYTYPE;
+
+ struct mynulltype {
+     int    id;
+     int    t;
+     int    d1;
+     int    d2;
+     int    c;
+ };
+ typedef struct mynulltype MYNULLTYPE;
diff -dcrpN pgsql.describe/src/interfaces/ecpg/test/compat_informix/struct.pgc
pgsql.ooscur/src/interfaces/ecpg/test/compat_informix/struct.pgc
*** pgsql.describe/src/interfaces/ecpg/test/compat_informix/struct.pgc    1970-01-01 01:00:00.000000000 +0100
--- pgsql.ooscur/src/interfaces/ecpg/test/compat_informix/struct.pgc    2009-09-03 13:57:48.000000000 +0200
***************
*** 0 ****
--- 1,76 ----
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+
+ exec sql include ../regression;
+
+ exec sql begin declare section;
+ exec sql include struct.h;
+ exec sql end declare section;
+
+ exec sql whenever sqlerror stop;
+
+ int
+ main (void)
+ {
+     exec sql begin declare section;
+     MYTYPE        myvar;
+     MYNULLTYPE    mynullvar;
+     exec sql end declare section;
+
+     char msg[128];
+
+     ECPGdebug(1, stderr);
+
+     strcpy(msg, "connect");
+     exec sql connect to REGRESSDB1;
+
+     strcpy(msg, "set");
+     exec sql set datestyle to iso;
+
+     strcpy(msg, "create");
+     exec sql create table a1(id serial primary key, t text, d1 numeric, d2 float8, c character(10));
+
+     strcpy(msg, "insert");
+     exec sql insert into a1(id, t, d1, d2, c) values (default, 'a', 1.0, 2, 'a');
+     exec sql insert into a1(id, t, d1, d2, c) values (default, null, null, null, null);
+     exec sql insert into a1(id, t, d1, d2, c) values (default, '"a"', -1.0, 'nan'::float8, 'a');
+     exec sql insert into a1(id, t, d1, d2, c) values (default, 'b', 2.0, 3, 'b');
+
+     strcpy(msg, "commit");
+     exec sql commit;
+
+     /* Test DECLARE ... SELECT ... INTO with struct type */
+
+     exec sql declare mycur cursor for select * into :myvar :mynullvar from a1;
+     exec sql open mycur;
+
+     exec sql whenever not found do break;
+
+     while (1)
+     {
+         memset(&myvar, 0, sizeof(myvar));
+         exec sql fetch mycur;
+         printf("id=%d%s t='%s'%s d1=%lf%s d2=%lf%s c = '%s'%s\n",
+             myvar.id, mynullvar.id ? " (NULL)" : "",
+             myvar.t, mynullvar.t ? " (NULL)" : "",
+             myvar.d1, mynullvar.d1 ? " (NULL)" : "",
+             myvar.d2, mynullvar.d2 ? " (NULL)" : "",
+             myvar.c, mynullvar.c ? " (NULL)" : "");
+     }
+
+     exec sql close mycur;
+
+     /* End test */
+
+     strcpy(msg, "drop");
+     exec sql drop table a1;
+
+     strcpy(msg, "commit");
+     exec sql commit;
+
+     strcpy(msg, "disconnect");
+     exec sql disconnect;
+
+     return (0);
+ }
diff -dcrpN pgsql.describe/src/interfaces/ecpg/test/ecpg_schedule pgsql.ooscur/src/interfaces/ecpg/test/ecpg_schedule
*** pgsql.describe/src/interfaces/ecpg/test/ecpg_schedule    2009-09-03 13:14:28.000000000 +0200
--- pgsql.ooscur/src/interfaces/ecpg/test/ecpg_schedule    2009-09-03 13:57:48.000000000 +0200
*************** test: compat_informix/rnull
*** 6,11 ****
--- 6,13 ----
  test: compat_informix/cursor
  test: compat_informix/sqlda
  test: compat_informix/describe
+ test: compat_informix/struct
+ test: compat_informix/outofscope
  test: compat_informix/test_informix
  test: compat_informix/test_informix2
  test: connect/test2
diff -dcrpN pgsql.describe/src/interfaces/ecpg/test/ecpg_schedule_tcp
pgsql.ooscur/src/interfaces/ecpg/test/ecpg_schedule_tcp
*** pgsql.describe/src/interfaces/ecpg/test/ecpg_schedule_tcp    2009-09-03 13:14:28.000000000 +0200
--- pgsql.ooscur/src/interfaces/ecpg/test/ecpg_schedule_tcp    2009-09-03 13:57:48.000000000 +0200
*************** test: compat_informix/rnull
*** 6,11 ****
--- 6,13 ----
  test: compat_informix/cursor
  test: compat_informix/sqlda
  test: compat_informix/describe
+ test: compat_informix/struct
+ test: compat_informix/outofscope
  test: compat_informix/test_informix
  test: compat_informix/test_informix2
  test: connect/test2
diff -dcrpN pgsql.describe/src/interfaces/ecpg/test/expected/compat_informix-cursor.c
pgsql.ooscur/src/interfaces/ecpg/test/expected/compat_informix-cursor.c
*** pgsql.describe/src/interfaces/ecpg/test/expected/compat_informix-cursor.c    2009-09-03 12:47:24.000000000 +0200
--- pgsql.ooscur/src/interfaces/ecpg/test/expected/compat_informix-cursor.c    2009-09-03 13:57:48.000000000 +0200
*************** if (sqlca.sqlcode < 0) exit (1);}
*** 162,168 ****

      strcpy(msg, "open");
      { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare $0 cursor for select id , t from t1",
!     ECPGt_char,&(*( char  *)(ECPG_informix_get_var( 0))),(long)0,(long)1,(1)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
  #line 62 "cursor.pgc"

--- 162,168 ----

      strcpy(msg, "open");
      { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare $0 cursor for select id , t from t1",
!     ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
  #line 62 "cursor.pgc"

*************** if (sqlca.sqlcode < 0) exit (1);}
*** 298,308 ****

      strcpy(msg, "open");
      { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare $0 cursor for select id , t from t1",
!     ECPGt_char,&(*( char  *)(ECPG_informix_get_var( 3))),(long)0,(long)1,(1)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
!     ECPGt_int,&(*( int  *)(ECPG_informix_get_var( 2))),(long)1,(long)1,sizeof(int),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
!     ECPGt_char,(( char  *)(ECPG_informix_get_var( 1))),(long)64,(long)1,(64)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
  #line 103 "cursor.pgc"

--- 298,308 ----

      strcpy(msg, "open");
      { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare $0 cursor for select id , t from t1",
!     ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
!     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
!     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
  #line 103 "cursor.pgc"

*************** if (sqlca.sqlcode < 0) exit (1);}
*** 314,322 ****
      { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch from $0",
      ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
!     ECPGt_int,&(*( int  *)(ECPG_informix_get_var( 2))),(long)1,(long)1,sizeof(int),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
!     ECPGt_char,(( char  *)(ECPG_informix_get_var( 1))),(long)64,(long)1,(64)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
  #line 106 "cursor.pgc"

--- 314,322 ----
      { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch from $0",
      ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
!     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
!     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
  #line 106 "cursor.pgc"

*************** if (sqlca.sqlcode < 0) exit (1);}
*** 329,337 ****
      { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch $0",
      ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
!     ECPGt_int,&(*( int  *)(ECPG_informix_get_var( 2))),(long)1,(long)1,sizeof(int),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
!     ECPGt_char,(( char  *)(ECPG_informix_get_var( 1))),(long)64,(long)1,(64)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
  #line 110 "cursor.pgc"

--- 329,337 ----
      { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch $0",
      ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
!     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
!     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
  #line 110 "cursor.pgc"

*************** if (sqlca.sqlcode < 0) exit (1);}
*** 344,352 ****
      { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch 1 from $0",
      ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
!     ECPGt_int,&(*( int  *)(ECPG_informix_get_var( 2))),(long)1,(long)1,sizeof(int),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
!     ECPGt_char,(( char  *)(ECPG_informix_get_var( 1))),(long)64,(long)1,(64)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
  #line 114 "cursor.pgc"

--- 344,352 ----
      { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch 1 from $0",
      ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
!     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
!     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
  #line 114 "cursor.pgc"

*************** if (sqlca.sqlcode < 0) exit (1);}
*** 362,370 ****
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
      ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
!     ECPGt_int,&(*( int  *)(ECPG_informix_get_var( 2))),(long)1,(long)1,sizeof(int),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
!     ECPGt_char,(( char  *)(ECPG_informix_get_var( 1))),(long)64,(long)1,(64)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
  #line 119 "cursor.pgc"

--- 362,370 ----
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
      ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
!     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
!     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
  #line 119 "cursor.pgc"

*************** if (sqlca.sqlcode < 0) exit (1);}
*** 377,385 ****
      { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "move absolute 0 $0",
      ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
!     ECPGt_int,&(*( int  *)(ECPG_informix_get_var( 2))),(long)1,(long)1,sizeof(int),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
!     ECPGt_char,(( char  *)(ECPG_informix_get_var( 1))),(long)64,(long)1,(64)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
  #line 123 "cursor.pgc"

--- 377,385 ----
      { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "move absolute 0 $0",
      ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
!     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
!     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
  #line 123 "cursor.pgc"

*************** if (sqlca.sqlcode < 0) exit (1);}
*** 391,399 ****
      { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch 1 $0",
      ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
!     ECPGt_int,&(*( int  *)(ECPG_informix_get_var( 2))),(long)1,(long)1,sizeof(int),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
!     ECPGt_char,(( char  *)(ECPG_informix_get_var( 1))),(long)64,(long)1,(64)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
  #line 126 "cursor.pgc"

--- 391,399 ----
      { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch 1 $0",
      ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
!     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
!     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
  #line 126 "cursor.pgc"

*************** if (sqlca.sqlcode < 0) exit (1);}
*** 409,417 ****
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
      ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
!     ECPGt_int,&(*( int  *)(ECPG_informix_get_var( 2))),(long)1,(long)1,sizeof(int),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
!     ECPGt_char,(( char  *)(ECPG_informix_get_var( 1))),(long)64,(long)1,(64)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
  #line 131 "cursor.pgc"

--- 409,417 ----
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
      ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
!     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
!     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
  #line 131 "cursor.pgc"

diff -dcrpN pgsql.describe/src/interfaces/ecpg/test/expected/compat_informix-outofscope.c
pgsql.ooscur/src/interfaces/ecpg/test/expected/compat_informix-outofscope.c
*** pgsql.describe/src/interfaces/ecpg/test/expected/compat_informix-outofscope.c    1970-01-01 01:00:00.000000000
+0100
--- pgsql.ooscur/src/interfaces/ecpg/test/expected/compat_informix-outofscope.c    2009-09-03 14:09:48.000000000 +0200
***************
*** 0 ****
--- 1,308 ----
+ /* Processed by ecpg (regression mode) */
+ /* These include files are added by the preprocessor */
+ #include <ecpglib.h>
+ #include <ecpgerrno.h>
+ #include <sqlca.h>
+ /* Needed for informix compatibility */
+ #include <ecpg_informix.h>
+ /* End of automatic include section */
+ #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+
+ #line 1 "outofscope.pgc"
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+
+
+ #line 1 "regression.h"
+
+
+
+
+
+
+ #line 5 "outofscope.pgc"
+
+
+ /* exec sql begin declare section */
+
+ #line 1 "struct.h"
+
+
+
+
+          /* dec_t */
+
+
+
+    typedef struct mytype  MYTYPE ;
+
+ #line 9 "struct.h"
+
+
+
+
+
+
+
+
+
+    typedef struct mynulltype  MYNULLTYPE ;
+
+ #line 18 "struct.h"
+
+
+ #line 8 "outofscope.pgc"
+
+ struct mytype {
+ #line 3 "struct.h"
+  int id ;
+
+ #line 4 "struct.h"
+  char t [ 64 ] ;
+
+ #line 5 "struct.h"
+  double d1 ;
+
+ #line 6 "struct.h"
+  double d2 ;
+
+ #line 7 "struct.h"
+  char c [ 30 ] ;
+  } ; struct mynulltype {
+ #line 12 "struct.h"
+  int id ;
+
+ #line 13 "struct.h"
+  int t ;
+
+ #line 14 "struct.h"
+  int d1 ;
+
+ #line 15 "struct.h"
+  int d2 ;
+
+ #line 16 "struct.h"
+  int c ;
+  } ;/* exec sql end declare section */
+ #line 9 "outofscope.pgc"
+
+
+ /* exec sql whenever sqlerror  stop ; */
+ #line 11 "outofscope.pgc"
+
+
+ static void
+ get_var(MYTYPE **myvar0, MYNULLTYPE **mynullvar0)
+ {
+     /* exec sql begin declare section */
+
+
+
+ #line 17 "outofscope.pgc"
+  MYTYPE * myvar = malloc ( sizeof ( MYTYPE ) ) ;
+
+ #line 18 "outofscope.pgc"
+  MYNULLTYPE * mynullvar = malloc ( sizeof ( MYNULLTYPE ) ) ;
+ /* exec sql end declare section */
+ #line 19 "outofscope.pgc"
+
+
+     /* Test DECLARE ... SELECT ... INTO with pointers */
+
+     ECPG_informix_set_var( 0, ( myvar ), __LINE__);\
+  ECPG_informix_set_var( 1, ( mynullvar ), __LINE__);\
+  ECPG_informix_reset_sqlca(); /* declare mycur cursor for select * from a1 */
+ #line 23 "outofscope.pgc"
+
+
+     if (sqlca.sqlcode != 0)
+         exit(1);
+
+     *myvar0 = myvar;
+     *mynullvar0 = mynullvar;
+ }
+
+ static void
+ open_cur(void)
+ {
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare mycur cursor for select * from a1", ECPGt_EOIT,
+     ECPGt_int,&((*( MYTYPE  *)(ECPG_informix_get_var( 0))).id),(long)1,(long)1,sizeof(int),
+     ECPGt_int,&((*( MYNULLTYPE  *)(ECPG_informix_get_var( 1))).id),(long)1,(long)1,sizeof(int),
+     ECPGt_char,&((*( MYTYPE  *)(ECPG_informix_get_var( 0))).t),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_int,&((*( MYNULLTYPE  *)(ECPG_informix_get_var( 1))).t),(long)1,(long)1,sizeof(int),
+     ECPGt_double,&((*( MYTYPE  *)(ECPG_informix_get_var( 0))).d1),(long)1,(long)1,sizeof(double),
+     ECPGt_int,&((*( MYNULLTYPE  *)(ECPG_informix_get_var( 1))).d1),(long)1,(long)1,sizeof(int),
+     ECPGt_double,&((*( MYTYPE  *)(ECPG_informix_get_var( 0))).d2),(long)1,(long)1,sizeof(double),
+     ECPGt_int,&((*( MYNULLTYPE  *)(ECPG_informix_get_var( 1))).d2),(long)1,(long)1,sizeof(int),
+     ECPGt_char,&((*( MYTYPE  *)(ECPG_informix_get_var( 0))).c),(long)30,(long)1,(30)*sizeof(char),
+     ECPGt_int,&((*( MYNULLTYPE  *)(ECPG_informix_get_var( 1))).c),(long)1,(long)1,sizeof(int), ECPGt_EORT);
+ #line 35 "outofscope.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 35 "outofscope.pgc"
+
+
+     if (sqlca.sqlcode != 0)
+         exit(1);
+ }
+
+ static void
+ get_record(void)
+ {
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch mycur", ECPGt_EOIT,
+     ECPGt_int,&((*( MYTYPE  *)(ECPG_informix_get_var( 0))).id),(long)1,(long)1,sizeof(int),
+     ECPGt_int,&((*( MYNULLTYPE  *)(ECPG_informix_get_var( 1))).id),(long)1,(long)1,sizeof(int),
+     ECPGt_char,&((*( MYTYPE  *)(ECPG_informix_get_var( 0))).t),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_int,&((*( MYNULLTYPE  *)(ECPG_informix_get_var( 1))).t),(long)1,(long)1,sizeof(int),
+     ECPGt_double,&((*( MYTYPE  *)(ECPG_informix_get_var( 0))).d1),(long)1,(long)1,sizeof(double),
+     ECPGt_int,&((*( MYNULLTYPE  *)(ECPG_informix_get_var( 1))).d1),(long)1,(long)1,sizeof(int),
+     ECPGt_double,&((*( MYTYPE  *)(ECPG_informix_get_var( 0))).d2),(long)1,(long)1,sizeof(double),
+     ECPGt_int,&((*( MYNULLTYPE  *)(ECPG_informix_get_var( 1))).d2),(long)1,(long)1,sizeof(int),
+     ECPGt_char,&((*( MYTYPE  *)(ECPG_informix_get_var( 0))).c),(long)30,(long)1,(30)*sizeof(char),
+     ECPGt_int,&((*( MYNULLTYPE  *)(ECPG_informix_get_var( 1))).c),(long)1,(long)1,sizeof(int), ECPGt_EORT);
+ #line 44 "outofscope.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 44 "outofscope.pgc"
+
+
+     if (sqlca.sqlcode != 0 && sqlca.sqlcode != SQLNOTFOUND)
+         exit(1);
+ }
+
+ static void
+ close_cur(void)
+ {
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "close mycur", ECPGt_EOIT, ECPGt_EORT);
+ #line 53 "outofscope.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 53 "outofscope.pgc"
+
+
+     if (sqlca.sqlcode != 0)
+         exit(1);
+ }
+
+ int
+ main (void)
+ {
+     MYTYPE        *myvar;
+     MYNULLTYPE    *mynullvar;
+
+     char msg[128];
+
+     ECPGdebug(1, stderr);
+
+     strcpy(msg, "connect");
+     { ECPGconnect(__LINE__, 1, "regress1" , NULL, NULL , NULL, 0);
+ #line 70 "outofscope.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 70 "outofscope.pgc"
+
+
+     strcpy(msg, "set");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
+ #line 73 "outofscope.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 73 "outofscope.pgc"
+
+
+     strcpy(msg, "create");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "create table a1 ( id serial primary key , t text , d1 numeric ,
d2float8 , c character ( 10 ) )", ECPGt_EOIT, ECPGt_EORT); 
+ #line 76 "outofscope.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 76 "outofscope.pgc"
+
+
+     strcpy(msg, "insert");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'a'
,1.0 , 2 , 'a' )", ECPGt_EOIT, ECPGt_EORT); 
+ #line 79 "outofscope.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 79 "outofscope.pgc"
+
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , null
,null , null , null )", ECPGt_EOIT, ECPGt_EORT); 
+ #line 80 "outofscope.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 80 "outofscope.pgc"
+
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default ,
'\"a\"', - 1.0 , 'nan' :: float8 , 'a' )", ECPGt_EOIT, ECPGt_EORT); 
+ #line 81 "outofscope.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 81 "outofscope.pgc"
+
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'b'
,2.0 , 3 , 'b' )", ECPGt_EOIT, ECPGt_EORT); 
+ #line 82 "outofscope.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 82 "outofscope.pgc"
+
+
+     strcpy(msg, "commit");
+     { ECPGtrans(__LINE__, NULL, "commit");
+ #line 85 "outofscope.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 85 "outofscope.pgc"
+
+
+     /* Test out-of-scope DECLARE/OPEN/FETCH/CLOSE */
+
+     get_var(&myvar, &mynullvar);
+     open_cur();
+
+     /* exec sql whenever not found  break ; */
+ #line 92 "outofscope.pgc"
+
+
+     while (1)
+     {
+         memset(myvar, 0, sizeof(MYTYPE));
+         get_record();
+         if (sqlca.sqlcode == SQLNOTFOUND)
+             break;
+         printf("id=%d%s t='%s'%s d1=%lf%s d2=%lf%s c = '%s'%s\n",
+             myvar->id, mynullvar->id ? " (NULL)" : "",
+             myvar->t, mynullvar->t ? " (NULL)" : "",
+             myvar->d1, mynullvar->d1 ? " (NULL)" : "",
+             myvar->d2, mynullvar->d2 ? " (NULL)" : "",
+             myvar->c, mynullvar->c ? " (NULL)" : "");
+     }
+
+     close_cur();
+
+     /* End test */
+
+     strcpy(msg, "drop");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "drop table a1", ECPGt_EOIT, ECPGt_EORT);
+ #line 113 "outofscope.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 113 "outofscope.pgc"
+
+
+     strcpy(msg, "commit");
+     { ECPGtrans(__LINE__, NULL, "commit");
+ #line 116 "outofscope.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 116 "outofscope.pgc"
+
+
+     strcpy(msg, "disconnect");
+     { ECPGdisconnect(__LINE__, "CURRENT");
+ #line 119 "outofscope.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 119 "outofscope.pgc"
+
+
+     return (0);
+ }
diff -dcrpN pgsql.describe/src/interfaces/ecpg/test/expected/compat_informix-outofscope.stderr
pgsql.ooscur/src/interfaces/ecpg/test/expected/compat_informix-outofscope.stderr
*** pgsql.describe/src/interfaces/ecpg/test/expected/compat_informix-outofscope.stderr    1970-01-01 01:00:00.000000000
+0100
--- pgsql.ooscur/src/interfaces/ecpg/test/expected/compat_informix-outofscope.stderr    2009-09-03 13:57:48.000000000
+0200
***************
*** 0 ****
--- 1,136 ----
+ [NO_PID]: ECPGdebug: set to 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 73: query: set datestyle to iso; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 73: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 73: OK: SET
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 76: query: create table a1 ( id serial primary key , t text , d1 numeric , d2 float8 ,
ccharacter ( 10 ) ); with 0 parameter(s) on connection regress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 76: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 76: OK: CREATE TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 79: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'a' , 1.0 , 2 ,
'a'); with 0 parameter(s) on connection regress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 79: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 79: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 80: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , null , null ,
null, null ); with 0 parameter(s) on connection regress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 80: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 80: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 81: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , '"a"' , - 1.0 ,
'nan':: float8 , 'a' ); with 0 parameter(s) on connection regress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 81: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 81: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 82: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'b' , 2.0 , 3 ,
'b'); with 0 parameter(s) on connection regress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 82: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 82: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 85: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 35: query: declare mycur cursor for select * from a1; with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 35: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 35: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 44: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 44: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 44: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 44: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 44: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 44: RESULT: 1.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 44: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 44: RESULT: a          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 44: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 44: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 44: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 44: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 44: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 44: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 44: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 44: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 44: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 44: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 44: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 44: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 44: RESULT: "a" offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 44: RESULT: -1.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 44: RESULT: NaN offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 44: RESULT: a          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 44: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 44: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 44: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 44: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 44: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 44: RESULT: 2.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 44: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 44: RESULT: b          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 44: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 44: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 44: correctly got 0 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: raising sqlcode 100 on line 44: no data found on line 44
+ [NO_PID]: sqlca: code: 100, state: 02000
+ [NO_PID]: ecpg_execute on line 53: query: close mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 113: query: drop table a1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 113: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 113: OK: DROP TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 116: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection regress1 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
diff -dcrpN pgsql.describe/src/interfaces/ecpg/test/expected/compat_informix-outofscope.stdout
pgsql.ooscur/src/interfaces/ecpg/test/expected/compat_informix-outofscope.stdout
*** pgsql.describe/src/interfaces/ecpg/test/expected/compat_informix-outofscope.stdout    1970-01-01 01:00:00.000000000
+0100
--- pgsql.ooscur/src/interfaces/ecpg/test/expected/compat_informix-outofscope.stdout    2009-09-03 13:57:48.000000000
+0200
***************
*** 0 ****
--- 1,4 ----
+ id=1 t='a' d1=1.000000 d2=2.000000 c = 'a         '
+ id=2 t='' (NULL) d1=0.000000 (NULL) d2=0.000000 (NULL) c = '' (NULL)
+ id=3 t='"a"' d1=-1.000000 d2=nan c = 'a         '
+ id=4 t='b' d1=2.000000 d2=3.000000 c = 'b         '
diff -dcrpN pgsql.describe/src/interfaces/ecpg/test/expected/compat_informix-struct.c
pgsql.ooscur/src/interfaces/ecpg/test/expected/compat_informix-struct.c
*** pgsql.describe/src/interfaces/ecpg/test/expected/compat_informix-struct.c    1970-01-01 01:00:00.000000000 +0100
--- pgsql.ooscur/src/interfaces/ecpg/test/expected/compat_informix-struct.c    2009-09-03 14:09:35.000000000 +0200
***************
*** 0 ****
--- 1,265 ----
+ /* Processed by ecpg (regression mode) */
+ /* These include files are added by the preprocessor */
+ #include <ecpglib.h>
+ #include <ecpgerrno.h>
+ #include <sqlca.h>
+ /* Needed for informix compatibility */
+ #include <ecpg_informix.h>
+ /* End of automatic include section */
+ #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+
+ #line 1 "struct.pgc"
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+
+
+ #line 1 "regression.h"
+
+
+
+
+
+
+ #line 5 "struct.pgc"
+
+
+ /* exec sql begin declare section */
+
+ #line 1 "struct.h"
+
+
+
+
+          /* dec_t */
+
+
+
+    typedef struct mytype  MYTYPE ;
+
+ #line 9 "struct.h"
+
+
+
+
+
+
+
+
+
+    typedef struct mynulltype  MYNULLTYPE ;
+
+ #line 18 "struct.h"
+
+
+ #line 8 "struct.pgc"
+
+ struct mytype {
+ #line 3 "struct.h"
+  int id ;
+
+ #line 4 "struct.h"
+  char t [ 64 ] ;
+
+ #line 5 "struct.h"
+  double d1 ;
+
+ #line 6 "struct.h"
+  double d2 ;
+
+ #line 7 "struct.h"
+  char c [ 30 ] ;
+  } ; struct mynulltype {
+ #line 12 "struct.h"
+  int id ;
+
+ #line 13 "struct.h"
+  int t ;
+
+ #line 14 "struct.h"
+  int d1 ;
+
+ #line 15 "struct.h"
+  int d2 ;
+
+ #line 16 "struct.h"
+  int c ;
+  } ;/* exec sql end declare section */
+ #line 9 "struct.pgc"
+
+
+ /* exec sql whenever sqlerror  stop ; */
+ #line 11 "struct.pgc"
+
+
+ int
+ main (void)
+ {
+     /* exec sql begin declare section */
+
+
+
+ #line 17 "struct.pgc"
+  MYTYPE myvar ;
+
+ #line 18 "struct.pgc"
+  MYNULLTYPE mynullvar ;
+ /* exec sql end declare section */
+ #line 19 "struct.pgc"
+
+
+     char msg[128];
+
+     ECPGdebug(1, stderr);
+
+     strcpy(msg, "connect");
+     { ECPGconnect(__LINE__, 1, "regress1" , NULL, NULL , NULL, 0);
+ #line 26 "struct.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 26 "struct.pgc"
+
+
+     strcpy(msg, "set");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
+ #line 29 "struct.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 29 "struct.pgc"
+
+
+     strcpy(msg, "create");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "create table a1 ( id serial primary key , t text , d1 numeric ,
d2float8 , c character ( 10 ) )", ECPGt_EOIT, ECPGt_EORT); 
+ #line 32 "struct.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 32 "struct.pgc"
+
+
+     strcpy(msg, "insert");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'a'
,1.0 , 2 , 'a' )", ECPGt_EOIT, ECPGt_EORT); 
+ #line 35 "struct.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 35 "struct.pgc"
+
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , null
,null , null , null )", ECPGt_EOIT, ECPGt_EORT); 
+ #line 36 "struct.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 36 "struct.pgc"
+
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default ,
'\"a\"', - 1.0 , 'nan' :: float8 , 'a' )", ECPGt_EOIT, ECPGt_EORT); 
+ #line 37 "struct.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 37 "struct.pgc"
+
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'b'
,2.0 , 3 , 'b' )", ECPGt_EOIT, ECPGt_EORT); 
+ #line 38 "struct.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 38 "struct.pgc"
+
+
+     strcpy(msg, "commit");
+     { ECPGtrans(__LINE__, NULL, "commit");
+ #line 41 "struct.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 41 "struct.pgc"
+
+
+     /* Test DECLARE ... SELECT ... INTO with struct type */
+
+     ECPG_informix_set_var( 0, &( myvar ), __LINE__);\
+  ECPG_informix_set_var( 1, &( mynullvar ), __LINE__);\
+  ECPG_informix_reset_sqlca(); /* declare mycur cursor for select * from a1 */
+ #line 45 "struct.pgc"
+
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare mycur cursor for select * from a1", ECPGt_EOIT,
+     ECPGt_int,&(myvar.id),(long)1,(long)1,sizeof(int),
+     ECPGt_int,&(mynullvar.id),(long)1,(long)1,sizeof(int),
+     ECPGt_char,&(myvar.t),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_int,&(mynullvar.t),(long)1,(long)1,sizeof(int),
+     ECPGt_double,&(myvar.d1),(long)1,(long)1,sizeof(double),
+     ECPGt_int,&(mynullvar.d1),(long)1,(long)1,sizeof(int),
+     ECPGt_double,&(myvar.d2),(long)1,(long)1,sizeof(double),
+     ECPGt_int,&(mynullvar.d2),(long)1,(long)1,sizeof(int),
+     ECPGt_char,&(myvar.c),(long)30,(long)1,(30)*sizeof(char),
+     ECPGt_int,&(mynullvar.c),(long)1,(long)1,sizeof(int), ECPGt_EORT);
+ #line 46 "struct.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 46 "struct.pgc"
+
+
+     /* exec sql whenever not found  break ; */
+ #line 48 "struct.pgc"
+
+
+     while (1)
+     {
+         memset(&myvar, 0, sizeof(myvar));
+         { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch mycur", ECPGt_EOIT,
+     ECPGt_int,&(myvar.id),(long)1,(long)1,sizeof(int),
+     ECPGt_int,&(mynullvar.id),(long)1,(long)1,sizeof(int),
+     ECPGt_char,&(myvar.t),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_int,&(mynullvar.t),(long)1,(long)1,sizeof(int),
+     ECPGt_double,&(myvar.d1),(long)1,(long)1,sizeof(double),
+     ECPGt_int,&(mynullvar.d1),(long)1,(long)1,sizeof(int),
+     ECPGt_double,&(myvar.d2),(long)1,(long)1,sizeof(double),
+     ECPGt_int,&(mynullvar.d2),(long)1,(long)1,sizeof(int),
+     ECPGt_char,&(myvar.c),(long)30,(long)1,(30)*sizeof(char),
+     ECPGt_int,&(mynullvar.c),(long)1,(long)1,sizeof(int), ECPGt_EORT);
+ #line 53 "struct.pgc"
+
+ if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
+ #line 53 "struct.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 53 "struct.pgc"
+
+         printf("id=%d%s t='%s'%s d1=%lf%s d2=%lf%s c = '%s'%s\n",
+             myvar.id, mynullvar.id ? " (NULL)" : "",
+             myvar.t, mynullvar.t ? " (NULL)" : "",
+             myvar.d1, mynullvar.d1 ? " (NULL)" : "",
+             myvar.d2, mynullvar.d2 ? " (NULL)" : "",
+             myvar.c, mynullvar.c ? " (NULL)" : "");
+     }
+
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "close mycur", ECPGt_EOIT, ECPGt_EORT);
+ #line 62 "struct.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 62 "struct.pgc"
+
+
+     /* End test */
+
+     strcpy(msg, "drop");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "drop table a1", ECPGt_EOIT, ECPGt_EORT);
+ #line 67 "struct.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 67 "struct.pgc"
+
+
+     strcpy(msg, "commit");
+     { ECPGtrans(__LINE__, NULL, "commit");
+ #line 70 "struct.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 70 "struct.pgc"
+
+
+     strcpy(msg, "disconnect");
+     { ECPGdisconnect(__LINE__, "CURRENT");
+ #line 73 "struct.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 73 "struct.pgc"
+
+
+     return (0);
+ }
diff -dcrpN pgsql.describe/src/interfaces/ecpg/test/expected/compat_informix-struct.stderr
pgsql.ooscur/src/interfaces/ecpg/test/expected/compat_informix-struct.stderr
*** pgsql.describe/src/interfaces/ecpg/test/expected/compat_informix-struct.stderr    1970-01-01 01:00:00.000000000
+0100
--- pgsql.ooscur/src/interfaces/ecpg/test/expected/compat_informix-struct.stderr    2009-09-03 13:57:48.000000000 +0200
***************
*** 0 ****
--- 1,136 ----
+ [NO_PID]: ECPGdebug: set to 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 29: query: set datestyle to iso; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 29: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 29: OK: SET
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 32: query: create table a1 ( id serial primary key , t text , d1 numeric , d2 float8 ,
ccharacter ( 10 ) ); with 0 parameter(s) on connection regress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 32: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 32: OK: CREATE TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 35: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'a' , 1.0 , 2 ,
'a'); with 0 parameter(s) on connection regress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 35: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 35: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , null , null ,
null, null ); with 0 parameter(s) on connection regress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , '"a"' , - 1.0 ,
'nan':: float8 , 'a' ); with 0 parameter(s) on connection regress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'b' , 2.0 , 3 ,
'b'); with 0 parameter(s) on connection regress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 41: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 46: query: declare mycur cursor for select * from a1; with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 46: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 46: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 1.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: a          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: "a" offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: -1.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: NaN offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: a          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 2.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: b          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: correctly got 0 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: raising sqlcode 100 on line 53: no data found on line 53
+ [NO_PID]: sqlca: code: 100, state: 02000
+ [NO_PID]: ecpg_execute on line 62: query: close mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 62: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 62: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 67: query: drop table a1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 67: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 67: OK: DROP TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 70: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection regress1 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
diff -dcrpN pgsql.describe/src/interfaces/ecpg/test/expected/compat_informix-struct.stdout
pgsql.ooscur/src/interfaces/ecpg/test/expected/compat_informix-struct.stdout
*** pgsql.describe/src/interfaces/ecpg/test/expected/compat_informix-struct.stdout    1970-01-01 01:00:00.000000000
+0100
--- pgsql.ooscur/src/interfaces/ecpg/test/expected/compat_informix-struct.stdout    2009-09-03 13:57:48.000000000 +0200
***************
*** 0 ****
--- 1,4 ----
+ id=1 t='a' d1=1.000000 d2=2.000000 c = 'a         '
+ id=2 t='' (NULL) d1=0.000000 (NULL) d2=0.000000 (NULL) c = '' (NULL)
+ id=3 t='"a"' d1=-1.000000 d2=nan c = 'a         '
+ id=4 t='b' d1=2.000000 d2=3.000000 c = 'b         '

Re: ECPG patchset

From
Boszormenyi Zoltan
Date:
Boszormenyi Zoltan írta:
> Out of scope cursor usage
>

New version of this, changes:
- DECLARE cursor FOR prepared_stmt is also handled properly
- ECPG_informix_set_var() calls are not emitted for global statements
- regression test "outofscope.pgc" is updated

I think it's now at the point where we can reconsider your argument
about making this feature generic and not an Informix-only feature:

> Yeah, right, and you also add this hack to all applications. No.

I don't think it's hackish at all now. Read the outofscope.pgc
regression test and its generated source.
- ECPG_informix_set_var() calls are only generated for variables
  in function scope, not for globals.
- ECPG_informix_get_var() calls are generated only when
  OPEN and FETCH are in a function different from the one
  where DECLARE was.

In the common case the generated source would only contain
some *_set_var() calls but the function references wouldn't change.

Best regards,
Zoltán Böszörményi

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
http://www.postgresql.at/

diff -dcrpN pgsql.describe/src/interfaces/ecpg/preproc/descriptor.c
pgsql.ooscur/src/interfaces/ecpg/preproc/descriptor.c
*** pgsql.describe/src/interfaces/ecpg/preproc/descriptor.c    2009-09-03 12:56:36.000000000 +0200
--- pgsql.ooscur/src/interfaces/ecpg/preproc/descriptor.c    2009-09-03 13:57:48.000000000 +0200
*************** struct variable *
*** 317,323 ****
  descriptor_variable(const char *name, int input)
  {
      static char descriptor_names[2][MAX_DESCRIPTOR_NAMELEN];
!     static const struct ECPGtype descriptor_type = {ECPGt_descriptor, NULL, NULL, {NULL}, 0};
      static const struct variable varspace[2] = {
          {descriptor_names[0], (struct ECPGtype *) & descriptor_type, 0, NULL},
          {descriptor_names[1], (struct ECPGtype *) & descriptor_type, 0, NULL}
--- 317,323 ----
  descriptor_variable(const char *name, int input)
  {
      static char descriptor_names[2][MAX_DESCRIPTOR_NAMELEN];
!     static const struct ECPGtype descriptor_type = {ECPGt_descriptor, NULL, NULL, NULL, {NULL}, 0};
      static const struct variable varspace[2] = {
          {descriptor_names[0], (struct ECPGtype *) & descriptor_type, 0, NULL},
          {descriptor_names[1], (struct ECPGtype *) & descriptor_type, 0, NULL}
diff -dcrpN pgsql.describe/src/interfaces/ecpg/preproc/ecpg.addons pgsql.ooscur/src/interfaces/ecpg/preproc/ecpg.addons
*** pgsql.describe/src/interfaces/ecpg/preproc/ecpg.addons    2009-09-03 12:58:29.000000000 +0200
--- pgsql.ooscur/src/interfaces/ecpg/preproc/ecpg.addons    2009-09-03 14:34:41.000000000 +0200
*************** ECPG: DeclareCursorStmtDECLAREcursor_nam
*** 315,325 ****
--- 315,328 ----

          this->next = cur;
          this->name = $2;
+         this->function = (current_function ? mm_strdup(current_function) : NULL);
          this->connection = connection;
          this->opened = false;
          this->command =  cat_str(7, make_str("declare"), cursor_marker, $3, make_str("cursor"), $5, make_str("for"),
$7);
          this->argsinsert = argsinsert;
+         this->argsinsert_oos = NULL;
          this->argsresult = argsresult;
+         this->argsresult_oos = NULL;
          argsinsert = argsresult = NULL;
          cur = this;

*************** ECPG: DeclareCursorStmtDECLAREcursor_nam
*** 329,338 ****
          {
              if (braces_open > 0) /* we're in a function */
              {
!                 $$ = cat_str(4, adjust_informix(this->argsinsert), adjust_informix(this->argsresult),
make_str("ECPG_informix_reset_sqlca();"),comment); 
              }
              else
!                 $$ = cat_str(3, adjust_informix(this->argsinsert), adjust_informix(this->argsresult), comment);
          }
          else
              $$ = comment;
--- 332,341 ----
          {
              if (braces_open > 0) /* we're in a function */
              {
!                 $$ = cat_str(4, adjust_informix(this, true), adjust_informix(this, false),
make_str("ECPG_informix_reset_sqlca();"),comment); 
              }
              else
!                 $$ = cat_str(3, adjust_informix(this, true), adjust_informix(this, false), comment);
          }
          else
              $$ = comment;
diff -dcrpN pgsql.describe/src/interfaces/ecpg/preproc/ecpg.header pgsql.ooscur/src/interfaces/ecpg/preproc/ecpg.header
*** pgsql.describe/src/interfaces/ecpg/preproc/ecpg.header    2009-08-07 13:06:28.000000000 +0200
--- pgsql.ooscur/src/interfaces/ecpg/preproc/ecpg.header    2009-09-05 14:01:05.000000000 +0200
***************
*** 33,38 ****
--- 33,39 ----
   */
  int struct_level = 0;
  int braces_open; /* brace level counter */
+ char *current_function;
  int ecpg_informix_var = 0;
  char    *connection = NULL;
  char    *input_filename = NULL;
*************** static char *ECPGstruct_sizeof = NULL;
*** 53,62 ****
  /* for forward declarations we have to store some data as well */
  static char *forward_name = NULL;

! struct ECPGtype ecpg_no_indicator = {ECPGt_NO_INDICATOR, NULL, NULL, {NULL}, 0};
  struct variable no_indicator = {"no_indicator", &ecpg_no_indicator, 0, NULL};

! struct ECPGtype ecpg_query = {ECPGt_char_variable, NULL, NULL, {NULL}, 0};

  /*
   * Handle parsing errors and warnings
--- 54,63 ----
  /* for forward declarations we have to store some data as well */
  static char *forward_name = NULL;

! struct ECPGtype ecpg_no_indicator = {ECPGt_NO_INDICATOR, NULL, NULL, NULL, {NULL}, 0};
  struct variable no_indicator = {"no_indicator", &ecpg_no_indicator, 0, NULL};

! struct ECPGtype ecpg_query = {ECPGt_char_variable, NULL, NULL, NULL, {NULL}, 0};

  /*
   * Handle parsing errors and warnings
*************** create_questionmarks(char *name, bool ar
*** 230,236 ****
  }

  static char *
! adjust_informix(struct arguments *list)
  {
      /* Informix accepts DECLARE with variables that are out of scope when OPEN is called.
        * for instance you can declare variables in a function, and then subsequently use them
--- 231,237 ----
  }

  static char *
! adjust_informix(struct cursor *cur, bool insert)
  {
      /* Informix accepts DECLARE with variables that are out of scope when OPEN is called.
        * for instance you can declare variables in a function, and then subsequently use them
*************** adjust_informix(struct arguments *list)
*** 244,305 ****
       * We have to change the variables to our own struct and just store the pointer instead of the variable
       */

       struct arguments *ptr;
       char *result = make_str("");

       for (ptr = list; ptr != NULL; ptr = ptr->next)
       {
           char temp[20]; /* this should be sufficient unless you have 8 byte integers */
          char *original_var;

           /* change variable name to "ECPG_informix_get_var(<counter>)" */
          original_var = ptr->variable->name;
          sprintf(temp, "%d))", ecpg_informix_var);

!         if ((ptr->variable->type->type != ECPGt_varchar && ptr->variable->type->type != ECPGt_char &&
ptr->variable->type->type!= ECPGt_unsigned_char && ptr->variable->type->type != ECPGt_string) &&
atoi(ptr->variable->type->size)> 1) 
          {
!             ptr->variable = new_variable(cat_str(4, make_str("("),
mm_strdup(ecpg_type_name(ptr->variable->type->u.element->type)),make_str(" *)(ECPG_informix_get_var("),
mm_strdup(temp)),ECPGmake_array_type(ECPGmake_simple_type(ptr->variable->type->u.element->type, make_str("1"),
ptr->variable->type->u.element->lineno),ptr->variable->type->size), 0); 
              sprintf(temp, "%d, (", ecpg_informix_var++);
          }
          else if ((ptr->variable->type->type == ECPGt_varchar || ptr->variable->type->type == ECPGt_char ||
ptr->variable->type->type== ECPGt_unsigned_char || ptr->variable->type->type == ECPGt_string) &&
atoi(ptr->variable->type->size)> 1) 
          {
!             ptr->variable = new_variable(cat_str(4, make_str("("),
mm_strdup(ecpg_type_name(ptr->variable->type->type)),make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)),
ECPGmake_simple_type(ptr->variable->type->type,ptr->variable->type->size, ptr->variable->type->lineno), 0); 
!             sprintf(temp, "%d, (", ecpg_informix_var++);
          }
          else
          {
!             ptr->variable = new_variable(cat_str(4, make_str("*("),
mm_strdup(ecpg_type_name(ptr->variable->type->type)),make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)),
ECPGmake_simple_type(ptr->variable->type->type,ptr->variable->type->size, ptr->variable->type->lineno), 0); 
              sprintf(temp, "%d, &(", ecpg_informix_var++);
          }

          /* create call to "ECPG_informix_set_var(<counter>, <pointer>. <linen number>)" */
!         result = cat_str(5, result, make_str("ECPG_informix_set_var("), mm_strdup(temp), mm_strdup(original_var),
make_str("),__LINE__);\n")); 

          /* now the indicator if there is one */
!         if (ptr->indicator->type->type != ECPGt_NO_INDICATOR)
          {
              /* change variable name to "ECPG_informix_get_var(<counter>)" */
              original_var = ptr->indicator->name;
              sprintf(temp, "%d))", ecpg_informix_var);

              /* create call to "ECPG_informix_set_var(<counter>, <pointer>. <linen number>)" */
!             if (atoi(ptr->indicator->type->size) > 1)
              {
!                 ptr->indicator = new_variable(cat_str(4, make_str("("),
mm_strdup(ecpg_type_name(ptr->indicator->type->type)),make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)),
ECPGmake_simple_type(ptr->indicator->type->type,ptr->indicator->type->size, ptr->variable->type->lineno), 0); 
                  sprintf(temp, "%d, (", ecpg_informix_var++);
              }
              else
              {
!                 ptr->indicator = new_variable(cat_str(4, make_str("*("),
mm_strdup(ecpg_type_name(ptr->indicator->type->type)),make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)),
ECPGmake_simple_type(ptr->indicator->type->type,ptr->indicator->type->size, ptr->variable->type->lineno), 0); 
                  sprintf(temp, "%d, &(", ecpg_informix_var++);
              }
              result = cat_str(5, result, make_str("ECPG_informix_set_var("), mm_strdup(temp), mm_strdup(original_var),
make_str("),__LINE__);\n")); 
          }
       }

       return result;
  }

  static struct cursor *
  add_additional_variables(char *name, bool insert)
  {
--- 245,383 ----
       * We have to change the variables to our own struct and just store the pointer instead of the variable
       */

+      struct arguments *list;
       struct arguments *ptr;
+      struct arguments *newlist = NULL;
+      struct variable *newvar, *newind;
       char *result = make_str("");

+      list = (insert ? cur->argsinsert : cur->argsresult);
+
       for (ptr = list; ptr != NULL; ptr = ptr->next)
       {
           char temp[20]; /* this should be sufficient unless you have 8 byte integers */
          char *original_var;
+         bool skip_set_var = false;

           /* change variable name to "ECPG_informix_get_var(<counter>)" */
          original_var = ptr->variable->name;
          sprintf(temp, "%d))", ecpg_informix_var);

!         /* Don't emit ECPGinformix_set_var() calls for global variables */
!         if (ptr->variable->brace_level == 0)
          {
!             newvar = ptr->variable;
!             skip_set_var = true;
!         }
!         else if ((ptr->variable->type->type == ECPGt_char_variable) && (!strncmp(ptr->variable->name,
"ECPGprepared_statement",strlen("ECPGprepared_statement")))) 
!         {
!             newvar = ptr->variable;
!             skip_set_var = true;
!         }
!         else if ((ptr->variable->type->type != ECPGt_varchar && ptr->variable->type->type != ECPGt_char &&
ptr->variable->type->type!= ECPGt_unsigned_char && ptr->variable->type->type != ECPGt_string) &&
atoi(ptr->variable->type->size)> 1) 
!         {
!             newvar = new_variable(cat_str(4, make_str("("),
mm_strdup(ecpg_type_name(ptr->variable->type->u.element->type)),make_str(" *)(ECPG_informix_get_var("),
mm_strdup(temp)),ECPGmake_array_type(ECPGmake_simple_type(ptr->variable->type->u.element->type, make_str("1"),
ptr->variable->type->u.element->lineno),ptr->variable->type->size), 0); 
              sprintf(temp, "%d, (", ecpg_informix_var++);
          }
          else if ((ptr->variable->type->type == ECPGt_varchar || ptr->variable->type->type == ECPGt_char ||
ptr->variable->type->type== ECPGt_unsigned_char || ptr->variable->type->type == ECPGt_string) &&
atoi(ptr->variable->type->size)> 1) 
          {
!             newvar = new_variable(cat_str(4, make_str("("), mm_strdup(ecpg_type_name(ptr->variable->type->type)),
make_str("*)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->variable->type->type,
ptr->variable->type->size,ptr->variable->type->lineno), 0); 
!             if (ptr->variable->type->type == ECPGt_varchar)
!                 sprintf(temp, "%d, &(", ecpg_informix_var++);
!             else
!                 sprintf(temp, "%d, (", ecpg_informix_var++);
!         }
!         else if (ptr->variable->type->type == ECPGt_struct || ptr->variable->type->type == ECPGt_union)
!         {
!             sprintf(temp, "%d)))", ecpg_informix_var);
!             newvar = new_variable(cat_str(4, make_str("(*("), mm_strdup(ptr->variable->type->type_name), make_str("
*)(ECPG_informix_get_var("),mm_strdup(temp)), ECPGmake_struct_type(ptr->variable->type->u.members,
ptr->variable->type->type,ptr->variable->type->type_name, ptr->variable->type->struct_sizeof), 0); 
!             sprintf(temp, "%d, &(", ecpg_informix_var++);
!         }
!         else if (ptr->variable->type->type == ECPGt_array)
!         {
!             if (ptr->variable->type->u.element->type == ECPGt_struct || ptr->variable->type->u.element->type ==
ECPGt_union)
!             {
!                 sprintf(temp, "%d)))", ecpg_informix_var);
!                 newvar = new_variable(cat_str(4, make_str("(*("),
mm_strdup(ptr->variable->type->u.element->type_name),make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)),
ECPGmake_struct_type(ptr->variable->type->u.element->u.members,ptr->variable->type->u.element->type,
ptr->variable->type->u.element->type_name,ptr->variable->type->u.element->struct_sizeof), 0); 
!                 sprintf(temp, "%d, (", ecpg_informix_var++);
!             }
!             else
!             {
!                 newvar = new_variable(cat_str(4, make_str("("), mm_strdup(ecpg_type_name(ptr->variable->type->type)),
make_str("*)(ECPG_informix_get_var("), mm_strdup(temp)),
ECPGmake_array_type(ECPGmake_simple_type(ptr->variable->type->u.element->type,ptr->variable->type->u.element->size,
ptr->variable->type->u.element->lineno),ptr->variable->type->size), 0); 
!                 sprintf(temp, "%d, &(", ecpg_informix_var++);
!             }
          }
          else
          {
!             newvar = new_variable(cat_str(4, make_str("*("), mm_strdup(ecpg_type_name(ptr->variable->type->type)),
make_str("*)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->variable->type->type,
ptr->variable->type->size,ptr->variable->type->lineno), 0); 
              sprintf(temp, "%d, &(", ecpg_informix_var++);
          }

          /* create call to "ECPG_informix_set_var(<counter>, <pointer>. <linen number>)" */
!         if (!skip_set_var)
!             result = cat_str(5, result, make_str("ECPG_informix_set_var("), mm_strdup(temp), mm_strdup(original_var),
make_str("),__LINE__);\n")); 

          /* now the indicator if there is one */
!         if ((ptr->indicator->type->type == ECPGt_NO_INDICATOR) || (ptr->indicator->brace_level == 0))
!         {
!             newind = ptr->indicator;
!         }
!         else
          {
              /* change variable name to "ECPG_informix_get_var(<counter>)" */
              original_var = ptr->indicator->name;
              sprintf(temp, "%d))", ecpg_informix_var);

              /* create call to "ECPG_informix_set_var(<counter>, <pointer>. <linen number>)" */
!             if (ptr->indicator->type->type == ECPGt_struct || ptr->indicator->type->type == ECPGt_union)
              {
!                 sprintf(temp, "%d)))", ecpg_informix_var);
!                 newind = new_variable(cat_str(4, make_str("(*("), mm_strdup(ptr->indicator->type->type_name),
make_str("*)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_struct_type(ptr->indicator->type->u.members,
ptr->indicator->type->type,ptr->indicator->type->type_name, ptr->indicator->type->struct_sizeof), 0); 
!                 sprintf(temp, "%d, &(", ecpg_informix_var++);
!             }
!             else if (ptr->indicator->type->type == ECPGt_array)
!             {
!                 if (ptr->indicator->type->u.element->type == ECPGt_struct || ptr->indicator->type->u.element->type ==
ECPGt_union)
!                 {
!                     sprintf(temp, "%d)))", ecpg_informix_var);
!                     newind = new_variable(cat_str(4, make_str("(*("),
mm_strdup(ptr->indicator->type->u.element->type_name),make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)),
ECPGmake_struct_type(ptr->indicator->type->u.element->u.members,ptr->indicator->type->u.element->type,
ptr->indicator->type->u.element->type_name,ptr->indicator->type->u.element->struct_sizeof), 0); 
!                     sprintf(temp, "%d, (", ecpg_informix_var++);
!                 }
!                 else
!                 {
!                     newind = new_variable(cat_str(4, make_str("("),
mm_strdup(ecpg_type_name(ptr->indicator->type->u.element->type)),make_str(" *)(ECPG_informix_get_var("),
mm_strdup(temp)),ECPGmake_array_type(ECPGmake_simple_type(ptr->indicator->type->u.element->type,
ptr->indicator->type->u.element->size,ptr->indicator->type->u.element->lineno), ptr->indicator->type->size), 0); 
!                     sprintf(temp, "%d, &(", ecpg_informix_var++);
!                 }
!             }
!             else if (atoi(ptr->indicator->type->size) > 1)
!             {
!                 newind = new_variable(cat_str(4, make_str("("),
mm_strdup(ecpg_type_name(ptr->indicator->type->type)),make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)),
ECPGmake_simple_type(ptr->indicator->type->type,ptr->indicator->type->size, ptr->variable->type->lineno), 0); 
                  sprintf(temp, "%d, (", ecpg_informix_var++);
              }
              else
              {
!                 newind = new_variable(cat_str(4, make_str("*("),
mm_strdup(ecpg_type_name(ptr->indicator->type->type)),make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)),
ECPGmake_simple_type(ptr->indicator->type->type,ptr->indicator->type->size, ptr->variable->type->lineno), 0); 
                  sprintf(temp, "%d, &(", ecpg_informix_var++);
              }
              result = cat_str(5, result, make_str("ECPG_informix_set_var("), mm_strdup(temp), mm_strdup(original_var),
make_str("),__LINE__);\n")); 
          }
+
+         add_variable_to_tail(&newlist, newvar, newind);
       }

+      if (insert)
+         cur->argsinsert_oos = newlist;
+      else
+         cur->argsresult_oos = newlist;
+
       return result;
  }

+ /* This tests whether the cursor was declared and opened in the same function. */
+ #define SAMEFUNC(cur)    \
+     ((cur->function == NULL) ||        \
+      (cur->function != NULL && !strcmp(cur->function, current_function)))
+
  static struct cursor *
  add_additional_variables(char *name, bool insert)
  {
*************** add_additional_variables(char *name, boo
*** 322,333 ****
      {
          /* add all those input variables that were given earlier
           * note that we have to append here but have to keep the existing order */
!         for (p = ptr->argsinsert; p; p = p->next)
              add_variable_to_tail(&argsinsert, p->variable, p->indicator);
      }

      /* add all those output variables that were given earlier */
!     for (p = ptr->argsresult; p; p = p->next)
          add_variable_to_tail(&argsresult, p->variable, p->indicator);

      return ptr;
--- 400,411 ----
      {
          /* add all those input variables that were given earlier
           * note that we have to append here but have to keep the existing order */
!         for (p = ((!INFORMIX_MODE || SAMEFUNC(ptr)) ? ptr->argsinsert : ptr->argsinsert_oos); p; p = p->next)
              add_variable_to_tail(&argsinsert, p->variable, p->indicator);
      }

      /* add all those output variables that were given earlier */
!     for (p = ((!INFORMIX_MODE || SAMEFUNC(ptr)) ? ptr->argsresult : ptr->argsresult_oos); p; p = p->next)
          add_variable_to_tail(&argsresult, p->variable, p->indicator);

      return ptr;
diff -dcrpN pgsql.describe/src/interfaces/ecpg/preproc/ecpg.trailer
pgsql.ooscur/src/interfaces/ecpg/preproc/ecpg.trailer
*** pgsql.describe/src/interfaces/ecpg/preproc/ecpg.trailer    2009-09-03 13:14:28.000000000 +0200
--- pgsql.ooscur/src/interfaces/ecpg/preproc/ecpg.trailer    2009-09-05 10:46:52.000000000 +0200
*************** statement: ecpgstart at stmt ';'
*** 16,22 ****
                  | c_thing               { fprintf(yyout, "%s", $1); free($1); }
                  | CPP_LINE              { fprintf(yyout, "%s", $1); free($1); }
                  | '{'                   { braces_open++; fputs("{", yyout); }
!                 | '}'                   { remove_typedefs(braces_open); remove_variables(braces_open--); fputs("}",
yyout);} 
                  ;

  CreateAsStmt: CREATE OptTemp TABLE create_as_target AS {FoundInto = 0;} SelectStmt opt_with_data
--- 16,32 ----
                  | c_thing               { fprintf(yyout, "%s", $1); free($1); }
                  | CPP_LINE              { fprintf(yyout, "%s", $1); free($1); }
                  | '{'                   { braces_open++; fputs("{", yyout); }
!                 | '}'
!         {
!             remove_typedefs(braces_open);
!             remove_variables(braces_open--);
!             if (braces_open == 0)
!             {
!                 free(current_function);
!                 current_function = NULL;
!             }
!             fputs("}", yyout);
!         }
                  ;

  CreateAsStmt: CREATE OptTemp TABLE create_as_target AS {FoundInto = 0;} SelectStmt opt_with_data
*************** ECPGCursorStmt:  DECLARE cursor_name cur
*** 323,328 ****
--- 333,339 ----
              char *cursor_marker = $2[0] == ':' ? make_str("$0") : mm_strdup($2);
              struct variable *thisquery = (struct variable *)mm_alloc(sizeof(struct variable));
              const char *con = connection ? connection : "NULL";
+             char *comment;

              for (ptr = cur; ptr != NULL; ptr = ptr->next)
              {
*************** ECPGCursorStmt:  DECLARE cursor_name cur
*** 336,344 ****
--- 347,357 ----
              /* initial definition */
              this->next = cur;
              this->name = $2;
+             this->function = (current_function ? mm_strdup(current_function) : NULL);
              this->connection = connection;
              this->command =  cat_str(6, make_str("declare"), cursor_marker, $3, make_str("cursor"), $5, make_str("for
$1"));
              this->argsresult = NULL;
+             this->argsresult_oos = NULL;

              thisquery->type = &ecpg_query;
              thisquery->brace_level = 0;
*************** ECPGCursorStmt:  DECLARE cursor_name cur
*** 347,352 ****
--- 360,366 ----
              sprintf(thisquery->name, "ECPGprepared_statement(%s, %s, __LINE__)", con, $7);

              this->argsinsert = NULL;
+             this->argsinsert_oos = NULL;
              if ($2[0] == ':')
              {
                  struct variable *var = find_variable($2 + 1);
*************** ECPGCursorStmt:  DECLARE cursor_name cur
*** 356,365 ****
              add_variable_to_head(&(this->argsinsert), thisquery, &no_indicator);
              cur = this;

!             if (INFORMIX_MODE && braces_open > 0) /* we're in a function */
!                 $$ = cat_str(4, make_str("ECPG_informix_reset_sqlca();"), make_str("/*"), mm_strdup(this->command),
make_str("*/"));
              else
!                 $$ = cat_str(3, make_str("/*"), mm_strdup(this->command), make_str("*/"));
          }
          ;

--- 370,386 ----
              add_variable_to_head(&(this->argsinsert), thisquery, &no_indicator);
              cur = this;

!             comment = cat_str(3, make_str("/*"), mm_strdup(this->command), make_str("*/"));
!
!             if (INFORMIX_MODE)
!             {
!                 if (braces_open > 0) /* we're in a function */
!                     $$ = cat_str(4, adjust_informix(this, true), adjust_informix(this, false),
make_str("ECPG_informix_reset_sqlca();"),comment); 
!                 else
!                     $$ = cat_str(3, adjust_informix(this, true), adjust_informix(this, false), comment);
!             }
              else
!                 $$ = comment;
          }
          ;

*************** var_declaration: storage_declaration
*** 443,448 ****
--- 464,470 ----
          var_type
          {
              actual_type[struct_level].type_enum = $2.type_enum;
+             actual_type[struct_level].type_str = $2.type_str;
              actual_type[struct_level].type_dimension = $2.type_dimension;
              actual_type[struct_level].type_index = $2.type_index;
              actual_type[struct_level].type_sizeof = $2.type_sizeof;
*************** var_declaration: storage_declaration
*** 456,461 ****
--- 478,484 ----
          | var_type
          {
              actual_type[struct_level].type_enum = $1.type_enum;
+             actual_type[struct_level].type_str = $1.type_str;
              actual_type[struct_level].type_dimension = $1.type_dimension;
              actual_type[struct_level].type_index = $1.type_index;
              actual_type[struct_level].type_sizeof = $1.type_sizeof;
*************** variable: opt_pointer ECPGColLabel opt_a
*** 867,875 ****
                  case ECPGt_struct:
                  case ECPGt_union:
                      if (atoi(dimension) < 0)
!                         type = ECPGmake_struct_type(struct_member_list[struct_level],
actual_type[struct_level].type_enum,actual_type[struct_level].type_sizeof); 
                      else
!                         type = ECPGmake_array_type(ECPGmake_struct_type(struct_member_list[struct_level],
actual_type[struct_level].type_enum,actual_type[struct_level].type_sizeof), dimension); 

                      $$ = cat_str(5, $1, mm_strdup($2), $3.str, $4, $5);
                      break;
--- 890,898 ----
                  case ECPGt_struct:
                  case ECPGt_union:
                      if (atoi(dimension) < 0)
!                         type = ECPGmake_struct_type(struct_member_list[struct_level],
actual_type[struct_level].type_enum,actual_type[struct_level].type_str, actual_type[struct_level].type_sizeof); 
                      else
!                         type = ECPGmake_array_type(ECPGmake_struct_type(struct_member_list[struct_level],
actual_type[struct_level].type_enum,actual_type[struct_level].type_str, actual_type[struct_level].type_sizeof),
dimension);

                      $$ = cat_str(5, $1, mm_strdup($2), $3.str, $4, $5);
                      break;
*************** ECPGVar: SQL_VAR
*** 1373,1381 ****
                      case ECPGt_struct:
                      case ECPGt_union:
                          if (atoi(dimension) < 0)
!                             type = ECPGmake_struct_type(struct_member_list[struct_level], $5.type_enum,
$5.type_sizeof);
                          else
!                             type = ECPGmake_array_type(ECPGmake_struct_type(struct_member_list[struct_level],
$5.type_enum,$5.type_sizeof),dimension); 
                          break;

                      case ECPGt_varchar:
--- 1396,1404 ----
                      case ECPGt_struct:
                      case ECPGt_union:
                          if (atoi(dimension) < 0)
!                             type = ECPGmake_struct_type(struct_member_list[struct_level], $5.type_enum, $5.type_str,
$5.type_sizeof);
                          else
!                             type = ECPGmake_array_type(ECPGmake_struct_type(struct_member_list[struct_level],
$5.type_enum,$5.type_str, $5.type_sizeof), dimension); 
                          break;

                      case ECPGt_varchar:
diff -dcrpN pgsql.describe/src/interfaces/ecpg/preproc/extern.h pgsql.ooscur/src/interfaces/ecpg/preproc/extern.h
*** pgsql.describe/src/interfaces/ecpg/preproc/extern.h    2009-09-03 12:56:36.000000000 +0200
--- pgsql.ooscur/src/interfaces/ecpg/preproc/extern.h    2009-09-03 13:57:48.000000000 +0200
*************** extern int    braces_open,
*** 29,34 ****
--- 29,35 ----
              ecpg_informix_var,
              regression_mode,
              auto_prepare;
+ extern char *current_function;
  extern char *descriptor_index;
  extern char *descriptor_name;
  extern char *connection;
diff -dcrpN pgsql.describe/src/interfaces/ecpg/preproc/pgc.l pgsql.ooscur/src/interfaces/ecpg/preproc/pgc.l
*** pgsql.describe/src/interfaces/ecpg/preproc/pgc.l    2009-01-30 17:28:46.000000000 +0100
--- pgsql.ooscur/src/interfaces/ecpg/preproc/pgc.l    2009-09-03 13:57:48.000000000 +0200
*************** static char    *literalbuf = NULL;        /* e
*** 41,46 ****
--- 41,49 ----
  static int        literallen;                /* actual current length */
  static int        literalalloc;            /* current allocated buffer size */

+ /* Used for detecting global state together with braces_open */
+ static int        parenths_open;
+
  #define startlit()    (literalbuf[0] = '\0', literallen = 0)
  static void addlit(char *ytext, int yleng);
  static void addlitchar (unsigned char);
*************** cppline            {space}*#(.*\\{space})*.*{newl
*** 788,794 ****
                      }
  <C>{identifier}     {
                          const ScanKeyword        *keyword;
!
                          /* Informix uses SQL defines only in SQL space */
                          /* however, some defines have to be taken care of for compatibility */
                          if ((!INFORMIX_MODE || !isinformixdefine()) && !isdefine())
--- 791,807 ----
                      }
  <C>{identifier}     {
                          const ScanKeyword        *keyword;
!
!                         /*
!                          * Try to detect a function name:
!                          * look for identifiers at the global scope
!                          * keep the last identifier before the first '(' and '{' */
!                         if (braces_open == 0 && parenths_open == 0)
!                         {
!                             if (current_function)
!                                 free(current_function);
!                             current_function = mm_strdup(yytext);
!                         }
                          /* Informix uses SQL defines only in SQL space */
                          /* however, some defines have to be taken care of for compatibility */
                          if ((!INFORMIX_MODE || !isinformixdefine()) && !isdefine())
*************** cppline            {space}*#(.*\\{space})*.*{newl
*** 811,818 ****
  <C>"/"                { return('/'); }
  <C>"+"                { return('+'); }
  <C>"-"                { return('-'); }
! <C>"("                { return('('); }
! <C>")"                { return(')'); }
  <C,xskip>{space}        { ECHO; }
  <C>\{                { return('{'); }
  <C>\}                { return('}'); }
--- 824,831 ----
  <C>"/"                { return('/'); }
  <C>"+"                { return('+'); }
  <C>"-"                { return('-'); }
! <C>"("                { parenths_open++; return('('); }
! <C>")"                { parenths_open--; return(')'); }
  <C,xskip>{space}        { ECHO; }
  <C>\{                { return('{'); }
  <C>\}                { return('}'); }
*************** void
*** 1178,1183 ****
--- 1191,1198 ----
  lex_init(void)
  {
      braces_open = 0;
+     parenths_open = 0;
+     current_function = NULL;

      preproc_tos = 0;
      yylineno = 1;
diff -dcrpN pgsql.describe/src/interfaces/ecpg/preproc/type.c pgsql.ooscur/src/interfaces/ecpg/preproc/type.c
*** pgsql.describe/src/interfaces/ecpg/preproc/type.c    2009-09-03 12:56:36.000000000 +0200
--- pgsql.ooscur/src/interfaces/ecpg/preproc/type.c    2009-09-03 13:57:48.000000000 +0200
*************** ECPGstruct_member_dup(struct ECPGstruct_
*** 46,52 ****
          {
              case ECPGt_struct:
              case ECPGt_union:
!                 type = ECPGmake_struct_type(rm->type->u.members, rm->type->type, rm->type->struct_sizeof);
                  break;
              case ECPGt_array:

--- 46,52 ----
          {
              case ECPGt_struct:
              case ECPGt_union:
!                 type = ECPGmake_struct_type(rm->type->u.members, rm->type->type, rm->type->type_name,
rm->type->struct_sizeof);
                  break;
              case ECPGt_array:

*************** ECPGstruct_member_dup(struct ECPGstruct_
*** 55,61 ****
                   * create the struct too
                   */
                  if (rm->type->u.element->type == ECPGt_struct)
!                     type = ECPGmake_struct_type(rm->type->u.element->u.members, rm->type->u.element->type,
rm->type->u.element->struct_sizeof);
                  else
                      type = ECPGmake_array_type(ECPGmake_simple_type(rm->type->u.element->type,
rm->type->u.element->size,rm->type->u.element->lineno), rm->type->size); 
                  break;
--- 55,61 ----
                   * create the struct too
                   */
                  if (rm->type->u.element->type == ECPGt_struct)
!                     type = ECPGmake_struct_type(rm->type->u.element->u.members, rm->type->u.element->type,
rm->type->u.element->type_name,rm->type->u.element->struct_sizeof); 
                  else
                      type = ECPGmake_array_type(ECPGmake_simple_type(rm->type->u.element->type,
rm->type->u.element->size,rm->type->u.element->lineno), rm->type->size); 
                  break;
*************** ECPGmake_simple_type(enum ECPGttype type
*** 98,103 ****
--- 98,104 ----
      struct ECPGtype *ne = (struct ECPGtype *) mm_alloc(sizeof(struct ECPGtype));

      ne->type = type;
+     ne->type_name = NULL;
      ne->size = size;
      ne->u.element = NULL;
      ne->struct_sizeof = NULL;
*************** ECPGmake_array_type(struct ECPGtype * ty
*** 117,126 ****
  }

  struct ECPGtype *
! ECPGmake_struct_type(struct ECPGstruct_member * rm, enum ECPGttype type, char *struct_sizeof)
  {
      struct ECPGtype *ne = ECPGmake_simple_type(type, make_str("1"), 0);

      ne->u.members = ECPGstruct_member_dup(rm);
      ne->struct_sizeof = struct_sizeof;

--- 118,128 ----
  }

  struct ECPGtype *
! ECPGmake_struct_type(struct ECPGstruct_member * rm, enum ECPGttype type, char *type_name, char *struct_sizeof)
  {
      struct ECPGtype *ne = ECPGmake_simple_type(type, make_str("1"), 0);

+     ne->type_name = mm_strdup(type_name);
      ne->u.members = ECPGstruct_member_dup(rm);
      ne->struct_sizeof = struct_sizeof;

diff -dcrpN pgsql.describe/src/interfaces/ecpg/preproc/type.h pgsql.ooscur/src/interfaces/ecpg/preproc/type.h
*** pgsql.describe/src/interfaces/ecpg/preproc/type.h    2009-06-13 18:25:05.000000000 +0200
--- pgsql.ooscur/src/interfaces/ecpg/preproc/type.h    2009-09-03 13:57:48.000000000 +0200
*************** struct ECPGstruct_member
*** 17,22 ****
--- 17,23 ----
  struct ECPGtype
  {
      enum ECPGttype type;
+     char       *type_name;            /* For struct and union types it is the struct name */
      char       *size;            /* For array it is the number of elements. For
                                   * varchar it is the maxsize of the area. */
      char       *struct_sizeof;    /* For a struct this is the sizeof() type as
*************** void        ECPGmake_struct_member(char *, str
*** 36,42 ****
  struct ECPGtype *ECPGmake_simple_type(enum ECPGttype, char *, int);
  struct ECPGtype *ECPGmake_varchar_type(enum ECPGttype, long);
  struct ECPGtype *ECPGmake_array_type(struct ECPGtype *, char *);
! struct ECPGtype *ECPGmake_struct_type(struct ECPGstruct_member *, enum ECPGttype, char *);
  struct ECPGstruct_member *ECPGstruct_member_dup(struct ECPGstruct_member *);

  /* Frees a type. */
--- 37,43 ----
  struct ECPGtype *ECPGmake_simple_type(enum ECPGttype, char *, int);
  struct ECPGtype *ECPGmake_varchar_type(enum ECPGttype, long);
  struct ECPGtype *ECPGmake_array_type(struct ECPGtype *, char *);
! struct ECPGtype *ECPGmake_struct_type(struct ECPGstruct_member *, enum ECPGttype, char *, char *);
  struct ECPGstruct_member *ECPGstruct_member_dup(struct ECPGstruct_member *);

  /* Frees a type. */
*************** struct _include_path
*** 123,133 ****
--- 124,137 ----
  struct cursor
  {
      char       *name;
+     char       *function;
      char       *command;
      char       *connection;
      bool        opened;
      struct arguments *argsinsert;
+     struct arguments *argsinsert_oos;
      struct arguments *argsresult;
+     struct arguments *argsresult_oos;
      struct cursor *next;
  };

diff -dcrpN pgsql.describe/src/interfaces/ecpg/preproc/variable.c pgsql.ooscur/src/interfaces/ecpg/preproc/variable.c
*** pgsql.describe/src/interfaces/ecpg/preproc/variable.c    2009-09-03 12:28:03.000000000 +0200
--- pgsql.ooscur/src/interfaces/ecpg/preproc/variable.c    2009-09-03 13:57:48.000000000 +0200
*************** find_struct_member(char *name, char *str
*** 47,53 ****
                          return (new_variable(name,
ECPGmake_array_type(ECPGmake_simple_type(members->type->u.element->type,members->type->u.element->size,
members->type->u.element->lineno),members->type->size), brace_level)); 
                      case ECPGt_struct:
                      case ECPGt_union:
!                         return (new_variable(name, ECPGmake_struct_type(members->type->u.members,
members->type->type,members->type->struct_sizeof), brace_level)); 
                      default:
                          return (new_variable(name, ECPGmake_simple_type(members->type->type, members->type->size,
members->type->lineno),brace_level)); 
                  }
--- 47,53 ----
                          return (new_variable(name,
ECPGmake_array_type(ECPGmake_simple_type(members->type->u.element->type,members->type->u.element->size,
members->type->u.element->lineno),members->type->size), brace_level)); 
                      case ECPGt_struct:
                      case ECPGt_union:
!                         return (new_variable(name, ECPGmake_struct_type(members->type->u.members,
members->type->type,members->type->type_name, members->type->struct_sizeof), brace_level)); 
                      default:
                          return (new_variable(name, ECPGmake_simple_type(members->type->type, members->type->size,
members->type->lineno),brace_level)); 
                  }
*************** find_struct_member(char *name, char *str
*** 94,100 ****
                                  return (new_variable(name,
ECPGmake_array_type(ECPGmake_simple_type(members->type->u.element->u.element->type,
members->type->u.element->u.element->size,members->type->u.element->u.element->lineno),
members->type->u.element->size),brace_level)); 
                              case ECPGt_struct:
                              case ECPGt_union:
!                                 return (new_variable(name, ECPGmake_struct_type(members->type->u.element->u.members,
members->type->u.element->type,members->type->u.element->struct_sizeof), brace_level)); 
                              default:
                                  return (new_variable(name, ECPGmake_simple_type(members->type->u.element->type,
members->type->u.element->size,members->type->u.element->lineno), brace_level)); 
                          }
--- 94,100 ----
                                  return (new_variable(name,
ECPGmake_array_type(ECPGmake_simple_type(members->type->u.element->u.element->type,
members->type->u.element->u.element->size,members->type->u.element->u.element->lineno),
members->type->u.element->size),brace_level)); 
                              case ECPGt_struct:
                              case ECPGt_union:
!                                 return (new_variable(name, ECPGmake_struct_type(members->type->u.element->u.members,
members->type->u.element->type,members->type->u.element->type_name, members->type->u.element->struct_sizeof),
brace_level));
                              default:
                                  return (new_variable(name, ECPGmake_simple_type(members->type->u.element->type,
members->type->u.element->size,members->type->u.element->lineno), brace_level)); 
                          }
*************** find_variable(char *name)
*** 235,241 ****
                          return (new_variable(name,
ECPGmake_array_type(ECPGmake_simple_type(p->type->u.element->u.element->type,p->type->u.element->u.element->size,
p->type->u.element->u.element->lineno),p->type->u.element->size), p->brace_level)); 
                      case ECPGt_struct:
                      case ECPGt_union:
!                         return (new_variable(name, ECPGmake_struct_type(p->type->u.element->u.members,
p->type->u.element->type,p->type->u.element->struct_sizeof), p->brace_level)); 
                      default:
                          return (new_variable(name, ECPGmake_simple_type(p->type->u.element->type,
p->type->u.element->size,p->type->u.element->lineno), p->brace_level)); 
                  }
--- 235,241 ----
                          return (new_variable(name,
ECPGmake_array_type(ECPGmake_simple_type(p->type->u.element->u.element->type,p->type->u.element->u.element->size,
p->type->u.element->u.element->lineno),p->type->u.element->size), p->brace_level)); 
                      case ECPGt_struct:
                      case ECPGt_union:
!                         return (new_variable(name, ECPGmake_struct_type(p->type->u.element->u.members,
p->type->u.element->type,p->type->u.element->type_name, p->type->u.element->struct_sizeof), p->brace_level)); 
                      default:
                          return (new_variable(name, ECPGmake_simple_type(p->type->u.element->type,
p->type->u.element->size,p->type->u.element->lineno), p->brace_level)); 
                  }
diff -dcrpN pgsql.describe/src/interfaces/ecpg/test/compat_informix/Makefile
pgsql.ooscur/src/interfaces/ecpg/test/compat_informix/Makefile
*** pgsql.describe/src/interfaces/ecpg/test/compat_informix/Makefile    2009-09-03 13:14:28.000000000 +0200
--- pgsql.ooscur/src/interfaces/ecpg/test/compat_informix/Makefile    2009-09-03 13:57:48.000000000 +0200
*************** TESTS = test_informix test_informix.c \
*** 14,19 ****
--- 14,21 ----
          test_informix2 test_informix2.c \
          cursor cursor.c \
          describe describe.c \
+         struct struct.c \
+         outofscope outofscope.c \
          dec_test dec_test.c \
          rfmtdate rfmtdate.c \
          rfmtlong rfmtlong.c \
*************** describe.c: describe.pgc ../regression.h
*** 38,43 ****
--- 40,51 ----
  sqlda.c: sqlda.pgc ../regression.h
      $(ECPG) -o $@ -I$(srcdir) $<

+ struct.c: struct.pgc ../regression.h
+     $(ECPG) -o $@ -I$(srcdir) $<
+
+ outofscope.c: outofscope.pgc ../regression.h
+     $(ECPG) -o $@ -I$(srcdir) $<
+
  dec_test.c: dec_test.pgc ../regression.h
      $(ECPG) -o $@ -I$(srcdir) $<

diff -dcrpN pgsql.describe/src/interfaces/ecpg/test/compat_informix/outofscope.pgc
pgsql.ooscur/src/interfaces/ecpg/test/compat_informix/outofscope.pgc
*** pgsql.describe/src/interfaces/ecpg/test/compat_informix/outofscope.pgc    1970-01-01 01:00:00.000000000 +0100
--- pgsql.ooscur/src/interfaces/ecpg/test/compat_informix/outofscope.pgc    2009-09-05 11:22:49.000000000 +0200
***************
*** 0 ****
--- 1,256 ----
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include <inttypes.h>
+
+ exec sql include ../regression;
+
+ exec sql include sqlda.h;
+ exec sql include sqltypes.h;
+
+ exec sql begin declare section;
+ exec sql include struct.h;
+ exec sql end declare section;
+
+ exec sql whenever sqlerror stop;
+
+ /* Functions for test 1 */
+
+ static void
+ get_var1(MYTYPE **myvar0, MYNULLTYPE **mynullvar0)
+ {
+     exec sql begin declare section;
+     MYTYPE        *myvar = malloc(sizeof(MYTYPE));
+     MYNULLTYPE    *mynullvar = malloc(sizeof(MYNULLTYPE));
+     exec sql end declare section;
+
+     /* Test DECLARE ... SELECT ... INTO with pointers */
+
+     exec sql declare mycur cursor for select * INTO :myvar :mynullvar from a1;
+
+     if (sqlca.sqlcode != 0)
+         exit(1);
+
+     *myvar0 = myvar;
+     *mynullvar0 = mynullvar;
+ }
+
+ static void
+ open_cur1(void)
+ {
+     exec sql open mycur;
+
+     if (sqlca.sqlcode != 0)
+         exit(1);
+ }
+
+ static void
+ get_record1(void)
+ {
+     exec sql fetch mycur;
+
+     if (sqlca.sqlcode != 0 && sqlca.sqlcode != SQLNOTFOUND)
+         exit(1);
+ }
+
+ static void
+ close_cur1(void)
+ {
+     exec sql close mycur;
+
+     if (sqlca.sqlcode != 0)
+         exit(1);
+ }
+
+ /* Functions for test 2 */
+
+ pg_sqlda_t    *inp_sqlda, *outp_sqlda;
+
+ exec sql begin declare section;
+ char    *stmt2 = "SELECT * FROM a1 WHERE id = ?";
+ char    *curname2 = "mycur";
+ int    id;
+ exec sql end declare section;
+
+ static void
+ prepare2(void)
+ {
+     exec sql prepare prepared_stmt from :stmt2;
+
+     if (sqlca.sqlcode != 0)
+         exit(1);
+
+     inp_sqlda = (pg_sqlda_t *)malloc(sizeof(pg_sqlda_t));
+     memset(inp_sqlda, 0, sizeof(pg_sqlda_t));
+     inp_sqlda->sqld = 1;
+     inp_sqlda->sqlvar = malloc(sizeof(pg_sqlvar_t));
+     memset(inp_sqlda->sqlvar, 0, sizeof(pg_sqlvar_t));
+
+     inp_sqlda->sqlvar[0].sqltype = SQLINT;
+     inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+     id = 4;
+ }
+
+ static void
+ declare2(void)
+ {
+     exec sql declare :curname2 cursor for prepared_stmt;
+
+     if (sqlca.sqlcode != 0)
+         exit(1);
+ }
+
+ static void
+ dealloc_prep2(void)
+ {
+     exec sql deallocate prepare prepared_stmt;
+
+     free(inp_sqlda->sqlvar);
+     free(inp_sqlda);
+     free(outp_sqlda);
+ }
+
+ static void
+ open_cur2(void)
+ {
+     exec sql open :curname2 using descriptor inp_sqlda;
+
+     if (sqlca.sqlcode != 0)
+         exit(1);
+ }
+
+ static void
+ close_cur2(void)
+ {
+     exec sql close :curname2;
+
+     if (sqlca.sqlcode != 0)
+         exit(1);
+ }
+
+ static void
+ get_record2(void)
+ {
+     exec sql fetch :curname2 into descriptor outp_sqlda;
+
+     if (sqlca.sqlcode != 0 && sqlca.sqlcode != SQLNOTFOUND)
+         exit(1);
+ }
+
+ static void
+ dump_sqlda(pg_sqlda_t *sqlda)
+ {
+     int    i;
+
+     for (i = 0; i < sqlda->sqld; i++)
+     {
+         if (outp_sqlda->sqlvar[i].sqlind && *(outp_sqlda->sqlvar[i].sqlind) == -1)
+             printf("name sqlda descriptor: '%s' value NULL'\n", outp_sqlda->sqlvar[i].sqlname);
+         else
+         switch (sqlda->sqlvar[i].sqltype)
+         {
+         case SQLCHAR:
+         case SQLVCHAR:
+         case SQLTEXT:
+             printf("name sqlda descriptor: '%s' value '%s'\n", sqlda->sqlvar[i].sqlname, sqlda->sqlvar[i].sqldata);
+             break;
+         case SQLSERIAL:
+         case SQLINT:
+             printf("name sqlda descriptor: '%s' value %d\n", sqlda->sqlvar[i].sqlname, *(int
*)sqlda->sqlvar[i].sqldata);
+             break;
+         case SQLSERIAL8:
+         case SQLINT8:
+             printf("name sqlda descriptor: '%s' value %" PRId64 "\n", sqlda->sqlvar[i].sqlname, *(int64_t
*)sqlda->sqlvar[i].sqldata);
+             break;
+         case SQLFLOAT:
+             printf("name sqlda descriptor: '%s' value %lf\n", sqlda->sqlvar[i].sqlname, *(double
*)sqlda->sqlvar[i].sqldata);
+             break;
+         case SQLDECIMAL:
+             {
+                 char    val[64];
+                 dectoasc((dec_t *)sqlda->sqlvar[i].sqldata, val, 64, -1);
+                 printf("name sqlda descriptor: '%s' value DECIMAL '%s'\n", sqlda->sqlvar[i].sqlname, val);
+                 break;
+             }
+         }
+     }
+ }
+
+ int
+ main (void)
+ {
+     MYTYPE        *myvar;
+     MYNULLTYPE    *mynullvar;
+
+     char msg[128];
+
+     ECPGdebug(1, stderr);
+
+     strcpy(msg, "connect");
+     exec sql connect to REGRESSDB1;
+
+     strcpy(msg, "set");
+     exec sql set datestyle to iso;
+
+     strcpy(msg, "create");
+     exec sql create table a1(id serial primary key, t text, d1 numeric, d2 float8, c character(10));
+
+     strcpy(msg, "insert");
+     exec sql insert into a1(id, t, d1, d2, c) values (default, 'a', 1.0, 2, 'a');
+     exec sql insert into a1(id, t, d1, d2, c) values (default, null, null, null, null);
+     exec sql insert into a1(id, t, d1, d2, c) values (default, '"a"', -1.0, 'nan'::float8, 'a');
+     exec sql insert into a1(id, t, d1, d2, c) values (default, 'b', 2.0, 3, 'b');
+
+     strcpy(msg, "commit");
+     exec sql commit;
+
+     /* Test out-of-scope DECLARE/OPEN/FETCH/CLOSE */
+
+     get_var1(&myvar, &mynullvar);
+     open_cur1();
+
+     exec sql whenever not found do break;
+
+     while (1)
+     {
+         memset(myvar, 0, sizeof(MYTYPE));
+         get_record1();
+         if (sqlca.sqlcode == SQLNOTFOUND)
+             break;
+         printf("id=%d%s t='%s'%s d1=%lf%s d2=%lf%s c = '%s'%s\n",
+             myvar->id, mynullvar->id ? " (NULL)" : "",
+             myvar->t, mynullvar->t ? " (NULL)" : "",
+             myvar->d1, mynullvar->d1 ? " (NULL)" : "",
+             myvar->d2, mynullvar->d2 ? " (NULL)" : "",
+             myvar->c, mynullvar->c ? " (NULL)" : "");
+     }
+
+     close_cur1();
+
+     /* Test out-of-scope DECLARE/OPEN/FETCH/CLOSE interaction
+      * with a dynamic cursor and prepared statment using an sqlda
+      */
+
+     prepare2();
+     declare2();
+     open_cur2();
+
+     get_record2();
+     dump_sqlda(outp_sqlda);
+
+     close_cur2();
+     dealloc_prep2();
+
+     /* End test */
+
+     strcpy(msg, "drop");
+     exec sql drop table a1;
+
+     strcpy(msg, "commit");
+     exec sql commit;
+
+     strcpy(msg, "disconnect");
+     exec sql disconnect;
+
+     return (0);
+ }
diff -dcrpN pgsql.describe/src/interfaces/ecpg/test/compat_informix/struct.h
pgsql.ooscur/src/interfaces/ecpg/test/compat_informix/struct.h
*** pgsql.describe/src/interfaces/ecpg/test/compat_informix/struct.h    1970-01-01 01:00:00.000000000 +0100
--- pgsql.ooscur/src/interfaces/ecpg/test/compat_informix/struct.h    2009-09-03 13:57:48.000000000 +0200
***************
*** 0 ****
--- 1,18 ----
+
+ struct mytype {
+     int    id;
+     char    t[64];
+     double    d1; /* dec_t */
+     double    d2;
+     char    c[30];
+ };
+ typedef struct mytype MYTYPE;
+
+ struct mynulltype {
+     int    id;
+     int    t;
+     int    d1;
+     int    d2;
+     int    c;
+ };
+ typedef struct mynulltype MYNULLTYPE;
diff -dcrpN pgsql.describe/src/interfaces/ecpg/test/compat_informix/struct.pgc
pgsql.ooscur/src/interfaces/ecpg/test/compat_informix/struct.pgc
*** pgsql.describe/src/interfaces/ecpg/test/compat_informix/struct.pgc    1970-01-01 01:00:00.000000000 +0100
--- pgsql.ooscur/src/interfaces/ecpg/test/compat_informix/struct.pgc    2009-09-03 13:57:48.000000000 +0200
***************
*** 0 ****
--- 1,76 ----
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+
+ exec sql include ../regression;
+
+ exec sql begin declare section;
+ exec sql include struct.h;
+ exec sql end declare section;
+
+ exec sql whenever sqlerror stop;
+
+ int
+ main (void)
+ {
+     exec sql begin declare section;
+     MYTYPE        myvar;
+     MYNULLTYPE    mynullvar;
+     exec sql end declare section;
+
+     char msg[128];
+
+     ECPGdebug(1, stderr);
+
+     strcpy(msg, "connect");
+     exec sql connect to REGRESSDB1;
+
+     strcpy(msg, "set");
+     exec sql set datestyle to iso;
+
+     strcpy(msg, "create");
+     exec sql create table a1(id serial primary key, t text, d1 numeric, d2 float8, c character(10));
+
+     strcpy(msg, "insert");
+     exec sql insert into a1(id, t, d1, d2, c) values (default, 'a', 1.0, 2, 'a');
+     exec sql insert into a1(id, t, d1, d2, c) values (default, null, null, null, null);
+     exec sql insert into a1(id, t, d1, d2, c) values (default, '"a"', -1.0, 'nan'::float8, 'a');
+     exec sql insert into a1(id, t, d1, d2, c) values (default, 'b', 2.0, 3, 'b');
+
+     strcpy(msg, "commit");
+     exec sql commit;
+
+     /* Test DECLARE ... SELECT ... INTO with struct type */
+
+     exec sql declare mycur cursor for select * into :myvar :mynullvar from a1;
+     exec sql open mycur;
+
+     exec sql whenever not found do break;
+
+     while (1)
+     {
+         memset(&myvar, 0, sizeof(myvar));
+         exec sql fetch mycur;
+         printf("id=%d%s t='%s'%s d1=%lf%s d2=%lf%s c = '%s'%s\n",
+             myvar.id, mynullvar.id ? " (NULL)" : "",
+             myvar.t, mynullvar.t ? " (NULL)" : "",
+             myvar.d1, mynullvar.d1 ? " (NULL)" : "",
+             myvar.d2, mynullvar.d2 ? " (NULL)" : "",
+             myvar.c, mynullvar.c ? " (NULL)" : "");
+     }
+
+     exec sql close mycur;
+
+     /* End test */
+
+     strcpy(msg, "drop");
+     exec sql drop table a1;
+
+     strcpy(msg, "commit");
+     exec sql commit;
+
+     strcpy(msg, "disconnect");
+     exec sql disconnect;
+
+     return (0);
+ }
diff -dcrpN pgsql.describe/src/interfaces/ecpg/test/ecpg_schedule pgsql.ooscur/src/interfaces/ecpg/test/ecpg_schedule
*** pgsql.describe/src/interfaces/ecpg/test/ecpg_schedule    2009-09-03 13:14:28.000000000 +0200
--- pgsql.ooscur/src/interfaces/ecpg/test/ecpg_schedule    2009-09-03 13:57:48.000000000 +0200
*************** test: compat_informix/rnull
*** 6,11 ****
--- 6,13 ----
  test: compat_informix/cursor
  test: compat_informix/sqlda
  test: compat_informix/describe
+ test: compat_informix/struct
+ test: compat_informix/outofscope
  test: compat_informix/test_informix
  test: compat_informix/test_informix2
  test: connect/test2
diff -dcrpN pgsql.describe/src/interfaces/ecpg/test/ecpg_schedule_tcp
pgsql.ooscur/src/interfaces/ecpg/test/ecpg_schedule_tcp
*** pgsql.describe/src/interfaces/ecpg/test/ecpg_schedule_tcp    2009-09-03 13:14:28.000000000 +0200
--- pgsql.ooscur/src/interfaces/ecpg/test/ecpg_schedule_tcp    2009-09-03 13:57:48.000000000 +0200
*************** test: compat_informix/rnull
*** 6,11 ****
--- 6,13 ----
  test: compat_informix/cursor
  test: compat_informix/sqlda
  test: compat_informix/describe
+ test: compat_informix/struct
+ test: compat_informix/outofscope
  test: compat_informix/test_informix
  test: compat_informix/test_informix2
  test: connect/test2
diff -dcrpN pgsql.describe/src/interfaces/ecpg/test/expected/compat_informix-cursor.c
pgsql.ooscur/src/interfaces/ecpg/test/expected/compat_informix-cursor.c
*** pgsql.describe/src/interfaces/ecpg/test/expected/compat_informix-cursor.c    2009-09-03 12:47:24.000000000 +0200
--- pgsql.ooscur/src/interfaces/ecpg/test/expected/compat_informix-cursor.c    2009-09-05 11:27:20.000000000 +0200
*************** if (sqlca.sqlcode < 0) exit (1);}
*** 162,168 ****

      strcpy(msg, "open");
      { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare $0 cursor for select id , t from t1",
!     ECPGt_char,&(*( char  *)(ECPG_informix_get_var( 0))),(long)0,(long)1,(1)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
  #line 62 "cursor.pgc"

--- 162,168 ----

      strcpy(msg, "open");
      { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare $0 cursor for select id , t from t1",
!     ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
  #line 62 "cursor.pgc"

*************** if (sqlca.sqlcode < 0) exit (1);}
*** 298,308 ****

      strcpy(msg, "open");
      { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare $0 cursor for select id , t from t1",
!     ECPGt_char,&(*( char  *)(ECPG_informix_get_var( 3))),(long)0,(long)1,(1)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
!     ECPGt_int,&(*( int  *)(ECPG_informix_get_var( 2))),(long)1,(long)1,sizeof(int),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
!     ECPGt_char,(( char  *)(ECPG_informix_get_var( 1))),(long)64,(long)1,(64)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
  #line 103 "cursor.pgc"

--- 298,308 ----

      strcpy(msg, "open");
      { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare $0 cursor for select id , t from t1",
!     ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
!     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
!     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
  #line 103 "cursor.pgc"

*************** if (sqlca.sqlcode < 0) exit (1);}
*** 314,322 ****
      { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch from $0",
      ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
!     ECPGt_int,&(*( int  *)(ECPG_informix_get_var( 2))),(long)1,(long)1,sizeof(int),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
!     ECPGt_char,(( char  *)(ECPG_informix_get_var( 1))),(long)64,(long)1,(64)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
  #line 106 "cursor.pgc"

--- 314,322 ----
      { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch from $0",
      ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
!     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
!     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
  #line 106 "cursor.pgc"

*************** if (sqlca.sqlcode < 0) exit (1);}
*** 329,337 ****
      { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch $0",
      ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
!     ECPGt_int,&(*( int  *)(ECPG_informix_get_var( 2))),(long)1,(long)1,sizeof(int),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
!     ECPGt_char,(( char  *)(ECPG_informix_get_var( 1))),(long)64,(long)1,(64)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
  #line 110 "cursor.pgc"

--- 329,337 ----
      { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch $0",
      ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
!     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
!     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
  #line 110 "cursor.pgc"

*************** if (sqlca.sqlcode < 0) exit (1);}
*** 344,352 ****
      { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch 1 from $0",
      ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
!     ECPGt_int,&(*( int  *)(ECPG_informix_get_var( 2))),(long)1,(long)1,sizeof(int),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
!     ECPGt_char,(( char  *)(ECPG_informix_get_var( 1))),(long)64,(long)1,(64)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
  #line 114 "cursor.pgc"

--- 344,352 ----
      { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch 1 from $0",
      ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
!     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
!     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
  #line 114 "cursor.pgc"

*************** if (sqlca.sqlcode < 0) exit (1);}
*** 362,370 ****
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
      ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
!     ECPGt_int,&(*( int  *)(ECPG_informix_get_var( 2))),(long)1,(long)1,sizeof(int),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
!     ECPGt_char,(( char  *)(ECPG_informix_get_var( 1))),(long)64,(long)1,(64)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
  #line 119 "cursor.pgc"

--- 362,370 ----
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
      ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
!     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
!     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
  #line 119 "cursor.pgc"

*************** if (sqlca.sqlcode < 0) exit (1);}
*** 377,385 ****
      { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "move absolute 0 $0",
      ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
!     ECPGt_int,&(*( int  *)(ECPG_informix_get_var( 2))),(long)1,(long)1,sizeof(int),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
!     ECPGt_char,(( char  *)(ECPG_informix_get_var( 1))),(long)64,(long)1,(64)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
  #line 123 "cursor.pgc"

--- 377,385 ----
      { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "move absolute 0 $0",
      ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
!     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
!     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
  #line 123 "cursor.pgc"

*************** if (sqlca.sqlcode < 0) exit (1);}
*** 391,399 ****
      { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch 1 $0",
      ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
!     ECPGt_int,&(*( int  *)(ECPG_informix_get_var( 2))),(long)1,(long)1,sizeof(int),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
!     ECPGt_char,(( char  *)(ECPG_informix_get_var( 1))),(long)64,(long)1,(64)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
  #line 126 "cursor.pgc"

--- 391,399 ----
      { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch 1 $0",
      ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
!     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
!     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
  #line 126 "cursor.pgc"

*************** if (sqlca.sqlcode < 0) exit (1);}
*** 409,417 ****
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
      ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
!     ECPGt_int,&(*( int  *)(ECPG_informix_get_var( 2))),(long)1,(long)1,sizeof(int),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
!     ECPGt_char,(( char  *)(ECPG_informix_get_var( 1))),(long)64,(long)1,(64)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
  #line 131 "cursor.pgc"

--- 409,417 ----
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
      ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
!     ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
!     ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
      ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
  #line 131 "cursor.pgc"

*************** if (sqlca.sqlcode < 0) exit (1);}
*** 441,447 ****


      strcpy(msg, "declare");
!     ECPG_informix_reset_sqlca(); /* declare $0 cursor for $1 */
  #line 143 "cursor.pgc"


--- 441,448 ----


      strcpy(msg, "declare");
!     ECPG_informix_set_var( 4, &( curname3 ), __LINE__);\
!  ECPG_informix_reset_sqlca(); /* declare $0 cursor for $1 */
  #line 143 "cursor.pgc"


*************** if (sqlca.sqlcode < 0) exit (1);}
*** 596,602 ****


      strcpy(msg, "declare");
!     ECPG_informix_reset_sqlca(); /* declare $0 cursor for $1 */
  #line 193 "cursor.pgc"


--- 597,604 ----


      strcpy(msg, "declare");
!     ECPG_informix_set_var( 5, &( curname4 ), __LINE__);\
!  ECPG_informix_reset_sqlca(); /* declare $0 cursor for $1 */
  #line 193 "cursor.pgc"


diff -dcrpN pgsql.describe/src/interfaces/ecpg/test/expected/compat_informix-outofscope.c
pgsql.ooscur/src/interfaces/ecpg/test/expected/compat_informix-outofscope.c
*** pgsql.describe/src/interfaces/ecpg/test/expected/compat_informix-outofscope.c    1970-01-01 01:00:00.000000000
+0100
--- pgsql.ooscur/src/interfaces/ecpg/test/expected/compat_informix-outofscope.c    2009-09-05 11:44:07.000000000 +0200
***************
*** 0 ****
--- 1,629 ----
+ /* Processed by ecpg (regression mode) */
+ /* These include files are added by the preprocessor */
+ #include <ecpglib.h>
+ #include <ecpgerrno.h>
+ #include <sqlca.h>
+ /* Needed for informix compatibility */
+ #include <ecpg_informix.h>
+ /* End of automatic include section */
+ #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+
+ #line 1 "outofscope.pgc"
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include <inttypes.h>
+
+
+ #line 1 "regression.h"
+
+
+
+
+
+
+ #line 6 "outofscope.pgc"
+
+
+
+ #line 1 "sqlda.h"
+ /*
+  * $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqlda.h,v 1.4 2009/06/11 14:49:13 momjian Exp $
+  */
+
+ #ifndef POSTGRES_SQLDA_H
+ #define POSTGRES_SQLDA_H
+
+ /* Define Informix "standard" types */
+ #ifndef C_H
+ typedef int        int4;
+ typedef    short        int2;
+ #endif
+ typedef    char        int1;
+
+ typedef    int        mint;
+ typedef    long        mlong;
+
+ typedef    short        MSHORT;
+ typedef    char        MCHAR;
+
+ typedef    unsigned int    uint4;
+ typedef    unsigned short    uint2;
+ typedef    unsigned char    uint1;
+
+ typedef    unsigned int    muint;
+ typedef    unsigned long    mulong;
+
+ typedef    unsigned short    MUSHORT;
+ typedef    unsigned char    MUCHAR;
+
+ #define MI_INT_SIZE     (sizeof(int)    * 8)
+ #define MI_LONG_SIZE    (sizeof(long)   * 8)
+ #define MI_PTR_SIZE     (sizeof(char *) * 8)
+
+ typedef struct sqlvar_struct
+ {
+     int2    sqltype;        /* variable type                */
+     int4    sqllen;            /* length in bytes              */
+     char       *sqldata;        /* pointer to data              */
+     int2       *sqlind;        /* pointer to indicator         */
+     char       *sqlname;        /* variable name                */
+     char       *sqlformat;        /* reserved for future use      */
+     int2    sqlitype;        /* ind variable type            */
+     int2    sqlilen;        /* ind length in bytes          */
+     char       *sqlidata;        /* ind data pointer             */
+     int4    sqlxid;            /* extended id type             */
+     char       *sqltypename;    /* extended type name           */
+     int2    sqltypelen;        /* length of extended type name */
+     int2    sqlownerlen;        /* length of owner name         */
+     int2    sqlsourcetype;        /* source type for distinct of built-ins */
+     char       *sqlownername;    /* owner name                   */
+     int4    sqlsourceid;        /* extended id of source type   */
+
+     /*
+      * sqlilongdata is new.  It supports data that exceeds the 32k
+      * limit.  sqlilen and sqlidata are for backward compatibility
+      * and they have maximum value of <32K.
+      */
+     char       *sqlilongdata;    /* for data field beyond 32K    */
+     int4    sqlflags;        /* for internal use only        */
+     void       *sqlreserved;    /* reserved for future use      */
+ } pg_sqlvar_t;
+
+ typedef struct sqlda
+ {
+     int2        sqld;
+     pg_sqlvar_t       *sqlvar;
+     char        desc_name[19];    /* descriptor name              */
+     int2        desc_occ;    /* size of sqlda structure      */
+     struct sqlda       *desc_next;    /* pointer to next sqlda struct */
+     void           *reserved;    /* reserved for future use */
+ } pg_sqlda_t;
+
+ #endif /* POSTGRES_SQLDA_H */
+
+ #line 8 "outofscope.pgc"
+
+
+ #line 1 "sqltypes.h"
+ /*
+  * $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqltypes.h,v 1.9 2009/06/11 14:49:13 momjian Exp $
+  */
+ #ifndef ECPG_SQLTYPES_H
+ #define ECPG_SQLTYPES_H
+
+ #define CCHARTYPE    ECPGt_char
+ #define CSHORTTYPE    ECPGt_short
+ #define CINTTYPE    ECPGt_int
+ #define CLONGTYPE    ECPGt_long
+ #define CFLOATTYPE    ECPGt_float
+ #define CDOUBLETYPE ECPGt_double
+ #define CDECIMALTYPE    ECPGt_decimal
+ #define CFIXCHARTYPE    108
+ #define CSTRINGTYPE ECPGt_char
+ #define CDATETYPE    ECPGt_date
+ #define CMONEYTYPE    111
+ #define CDTIMETYPE    ECPGt_timestamp
+ #define CLOCATORTYPE    113
+ #define CVCHARTYPE    ECPGt_varchar
+ #define CINVTYPE    115
+ #define CFILETYPE    116
+ #define CINT8TYPE    ECPGt_long_long
+ #define CCOLLTYPE        118
+ #define CLVCHARTYPE        119
+ #define CFIXBINTYPE        120
+ #define CVARBINTYPE        121
+ #define CBOOLTYPE        ECPGt_bool
+ #define CROWTYPE        123
+ #define CLVCHARPTRTYPE    124
+ #define CTYPEMAX    25
+
+ /*
+  * Values used in sqlda->sqlvar[i]->sqltype
+  */
+ #define    SQLCHAR        0
+ #define    SQLSMINT    1
+ #define    SQLINT        2
+ #define    SQLFLOAT    3
+ #define    SQLSMFLOAT    4
+ #define    SQLDECIMAL    5
+ #define    SQLSERIAL    6
+ #define    SQLDATE        7
+ #define    SQLMONEY    8
+ #define    SQLDTIME    10
+ #define    SQLBYTES    11
+ #define    SQLTEXT        12
+ #define    SQLVCHAR    13
+ #define    SQLINTERVAL    14
+ #define    SQLNCHAR    15
+ #define    SQLNVCHAR    16
+ #define    SQLINT8        17
+ #define    SQLSERIAL8    18
+
+ #endif   /* ndef ECPG_SQLTYPES_H */
+
+ #line 9 "outofscope.pgc"
+
+
+ /* exec sql begin declare section */
+
+ #line 1 "struct.h"
+
+
+
+
+          /* dec_t */
+
+
+
+    typedef struct mytype  MYTYPE ;
+
+ #line 9 "struct.h"
+
+
+
+
+
+
+
+
+
+    typedef struct mynulltype  MYNULLTYPE ;
+
+ #line 18 "struct.h"
+
+
+ #line 12 "outofscope.pgc"
+
+ struct mytype {
+ #line 3 "struct.h"
+  int id ;
+
+ #line 4 "struct.h"
+  char t [ 64 ] ;
+
+ #line 5 "struct.h"
+  double d1 ;
+
+ #line 6 "struct.h"
+  double d2 ;
+
+ #line 7 "struct.h"
+  char c [ 30 ] ;
+  } ; struct mynulltype {
+ #line 12 "struct.h"
+  int id ;
+
+ #line 13 "struct.h"
+  int t ;
+
+ #line 14 "struct.h"
+  int d1 ;
+
+ #line 15 "struct.h"
+  int d2 ;
+
+ #line 16 "struct.h"
+  int c ;
+  } ;/* exec sql end declare section */
+ #line 13 "outofscope.pgc"
+
+
+ /* exec sql whenever sqlerror  stop ; */
+ #line 15 "outofscope.pgc"
+
+
+ /* Functions for test 1 */
+
+ static void
+ get_var1(MYTYPE **myvar0, MYNULLTYPE **mynullvar0)
+ {
+     /* exec sql begin declare section */
+
+
+
+ #line 23 "outofscope.pgc"
+  MYTYPE * myvar = malloc ( sizeof ( MYTYPE ) ) ;
+
+ #line 24 "outofscope.pgc"
+  MYNULLTYPE * mynullvar = malloc ( sizeof ( MYNULLTYPE ) ) ;
+ /* exec sql end declare section */
+ #line 25 "outofscope.pgc"
+
+
+     /* Test DECLARE ... SELECT ... INTO with pointers */
+
+     ECPG_informix_set_var( 0, ( myvar ), __LINE__);\
+  ECPG_informix_set_var( 1, ( mynullvar ), __LINE__);\
+  ECPG_informix_reset_sqlca(); /* declare mycur cursor for select * from a1 */
+ #line 29 "outofscope.pgc"
+
+
+     if (sqlca.sqlcode != 0)
+         exit(1);
+
+     *myvar0 = myvar;
+     *mynullvar0 = mynullvar;
+ }
+
+ static void
+ open_cur1(void)
+ {
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare mycur cursor for select * from a1", ECPGt_EOIT,
+     ECPGt_int,&((*( MYTYPE  *)(ECPG_informix_get_var( 0))).id),(long)1,(long)1,sizeof(int),
+     ECPGt_int,&((*( MYNULLTYPE  *)(ECPG_informix_get_var( 1))).id),(long)1,(long)1,sizeof(int),
+     ECPGt_char,&((*( MYTYPE  *)(ECPG_informix_get_var( 0))).t),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_int,&((*( MYNULLTYPE  *)(ECPG_informix_get_var( 1))).t),(long)1,(long)1,sizeof(int),
+     ECPGt_double,&((*( MYTYPE  *)(ECPG_informix_get_var( 0))).d1),(long)1,(long)1,sizeof(double),
+     ECPGt_int,&((*( MYNULLTYPE  *)(ECPG_informix_get_var( 1))).d1),(long)1,(long)1,sizeof(int),
+     ECPGt_double,&((*( MYTYPE  *)(ECPG_informix_get_var( 0))).d2),(long)1,(long)1,sizeof(double),
+     ECPGt_int,&((*( MYNULLTYPE  *)(ECPG_informix_get_var( 1))).d2),(long)1,(long)1,sizeof(int),
+     ECPGt_char,&((*( MYTYPE  *)(ECPG_informix_get_var( 0))).c),(long)30,(long)1,(30)*sizeof(char),
+     ECPGt_int,&((*( MYNULLTYPE  *)(ECPG_informix_get_var( 1))).c),(long)1,(long)1,sizeof(int), ECPGt_EORT);
+ #line 41 "outofscope.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 41 "outofscope.pgc"
+
+
+     if (sqlca.sqlcode != 0)
+         exit(1);
+ }
+
+ static void
+ get_record1(void)
+ {
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch mycur", ECPGt_EOIT,
+     ECPGt_int,&((*( MYTYPE  *)(ECPG_informix_get_var( 0))).id),(long)1,(long)1,sizeof(int),
+     ECPGt_int,&((*( MYNULLTYPE  *)(ECPG_informix_get_var( 1))).id),(long)1,(long)1,sizeof(int),
+     ECPGt_char,&((*( MYTYPE  *)(ECPG_informix_get_var( 0))).t),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_int,&((*( MYNULLTYPE  *)(ECPG_informix_get_var( 1))).t),(long)1,(long)1,sizeof(int),
+     ECPGt_double,&((*( MYTYPE  *)(ECPG_informix_get_var( 0))).d1),(long)1,(long)1,sizeof(double),
+     ECPGt_int,&((*( MYNULLTYPE  *)(ECPG_informix_get_var( 1))).d1),(long)1,(long)1,sizeof(int),
+     ECPGt_double,&((*( MYTYPE  *)(ECPG_informix_get_var( 0))).d2),(long)1,(long)1,sizeof(double),
+     ECPGt_int,&((*( MYNULLTYPE  *)(ECPG_informix_get_var( 1))).d2),(long)1,(long)1,sizeof(int),
+     ECPGt_char,&((*( MYTYPE  *)(ECPG_informix_get_var( 0))).c),(long)30,(long)1,(30)*sizeof(char),
+     ECPGt_int,&((*( MYNULLTYPE  *)(ECPG_informix_get_var( 1))).c),(long)1,(long)1,sizeof(int), ECPGt_EORT);
+ #line 50 "outofscope.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 50 "outofscope.pgc"
+
+
+     if (sqlca.sqlcode != 0 && sqlca.sqlcode != SQLNOTFOUND)
+         exit(1);
+ }
+
+ static void
+ close_cur1(void)
+ {
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "close mycur", ECPGt_EOIT, ECPGt_EORT);
+ #line 59 "outofscope.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 59 "outofscope.pgc"
+
+
+     if (sqlca.sqlcode != 0)
+         exit(1);
+ }
+
+ /* Functions for test 2 */
+
+ pg_sqlda_t    *inp_sqlda, *outp_sqlda;
+
+ /* exec sql begin declare section */
+
+
+
+
+ #line 70 "outofscope.pgc"
+  char * stmt2 = "SELECT * FROM a1 WHERE id = ?" ;
+
+ #line 71 "outofscope.pgc"
+  char * curname2 = "mycur" ;
+
+ #line 72 "outofscope.pgc"
+  int id ;
+ /* exec sql end declare section */
+ #line 73 "outofscope.pgc"
+
+
+ static void
+ prepare2(void)
+ {
+     { ECPGprepare(__LINE__, NULL, 0, "prepared_stmt", stmt2);
+ #line 78 "outofscope.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 78 "outofscope.pgc"
+
+
+     if (sqlca.sqlcode != 0)
+         exit(1);
+
+     inp_sqlda = (pg_sqlda_t *)malloc(sizeof(pg_sqlda_t));
+     memset(inp_sqlda, 0, sizeof(pg_sqlda_t));
+     inp_sqlda->sqld = 1;
+     inp_sqlda->sqlvar = malloc(sizeof(pg_sqlvar_t));
+     memset(inp_sqlda->sqlvar, 0, sizeof(pg_sqlvar_t));
+
+     inp_sqlda->sqlvar[0].sqltype = SQLINT;
+     inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+     id = 4;
+ }
+
+ static void
+ declare2(void)
+ {
+     ECPG_informix_reset_sqlca(); /* declare $0 cursor for $1 */
+ #line 97 "outofscope.pgc"
+
+
+     if (sqlca.sqlcode != 0)
+         exit(1);
+ }
+
+ static void
+ dealloc_prep2(void)
+ {
+     { ECPGdeallocate(__LINE__, 1, NULL, "prepared_stmt");
+ #line 106 "outofscope.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 106 "outofscope.pgc"
+
+
+     free(inp_sqlda->sqlvar);
+     free(inp_sqlda);
+     free(outp_sqlda);
+ }
+
+ static void
+ open_cur2(void)
+ {
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare $0 cursor for $1",
+     ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_char_variable,(ECPGprepared_statement(NULL, "prepared_stmt", __LINE__)),(long)1,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+     ECPGt_sqlda, & inp_sqlda , 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 116 "outofscope.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 116 "outofscope.pgc"
+
+
+     if (sqlca.sqlcode != 0)
+         exit(1);
+ }
+
+ static void
+ close_cur2(void)
+ {
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "close $0",
+     ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 125 "outofscope.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 125 "outofscope.pgc"
+
+
+     if (sqlca.sqlcode != 0)
+         exit(1);
+ }
+
+ static void
+ get_record2(void)
+ {
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch $0",
+     ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_sqlda, & outp_sqlda , 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 134 "outofscope.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 134 "outofscope.pgc"
+
+
+     if (sqlca.sqlcode != 0 && sqlca.sqlcode != SQLNOTFOUND)
+         exit(1);
+ }
+
+ static void
+ dump_sqlda(pg_sqlda_t *sqlda)
+ {
+     int    i;
+
+     for (i = 0; i < sqlda->sqld; i++)
+     {
+         if (outp_sqlda->sqlvar[i].sqlind && *(outp_sqlda->sqlvar[i].sqlind) == -1)
+             printf("name sqlda descriptor: '%s' value NULL'\n", outp_sqlda->sqlvar[i].sqlname);
+         else
+         switch (sqlda->sqlvar[i].sqltype)
+         {
+         case SQLCHAR:
+         case SQLVCHAR:
+         case SQLTEXT:
+             printf("name sqlda descriptor: '%s' value '%s'\n", sqlda->sqlvar[i].sqlname, sqlda->sqlvar[i].sqldata);
+             break;
+         case SQLSERIAL:
+         case SQLINT:
+             printf("name sqlda descriptor: '%s' value %d\n", sqlda->sqlvar[i].sqlname, *(int
*)sqlda->sqlvar[i].sqldata);
+             break;
+         case SQLSERIAL8:
+         case SQLINT8:
+             printf("name sqlda descriptor: '%s' value %" PRId64 "\n", sqlda->sqlvar[i].sqlname, *(int64_t
*)sqlda->sqlvar[i].sqldata);
+             break;
+         case SQLFLOAT:
+             printf("name sqlda descriptor: '%s' value %lf\n", sqlda->sqlvar[i].sqlname, *(double
*)sqlda->sqlvar[i].sqldata);
+             break;
+         case SQLDECIMAL:
+             {
+                 char    val[64];
+                 dectoasc((decimal *)sqlda->sqlvar[i].sqldata, val, 64, -1);
+                 printf("name sqlda descriptor: '%s' value DECIMAL '%s'\n", sqlda->sqlvar[i].sqlname, val);
+                 break;
+             }
+         }
+     }
+ }
+
+ int
+ main (void)
+ {
+     MYTYPE        *myvar;
+     MYNULLTYPE    *mynullvar;
+
+     char msg[128];
+
+     ECPGdebug(1, stderr);
+
+     strcpy(msg, "connect");
+     { ECPGconnect(__LINE__, 1, "regress1" , NULL, NULL , NULL, 0);
+ #line 190 "outofscope.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 190 "outofscope.pgc"
+
+
+     strcpy(msg, "set");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
+ #line 193 "outofscope.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 193 "outofscope.pgc"
+
+
+     strcpy(msg, "create");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "create table a1 ( id serial primary key , t text , d1 numeric ,
d2float8 , c character ( 10 ) )", ECPGt_EOIT, ECPGt_EORT); 
+ #line 196 "outofscope.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 196 "outofscope.pgc"
+
+
+     strcpy(msg, "insert");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'a'
,1.0 , 2 , 'a' )", ECPGt_EOIT, ECPGt_EORT); 
+ #line 199 "outofscope.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 199 "outofscope.pgc"
+
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , null
,null , null , null )", ECPGt_EOIT, ECPGt_EORT); 
+ #line 200 "outofscope.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 200 "outofscope.pgc"
+
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default ,
'\"a\"', - 1.0 , 'nan' :: float8 , 'a' )", ECPGt_EOIT, ECPGt_EORT); 
+ #line 201 "outofscope.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 201 "outofscope.pgc"
+
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'b'
,2.0 , 3 , 'b' )", ECPGt_EOIT, ECPGt_EORT); 
+ #line 202 "outofscope.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 202 "outofscope.pgc"
+
+
+     strcpy(msg, "commit");
+     { ECPGtrans(__LINE__, NULL, "commit");
+ #line 205 "outofscope.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 205 "outofscope.pgc"
+
+
+     /* Test out-of-scope DECLARE/OPEN/FETCH/CLOSE */
+
+     get_var1(&myvar, &mynullvar);
+     open_cur1();
+
+     /* exec sql whenever not found  break ; */
+ #line 212 "outofscope.pgc"
+
+
+     while (1)
+     {
+         memset(myvar, 0, sizeof(MYTYPE));
+         get_record1();
+         if (sqlca.sqlcode == SQLNOTFOUND)
+             break;
+         printf("id=%d%s t='%s'%s d1=%lf%s d2=%lf%s c = '%s'%s\n",
+             myvar->id, mynullvar->id ? " (NULL)" : "",
+             myvar->t, mynullvar->t ? " (NULL)" : "",
+             myvar->d1, mynullvar->d1 ? " (NULL)" : "",
+             myvar->d2, mynullvar->d2 ? " (NULL)" : "",
+             myvar->c, mynullvar->c ? " (NULL)" : "");
+     }
+
+     close_cur1();
+
+     /* Test out-of-scope DECLARE/OPEN/FETCH/CLOSE interaction
+      * with a dynamic cursor and prepared statment using an sqlda
+      */
+
+     prepare2();
+     declare2();
+     open_cur2();
+
+     get_record2();
+     dump_sqlda(outp_sqlda);
+
+     close_cur2();
+     dealloc_prep2();
+
+     /* End test */
+
+     strcpy(msg, "drop");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "drop table a1", ECPGt_EOIT, ECPGt_EORT);
+ #line 247 "outofscope.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 247 "outofscope.pgc"
+
+
+     strcpy(msg, "commit");
+     { ECPGtrans(__LINE__, NULL, "commit");
+ #line 250 "outofscope.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 250 "outofscope.pgc"
+
+
+     strcpy(msg, "disconnect");
+     { ECPGdisconnect(__LINE__, "CURRENT");
+ #line 253 "outofscope.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 253 "outofscope.pgc"
+
+
+     return (0);
+ }
diff -dcrpN pgsql.describe/src/interfaces/ecpg/test/expected/compat_informix-outofscope.stderr
pgsql.ooscur/src/interfaces/ecpg/test/expected/compat_informix-outofscope.stderr
*** pgsql.describe/src/interfaces/ecpg/test/expected/compat_informix-outofscope.stderr    1970-01-01 01:00:00.000000000
+0100
--- pgsql.ooscur/src/interfaces/ecpg/test/expected/compat_informix-outofscope.stderr    2009-09-05 11:44:07.000000000
+0200
***************
*** 0 ****
--- 1,170 ----
+ [NO_PID]: ECPGdebug: set to 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 193: query: set datestyle to iso; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 193: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 193: OK: SET
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 196: query: create table a1 ( id serial primary key , t text , d1 numeric , d2 float8
,c character ( 10 ) ); with 0 parameter(s) on connection regress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 196: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 196: OK: CREATE TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 199: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'a' , 1.0 , 2 ,
'a'); with 0 parameter(s) on connection regress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 199: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 199: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 200: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , null , null ,
null, null ); with 0 parameter(s) on connection regress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 200: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 200: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 201: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , '"a"' , - 1.0 ,
'nan':: float8 , 'a' ); with 0 parameter(s) on connection regress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 201: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 201: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 202: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'b' , 2.0 , 3 ,
'b'); with 0 parameter(s) on connection regress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 202: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 202: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 205: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 41: query: declare mycur cursor for select * from a1; with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 41: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 41: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT: 1.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT: a          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT: "a" offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT: -1.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT: NaN offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT: a          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT: 2.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT: b          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: correctly got 0 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: raising sqlcode 100 on line 50: no data found on line 50
+ [NO_PID]: sqlca: code: 100, state: 02000
+ [NO_PID]: ecpg_execute on line 59: query: close mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 59: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 59: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 78: name prepared_stmt; query: "SELECT * FROM a1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 116: query: declare mycur cursor for SELECT * FROM a1 WHERE id = $1; with 1
parameter(s)on connection regress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 116: using PQexecParams
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: free_params on line 116: parameter 1 = 4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 116: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 134: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 134: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 134: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 134: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 134: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 134: RESULT: 2.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 134: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 134: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 125: query: close mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 125: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 125: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 106: name prepared_stmt
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 247: query: drop table a1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 247: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 247: OK: DROP TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 250: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection regress1 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
diff -dcrpN pgsql.describe/src/interfaces/ecpg/test/expected/compat_informix-outofscope.stdout
pgsql.ooscur/src/interfaces/ecpg/test/expected/compat_informix-outofscope.stdout
*** pgsql.describe/src/interfaces/ecpg/test/expected/compat_informix-outofscope.stdout    1970-01-01 01:00:00.000000000
+0100
--- pgsql.ooscur/src/interfaces/ecpg/test/expected/compat_informix-outofscope.stdout    2009-09-05 11:44:08.000000000
+0200
***************
*** 0 ****
--- 1,9 ----
+ id=1 t='a' d1=1.000000 d2=2.000000 c = 'a         '
+ id=2 t='' (NULL) d1=0.000000 (NULL) d2=0.000000 (NULL) c = '' (NULL)
+ id=3 t='"a"' d1=-1.000000 d2=nan c = 'a         '
+ id=4 t='b' d1=2.000000 d2=3.000000 c = 'b         '
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'b'
+ name sqlda descriptor: 'd1' value DECIMAL '2.0'
+ name sqlda descriptor: 'd2' value 3.000000
+ name sqlda descriptor: 'c' value 'b         '
diff -dcrpN pgsql.describe/src/interfaces/ecpg/test/expected/compat_informix-struct.c
pgsql.ooscur/src/interfaces/ecpg/test/expected/compat_informix-struct.c
*** pgsql.describe/src/interfaces/ecpg/test/expected/compat_informix-struct.c    1970-01-01 01:00:00.000000000 +0100
--- pgsql.ooscur/src/interfaces/ecpg/test/expected/compat_informix-struct.c    2009-09-03 14:09:35.000000000 +0200
***************
*** 0 ****
--- 1,265 ----
+ /* Processed by ecpg (regression mode) */
+ /* These include files are added by the preprocessor */
+ #include <ecpglib.h>
+ #include <ecpgerrno.h>
+ #include <sqlca.h>
+ /* Needed for informix compatibility */
+ #include <ecpg_informix.h>
+ /* End of automatic include section */
+ #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+
+ #line 1 "struct.pgc"
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+
+
+ #line 1 "regression.h"
+
+
+
+
+
+
+ #line 5 "struct.pgc"
+
+
+ /* exec sql begin declare section */
+
+ #line 1 "struct.h"
+
+
+
+
+          /* dec_t */
+
+
+
+    typedef struct mytype  MYTYPE ;
+
+ #line 9 "struct.h"
+
+
+
+
+
+
+
+
+
+    typedef struct mynulltype  MYNULLTYPE ;
+
+ #line 18 "struct.h"
+
+
+ #line 8 "struct.pgc"
+
+ struct mytype {
+ #line 3 "struct.h"
+  int id ;
+
+ #line 4 "struct.h"
+  char t [ 64 ] ;
+
+ #line 5 "struct.h"
+  double d1 ;
+
+ #line 6 "struct.h"
+  double d2 ;
+
+ #line 7 "struct.h"
+  char c [ 30 ] ;
+  } ; struct mynulltype {
+ #line 12 "struct.h"
+  int id ;
+
+ #line 13 "struct.h"
+  int t ;
+
+ #line 14 "struct.h"
+  int d1 ;
+
+ #line 15 "struct.h"
+  int d2 ;
+
+ #line 16 "struct.h"
+  int c ;
+  } ;/* exec sql end declare section */
+ #line 9 "struct.pgc"
+
+
+ /* exec sql whenever sqlerror  stop ; */
+ #line 11 "struct.pgc"
+
+
+ int
+ main (void)
+ {
+     /* exec sql begin declare section */
+
+
+
+ #line 17 "struct.pgc"
+  MYTYPE myvar ;
+
+ #line 18 "struct.pgc"
+  MYNULLTYPE mynullvar ;
+ /* exec sql end declare section */
+ #line 19 "struct.pgc"
+
+
+     char msg[128];
+
+     ECPGdebug(1, stderr);
+
+     strcpy(msg, "connect");
+     { ECPGconnect(__LINE__, 1, "regress1" , NULL, NULL , NULL, 0);
+ #line 26 "struct.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 26 "struct.pgc"
+
+
+     strcpy(msg, "set");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
+ #line 29 "struct.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 29 "struct.pgc"
+
+
+     strcpy(msg, "create");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "create table a1 ( id serial primary key , t text , d1 numeric ,
d2float8 , c character ( 10 ) )", ECPGt_EOIT, ECPGt_EORT); 
+ #line 32 "struct.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 32 "struct.pgc"
+
+
+     strcpy(msg, "insert");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'a'
,1.0 , 2 , 'a' )", ECPGt_EOIT, ECPGt_EORT); 
+ #line 35 "struct.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 35 "struct.pgc"
+
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , null
,null , null , null )", ECPGt_EOIT, ECPGt_EORT); 
+ #line 36 "struct.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 36 "struct.pgc"
+
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default ,
'\"a\"', - 1.0 , 'nan' :: float8 , 'a' )", ECPGt_EOIT, ECPGt_EORT); 
+ #line 37 "struct.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 37 "struct.pgc"
+
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'b'
,2.0 , 3 , 'b' )", ECPGt_EOIT, ECPGt_EORT); 
+ #line 38 "struct.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 38 "struct.pgc"
+
+
+     strcpy(msg, "commit");
+     { ECPGtrans(__LINE__, NULL, "commit");
+ #line 41 "struct.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 41 "struct.pgc"
+
+
+     /* Test DECLARE ... SELECT ... INTO with struct type */
+
+     ECPG_informix_set_var( 0, &( myvar ), __LINE__);\
+  ECPG_informix_set_var( 1, &( mynullvar ), __LINE__);\
+  ECPG_informix_reset_sqlca(); /* declare mycur cursor for select * from a1 */
+ #line 45 "struct.pgc"
+
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare mycur cursor for select * from a1", ECPGt_EOIT,
+     ECPGt_int,&(myvar.id),(long)1,(long)1,sizeof(int),
+     ECPGt_int,&(mynullvar.id),(long)1,(long)1,sizeof(int),
+     ECPGt_char,&(myvar.t),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_int,&(mynullvar.t),(long)1,(long)1,sizeof(int),
+     ECPGt_double,&(myvar.d1),(long)1,(long)1,sizeof(double),
+     ECPGt_int,&(mynullvar.d1),(long)1,(long)1,sizeof(int),
+     ECPGt_double,&(myvar.d2),(long)1,(long)1,sizeof(double),
+     ECPGt_int,&(mynullvar.d2),(long)1,(long)1,sizeof(int),
+     ECPGt_char,&(myvar.c),(long)30,(long)1,(30)*sizeof(char),
+     ECPGt_int,&(mynullvar.c),(long)1,(long)1,sizeof(int), ECPGt_EORT);
+ #line 46 "struct.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 46 "struct.pgc"
+
+
+     /* exec sql whenever not found  break ; */
+ #line 48 "struct.pgc"
+
+
+     while (1)
+     {
+         memset(&myvar, 0, sizeof(myvar));
+         { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch mycur", ECPGt_EOIT,
+     ECPGt_int,&(myvar.id),(long)1,(long)1,sizeof(int),
+     ECPGt_int,&(mynullvar.id),(long)1,(long)1,sizeof(int),
+     ECPGt_char,&(myvar.t),(long)64,(long)1,(64)*sizeof(char),
+     ECPGt_int,&(mynullvar.t),(long)1,(long)1,sizeof(int),
+     ECPGt_double,&(myvar.d1),(long)1,(long)1,sizeof(double),
+     ECPGt_int,&(mynullvar.d1),(long)1,(long)1,sizeof(int),
+     ECPGt_double,&(myvar.d2),(long)1,(long)1,sizeof(double),
+     ECPGt_int,&(mynullvar.d2),(long)1,(long)1,sizeof(int),
+     ECPGt_char,&(myvar.c),(long)30,(long)1,(30)*sizeof(char),
+     ECPGt_int,&(mynullvar.c),(long)1,(long)1,sizeof(int), ECPGt_EORT);
+ #line 53 "struct.pgc"
+
+ if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
+ #line 53 "struct.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 53 "struct.pgc"
+
+         printf("id=%d%s t='%s'%s d1=%lf%s d2=%lf%s c = '%s'%s\n",
+             myvar.id, mynullvar.id ? " (NULL)" : "",
+             myvar.t, mynullvar.t ? " (NULL)" : "",
+             myvar.d1, mynullvar.d1 ? " (NULL)" : "",
+             myvar.d2, mynullvar.d2 ? " (NULL)" : "",
+             myvar.c, mynullvar.c ? " (NULL)" : "");
+     }
+
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "close mycur", ECPGt_EOIT, ECPGt_EORT);
+ #line 62 "struct.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 62 "struct.pgc"
+
+
+     /* End test */
+
+     strcpy(msg, "drop");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "drop table a1", ECPGt_EOIT, ECPGt_EORT);
+ #line 67 "struct.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 67 "struct.pgc"
+
+
+     strcpy(msg, "commit");
+     { ECPGtrans(__LINE__, NULL, "commit");
+ #line 70 "struct.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 70 "struct.pgc"
+
+
+     strcpy(msg, "disconnect");
+     { ECPGdisconnect(__LINE__, "CURRENT");
+ #line 73 "struct.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 73 "struct.pgc"
+
+
+     return (0);
+ }
diff -dcrpN pgsql.describe/src/interfaces/ecpg/test/expected/compat_informix-struct.stderr
pgsql.ooscur/src/interfaces/ecpg/test/expected/compat_informix-struct.stderr
*** pgsql.describe/src/interfaces/ecpg/test/expected/compat_informix-struct.stderr    1970-01-01 01:00:00.000000000
+0100
--- pgsql.ooscur/src/interfaces/ecpg/test/expected/compat_informix-struct.stderr    2009-09-03 13:57:48.000000000 +0200
***************
*** 0 ****
--- 1,136 ----
+ [NO_PID]: ECPGdebug: set to 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 29: query: set datestyle to iso; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 29: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 29: OK: SET
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 32: query: create table a1 ( id serial primary key , t text , d1 numeric , d2 float8 ,
ccharacter ( 10 ) ); with 0 parameter(s) on connection regress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 32: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 32: OK: CREATE TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 35: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'a' , 1.0 , 2 ,
'a'); with 0 parameter(s) on connection regress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 35: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 35: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , null , null ,
null, null ); with 0 parameter(s) on connection regress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , '"a"' , - 1.0 ,
'nan':: float8 , 'a' ); with 0 parameter(s) on connection regress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'b' , 2.0 , 3 ,
'b'); with 0 parameter(s) on connection regress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 41: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 46: query: declare mycur cursor for select * from a1; with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 46: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 46: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 1.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: a          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: "a" offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: -1.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: NaN offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: a          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 2.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: b          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: correctly got 0 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: raising sqlcode 100 on line 53: no data found on line 53
+ [NO_PID]: sqlca: code: 100, state: 02000
+ [NO_PID]: ecpg_execute on line 62: query: close mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 62: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 62: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 67: query: drop table a1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 67: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 67: OK: DROP TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 70: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection regress1 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
diff -dcrpN pgsql.describe/src/interfaces/ecpg/test/expected/compat_informix-struct.stdout
pgsql.ooscur/src/interfaces/ecpg/test/expected/compat_informix-struct.stdout
*** pgsql.describe/src/interfaces/ecpg/test/expected/compat_informix-struct.stdout    1970-01-01 01:00:00.000000000
+0100
--- pgsql.ooscur/src/interfaces/ecpg/test/expected/compat_informix-struct.stdout    2009-09-03 13:57:48.000000000 +0200
***************
*** 0 ****
--- 1,4 ----
+ id=1 t='a' d1=1.000000 d2=2.000000 c = 'a         '
+ id=2 t='' (NULL) d1=0.000000 (NULL) d2=0.000000 (NULL) c = '' (NULL)
+ id=3 t='"a"' d1=-1.000000 d2=nan c = 'a         '
+ id=4 t='b' d1=2.000000 d2=3.000000 c = 'b         '

Re: ECPG patchset

From
Boszormenyi Zoltan
Date:
New patch, typo fix in pgc.l.

According to our customer who is porting their application
to PostgreSQL, this causes an error currently in ECPG:

========================================

1. within included structures the use of "$else;" is causing an
   precompiler error (tested several times in different programs)
/home/progs/fors_neu/share/include/bwltrec.h:124: ERROR: syntax error at
or near ";"

Example:

mainprog.ec:
EXEC SQL BEGIN DECLARE SECTION;
EXEC SQL INCLUDE share/include/bwltrec.h;      /* record bwlt      */
EXEC SQL END DECLARE SECTION;

bwltrec.h:
   struct record_type_bwlt
   {  int    firmnr;             /* Firmennummer              (2,0)  */
      int    liwerk;             /* Werk - Lieferant          (2,0)  */
...
$ifdef FORS3;
      string besktr[7];           /* Kostentraeger                 */
$else;
      string besktr[13];          /* Kostentraeger                 */
$endif;
   } bwlt;

========================================

It looks to me that "EXEC SQL else;" is expected in the native
syntax, but "$else" (without ";" at the end of the line) is expected
in compat mode. Considering that the ";" seems to be expected
by esql, this must be a typo in ecpg/preproc/pgc.l

Best regards,
Zoltán Böszörményi

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
http://www.postgresql.at/

diff -dcrpN pgsql.locktimeout/src/interfaces/ecpg/preproc/pgc.l pgsql.ifdef/src/interfaces/ecpg/preproc/pgc.l
*** pgsql.locktimeout/src/interfaces/ecpg/preproc/pgc.l    2009-09-03 13:57:48.000000000 +0200
--- pgsql.ifdef/src/interfaces/ecpg/preproc/pgc.l    2009-09-08 11:47:05.000000000 +0200
*************** cppline            {space}*#(.*\\{space})*.*{newl
*** 1000,1006 ****
                              BEGIN(xskip);
                      }
                  }
! <C,xskip>{informix_special}{else}{space}*    {
                      /* are we simulating Informix? */
                      if (INFORMIX_MODE)
                      {
--- 1000,1006 ----
                              BEGIN(xskip);
                      }
                  }
! <C,xskip>{informix_special}{else}{space}*";"    {
                      /* are we simulating Informix? */
                      if (INFORMIX_MODE)
                      {

Re: ECPG patchset

From
Boszormenyi Zoltan
Date:
New version of the SQLDA support
Changes:
- removed a decimal-related leak fix (to be posted separately)
- free(sqlda->sqlvar) as well if it's not in the same allocation area
   as the main sqlda

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
http://www.postgresql.at/

diff -dcrpN pgsql.dyncursor/src/interfaces/ecpg/ecpglib/execute.c pgsql.sqlda/src/interfaces/ecpg/ecpglib/execute.c
*** pgsql.dyncursor/src/interfaces/ecpg/ecpglib/execute.c    2009-08-07 13:06:28.000000000 +0200
--- pgsql.sqlda/src/interfaces/ecpg/ecpglib/execute.c    2009-09-15 12:04:56.000000000 +0200
***************
*** 25,30 ****
--- 25,31 ----
  #include "ecpgerrno.h"
  #include "extern.h"
  #include "sqlca.h"
+ #include "sqlda.h"
  #include "sql3types.h"
  #include "pgtypes_numeric.h"
  #include "pgtypes_date.h"
*************** ecpg_store_input(const int lineno, const
*** 1033,1038 ****
--- 1034,1040 ----
                  break;

              case ECPGt_descriptor:
+             case ECPGt_sqlda:
                  break;

              default:
*************** ecpg_execute(struct statement * stmt)
*** 1172,1177 ****
--- 1174,1235 ----
              if (desc->count == desc_counter)
                  desc_counter = 0;
          }
+         else if (var->type == ECPGt_sqlda)
+         {
+             pg_sqlda_t      **_sqlda = (pg_sqlda_t **)var->pointer;
+             pg_sqlda_t       *sqlda = *_sqlda;
+             struct variable    desc_inlist;
+             int        i;
+
+             if (sqlda == NULL)
+                 return false;
+
+             desc_counter++;
+             for (i = 0; i < sqlda->sqld; i++)
+             {
+                 if (i + 1 == desc_counter)
+                 {
+                     desc_inlist.type = ecpg_sqlda_type(sqlda->sqlvar[i].sqltype);
+                     desc_inlist.value = sqlda->sqlvar[i].sqldata;
+                     desc_inlist.pointer = &(sqlda->sqlvar[i].sqldata);
+                     switch (desc_inlist.type)
+                     {
+                         case ECPGt_char:
+                         case ECPGt_varchar:
+                             desc_inlist.varcharsize = strlen(sqlda->sqlvar[i].sqldata);
+                             break;
+                         default:
+                             desc_inlist.varcharsize = 0;
+                             break;
+                     }
+                     desc_inlist.arrsize = 1;
+                     desc_inlist.offset = 0;
+                     if (sqlda->sqlvar[i].sqlind)
+                     {
+                         desc_inlist.ind_type = ECPGt_short;
+                         /* ECPG expects indicator value < 0 */
+                         if (*(sqlda->sqlvar[i].sqlind))
+                             *(sqlda->sqlvar[i].sqlind) = -1;
+                         desc_inlist.ind_value = sqlda->sqlvar[i].sqlind;
+                         desc_inlist.ind_pointer = &(sqlda->sqlvar[i].sqlind);
+                         desc_inlist.ind_varcharsize = desc_inlist.ind_arrsize = 1;
+                         desc_inlist.ind_offset = 0;
+                     }
+                     else
+                     {
+                         desc_inlist.ind_type = ECPGt_NO_INDICATOR;
+                         desc_inlist.ind_value = desc_inlist.ind_pointer = NULL;
+                         desc_inlist.ind_varcharsize = desc_inlist.ind_arrsize = desc_inlist.ind_offset = 0;
+                     }
+                     if (!ecpg_store_input(stmt->lineno, stmt->force_indicator, &desc_inlist, &tobeinserted, false))
+                         return false;
+
+                     break;
+                 }
+             }
+             if (sqlda->sqld == desc_counter)
+                 desc_counter = 0;
+         }
          else
          {
              if (!ecpg_store_input(stmt->lineno, stmt->force_indicator, var, &tobeinserted, false))
*************** ecpg_execute(struct statement * stmt)
*** 1353,1358 ****
--- 1411,1452 ----
                  }
                  var = var->next;
              }
+             else if (var != NULL && var->type == ECPGt_sqlda)
+             {
+                 pg_sqlda_t      **_sqlda = (pg_sqlda_t **)var->pointer;
+                 pg_sqlda_t       *sqlda = *_sqlda;
+                 pg_sqlda_t       *sqlda_new;
+
+                 /* Build a new sqlda structure. Note that only fetching 1 record is supported */
+                 sqlda_new = ecpg_build_sqlda_for_PGresult(stmt->lineno, results, 0);
+
+                 if (!sqlda_new)
+                 {
+                     ecpg_log("ecpg_execute on line %d: out of memory allocating a new sqlda\n", stmt->lineno);
+                     status = false;
+                 }
+                 else
+                 {
+                     ecpg_log("ecpg_execute on line %d: new sqlda was built\n", stmt->lineno);
+
+                     /* If we are passed in a previously existing sqlda then free it. */
+                     if (sqlda)
+                     {
+                         if (sqlda->sqlvar != (pg_sqlvar_t *)(sqlda + 1))
+                             free(sqlda->sqlvar);
+                         free(sqlda);
+                         sqlda = NULL;
+                     }
+
+                     *_sqlda = sqlda_new;
+
+                     ecpg_set_sqlda_from_PGresult(stmt->lineno, _sqlda, results, 0);
+                     ecpg_log("ecpg_execute on line %d: putting result (1 tuple %d fields) into sqlda descriptor\n",
+                             stmt->lineno, PQnfields(results));
+                 }
+
+                 var = var->next;
+             }
              else
                  for (act_field = 0; act_field < nfields && status; act_field++)
                  {
diff -dcrpN pgsql.dyncursor/src/interfaces/ecpg/ecpglib/extern.h pgsql.sqlda/src/interfaces/ecpg/ecpglib/extern.h
*** pgsql.dyncursor/src/interfaces/ecpg/ecpglib/extern.h    2009-05-25 12:08:48.000000000 +0200
--- pgsql.sqlda/src/interfaces/ecpg/ecpglib/extern.h    2009-09-03 13:02:55.000000000 +0200
***************
*** 6,11 ****
--- 6,12 ----
  #include "postgres_fe.h"
  #include "libpq-fe.h"
  #include "sqlca.h"
+ #include "sqlda.h"
  #include "ecpg_config.h"
  #ifndef CHAR_BIT
  #include <limits.h>
*************** bool        ecpg_init(const struct connection
*** 129,134 ****
--- 130,137 ----
  char       *ecpg_strdup(const char *, int);
  const char *ecpg_type_name(enum ECPGttype);
  int            ecpg_dynamic_type(Oid);
+ int            ecpg_sqlda_type(int);
+ int            ecpg_to_sqlda_type(Oid);
  void        ecpg_free_auto_mem(void);
  void        ecpg_clear_auto_mem(void);

*************** void        ecpg_log(const char *format,...);
*** 149,154 ****
--- 152,160 ----
  bool        ecpg_auto_prepare(int, const char *, const int, char **, const char *);
  void        ecpg_init_sqlca(struct sqlca_t * sqlca);

+ pg_sqlda_t *ecpg_build_sqlda_for_PGresult(int, PGresult *, int);
+ void        ecpg_set_sqlda_from_PGresult(int, pg_sqlda_t **, const PGresult *, int);
+
  /* SQLSTATE values generated or processed by ecpglib (intentionally
   * not exported -- users should refer to the codes directly) */

diff -dcrpN pgsql.dyncursor/src/interfaces/ecpg/ecpglib/Makefile pgsql.sqlda/src/interfaces/ecpg/ecpglib/Makefile
*** pgsql.dyncursor/src/interfaces/ecpg/ecpglib/Makefile    2009-07-13 11:16:41.000000000 +0200
--- pgsql.sqlda/src/interfaces/ecpg/ecpglib/Makefile    2009-09-03 12:56:36.000000000 +0200
*************** override CFLAGS += $(PTHREAD_CFLAGS)
*** 24,30 ****
  # Need to recompile any libpgport object files
  LIBS := $(filter-out -lpgport, $(LIBS))

! OBJS= execute.o typename.o descriptor.o data.o error.o prepare.o memory.o \
      connect.o misc.o path.o pgstrcasecmp.o \
      $(filter snprintf.o strlcpy.o, $(LIBOBJS))

--- 24,30 ----
  # Need to recompile any libpgport object files
  LIBS := $(filter-out -lpgport, $(LIBS))

! OBJS= execute.o typename.o descriptor.o sqlda.o data.o error.o prepare.o memory.o \
      connect.o misc.o path.o pgstrcasecmp.o \
      $(filter snprintf.o strlcpy.o, $(LIBOBJS))

diff -dcrpN pgsql.dyncursor/src/interfaces/ecpg/ecpglib/sqlda.c pgsql.sqlda/src/interfaces/ecpg/ecpglib/sqlda.c
*** pgsql.dyncursor/src/interfaces/ecpg/ecpglib/sqlda.c    1970-01-01 01:00:00.000000000 +0100
--- pgsql.sqlda/src/interfaces/ecpg/ecpglib/sqlda.c    2009-09-15 12:02:47.000000000 +0200
***************
*** 0 ****
--- 1,276 ----
+ /*
+  * Crude SQLDA support routines
+  * Only supports fetching 1 record at a time
+  *
+  * The allocated memory area pointed by an sqlda pointer
+  * contains both the metadata and the data, so freeing up
+  * is a simple free(sqlda) as expected by the ESQL/C examples.
+  */
+
+ #define POSTGRES_ECPG_INTERNAL
+ #include "postgres_fe.h"
+ #include "pg_type.h"
+
+ #include <inttypes.h>
+ #include <dlfcn.h>
+
+ #include "ecpg-pthread-win32.h"
+ #include "decimal.h"
+ #include "ecpgtype.h"
+ #include "ecpglib.h"
+ #include "ecpgerrno.h"
+ #include "extern.h"
+ #include "sqlca.h"
+ #include "sqlda.h"
+ #include "sqltypes.h"
+
+ /*
+  * Compute the next variable's offset with
+  * the current variable's size and alignment.
+  */
+ static long
+ ecpg_sqlda_size_round_align(long offset, int alignment, int size)
+ {
+     if (offset % alignment)
+         offset += alignment - (offset % alignment);
+     offset += size;
+     return offset;
+ }
+
+ /*
+  * Compute the current variable's offset with alignment.
+  */
+ static long
+ ecpg_sqlda_size_align(long offset, int alignment)
+ {
+     if (offset % alignment)
+         offset += alignment - (offset % alignment);
+     return offset;
+ }
+
+ static long
+ ecpg_sqlda_empty_size(const PGresult *res)
+ {
+     long    size;
+     int    i;
+     int    sqld = PQnfields(res);
+
+     /* Initial size to store main structure and field structures */
+     size = sizeof(pg_sqlda_t) + sqld * sizeof(pg_sqlvar_t);
+
+     /* Add space for field names */
+     for (i = 0; i < sqld; i++)
+         size += strlen(PQfname(res, i)) + 1;
+
+     /* Add padding to the first field value */
+     size = ecpg_sqlda_size_align(size, sizeof(int));
+
+     return size;
+ }
+
+ static long
+ ecpg_sqlda_total_size(const PGresult *res, int row)
+ {
+     int    i;
+     int    sqld = PQnfields(res);
+     long    size;
+
+     size = ecpg_sqlda_empty_size(res);
+
+     if (row < 0)
+         return size;
+
+     /* Add space for the field values */
+     for (i = 0; i < sqld; i++)
+     {
+         switch (ecpg_to_sqlda_type(PQftype(res, i)))
+         {
+             case SQLSMINT:
+                 size = ecpg_sqlda_size_round_align(size, sizeof(short), sizeof(short));
+                 break;
+             case SQLINT:
+             case SQLSERIAL:
+                 size = ecpg_sqlda_size_round_align(size, sizeof(int), sizeof(int));
+                 break;
+             case SQLFLOAT:
+                 size = ecpg_sqlda_size_round_align(size, sizeof(double), sizeof(double));
+                 break;
+             case SQLSMFLOAT:
+                 size = ecpg_sqlda_size_round_align(size, sizeof(float), sizeof(float));
+                 break;
+             case SQLDECIMAL:
+                 size = ecpg_sqlda_size_round_align(size, sizeof(int), sizeof(decimal));
+                 break;
+             case SQLINT8:
+             case SQLSERIAL8:
+                 size = ecpg_sqlda_size_round_align(size, sizeof(int64_t), sizeof(int64_t));
+                 break;
+
+             /*
+              * These types will be passed as character strings
+              * copied as is from the PGresult until we know
+              * what to do with them.
+              */
+             case SQLCHAR:
+             case SQLTEXT:
+             case SQLVCHAR:
+             case SQLNCHAR:
+             case SQLNVCHAR:
+             case SQLMONEY:
+             case SQLDATE:
+             case SQLDTIME:
+             case SQLINTERVAL:
+             default:
+                 size += strlen(PQgetvalue(res, row, i)) + 1;
+                 break;
+         }
+     }
+     return size;
+ }
+
+ /*
+  * Build pg_sqlda_t (metadata only) from PGresult
+  * leaving enough space for the field values in
+  * the given row number
+  */
+ pg_sqlda_t *
+ ecpg_build_sqlda_for_PGresult(int line, PGresult *res, int row)
+ {
+     pg_sqlda_t *sqlda;
+     pg_sqlvar_t*sqlvar;
+     char       *fname;
+     long        size;
+     int        sqld;
+     int        i;
+
+     size = ecpg_sqlda_total_size(res, row);
+     sqlda = (pg_sqlda_t *)ecpg_alloc(size, line);
+     if (!sqlda)
+         return NULL;
+
+     memset(sqlda, 0, size);
+     sqlvar = (pg_sqlvar_t *)(sqlda + 1);
+     sqld = PQnfields(res);
+     fname = (char *)(sqlvar + sqld);
+
+     sqlda->sqld = sqld;
+     sqlda->desc_occ = size; /* cheat here, keep the full allocated size */
+     sqlda->sqlvar = sqlvar;
+
+     for (i = 0; i < sqlda->sqld; i++)
+     {
+         sqlda->sqlvar[i].sqltype = ecpg_to_sqlda_type(PQftype(res, i));
+         strcpy(fname, PQfname(res, i));
+         sqlda->sqlvar[i].sqlname = fname;
+         fname += strlen(sqlda->sqlvar[i].sqlname) + 1;
+         sqlda->sqlvar[i].sqlformat = (char *)(long)PQfformat(res, i);
+         sqlda->sqlvar[i].sqlxid = PQftype(res, i);
+         sqlda->sqlvar[i].sqltypelen = PQfsize(res, i);
+     }
+
+     return sqlda;
+ }
+
+ /*
+  * Sets values from PGresult.
+  */
+ void
+ ecpg_set_sqlda_from_PGresult(int lineno, pg_sqlda_t **_sqlda, const PGresult *res, int row)
+ {
+     pg_sqlda_t *sqlda = (*_sqlda);
+     int        i;
+     long        size;
+     static    int2    value_is_null = -1;
+     static    int2    value_is_not_null = 0;
+
+     /* Offset for the first field value */
+     size = ecpg_sqlda_empty_size(res);
+
+     /*
+      * Set sqlvar[i]->sqldata pointers and convert values to correct format
+      */
+     for (i = 0; i < sqlda->sqld; i++)
+     {
+         int type = -1, isnull;
+         int use_getdata = true;
+
+         switch (sqlda->sqlvar[i].sqltype)
+         {
+             case SQLSMINT:
+                 size = ecpg_sqlda_size_align(size, sizeof(short));
+                 sqlda->sqlvar[i].sqldata = (char *)sqlda + size;
+                 size += sizeof(short);
+                 type = ECPGt_short;
+                 break;
+             case SQLINT:
+             case SQLSERIAL:
+                 size = ecpg_sqlda_size_align(size, sizeof(int));
+                 sqlda->sqlvar[i].sqldata = (char *)sqlda + size;
+                 size += sizeof(int);
+                 type = ECPGt_int;
+                 break;
+             case SQLFLOAT:
+                 size = ecpg_sqlda_size_align(size, sizeof(double));
+                 sqlda->sqlvar[i].sqldata = (char *)sqlda + size;
+                 size += sizeof(double);
+                 type = ECPGt_double;
+                 break;
+             case SQLSMFLOAT:
+                 size = ecpg_sqlda_size_align(size, sizeof(float));
+                 sqlda->sqlvar[i].sqldata = (char *)sqlda + size;
+                 size += sizeof(float);
+                 type = ECPGt_float;
+                 break;
+             case SQLDECIMAL:
+             {
+                 size = ecpg_sqlda_size_align(size, sizeof(int));
+                 sqlda->sqlvar[i].sqldata = (char *)sqlda + size;
+                 size += sizeof(decimal);
+                 type = ECPGt_decimal;
+                 break;
+             }
+             case SQLINT8:
+             case SQLSERIAL8:
+                 size = ecpg_sqlda_size_align(size, sizeof(int64_t));
+                 sqlda->sqlvar[i].sqldata = (char *)sqlda + size;
+                 size += sizeof(int64_t);
+                 type = ECPGt_long_long;
+                 break;
+
+             /*
+              * These types will be passed as character strings until
+              * it's known what to do with them. We use sqlvar->sqldata
+              * in all cases regardless of length, don't care about
+              * sqlvar->sqlilongdata.
+              */
+             case SQLCHAR:
+             case SQLTEXT:
+             case SQLVCHAR:
+             case SQLNCHAR:
+             case SQLNVCHAR:
+             case SQLMONEY:
+             case SQLDATE:
+             case SQLDTIME:
+             case SQLINTERVAL:
+             default:
+                 sqlda->sqlvar[i].sqldata = (char *)sqlda + size;
+                 size += strlen(PQgetvalue(res, row, i)) + 1;
+                 use_getdata = false;
+                 break;
+         }
+
+         isnull = PQgetisnull(res, 0, i);
+         sqlda->sqlvar[i].sqlind = isnull ? &value_is_null : &value_is_not_null;
+         if (!isnull)
+         {
+             if (use_getdata)
+                 ecpg_get_data(res, row, i, lineno,
+                         type, ECPGt_NO_INDICATOR,
+                         sqlda->sqlvar[i].sqldata, NULL, 0, 0, 0,
+                         ECPG_ARRAY_NONE, ECPG_COMPAT_INFORMIX, false);
+             else
+                 strcpy(sqlda->sqlvar[i].sqldata, PQgetvalue(res, row, i));
+         }
+     }
+ }
+
diff -dcrpN pgsql.dyncursor/src/interfaces/ecpg/ecpglib/typename.c pgsql.sqlda/src/interfaces/ecpg/ecpglib/typename.c
*** pgsql.dyncursor/src/interfaces/ecpg/ecpglib/typename.c    2009-08-07 13:06:28.000000000 +0200
--- pgsql.sqlda/src/interfaces/ecpg/ecpglib/typename.c    2009-09-03 12:56:36.000000000 +0200
***************
*** 7,12 ****
--- 7,13 ----
  #include "ecpgtype.h"
  #include "ecpglib.h"
  #include "extern.h"
+ #include "sqltypes.h"
  #include "sql3types.h"
  #include "pg_type.h"

*************** ecpg_dynamic_type(Oid type)
*** 100,102 ****
--- 101,190 ----
              return -(int) type;
      }
  }
+
+ int
+ ecpg_sqlda_type(int type)
+ {
+     switch (type)
+     {
+         case SQLCHAR:
+         case SQLNCHAR:
+             return ECPGt_char;
+         case SQLSMINT:
+             return ECPGt_short;
+         case SQLINT:
+             return ECPGt_int;
+         case SQLFLOAT:
+             return ECPGt_double;
+         case SQLSMFLOAT:
+             return ECPGt_float;
+         case SQLDECIMAL:
+             return ECPGt_decimal;
+         case SQLSERIAL:
+             return ECPGt_int;
+         case SQLDATE:
+             return ECPGt_date;
+ #if 0
+         case SQLMONEY:
+             return ???;
+         case SQLNULL:
+             return ???;
+ #endif
+         case SQLDTIME:
+             return ECPGt_timestamp;
+ #if 0
+         case SQLBYTES:
+             return ???;
+ #endif
+         case SQLTEXT:
+             return ECPGt_char;
+         case SQLVCHAR:
+         case SQLNVCHAR:
+             return ECPGt_varchar;
+         case SQLINTERVAL:
+             return ECPGt_interval;
+         case SQLINT8:
+         case SQLSERIAL8:
+             return ECPGt_long_long;
+         default:
+             return (-type);
+     }
+ }
+
+ int
+ ecpg_to_sqlda_type(Oid type)
+ {
+     switch (type)
+     {
+         case CHAROID:
+         case BPCHAROID:
+             return SQLCHAR;
+         case INT2OID:
+             return SQLSMINT;
+         case INT4OID:
+             return SQLINT;
+         case FLOAT8OID:
+             return SQLFLOAT;
+         case FLOAT4OID:
+             return SQLSMFLOAT;
+         case NUMERICOID:
+             return SQLDECIMAL;
+         case DATEOID:
+             return SQLDATE;
+         case CASHOID:
+             return SQLMONEY;
+         case TIMESTAMPOID:
+         case TIMESTAMPTZOID:
+             return SQLDTIME;
+         case TEXTOID:
+             return SQLTEXT;
+         case VARCHAROID:
+             return SQLVCHAR;
+         case INTERVALOID:
+             return SQLINTERVAL;
+         case INT8OID:
+             return SQLINT8;
+         default:
+             return (-type);
+     }
+ }
diff -dcrpN pgsql.dyncursor/src/interfaces/ecpg/include/ecpgtype.h pgsql.sqlda/src/interfaces/ecpg/include/ecpgtype.h
*** pgsql.dyncursor/src/interfaces/ecpg/include/ecpgtype.h    2009-08-07 13:06:28.000000000 +0200
--- pgsql.sqlda/src/interfaces/ecpg/include/ecpgtype.h    2009-09-03 12:56:36.000000000 +0200
*************** enum ECPGttype
*** 62,68 ****
      ECPGt_EOIT,                    /* End of insert types. */
      ECPGt_EORT,                    /* End of result types. */
      ECPGt_NO_INDICATOR,            /* no indicator */
!     ECPGt_string                            /* trimmed (char *) type */
  };

   /* descriptor items */
--- 62,69 ----
      ECPGt_EOIT,                    /* End of insert types. */
      ECPGt_EORT,                    /* End of result types. */
      ECPGt_NO_INDICATOR,            /* no indicator */
!     ECPGt_string,                /* trimmed (char *) type */
!     ECPGt_sqlda                /* C struct descriptor */
  };

   /* descriptor items */
diff -dcrpN pgsql.dyncursor/src/interfaces/ecpg/include/sqlda.h pgsql.sqlda/src/interfaces/ecpg/include/sqlda.h
*** pgsql.dyncursor/src/interfaces/ecpg/include/sqlda.h    2009-06-13 18:25:05.000000000 +0200
--- pgsql.sqlda/src/interfaces/ecpg/include/sqlda.h    2009-09-03 12:56:36.000000000 +0200
***************
*** 1,3 ****
--- 1,74 ----
  /*
   * $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqlda.h,v 1.4 2009/06/11 14:49:13 momjian Exp $
   */
+
+ #ifndef POSTGRES_SQLDA_H
+ #define POSTGRES_SQLDA_H
+
+ /* Define Informix "standard" types */
+ #ifndef C_H
+ typedef int        int4;
+ typedef    short        int2;
+ #endif
+ typedef    char        int1;
+
+ typedef    int        mint;
+ typedef    long        mlong;
+
+ typedef    short        MSHORT;
+ typedef    char        MCHAR;
+
+ typedef    unsigned int    uint4;
+ typedef    unsigned short    uint2;
+ typedef    unsigned char    uint1;
+
+ typedef    unsigned int    muint;
+ typedef    unsigned long    mulong;
+
+ typedef    unsigned short    MUSHORT;
+ typedef    unsigned char    MUCHAR;
+
+ #define MI_INT_SIZE     (sizeof(int)    * 8)
+ #define MI_LONG_SIZE    (sizeof(long)   * 8)
+ #define MI_PTR_SIZE     (sizeof(char *) * 8)
+
+ typedef struct sqlvar_struct
+ {
+     int2    sqltype;        /* variable type                */
+     int4    sqllen;            /* length in bytes              */
+     char       *sqldata;        /* pointer to data              */
+     int2       *sqlind;        /* pointer to indicator         */
+     char       *sqlname;        /* variable name                */
+     char       *sqlformat;        /* reserved for future use      */
+     int2    sqlitype;        /* ind variable type            */
+     int2    sqlilen;        /* ind length in bytes          */
+     char       *sqlidata;        /* ind data pointer             */
+     int4    sqlxid;            /* extended id type             */
+     char       *sqltypename;    /* extended type name           */
+     int2    sqltypelen;        /* length of extended type name */
+     int2    sqlownerlen;        /* length of owner name         */
+     int2    sqlsourcetype;        /* source type for distinct of built-ins */
+     char       *sqlownername;    /* owner name                   */
+     int4    sqlsourceid;        /* extended id of source type   */
+
+     /*
+      * sqlilongdata is new.  It supports data that exceeds the 32k
+      * limit.  sqlilen and sqlidata are for backward compatibility
+      * and they have maximum value of <32K.
+      */
+     char       *sqlilongdata;    /* for data field beyond 32K    */
+     int4    sqlflags;        /* for internal use only        */
+     void       *sqlreserved;    /* reserved for future use      */
+ } pg_sqlvar_t;
+
+ typedef struct sqlda
+ {
+     int2        sqld;
+     pg_sqlvar_t       *sqlvar;
+     char        desc_name[19];    /* descriptor name              */
+     int2        desc_occ;    /* size of sqlda structure      */
+     struct sqlda       *desc_next;    /* pointer to next sqlda struct */
+     void           *reserved;    /* reserved for future use */
+ } pg_sqlda_t;
+
+ #endif /* POSTGRES_SQLDA_H */
diff -dcrpN pgsql.dyncursor/src/interfaces/ecpg/include/sqltypes.h pgsql.sqlda/src/interfaces/ecpg/include/sqltypes.h
*** pgsql.dyncursor/src/interfaces/ecpg/include/sqltypes.h    2009-06-13 18:25:05.000000000 +0200
--- pgsql.sqlda/src/interfaces/ecpg/include/sqltypes.h    2009-09-03 12:56:36.000000000 +0200
***************
*** 30,33 ****
--- 30,55 ----
  #define CLVCHARPTRTYPE    124
  #define CTYPEMAX    25

+ /*
+  * Values used in sqlda->sqlvar[i]->sqltype
+  */
+ #define    SQLCHAR        0
+ #define    SQLSMINT    1
+ #define    SQLINT        2
+ #define    SQLFLOAT    3
+ #define    SQLSMFLOAT    4
+ #define    SQLDECIMAL    5
+ #define    SQLSERIAL    6
+ #define    SQLDATE        7
+ #define    SQLMONEY    8
+ #define    SQLDTIME    10
+ #define    SQLBYTES    11
+ #define    SQLTEXT        12
+ #define    SQLVCHAR    13
+ #define    SQLINTERVAL    14
+ #define    SQLNCHAR    15
+ #define    SQLNVCHAR    16
+ #define    SQLINT8        17
+ #define    SQLSERIAL8    18
+
  #endif   /* ndef ECPG_SQLTYPES_H */
diff -dcrpN pgsql.dyncursor/src/interfaces/ecpg/preproc/descriptor.c
pgsql.sqlda/src/interfaces/ecpg/preproc/descriptor.c
*** pgsql.dyncursor/src/interfaces/ecpg/preproc/descriptor.c    2009-01-30 17:28:46.000000000 +0100
--- pgsql.sqlda/src/interfaces/ecpg/preproc/descriptor.c    2009-09-03 12:56:36.000000000 +0200
*************** descriptor_variable(const char *name, in
*** 326,328 ****
--- 326,347 ----
      strlcpy(descriptor_names[input], name, sizeof(descriptor_names[input]));
      return (struct variable *) & varspace[input];
  }
+
+ struct variable *
+ sqlda_variable(const char *name)
+ {
+     struct variable *p = (struct variable *) mm_alloc(sizeof(struct variable));
+
+     p->name = mm_strdup(name);
+     p->type = (struct ECPGtype *) mm_alloc(sizeof(struct ECPGtype));
+     p->type->type = ECPGt_sqlda;
+     p->type->size = NULL;
+     p->type->struct_sizeof = NULL;
+     p->type->u.element = NULL;
+     p->type->lineno = 0;
+     p->brace_level = 0;
+     p->next = NULL;
+
+     return p;
+ }
+
diff -dcrpN pgsql.dyncursor/src/interfaces/ecpg/preproc/ecpg.addons pgsql.sqlda/src/interfaces/ecpg/preproc/ecpg.addons
*** pgsql.dyncursor/src/interfaces/ecpg/preproc/ecpg.addons    2009-09-03 12:31:30.000000000 +0200
--- pgsql.sqlda/src/interfaces/ecpg/preproc/ecpg.addons    2009-09-03 12:58:29.000000000 +0200
*************** ECPG: VariableShowStmtSHOWALL block
*** 407,426 ****
          $$ = EMPTY;
      }
  ECPG: FetchStmtMOVEfetch_args rule
!     | FETCH fetch_args ecpg_into
      {
          add_additional_variables(current_cursor, false);
          free(current_cursor);
          current_cursor = NULL;
          $$ = cat2_str(make_str("fetch"), $2);
      }
!     | FETCH FORWARD cursor_name opt_ecpg_into
      {
          char *cursor_marker = $3[0] == ':' ? make_str("$0") : $3;
          add_additional_variables($3, false);
          $$ = cat_str(2, make_str("fetch forward"), cursor_marker);
      }
!     | FETCH FORWARD from_in cursor_name opt_ecpg_into
      {
          char *cursor_marker = $4[0] == ':' ? make_str("$0") : $4;
          add_additional_variables($4, false);
--- 407,426 ----
          $$ = EMPTY;
      }
  ECPG: FetchStmtMOVEfetch_args rule
!     | FETCH fetch_args ecpg_fetch_into
      {
          add_additional_variables(current_cursor, false);
          free(current_cursor);
          current_cursor = NULL;
          $$ = cat2_str(make_str("fetch"), $2);
      }
!     | FETCH FORWARD cursor_name opt_ecpg_fetch_into
      {
          char *cursor_marker = $3[0] == ':' ? make_str("$0") : $3;
          add_additional_variables($3, false);
          $$ = cat_str(2, make_str("fetch forward"), cursor_marker);
      }
!     | FETCH FORWARD from_in cursor_name opt_ecpg_fetch_into
      {
          char *cursor_marker = $4[0] == ':' ? make_str("$0") : $4;
          add_additional_variables($4, false);
diff -dcrpN pgsql.dyncursor/src/interfaces/ecpg/preproc/ecpg.trailer
pgsql.sqlda/src/interfaces/ecpg/preproc/ecpg.trailer
*** pgsql.dyncursor/src/interfaces/ecpg/preproc/ecpg.trailer    2009-09-03 12:28:03.000000000 +0200
--- pgsql.sqlda/src/interfaces/ecpg/preproc/ecpg.trailer    2009-09-03 12:56:36.000000000 +0200
*************** ecpg_using:    USING using_list     { $$ = EMP
*** 1017,1035 ****

  using_descriptor: USING opt_sql SQL_DESCRIPTOR quoted_ident_stringvar
          {
!             add_variable_to_head(&argsinsert, descriptor_variable($4,0), &no_indicator);
              $$ = EMPTY;
          }
          ;

  into_descriptor: INTO opt_sql SQL_DESCRIPTOR quoted_ident_stringvar
          {
!             add_variable_to_head(&argsresult, descriptor_variable($4,1), &no_indicator);
              $$ = EMPTY;
          }
          ;

! opt_sql: /*EMPTY*/ | SQL_SQL;

  using_list: UsingValue | UsingValue ',' using_list;

--- 1017,1065 ----

  using_descriptor: USING opt_sql SQL_DESCRIPTOR quoted_ident_stringvar
          {
!             if (strlen($2) || !(INFORMIX_MODE))
!                 add_variable_to_head(&argsinsert, descriptor_variable($4,0), &no_indicator);
!             else
!             {
!                 if ($4[0] == '\"')
!                 {
!                     char *pos;
!
!                     $4[0] = ' ';
!                     for (pos = $4; *pos; pos++)
!                         if (*pos == '\"')
!                             *pos = ' ';
!                 }
!                 add_variable_to_head(&argsinsert, sqlda_variable($4), &no_indicator);
!             }
              $$ = EMPTY;
          }
          ;

  into_descriptor: INTO opt_sql SQL_DESCRIPTOR quoted_ident_stringvar
          {
!             if (strlen($2) || !(INFORMIX_MODE))
!                 add_variable_to_head(&argsresult, descriptor_variable($4,1), &no_indicator);
!             else
!             {
!                 if ($4[0] == '\"')
!                 {
!                     char *pos;
!
!                     $4[0] = ' ';
!                     for (pos = $4; *pos; pos++)
!                         if (*pos == '\"')
!                             *pos = ' ';
!                 }
!                 add_variable_to_head(&argsresult, sqlda_variable($4), &no_indicator);
!             }
              $$ = EMPTY;
          }
          ;

! opt_sql: /*EMPTY*/        { $$ = EMPTY; }
!         | SQL_SQL    { $$ = make_str("sql"); }
!         ;

  using_list: UsingValue | UsingValue ',' using_list;

*************** ecpg_into: INTO into_list    { $$ = EMPTY;
*** 2053,2060 ****
      ;


! opt_ecpg_into:    /* EMPTY */    { $$ = EMPTY; }
!     | ecpg_into        { $$ = $1; }

  %%

--- 2083,2106 ----
      ;


! ecpg_fetch_into: ecpg_into    { $$ = $1; }
!     | using_descriptor
!     {
!         struct variable *var;
!
!         if (!INFORMIX_MODE)
!             mmerror(PARSE_ERROR, ET_ERROR, "Not in Informix compatibility mode");
!
!         var = argsinsert->variable;
!         remove_variable_from_list(&argsinsert, var);
!         add_variable_to_head(&argsresult, var, &no_indicator);
!         $$ = $1;
!     }
!     ;
!
! opt_ecpg_fetch_into: /* EMPTY */    { $$ = EMPTY; }
!     | ecpg_fetch_into        { $$ = $1; }
!     ;

  %%

diff -dcrpN pgsql.dyncursor/src/interfaces/ecpg/preproc/ecpg.type pgsql.sqlda/src/interfaces/ecpg/preproc/ecpg.type
*** pgsql.dyncursor/src/interfaces/ecpg/preproc/ecpg.type    2009-09-03 12:28:03.000000000 +0200
--- pgsql.sqlda/src/interfaces/ecpg/preproc/ecpg.type    2009-09-03 12:56:36.000000000 +0200
***************
*** 62,67 ****
--- 62,68 ----
  %type <str> ecpg_ident
  %type <str> ecpg_interval
  %type <str> ecpg_into
+ %type <str> ecpg_fetch_into
  %type <str> ecpg_param
  %type <str> ecpg_sconst
  %type <str> ecpg_using
***************
*** 77,83 ****
  %type <str> opt_bit_field
  %type <str> opt_connection_name
  %type <str> opt_database_name
! %type <str> opt_ecpg_into
  %type <str> opt_ecpg_using
  %type <str> opt_initializer
  %type <str> opt_options
--- 78,84 ----
  %type <str> opt_bit_field
  %type <str> opt_connection_name
  %type <str> opt_database_name
! %type <str> opt_ecpg_fetch_into
  %type <str> opt_ecpg_using
  %type <str> opt_initializer
  %type <str> opt_options
***************
*** 87,92 ****
--- 88,94 ----
  %type <str> opt_reference
  %type <str> opt_scale
  %type <str> opt_server
+ %type <str> opt_sql
  %type <str> opt_user
  %type <str> opt_opt_value
  %type <str> ora_user
diff -dcrpN pgsql.dyncursor/src/interfaces/ecpg/preproc/extern.h pgsql.sqlda/src/interfaces/ecpg/preproc/extern.h
*** pgsql.dyncursor/src/interfaces/ecpg/preproc/extern.h    2009-09-03 12:28:03.000000000 +0200
--- pgsql.sqlda/src/interfaces/ecpg/preproc/extern.h    2009-09-03 12:56:36.000000000 +0200
*************** extern void add_descriptor(char *, char
*** 90,95 ****
--- 90,96 ----
  extern void drop_descriptor(char *, char *);
  extern struct descriptor *lookup_descriptor(char *, char *);
  extern struct variable *descriptor_variable(const char *name, int input);
+ extern struct variable *sqlda_variable(const char *name);
  extern void add_variable_to_head(struct arguments **, struct variable *, struct variable *);
  extern void add_variable_to_tail(struct arguments **, struct variable *, struct variable *);
  extern void remove_variable_from_list(struct arguments ** list, struct variable * var);
diff -dcrpN pgsql.dyncursor/src/interfaces/ecpg/preproc/type.c pgsql.sqlda/src/interfaces/ecpg/preproc/type.c
*** pgsql.dyncursor/src/interfaces/ecpg/preproc/type.c    2009-09-03 12:25:47.000000000 +0200
--- pgsql.sqlda/src/interfaces/ecpg/preproc/type.c    2009-09-03 12:56:36.000000000 +0200
*************** get_type(enum ECPGttype type)
*** 194,199 ****
--- 194,202 ----
          case ECPGt_descriptor:
              return ("ECPGt_descriptor");
              break;
+         case ECPGt_sqlda:
+             return ("ECPGt_sqlda");
+             break;
          case ECPGt_date:
              return ("ECPGt_date");
              break;
*************** ECPGdump_a_simple(FILE *o, const char *n
*** 328,333 ****
--- 331,338 ----
      else if (type == ECPGt_descriptor)
          /* remember that name here already contains quotes (if needed) */
          fprintf(o, "\n\tECPGt_descriptor, %s, 0L, 0L, 0L, ", name);
+     else if (type == ECPGt_sqlda)
+         fprintf(o, "\n\tECPGt_sqlda, &%s, 0L, 0L, 0L, ", name);
      else
      {
          char       *variable = (char *) mm_alloc(strlen(name) + ((prefix == NULL) ? 0 : strlen(prefix)) + 4);
diff -dcrpN pgsql.dyncursor/src/interfaces/ecpg/test/compat_informix/Makefile
pgsql.sqlda/src/interfaces/ecpg/test/compat_informix/Makefile
*** pgsql.dyncursor/src/interfaces/ecpg/test/compat_informix/Makefile    2009-09-03 12:28:03.000000000 +0200
--- pgsql.sqlda/src/interfaces/ecpg/test/compat_informix/Makefile    2009-09-03 12:56:36.000000000 +0200
*************** TESTS = test_informix test_informix.c \
*** 17,22 ****
--- 17,23 ----
          rfmtdate rfmtdate.c \
          rfmtlong rfmtlong.c \
          rnull rnull.c \
+         sqlda sqlda.c \
          charfuncs charfuncs.c

  all: $(TESTS)
*************** test_informix2.c: test_informix2.pgc ../
*** 30,35 ****
--- 31,39 ----
  cursor.c: cursor.pgc ../regression.h
      $(ECPG) -o $@ -I$(srcdir) $<

+ sqlda.c: sqlda.pgc ../regression.h
+     $(ECPG) -o $@ -I$(srcdir) $<
+
  dec_test.c: dec_test.pgc ../regression.h
      $(ECPG) -o $@ -I$(srcdir) $<

diff -dcrpN pgsql.dyncursor/src/interfaces/ecpg/test/compat_informix/sqlda.pgc
pgsql.sqlda/src/interfaces/ecpg/test/compat_informix/sqlda.pgc
*** pgsql.dyncursor/src/interfaces/ecpg/test/compat_informix/sqlda.pgc    1970-01-01 01:00:00.000000000 +0100
--- pgsql.sqlda/src/interfaces/ecpg/test/compat_informix/sqlda.pgc    2009-09-04 10:43:48.000000000 +0200
***************
*** 0 ****
--- 1,252 ----
+ #include <stdlib.h>
+ #include <string.h>
+ #include <inttypes.h>
+
+ exec sql include ../regression;
+
+ exec sql include sqlda.h;
+ exec sql include sqltypes.h;
+
+ exec sql whenever sqlerror stop;
+
+ /* These shouldn't be under DECLARE SECTION */
+ pg_sqlda_t    *inp_sqlda, *outp_sqlda;
+
+ static void
+ dump_sqlda(pg_sqlda_t *sqlda)
+ {
+     int    i;
+
+     for (i = 0; i < sqlda->sqld; i++)
+     {
+         if (outp_sqlda->sqlvar[i].sqlind && *(outp_sqlda->sqlvar[i].sqlind) == -1)
+             printf("name sqlda descriptor: '%s' value NULL'\n", outp_sqlda->sqlvar[i].sqlname);
+         else
+         switch (sqlda->sqlvar[i].sqltype)
+         {
+         case SQLCHAR:
+         case SQLVCHAR:
+         case SQLTEXT:
+             printf("name sqlda descriptor: '%s' value '%s'\n", sqlda->sqlvar[i].sqlname, sqlda->sqlvar[i].sqldata);
+             break;
+         case SQLSERIAL:
+         case SQLINT:
+             printf("name sqlda descriptor: '%s' value %d\n", sqlda->sqlvar[i].sqlname, *(int
*)sqlda->sqlvar[i].sqldata);
+             break;
+         case SQLSERIAL8:
+         case SQLINT8:
+             printf("name sqlda descriptor: '%s' value %" PRId64 "\n", sqlda->sqlvar[i].sqlname, *(int64_t
*)sqlda->sqlvar[i].sqldata);
+             break;
+         case SQLFLOAT:
+             printf("name sqlda descriptor: '%s' value %lf\n", sqlda->sqlvar[i].sqlname, *(double
*)sqlda->sqlvar[i].sqldata);
+             break;
+         case SQLDECIMAL:
+             {
+                 char    val[64];
+                 dectoasc((dec_t *)sqlda->sqlvar[i].sqldata, val, 64, -1);
+                 printf("name sqlda descriptor: '%s' value DECIMAL '%s'\n", sqlda->sqlvar[i].sqlname, val);
+                 break;
+             }
+         }
+     }
+ }
+
+ int
+ main (void)
+ {
+ exec sql begin declare section;
+     char    *stmt1 = "SELECT * FROM t1";
+     char    *stmt2 = "SELECT * FROM t1 WHERE id = ?";
+     int    rec;
+     int    id;
+ exec sql end declare section;
+
+     char msg[128];
+
+     ECPGdebug(1, stderr);
+
+     strcpy(msg, "connect");
+     exec sql connect to REGRESSDB1 as regress1;
+
+     strcpy(msg, "set");
+     exec sql set datestyle to iso;
+
+     strcpy(msg, "create");
+     exec sql create table t1(
+         id integer,
+         t text,
+         d1 numeric,
+         d2 float8,
+         c char(10));
+
+     strcpy(msg, "insert");
+     exec sql insert into t1 values
+         (1, 'a', 1.0, 1, 'a'),
+         (2, null, null, null, null),
+         (3, '"c"', -3, 'nan'::float8, 'c'),
+         (4, 'd', 4.0, 4, 'd');
+
+     strcpy(msg, "commit");
+     exec sql commit;
+
+     /* SQLDA test for getting all records from a table */
+
+     outp_sqlda = NULL;
+
+     strcpy(msg, "prepare");
+     exec sql prepare st_id1 from :stmt1;
+
+     strcpy(msg, "declare");
+     exec sql declare mycur1 cursor for st_id1;
+
+     strcpy(msg, "open");
+     exec sql open mycur1;
+
+     exec sql whenever not found do break;
+
+     rec = 0;
+     while (1)
+     {
+         strcpy(msg, "fetch");
+         exec sql fetch 1 from mycur1 into descriptor outp_sqlda;
+
+         printf("FETCH RECORD %d\n", ++rec);
+         dump_sqlda(outp_sqlda);
+     }
+
+     exec sql whenever not found continue;
+
+     strcpy(msg, "close");
+     exec sql close mycur1;
+
+     strcpy(msg, "deallocate");
+     exec sql deallocate prepare st_id1;
+
+     free(outp_sqlda);
+
+     /* SQLDA test for getting all records from a table
+        using the Informix-specific FETCH ... USING DESCRIPTOR
+      */
+
+     outp_sqlda = NULL;
+
+     strcpy(msg, "prepare");
+     exec sql prepare st_id2 from :stmt1;
+
+     strcpy(msg, "declare");
+     exec sql declare mycur2 cursor for st_id2;
+
+     strcpy(msg, "open");
+     exec sql open mycur2;
+
+     exec sql whenever not found do break;
+
+     rec = 0;
+     while (1)
+     {
+         strcpy(msg, "fetch");
+         exec sql fetch from mycur2 using descriptor outp_sqlda;
+
+         printf("FETCH RECORD %d\n", ++rec);
+         dump_sqlda(outp_sqlda);
+     }
+
+     exec sql whenever not found continue;
+
+     strcpy(msg, "close");
+     exec sql close mycur2;
+
+     strcpy(msg, "deallocate");
+     exec sql deallocate prepare st_id2;
+
+     free(outp_sqlda);
+
+     /* SQLDA test for getting one record using an input descriptor */
+
+     /* Input sqlda has to be built manually */
+     inp_sqlda = (pg_sqlda_t *)malloc(sizeof(pg_sqlda_t));
+     memset(inp_sqlda, 0, sizeof(pg_sqlda_t));
+     inp_sqlda->sqld = 1;
+     inp_sqlda->sqlvar = malloc(sizeof(pg_sqlvar_t));
+     memset(inp_sqlda->sqlvar, 0, sizeof(pg_sqlvar_t));
+
+     inp_sqlda->sqlvar[0].sqltype = SQLINT;
+     inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+
+     printf("EXECUTE RECORD 4\n");
+
+     id = 4;
+
+     outp_sqlda = NULL;
+
+     strcpy(msg, "prepare");
+     exec sql prepare st_id3 FROM :stmt2;
+
+     strcpy(msg, "execute");
+     exec sql execute st_id3 using descriptor inp_sqlda into descriptor outp_sqlda;
+
+     dump_sqlda(outp_sqlda);
+
+     strcpy(msg, "deallocate");
+     exec sql deallocate prepare st_id3;
+
+     free(inp_sqlda->sqlvar);
+     free(inp_sqlda);
+     free(outp_sqlda);
+
+     /* SQLDA test for getting one record using an input descriptor
+      * on a named connection
+      */
+
+     exec sql connect to REGRESSDB1 as con2;
+
+     /* Input sqlda has to be built manually */
+     inp_sqlda = (pg_sqlda_t *)malloc(sizeof(pg_sqlda_t));
+     memset(inp_sqlda, 0, sizeof(pg_sqlda_t));
+     inp_sqlda->sqld = 1;
+     inp_sqlda->sqlvar = malloc(sizeof(pg_sqlvar_t));
+     memset(inp_sqlda->sqlvar, 0, sizeof(pg_sqlvar_t));
+
+     inp_sqlda->sqlvar[0].sqltype = SQLINT;
+     inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+
+     printf("EXECUTE RECORD 4\n");
+
+     id = 4;
+
+     outp_sqlda = NULL;
+
+     strcpy(msg, "prepare");
+     exec sql at con2 prepare st_id4 FROM :stmt2;
+
+     strcpy(msg, "execute");
+     exec sql at con2 execute st_id4 using descriptor inp_sqlda into descriptor outp_sqlda;
+
+     dump_sqlda(outp_sqlda);
+
+     strcpy(msg, "commit");
+     exec sql at con2 commit;
+
+     strcpy(msg, "deallocate");
+     exec sql deallocate prepare st_id4;
+
+     free(inp_sqlda->sqlvar);
+     free(inp_sqlda);
+     free(outp_sqlda);
+
+     strcpy(msg, "disconnect");
+     exec sql disconnect con2;
+
+     /* End test */
+
+     strcpy(msg, "drop");
+     exec sql drop table t1;
+
+     strcpy(msg, "commit");
+     exec sql commit;
+
+     strcpy(msg, "disconnect");
+     exec sql disconnect;
+
+     return (0);
+ }
diff -dcrpN pgsql.dyncursor/src/interfaces/ecpg/test/ecpg_schedule pgsql.sqlda/src/interfaces/ecpg/test/ecpg_schedule
*** pgsql.dyncursor/src/interfaces/ecpg/test/ecpg_schedule    2009-09-03 12:28:03.000000000 +0200
--- pgsql.sqlda/src/interfaces/ecpg/test/ecpg_schedule    2009-09-03 12:56:36.000000000 +0200
*************** test: compat_informix/rfmtdate
*** 4,9 ****
--- 4,10 ----
  test: compat_informix/rfmtlong
  test: compat_informix/rnull
  test: compat_informix/cursor
+ test: compat_informix/sqlda
  test: compat_informix/test_informix
  test: compat_informix/test_informix2
  test: connect/test2
diff -dcrpN pgsql.dyncursor/src/interfaces/ecpg/test/ecpg_schedule_tcp
pgsql.sqlda/src/interfaces/ecpg/test/ecpg_schedule_tcp
*** pgsql.dyncursor/src/interfaces/ecpg/test/ecpg_schedule_tcp    2009-09-03 12:28:03.000000000 +0200
--- pgsql.sqlda/src/interfaces/ecpg/test/ecpg_schedule_tcp    2009-09-03 12:56:36.000000000 +0200
*************** test: compat_informix/rfmtdate
*** 4,9 ****
--- 4,10 ----
  test: compat_informix/rfmtlong
  test: compat_informix/rnull
  test: compat_informix/cursor
+ test: compat_informix/sqlda
  test: compat_informix/test_informix
  test: compat_informix/test_informix2
  test: connect/test2
diff -dcrpN pgsql.dyncursor/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c
pgsql.sqlda/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c
*** pgsql.dyncursor/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c    1970-01-01 01:00:00.000000000 +0100
--- pgsql.sqlda/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c    2009-09-04 11:05:28.000000000 +0200
***************
*** 0 ****
--- 1,585 ----
+ /* Processed by ecpg (regression mode) */
+ /* These include files are added by the preprocessor */
+ #include <ecpglib.h>
+ #include <ecpgerrno.h>
+ #include <sqlca.h>
+ /* Needed for informix compatibility */
+ #include <ecpg_informix.h>
+ /* End of automatic include section */
+ #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+
+ #line 1 "sqlda.pgc"
+ #include <stdlib.h>
+ #include <string.h>
+ #include <inttypes.h>
+
+
+ #line 1 "regression.h"
+
+
+
+
+
+
+ #line 5 "sqlda.pgc"
+
+
+
+ #line 1 "sqlda.h"
+ /*
+  * $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqlda.h,v 1.4 2009/06/11 14:49:13 momjian Exp $
+  */
+
+ #ifndef POSTGRES_SQLDA_H
+ #define POSTGRES_SQLDA_H
+
+ /* Define Informix "standard" types */
+ #ifndef C_H
+ typedef int        int4;
+ typedef    short        int2;
+ #endif
+ typedef    char        int1;
+
+ typedef    int        mint;
+ typedef    long        mlong;
+
+ typedef    short        MSHORT;
+ typedef    char        MCHAR;
+
+ typedef    unsigned int    uint4;
+ typedef    unsigned short    uint2;
+ typedef    unsigned char    uint1;
+
+ typedef    unsigned int    muint;
+ typedef    unsigned long    mulong;
+
+ typedef    unsigned short    MUSHORT;
+ typedef    unsigned char    MUCHAR;
+
+ #define MI_INT_SIZE     (sizeof(int)    * 8)
+ #define MI_LONG_SIZE    (sizeof(long)   * 8)
+ #define MI_PTR_SIZE     (sizeof(char *) * 8)
+
+ typedef struct sqlvar_struct
+ {
+     int2    sqltype;        /* variable type                */
+     int4    sqllen;            /* length in bytes              */
+     char       *sqldata;        /* pointer to data              */
+     int2       *sqlind;        /* pointer to indicator         */
+     char       *sqlname;        /* variable name                */
+     char       *sqlformat;        /* reserved for future use      */
+     int2    sqlitype;        /* ind variable type            */
+     int2    sqlilen;        /* ind length in bytes          */
+     char       *sqlidata;        /* ind data pointer             */
+     int4    sqlxid;            /* extended id type             */
+     char       *sqltypename;    /* extended type name           */
+     int2    sqltypelen;        /* length of extended type name */
+     int2    sqlownerlen;        /* length of owner name         */
+     int2    sqlsourcetype;        /* source type for distinct of built-ins */
+     char       *sqlownername;    /* owner name                   */
+     int4    sqlsourceid;        /* extended id of source type   */
+
+     /*
+      * sqlilongdata is new.  It supports data that exceeds the 32k
+      * limit.  sqlilen and sqlidata are for backward compatibility
+      * and they have maximum value of <32K.
+      */
+     char       *sqlilongdata;    /* for data field beyond 32K    */
+     int4    sqlflags;        /* for internal use only        */
+     void       *sqlreserved;    /* reserved for future use      */
+ } pg_sqlvar_t;
+
+ typedef struct sqlda
+ {
+     int2        sqld;
+     pg_sqlvar_t       *sqlvar;
+     char        desc_name[19];    /* descriptor name              */
+     int2        desc_occ;    /* size of sqlda structure      */
+     struct sqlda       *desc_next;    /* pointer to next sqlda struct */
+     void           *reserved;    /* reserved for future use */
+ } pg_sqlda_t;
+
+ #endif /* POSTGRES_SQLDA_H */
+
+ #line 7 "sqlda.pgc"
+
+
+ #line 1 "sqltypes.h"
+ /*
+  * $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqltypes.h,v 1.9 2009/06/11 14:49:13 momjian Exp $
+  */
+ #ifndef ECPG_SQLTYPES_H
+ #define ECPG_SQLTYPES_H
+
+ #define CCHARTYPE    ECPGt_char
+ #define CSHORTTYPE    ECPGt_short
+ #define CINTTYPE    ECPGt_int
+ #define CLONGTYPE    ECPGt_long
+ #define CFLOATTYPE    ECPGt_float
+ #define CDOUBLETYPE ECPGt_double
+ #define CDECIMALTYPE    ECPGt_decimal
+ #define CFIXCHARTYPE    108
+ #define CSTRINGTYPE ECPGt_char
+ #define CDATETYPE    ECPGt_date
+ #define CMONEYTYPE    111
+ #define CDTIMETYPE    ECPGt_timestamp
+ #define CLOCATORTYPE    113
+ #define CVCHARTYPE    ECPGt_varchar
+ #define CINVTYPE    115
+ #define CFILETYPE    116
+ #define CINT8TYPE    ECPGt_long_long
+ #define CCOLLTYPE        118
+ #define CLVCHARTYPE        119
+ #define CFIXBINTYPE        120
+ #define CVARBINTYPE        121
+ #define CBOOLTYPE        ECPGt_bool
+ #define CROWTYPE        123
+ #define CLVCHARPTRTYPE    124
+ #define CTYPEMAX    25
+
+ /*
+  * Values used in sqlda->sqlvar[i]->sqltype
+  */
+ #define    SQLCHAR        0
+ #define    SQLSMINT    1
+ #define    SQLINT        2
+ #define    SQLFLOAT    3
+ #define    SQLSMFLOAT    4
+ #define    SQLDECIMAL    5
+ #define    SQLSERIAL    6
+ #define    SQLDATE        7
+ #define    SQLMONEY    8
+ #define    SQLDTIME    10
+ #define    SQLBYTES    11
+ #define    SQLTEXT        12
+ #define    SQLVCHAR    13
+ #define    SQLINTERVAL    14
+ #define    SQLNCHAR    15
+ #define    SQLNVCHAR    16
+ #define    SQLINT8        17
+ #define    SQLSERIAL8    18
+
+ #endif   /* ndef ECPG_SQLTYPES_H */
+
+ #line 8 "sqlda.pgc"
+
+
+ /* exec sql whenever sqlerror  stop ; */
+ #line 10 "sqlda.pgc"
+
+
+ /* These shouldn't be under DECLARE SECTION */
+ pg_sqlda_t    *inp_sqlda, *outp_sqlda;
+
+ static void
+ dump_sqlda(pg_sqlda_t *sqlda)
+ {
+     int    i;
+
+     for (i = 0; i < sqlda->sqld; i++)
+     {
+         if (outp_sqlda->sqlvar[i].sqlind && *(outp_sqlda->sqlvar[i].sqlind) == -1)
+             printf("name sqlda descriptor: '%s' value NULL'\n", outp_sqlda->sqlvar[i].sqlname);
+         else
+         switch (sqlda->sqlvar[i].sqltype)
+         {
+         case SQLCHAR:
+         case SQLVCHAR:
+         case SQLTEXT:
+             printf("name sqlda descriptor: '%s' value '%s'\n", sqlda->sqlvar[i].sqlname, sqlda->sqlvar[i].sqldata);
+             break;
+         case SQLSERIAL:
+         case SQLINT:
+             printf("name sqlda descriptor: '%s' value %d\n", sqlda->sqlvar[i].sqlname, *(int
*)sqlda->sqlvar[i].sqldata);
+             break;
+         case SQLSERIAL8:
+         case SQLINT8:
+             printf("name sqlda descriptor: '%s' value %" PRId64 "\n", sqlda->sqlvar[i].sqlname, *(int64_t
*)sqlda->sqlvar[i].sqldata);
+             break;
+         case SQLFLOAT:
+             printf("name sqlda descriptor: '%s' value %lf\n", sqlda->sqlvar[i].sqlname, *(double
*)sqlda->sqlvar[i].sqldata);
+             break;
+         case SQLDECIMAL:
+             {
+                 char    val[64];
+                 dectoasc((decimal *)sqlda->sqlvar[i].sqldata, val, 64, -1);
+                 printf("name sqlda descriptor: '%s' value DECIMAL '%s'\n", sqlda->sqlvar[i].sqlname, val);
+                 break;
+             }
+         }
+     }
+ }
+
+ int
+ main (void)
+ {
+ /* exec sql begin declare section */
+
+
+
+
+
+ #line 58 "sqlda.pgc"
+  char * stmt1 = "SELECT * FROM t1" ;
+
+ #line 59 "sqlda.pgc"
+  char * stmt2 = "SELECT * FROM t1 WHERE id = ?" ;
+
+ #line 60 "sqlda.pgc"
+  int rec ;
+
+ #line 61 "sqlda.pgc"
+  int id ;
+ /* exec sql end declare section */
+ #line 62 "sqlda.pgc"
+
+
+     char msg[128];
+
+     ECPGdebug(1, stderr);
+
+     strcpy(msg, "connect");
+     { ECPGconnect(__LINE__, 1, "regress1" , NULL, NULL , "regress1", 0);
+ #line 69 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 69 "sqlda.pgc"
+
+
+     strcpy(msg, "set");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
+ #line 72 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 72 "sqlda.pgc"
+
+
+     strcpy(msg, "create");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "create table t1 ( id integer , t text , d1 numeric , d2 float8
,c char ( 10 ) )", ECPGt_EOIT, ECPGt_EORT); 
+ #line 80 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 80 "sqlda.pgc"
+
+
+     strcpy(msg, "insert");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into t1 values ( 1 , 'a' , 1.0 , 1 , 'a' ) , ( 2 , null
,null , null , null ) , ( 3 , '\"c\"' , - 3 , 'nan' :: float8 , 'c' ) , ( 4 , 'd' , 4.0 , 4 , 'd' )", ECPGt_EOIT,
ECPGt_EORT);
+ #line 87 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 87 "sqlda.pgc"
+
+
+     strcpy(msg, "commit");
+     { ECPGtrans(__LINE__, NULL, "commit");
+ #line 90 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 90 "sqlda.pgc"
+
+
+     /* SQLDA test for getting all records from a table */
+
+     outp_sqlda = NULL;
+
+     strcpy(msg, "prepare");
+     { ECPGprepare(__LINE__, NULL, 0, "st_id1", stmt1);
+ #line 97 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 97 "sqlda.pgc"
+
+
+     strcpy(msg, "declare");
+     ECPG_informix_reset_sqlca(); /* declare mycur1 cursor for $1 */
+ #line 100 "sqlda.pgc"
+
+
+     strcpy(msg, "open");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare mycur1 cursor for $1",
+     ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id1", __LINE__)),(long)1,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 103 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 103 "sqlda.pgc"
+
+
+     /* exec sql whenever not found  break ; */
+ #line 105 "sqlda.pgc"
+
+
+     rec = 0;
+     while (1)
+     {
+         strcpy(msg, "fetch");
+         { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch 1 from mycur1", ECPGt_EOIT,
+     ECPGt_sqlda, & outp_sqlda , 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 111 "sqlda.pgc"
+
+ if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
+ #line 111 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 111 "sqlda.pgc"
+
+
+         printf("FETCH RECORD %d\n", ++rec);
+         dump_sqlda(outp_sqlda);
+     }
+
+     /* exec sql whenever not found  continue ; */
+ #line 117 "sqlda.pgc"
+
+
+     strcpy(msg, "close");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "close mycur1", ECPGt_EOIT, ECPGt_EORT);
+ #line 120 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 120 "sqlda.pgc"
+
+
+     strcpy(msg, "deallocate");
+     { ECPGdeallocate(__LINE__, 1, NULL, "st_id1");
+ #line 123 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 123 "sqlda.pgc"
+
+
+     free(outp_sqlda);
+
+     /* SQLDA test for getting all records from a table
+        using the Informix-specific FETCH ... USING DESCRIPTOR
+      */
+
+     outp_sqlda = NULL;
+
+     strcpy(msg, "prepare");
+     { ECPGprepare(__LINE__, NULL, 0, "st_id2", stmt1);
+ #line 134 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 134 "sqlda.pgc"
+
+
+     strcpy(msg, "declare");
+     ECPG_informix_reset_sqlca(); /* declare mycur2 cursor for $1 */
+ #line 137 "sqlda.pgc"
+
+
+     strcpy(msg, "open");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare mycur2 cursor for $1",
+     ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id2", __LINE__)),(long)1,(long)1,(1)*sizeof(char),
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 140 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 140 "sqlda.pgc"
+
+
+     /* exec sql whenever not found  break ; */
+ #line 142 "sqlda.pgc"
+
+
+     rec = 0;
+     while (1)
+     {
+         strcpy(msg, "fetch");
+         { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch from mycur2", ECPGt_EOIT,
+     ECPGt_sqlda, & outp_sqlda , 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 148 "sqlda.pgc"
+
+ if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
+ #line 148 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 148 "sqlda.pgc"
+
+
+         printf("FETCH RECORD %d\n", ++rec);
+         dump_sqlda(outp_sqlda);
+     }
+
+     /* exec sql whenever not found  continue ; */
+ #line 154 "sqlda.pgc"
+
+
+     strcpy(msg, "close");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "close mycur2", ECPGt_EOIT, ECPGt_EORT);
+ #line 157 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 157 "sqlda.pgc"
+
+
+     strcpy(msg, "deallocate");
+     { ECPGdeallocate(__LINE__, 1, NULL, "st_id2");
+ #line 160 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 160 "sqlda.pgc"
+
+
+     free(outp_sqlda);
+
+     /* SQLDA test for getting one record using an input descriptor */
+
+     /* Input sqlda has to be built manually */
+     inp_sqlda = (pg_sqlda_t *)malloc(sizeof(pg_sqlda_t));
+     memset(inp_sqlda, 0, sizeof(pg_sqlda_t));
+     inp_sqlda->sqld = 1;
+     inp_sqlda->sqlvar = malloc(sizeof(pg_sqlvar_t));
+     memset(inp_sqlda->sqlvar, 0, sizeof(pg_sqlvar_t));
+
+     inp_sqlda->sqlvar[0].sqltype = SQLINT;
+     inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+
+     printf("EXECUTE RECORD 4\n");
+
+     id = 4;
+
+     outp_sqlda = NULL;
+
+     strcpy(msg, "prepare");
+     { ECPGprepare(__LINE__, NULL, 0, "st_id3", stmt2);
+ #line 183 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 183 "sqlda.pgc"
+
+
+     strcpy(msg, "execute");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, 1, "st_id3",
+     ECPGt_sqlda, & inp_sqlda , 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_sqlda, & outp_sqlda , 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 186 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 186 "sqlda.pgc"
+
+
+     dump_sqlda(outp_sqlda);
+
+     strcpy(msg, "deallocate");
+     { ECPGdeallocate(__LINE__, 1, NULL, "st_id3");
+ #line 191 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 191 "sqlda.pgc"
+
+
+     free(inp_sqlda->sqlvar);
+     free(inp_sqlda);
+     free(outp_sqlda);
+
+     /* SQLDA test for getting one record using an input descriptor
+      * on a named connection
+      */
+
+     { ECPGconnect(__LINE__, 1, "regress1" , NULL, NULL , "con2", 0);
+ #line 201 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 201 "sqlda.pgc"
+
+
+     /* Input sqlda has to be built manually */
+     inp_sqlda = (pg_sqlda_t *)malloc(sizeof(pg_sqlda_t));
+     memset(inp_sqlda, 0, sizeof(pg_sqlda_t));
+     inp_sqlda->sqld = 1;
+     inp_sqlda->sqlvar = malloc(sizeof(pg_sqlvar_t));
+     memset(inp_sqlda->sqlvar, 0, sizeof(pg_sqlvar_t));
+
+     inp_sqlda->sqlvar[0].sqltype = SQLINT;
+     inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+
+     printf("EXECUTE RECORD 4\n");
+
+     id = 4;
+
+     outp_sqlda = NULL;
+
+     strcpy(msg, "prepare");
+     { ECPGprepare(__LINE__, "con2", 0, "st_id4", stmt2);
+ #line 220 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 220 "sqlda.pgc"
+
+
+     strcpy(msg, "execute");
+     { ECPGdo(__LINE__, 1, 1, "con2", 0, 1, "st_id4",
+     ECPGt_sqlda, & inp_sqlda , 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
+     ECPGt_sqlda, & outp_sqlda , 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 223 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 223 "sqlda.pgc"
+
+
+     dump_sqlda(outp_sqlda);
+
+     strcpy(msg, "commit");
+     { ECPGtrans(__LINE__, "con2", "commit");
+ #line 228 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 228 "sqlda.pgc"
+
+
+     strcpy(msg, "deallocate");
+     { ECPGdeallocate(__LINE__, 1, NULL, "st_id4");
+ #line 231 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 231 "sqlda.pgc"
+
+
+     free(inp_sqlda->sqlvar);
+     free(inp_sqlda);
+     free(outp_sqlda);
+
+     strcpy(msg, "disconnect");
+     { ECPGdisconnect(__LINE__, "con2");
+ #line 238 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 238 "sqlda.pgc"
+
+
+     /* End test */
+
+     strcpy(msg, "drop");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT);
+ #line 243 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 243 "sqlda.pgc"
+
+
+     strcpy(msg, "commit");
+     { ECPGtrans(__LINE__, NULL, "commit");
+ #line 246 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 246 "sqlda.pgc"
+
+
+     strcpy(msg, "disconnect");
+     { ECPGdisconnect(__LINE__, "CURRENT");
+ #line 249 "sqlda.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 249 "sqlda.pgc"
+
+
+     return (0);
+ }
diff -dcrpN pgsql.dyncursor/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stderr
pgsql.sqlda/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stderr
*** pgsql.dyncursor/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stderr    1970-01-01 01:00:00.000000000
+0100
--- pgsql.sqlda/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stderr    2009-09-04 11:04:43.000000000 +0200
***************
*** 0 ****
--- 1,252 ----
+ [NO_PID]: ECPGdebug: set to 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 72: query: set datestyle to iso; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 72: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 72: OK: SET
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 75: query: create table t1 ( id integer , t text , d1 numeric , d2 float8 , c char (
10) ); with 0 parameter(s) on connection regress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 75: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 75: OK: CREATE TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 83: query: insert into t1 values ( 1 , 'a' , 1.0 , 1 , 'a' ) , ( 2 , null , null ,
null, null ) , ( 3 , '"c"' , - 3 , 'nan' :: float8 , 'c' ) , ( 4 , 'd' , 4.0 , 4 , 'd' ); with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 83: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 83: OK: INSERT 0 4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 90: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 97: name st_id1; query: "SELECT * FROM t1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 103: query: declare mycur1 cursor for SELECT * FROM t1; with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 103: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 103: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 111: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 111: RESULT: 1.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 111: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 111: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 111: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 111: RESULT: -3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 111: RESULT: NaN offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 111: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 111: RESULT: 4.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 111: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: correctly got 0 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: raising sqlcode 100 on line 111: no data found on line 111
+ [NO_PID]: sqlca: code: 100, state: 02000
+ [NO_PID]: ecpg_execute on line 120: query: close mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 120: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 120: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 123: name st_id1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 134: name st_id2; query: "SELECT * FROM t1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 140: query: declare mycur2 cursor for SELECT * FROM t1; with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 140: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 140: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: query: fetch from mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: 1.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: query: fetch from mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: query: fetch from mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: -3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: NaN offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: query: fetch from mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: 4.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: query: fetch from mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: correctly got 0 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: raising sqlcode 100 on line 148: no data found on line 148
+ [NO_PID]: sqlca: code: 100, state: 02000
+ [NO_PID]: ecpg_execute on line 157: query: close mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 157: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 157: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 160: name st_id2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 183: name st_id3; query: "SELECT * FROM t1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 186: query: SELECT * FROM t1 WHERE id = $1; with 1 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 186: using PQexecPrepared for "SELECT * FROM t1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: free_params on line 186: parameter 1 = 4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 186: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 186: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 186: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 186: RESULT: 4.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 186: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 186: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 191: name st_id3
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 220: name st_id4; query: "SELECT * FROM t1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 223: query: SELECT * FROM t1 WHERE id = $1; with 1 parameter(s) on connection con2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 223: using PQexecPrepared for "SELECT * FROM t1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: free_params on line 223: parameter 1 = 4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 223: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 223: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 223: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 223: RESULT: 4.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 223: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 223: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 228: action "commit"; connection "con2"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 231: name st_id4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection con2 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 243: query: drop table t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 243: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 243: OK: DROP TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 246: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection regress1 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
diff -dcrpN pgsql.dyncursor/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stdout
pgsql.sqlda/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stdout
*** pgsql.dyncursor/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stdout    1970-01-01 01:00:00.000000000
+0100
--- pgsql.sqlda/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stdout    2009-09-04 11:04:21.000000000 +0200
***************
*** 0 ****
--- 1,60 ----
+ FETCH RECORD 1
+ name sqlda descriptor: 'id' value 1
+ name sqlda descriptor: 't' value 'a'
+ name sqlda descriptor: 'd1' value DECIMAL '1.0'
+ name sqlda descriptor: 'd2' value 1.000000
+ name sqlda descriptor: 'c' value 'a         '
+ FETCH RECORD 2
+ name sqlda descriptor: 'id' value 2
+ name sqlda descriptor: 't' value NULL'
+ name sqlda descriptor: 'd1' value NULL'
+ name sqlda descriptor: 'd2' value NULL'
+ name sqlda descriptor: 'c' value NULL'
+ FETCH RECORD 3
+ name sqlda descriptor: 'id' value 3
+ name sqlda descriptor: 't' value '"c"'
+ name sqlda descriptor: 'd1' value DECIMAL '-3'
+ name sqlda descriptor: 'd2' value nan
+ name sqlda descriptor: 'c' value 'c         '
+ FETCH RECORD 4
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'd'
+ name sqlda descriptor: 'd1' value DECIMAL '4.0'
+ name sqlda descriptor: 'd2' value 4.000000
+ name sqlda descriptor: 'c' value 'd         '
+ FETCH RECORD 1
+ name sqlda descriptor: 'id' value 1
+ name sqlda descriptor: 't' value 'a'
+ name sqlda descriptor: 'd1' value DECIMAL '1.0'
+ name sqlda descriptor: 'd2' value 1.000000
+ name sqlda descriptor: 'c' value 'a         '
+ FETCH RECORD 2
+ name sqlda descriptor: 'id' value 2
+ name sqlda descriptor: 't' value NULL'
+ name sqlda descriptor: 'd1' value NULL'
+ name sqlda descriptor: 'd2' value NULL'
+ name sqlda descriptor: 'c' value NULL'
+ FETCH RECORD 3
+ name sqlda descriptor: 'id' value 3
+ name sqlda descriptor: 't' value '"c"'
+ name sqlda descriptor: 'd1' value DECIMAL '-3'
+ name sqlda descriptor: 'd2' value nan
+ name sqlda descriptor: 'c' value 'c         '
+ FETCH RECORD 4
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'd'
+ name sqlda descriptor: 'd1' value DECIMAL '4.0'
+ name sqlda descriptor: 'd2' value 4.000000
+ name sqlda descriptor: 'c' value 'd         '
+ EXECUTE RECORD 4
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'd'
+ name sqlda descriptor: 'd1' value DECIMAL '4.0'
+ name sqlda descriptor: 'd2' value 4.000000
+ name sqlda descriptor: 'c' value 'd         '
+ EXECUTE RECORD 4
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'd'
+ name sqlda descriptor: 'd1' value DECIMAL '4.0'
+ name sqlda descriptor: 'd2' value 4.000000
+ name sqlda descriptor: 'c' value 'd         '

Re: ECPG patchset

From
Boszormenyi Zoltan
Date:
New version of the DESCRIBE patch
Changes:
- free(sqlda->sqlvar) as well if it's not in the same
  allocation area as teh main sqlda
- allow variable name for the prepared stmt in DESCRIBE

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
http://www.postgresql.at/

diff -dcrpN pgsql.sqlda/src/interfaces/ecpg/ecpglib/descriptor.c
pgsql.describe/src/interfaces/ecpg/ecpglib/descriptor.c
*** pgsql.sqlda/src/interfaces/ecpg/ecpglib/descriptor.c    2009-08-07 13:06:28.000000000 +0200
--- pgsql.describe/src/interfaces/ecpg/ecpglib/descriptor.c    2009-09-15 12:08:29.000000000 +0200
***************
*** 13,18 ****
--- 13,19 ----
  #include "ecpgerrno.h"
  #include "extern.h"
  #include "sqlca.h"
+ #include "sqlda.h"
  #include "sql3types.h"

  static void descriptor_free(struct descriptor * desc);
*************** get_char_item(int lineno, void *var, enu
*** 226,231 ****
--- 227,238 ----
      return (true);
  }

+ #define RETURN_IF_NO_DATA    if (ntuples < 1) \
+                 { \
+                     ecpg_raise(lineno, ECPG_NOT_FOUND, ECPG_SQLSTATE_NO_DATA, NULL); \
+                     return (false); \
+                 }
+
  bool
  ECPGget_desc(int lineno, const char *desc_name, int index,...)
  {
*************** ECPGget_desc(int lineno, const char *des
*** 244,254 ****
          return (false);

      ntuples = PQntuples(ECPGresult);
-     if (ntuples < 1)
-     {
-         ecpg_raise(lineno, ECPG_NOT_FOUND, ECPG_SQLSTATE_NO_DATA, NULL);
-         return (false);
-     }

      if (index < 1 || index > PQnfields(ECPGresult))
      {
--- 251,256 ----
*************** ECPGget_desc(int lineno, const char *des
*** 283,288 ****
--- 285,291 ----
          switch (type)
          {
              case (ECPGd_indicator):
+                 RETURN_IF_NO_DATA;
                  data_var.ind_type = vartype;
                  data_var.ind_pointer = var;
                  data_var.ind_varcharsize = varcharsize;
*************** ECPGget_desc(int lineno, const char *des
*** 295,300 ****
--- 298,304 ----
                  break;

              case ECPGd_data:
+                 RETURN_IF_NO_DATA;
                  data_var.type = vartype;
                  data_var.pointer = var;
                  data_var.varcharsize = varcharsize;
*************** ECPGget_desc(int lineno, const char *des
*** 377,382 ****
--- 381,387 ----
              case ECPGd_ret_length:
              case ECPGd_ret_octet:

+                 RETURN_IF_NO_DATA;
                  /*
                   * this is like ECPGstore_result
                   */
*************** ECPGget_desc(int lineno, const char *des
*** 480,485 ****
--- 485,491 ----
      sqlca->sqlerrd[2] = ntuples;
      return (true);
  }
+ #undef RETURN_IF_NO_DATA

  bool
  ECPGset_desc_header(int lineno, const char *desc_name, int count)
*************** ecpg_find_desc(int line, const char *nam
*** 722,730 ****
      return NULL;                /* not found */
  }

  bool
! ECPGdescribe(int line, bool input, const char *statement,...)
  {
!     ecpg_log("ECPGdescribe called on line %d for %s: %s\n", line, input ? "input" : "output", statement);
!     return false;
  }
--- 728,839 ----
      return NULL;                /* not found */
  }

+ static pg_sqlda_t*
+ build_sqlda(int lineno, bool input, const char *connection_name, const char *stmt_name)
+ {
+     struct connection *con;
+     PGresult    *res;
+     pg_sqlda_t    *sqlda = NULL;
+
+     con = ecpg_get_connection(connection_name);
+     res = PQdescribePrepared(con->connection, stmt_name);
+     if (!ecpg_check_PQresult(res, lineno, con->connection, ECPG_COMPAT_INFORMIX))
+         return NULL;
+
+     sqlda = ecpg_build_sqlda_for_PGresult(lineno, res, -1);
+
+     PQclear(res);
+     return sqlda;
+ }
+
  bool
! ECPGdescribe(int line, bool input, const char *connection_name, const char *stmt_name, ...)
  {
!     bool        ret = false;
!     va_list        args;
!
!     /* DESCRIBE INPUT is not yet supported */
!     if (input)
!         return false;
!
!     va_start(args, stmt_name);
!
!     for (;;)
!     {
!         enum ECPGttype    type, dummy_type;
!         void        *ptr, *dummy_ptr;
!         long        dummy;
!
!         /* variable type */
!         type = va_arg(args, enum ECPGttype);
!
!         if (type == ECPGt_EORT)
!             break;
!
!         /* rest of variable parameters*/
!         ptr = va_arg(args, void *);
!         dummy = va_arg(args, long);
!         dummy = va_arg(args, long);
!         dummy = va_arg(args, long);
!
!         /* variable indicator */
!         dummy_type = va_arg(args, enum ECPGttype);
!         dummy_ptr = va_arg(args, void *);
!         dummy = va_arg(args, long);
!         dummy = va_arg(args, long);
!         dummy = va_arg(args, long);
!
!         switch (type)
!         {
!             case ECPGt_descriptor:
!             {
!                 char    *name = ptr;
!                 struct connection *con = ecpg_get_connection(connection_name);
!                 struct descriptor *desc = ecpg_find_desc(line, name);
!                 PGresult    *res;
!                 ExecStatusType  ret;
!
!                 if (con == NULL)
!                     break;
!                 if (desc == NULL)
!                     break;
!
!                 res = PQdescribePrepared(con->connection, stmt_name);
!                 ret = PQresultStatus(res);
!                 if (ecpg_check_PQresult(res, line, con->connection, ECPG_COMPAT_PGSQL))
!                 {
!                     if (desc->result != NULL)
!                         PQclear(desc->result);
!                     desc->result = res;
!                     ret = true;
!                 }
!                 break;
!             }
!             case ECPGt_sqlda:
!             {
!                 pg_sqlda_t **_sqlda = ptr;
!                 pg_sqlda_t *sqlda;
!
!                 sqlda = build_sqlda(line, input, connection_name, stmt_name);
!                 if (sqlda)
!                 {
!                     pg_sqlda_t *sqlda_old = *_sqlda;
!                     if (sqlda_old)
!                     {
!                         if (sqlda->sqlvar != (pg_sqlvar_t *)(sqlda + 1))
!                             free(sqlda->sqlvar);
!                         free(sqlda_old);
!                     }
!                     *_sqlda = sqlda;
!                     ret = true;
!                 }
!                 break;
!             }
!             default:
!                 /* nothing else may come */
!                 ;
!         }
!     }
!
!     return ret;
  }
diff -dcrpN pgsql.sqlda/src/interfaces/ecpg/include/ecpglib.h pgsql.describe/src/interfaces/ecpg/include/ecpglib.h
*** pgsql.sqlda/src/interfaces/ecpg/include/ecpglib.h    2009-06-13 18:25:05.000000000 +0200
--- pgsql.describe/src/interfaces/ecpg/include/ecpglib.h    2009-09-15 12:07:39.000000000 +0200
*************** bool        ECPGset_desc(int, const char *, in
*** 83,89 ****

  void        ECPGset_noind_null(enum ECPGttype, void *);
  bool        ECPGis_noind_null(enum ECPGttype, void *);
! bool        ECPGdescribe(int, bool, const char *,...);

  /* dynamic result allocation */
  void        ECPGfree_auto_mem(void);
--- 83,89 ----

  void        ECPGset_noind_null(enum ECPGttype, void *);
  bool        ECPGis_noind_null(enum ECPGttype, void *);
! bool        ECPGdescribe(int, bool, const char *, const char *, ...);

  /* dynamic result allocation */
  void        ECPGfree_auto_mem(void);
diff -dcrpN pgsql.sqlda/src/interfaces/ecpg/preproc/ecpg.trailer
pgsql.describe/src/interfaces/ecpg/preproc/ecpg.trailer
*** pgsql.sqlda/src/interfaces/ecpg/preproc/ecpg.trailer    2009-09-03 12:56:36.000000000 +0200
--- pgsql.describe/src/interfaces/ecpg/preproc/ecpg.trailer    2009-09-18 05:11:18.000000000 +0200
*************** into_descriptor: INTO opt_sql SQL_DESCRI
*** 1057,1062 ****
--- 1057,1069 ----
          }
          ;

+ into_sqlda: INTO name
+         {
+             add_variable_to_head(&argsresult, sqlda_variable($2), &no_indicator);
+             $$ = EMPTY;
+         }
+         ;
+
  opt_sql: /*EMPTY*/        { $$ = EMPTY; }
          | SQL_SQL    { $$ = make_str("sql"); }
          ;
*************** UsingConst: Iconst            { $$ = $1; }
*** 1088,1113 ****
  /*
   * We accept descibe but do nothing with it so far.
   */
! ECPGDescribe: SQL_DESCRIBE INPUT_P name using_descriptor
      {
          const char *con = connection ? connection : "NULL";
          mmerror(PARSE_ERROR, ET_WARNING, "using unsupported DESCRIBE statement");
!         $$ = (char *) mm_alloc(sizeof("1, ECPGprepared_statement(, \"\", __LINE__)") + strlen(con) + strlen($3));
!         sprintf($$, "1, ECPGprepared_statement(%s, \"%s\", __LINE__)", con, $3);
      }
!     | SQL_DESCRIBE opt_output name using_descriptor
      {
          const char *con = connection ? connection : "NULL";
!         mmerror(PARSE_ERROR, ET_WARNING, "using unsupported DESCRIBE statement");
!         $$ = (char *) mm_alloc(sizeof("0, ECPGprepared_statement(, \"\", __LINE__)") + strlen(con) + strlen($3));
!         sprintf($$, "0, ECPGprepared_statement(%s, \"%s\", __LINE__)", con, $3);
      }
!     | SQL_DESCRIBE opt_output name into_descriptor
      {
          const char *con = connection ? connection : "NULL";
          mmerror(PARSE_ERROR, ET_WARNING, "using unsupported DESCRIBE statement");
!         $$ = (char *) mm_alloc(sizeof("0, ECPGprepared_statement(, \"\", __LINE__)") + strlen(con) + strlen($3));
!         sprintf($$, "0, ECPGprepared_statement(%s, \"%s\", __LINE__)", con, $3);
      }
      ;

--- 1095,1141 ----
  /*
   * We accept descibe but do nothing with it so far.
   */
! ECPGDescribe: SQL_DESCRIBE INPUT_P prepared_name using_descriptor
      {
          const char *con = connection ? connection : "NULL";
          mmerror(PARSE_ERROR, ET_WARNING, "using unsupported DESCRIBE statement");
!         $$ = (char *) mm_alloc(sizeof("1, , \"\"") + strlen(con) + strlen($3));
!         sprintf($$, "1, %s, \"%s\"", con, $3);
      }
!     | SQL_DESCRIBE opt_output prepared_name using_descriptor
      {
          const char *con = connection ? connection : "NULL";
!         struct variable *var;
!
!         var = argsinsert->variable;
!         remove_variable_from_list(&argsinsert, var);
!         add_variable_to_head(&argsresult, var, &no_indicator);
!
!         $$ = (char *) mm_alloc(sizeof("0, , \"\"") + strlen(con) + strlen($3));
!         sprintf($$, "0, %s, \"%s\"", con, $3);
      }
!     | SQL_DESCRIBE opt_output prepared_name into_descriptor
!     {
!         const char *con = connection ? connection : "NULL";
!         $$ = (char *) mm_alloc(sizeof("0, , \"\"") + strlen(con) + strlen($3));
!         sprintf($$, "0, %s, \"%s\"", con, $3);
!     }
!     | SQL_DESCRIBE INPUT_P prepared_name into_sqlda
      {
          const char *con = connection ? connection : "NULL";
          mmerror(PARSE_ERROR, ET_WARNING, "using unsupported DESCRIBE statement");
!         if (!INFORMIX_MODE)
!             mmerror(PARSE_ERROR, ET_ERROR, "Not in Informix compatibility mode");
!         $$ = (char *) mm_alloc(sizeof("1, , \"\"") + strlen(con) + strlen($3));
!         sprintf($$, "1, %s, \"%s\"", con, $3);
!     }
!     | SQL_DESCRIBE opt_output prepared_name into_sqlda
!     {
!         const char *con = connection ? connection : "NULL";
!         if (!INFORMIX_MODE)
!             mmerror(PARSE_ERROR, ET_ERROR, "Not in Informix compatibility mode");
!         $$ = (char *) mm_alloc(sizeof("0, , \"\"") + strlen(con) + strlen($3));
!         sprintf($$, "0, %s, \"%s\"", con, $3);
      }
      ;

diff -dcrpN pgsql.sqlda/src/interfaces/ecpg/preproc/ecpg.type pgsql.describe/src/interfaces/ecpg/preproc/ecpg.type
*** pgsql.sqlda/src/interfaces/ecpg/preproc/ecpg.type    2009-09-03 12:56:36.000000000 +0200
--- pgsql.describe/src/interfaces/ecpg/preproc/ecpg.type    2009-09-15 12:07:39.000000000 +0200
***************
*** 73,78 ****
--- 73,79 ----
  %type <str> execute_rest
  %type <str> indicator
  %type <str> into_descriptor
+ %type <str> into_sqlda
  %type <str> Iresult
  %type <str> on_off
  %type <str> opt_bit_field
***************
*** 88,94 ****
  %type <str> opt_reference
  %type <str> opt_scale
  %type <str> opt_server
! %type <str> opt_sql
  %type <str> opt_user
  %type <str> opt_opt_value
  %type <str> ora_user
--- 89,95 ----
  %type <str> opt_reference
  %type <str> opt_scale
  %type <str> opt_server
! %type <str> opt_sql
  %type <str> opt_user
  %type <str> opt_opt_value
  %type <str> ora_user
diff -dcrpN pgsql.sqlda/src/interfaces/ecpg/test/compat_informix/describe.pgc
pgsql.describe/src/interfaces/ecpg/test/compat_informix/describe.pgc
*** pgsql.sqlda/src/interfaces/ecpg/test/compat_informix/describe.pgc    1970-01-01 01:00:00.000000000 +0100
--- pgsql.describe/src/interfaces/ecpg/test/compat_informix/describe.pgc    2009-09-15 12:07:39.000000000 +0200
***************
*** 0 ****
--- 1,166 ----
+ #include <stdlib.h>
+ #include <string.h>
+
+ exec sql include ../regression;
+ exec sql include sqlda.h;
+
+ exec sql whenever sqlerror stop;
+
+ pg_sqlda_t    *sqlda1, *sqlda2, *sqlda3;
+
+ int
+ main (void)
+ {
+ exec sql begin declare section;
+     char    *stmt1 = "SELECT id, t FROM t1";
+     char    *stmt2 = "SELECT id, t FROM t1 WHERE id = -1";
+     int    i, count1, count2;
+     char    field_name1[30] = "not set";
+     char    field_name2[30] = "not set";
+ exec sql end declare section;
+
+     char msg[128];
+
+     ECPGdebug(1, stderr);
+
+     strcpy(msg, "connect");
+     exec sql connect to REGRESSDB1;
+
+     strcpy(msg, "set");
+     exec sql set datestyle to iso;
+
+     strcpy(msg, "create");
+     exec sql create table t1(id serial primary key, t text);
+
+     strcpy(msg, "insert");
+     exec sql insert into t1(id, t) values (default, 'a');
+     exec sql insert into t1(id, t) values (default, 'b');
+     exec sql insert into t1(id, t) values (default, 'c');
+     exec sql insert into t1(id, t) values (default, 'd');
+
+     strcpy(msg, "commit");
+     exec sql commit;
+
+     /*
+      * Test DESCRIBE with a query producing tuples.
+      * DESCRIPTOR and SQL DESCRIPTOR are NOT the same in
+      * Informix-compat mode.
+      */
+
+     strcpy(msg, "allocate");
+     exec sql allocate descriptor desc1;
+     exec sql allocate descriptor desc2;
+
+     strcpy(msg, "prepare");
+     exec sql prepare st_id1 FROM :stmt1;
+
+     sqlda1 = sqlda2 = sqlda3 = NULL;
+
+     strcpy(msg, "describe");
+     exec sql describe st_id1 into sql descriptor desc1;
+     exec sql describe st_id1 using sql descriptor desc2;
+
+     exec sql describe st_id1 into descriptor sqlda1;
+     exec sql describe st_id1 using descriptor sqlda2;
+     exec sql describe st_id1 into sqlda3;
+
+     if (sqlda1 == NULL || sqlda1 == NULL || sqlda2 == NULL)
+         exit(1);
+
+     strcpy(msg, "get descriptor");
+     exec sql get descriptor desc1 :count1 = count;
+     exec sql get descriptor desc1 :count2 = count;
+
+     if (!(    count1 == count2 &&
+         count1 == sqlda1->sqld &&
+         count1 == sqlda2->sqld &&
+         count1 == sqlda3->sqld))
+         exit(1);
+
+     for (i = 1; i <= count1; i++)
+     {
+         exec sql get descriptor desc1 value :i :field_name1 = name;
+         exec sql get descriptor desc2 value :i :field_name2 = name;
+         printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
+             "sqlda1 '%s'\n\tsqlda2 '%s'\n\tsqlda3 '%s'\n",
+             i, field_name1, field_name2,
+             sqlda1->sqlvar[i-1].sqlname,
+             sqlda2->sqlvar[i-1].sqlname,
+             sqlda3->sqlvar[i-1].sqlname);
+     }
+
+     strcpy(msg, "deallocate");
+     exec sql deallocate descriptor desc1;
+     exec sql deallocate descriptor desc2;
+     free(sqlda1);
+     free(sqlda2);
+     free(sqlda3);
+
+     exec sql deallocate prepare st_id1;
+
+     /* Test DESCRIBE with a query not producing tuples */
+
+     strcpy(msg, "allocate");
+     exec sql allocate descriptor desc1;
+     exec sql allocate descriptor desc2;
+
+     strcpy(msg, "prepare");
+     exec sql prepare st_id2 FROM :stmt2;
+
+     sqlda1 = sqlda2 = sqlda3 = NULL;
+
+     strcpy(msg, "describe");
+     exec sql describe st_id2 into sql descriptor desc1;
+     exec sql describe st_id2 using sql descriptor desc2;
+
+     exec sql describe st_id2 into descriptor sqlda1;
+     exec sql describe st_id2 using descriptor sqlda2;
+     exec sql describe st_id2 into sqlda3;
+
+     if (sqlda1 == NULL || sqlda1 == NULL || sqlda2 == NULL)
+         exit(1);
+
+     strcpy(msg, "get descriptor");
+     exec sql get descriptor desc1 :count1 = count;
+     exec sql get descriptor desc1 :count2 = count;
+
+     if (!(    count1 == count2 &&
+         count1 == sqlda1->sqld &&
+         count1 == sqlda2->sqld &&
+         count1 == sqlda3->sqld))
+         exit(1);
+
+     for (i = 1; i <= count1; i++)
+     {
+         exec sql get descriptor desc1 value :i :field_name1 = name;
+         exec sql get descriptor desc2 value :i :field_name2 = name;
+         printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
+             "sqlda1 '%s'\n\tsqlda2 '%s'\n\tsqlda3 '%s'\n",
+             i, field_name1, field_name2,
+             sqlda1->sqlvar[i-1].sqlname,
+             sqlda2->sqlvar[i-1].sqlname,
+             sqlda3->sqlvar[i-1].sqlname);
+     }
+
+     strcpy(msg, "deallocate");
+     exec sql deallocate descriptor desc1;
+     exec sql deallocate descriptor desc2;
+     free(sqlda1);
+     free(sqlda2);
+     free(sqlda3);
+
+     exec sql deallocate prepare st_id2;
+
+     /* End test */
+
+     strcpy(msg, "drop");
+     exec sql drop table t1;
+
+     strcpy(msg, "commit");
+     exec sql commit;
+
+     strcpy(msg, "disconnect");
+     exec sql disconnect;
+
+     return (0);
+ }
diff -dcrpN pgsql.sqlda/src/interfaces/ecpg/test/compat_informix/Makefile
pgsql.describe/src/interfaces/ecpg/test/compat_informix/Makefile
*** pgsql.sqlda/src/interfaces/ecpg/test/compat_informix/Makefile    2009-09-03 12:56:36.000000000 +0200
--- pgsql.describe/src/interfaces/ecpg/test/compat_informix/Makefile    2009-09-15 12:07:39.000000000 +0200
*************** override LIBS := -lecpg_compat $(LIBS)
*** 13,18 ****
--- 13,19 ----
  TESTS = test_informix test_informix.c \
          test_informix2 test_informix2.c \
          cursor cursor.c \
+         describe describe.c \
          dec_test dec_test.c \
          rfmtdate rfmtdate.c \
          rfmtlong rfmtlong.c \
*************** test_informix2.c: test_informix2.pgc ../
*** 31,36 ****
--- 32,40 ----
  cursor.c: cursor.pgc ../regression.h
      $(ECPG) -o $@ -I$(srcdir) $<

+ describe.c: describe.pgc ../regression.h
+     $(ECPG) -o $@ -I$(srcdir) $<
+
  sqlda.c: sqlda.pgc ../regression.h
      $(ECPG) -o $@ -I$(srcdir) $<

diff -dcrpN pgsql.sqlda/src/interfaces/ecpg/test/ecpg_schedule pgsql.describe/src/interfaces/ecpg/test/ecpg_schedule
*** pgsql.sqlda/src/interfaces/ecpg/test/ecpg_schedule    2009-09-03 12:56:36.000000000 +0200
--- pgsql.describe/src/interfaces/ecpg/test/ecpg_schedule    2009-09-15 12:07:39.000000000 +0200
*************** test: compat_informix/rfmtlong
*** 5,10 ****
--- 5,11 ----
  test: compat_informix/rnull
  test: compat_informix/cursor
  test: compat_informix/sqlda
+ test: compat_informix/describe
  test: compat_informix/test_informix
  test: compat_informix/test_informix2
  test: connect/test2
*************** test: preproc/array_of_struct
*** 19,24 ****
--- 20,26 ----
  test: preproc/autoprep
  test: preproc/comment
  test: preproc/cursor
+ test: preproc/describe
  test: preproc/define
  test: preproc/init
  test: preproc/strings
diff -dcrpN pgsql.sqlda/src/interfaces/ecpg/test/ecpg_schedule_tcp
pgsql.describe/src/interfaces/ecpg/test/ecpg_schedule_tcp
*** pgsql.sqlda/src/interfaces/ecpg/test/ecpg_schedule_tcp    2009-09-03 12:56:36.000000000 +0200
--- pgsql.describe/src/interfaces/ecpg/test/ecpg_schedule_tcp    2009-09-15 12:07:39.000000000 +0200
*************** test: compat_informix/rfmtlong
*** 5,10 ****
--- 5,11 ----
  test: compat_informix/rnull
  test: compat_informix/cursor
  test: compat_informix/sqlda
+ test: compat_informix/describe
  test: compat_informix/test_informix
  test: compat_informix/test_informix2
  test: connect/test2
*************** test: preproc/array_of_struct
*** 19,24 ****
--- 20,26 ----
  test: preproc/autoprep
  test: preproc/comment
  test: preproc/cursor
+ test: preproc/describe
  test: preproc/define
  test: preproc/init
  test: preproc/strings
diff -dcrpN pgsql.sqlda/src/interfaces/ecpg/test/expected/compat_informix-describe.c
pgsql.describe/src/interfaces/ecpg/test/expected/compat_informix-describe.c
*** pgsql.sqlda/src/interfaces/ecpg/test/expected/compat_informix-describe.c    1970-01-01 01:00:00.000000000 +0100
--- pgsql.describe/src/interfaces/ecpg/test/expected/compat_informix-describe.c    2009-09-15 12:07:39.000000000 +0200
***************
*** 0 ****
--- 1,490 ----
+ /* Processed by ecpg (regression mode) */
+ /* These include files are added by the preprocessor */
+ #include <ecpglib.h>
+ #include <ecpgerrno.h>
+ #include <sqlca.h>
+ /* Needed for informix compatibility */
+ #include <ecpg_informix.h>
+ /* End of automatic include section */
+ #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+
+ #line 1 "describe.pgc"
+ #include <stdlib.h>
+ #include <string.h>
+
+
+ #line 1 "regression.h"
+
+
+
+
+
+
+ #line 4 "describe.pgc"
+
+
+ #line 1 "sqlda.h"
+ /*
+  * $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqlda.h,v 1.4 2009/06/11 14:49:13 momjian Exp $
+  */
+
+ #ifndef POSTGRES_SQLDA_H
+ #define POSTGRES_SQLDA_H
+
+ /* Define Informix "standard" types */
+ #ifndef C_H
+ typedef int        int4;
+ typedef    short        int2;
+ #endif
+ typedef    char        int1;
+
+ typedef    int        mint;
+ typedef    long        mlong;
+
+ typedef    short        MSHORT;
+ typedef    char        MCHAR;
+
+ typedef    unsigned int    uint4;
+ typedef    unsigned short    uint2;
+ typedef    unsigned char    uint1;
+
+ typedef    unsigned int    muint;
+ typedef    unsigned long    mulong;
+
+ typedef    unsigned short    MUSHORT;
+ typedef    unsigned char    MUCHAR;
+
+ #define MI_INT_SIZE     (sizeof(int)    * 8)
+ #define MI_LONG_SIZE    (sizeof(long)   * 8)
+ #define MI_PTR_SIZE     (sizeof(char *) * 8)
+
+ typedef struct sqlvar_struct
+ {
+     int2    sqltype;        /* variable type                */
+     int4    sqllen;            /* length in bytes              */
+     char       *sqldata;        /* pointer to data              */
+     int2       *sqlind;        /* pointer to indicator         */
+     char       *sqlname;        /* variable name                */
+     char       *sqlformat;        /* reserved for future use      */
+     int2    sqlitype;        /* ind variable type            */
+     int2    sqlilen;        /* ind length in bytes          */
+     char       *sqlidata;        /* ind data pointer             */
+     int4    sqlxid;            /* extended id type             */
+     char       *sqltypename;    /* extended type name           */
+     int2    sqltypelen;        /* length of extended type name */
+     int2    sqlownerlen;        /* length of owner name         */
+     int2    sqlsourcetype;        /* source type for distinct of built-ins */
+     char       *sqlownername;    /* owner name                   */
+     int4    sqlsourceid;        /* extended id of source type   */
+
+     /*
+      * sqlilongdata is new.  It supports data that exceeds the 32k
+      * limit.  sqlilen and sqlidata are for backward compatibility
+      * and they have maximum value of <32K.
+      */
+     char       *sqlilongdata;    /* for data field beyond 32K    */
+     int4    sqlflags;        /* for internal use only        */
+     void       *sqlreserved;    /* reserved for future use      */
+ } pg_sqlvar_t;
+
+ typedef struct sqlda
+ {
+     int2        sqld;
+     pg_sqlvar_t       *sqlvar;
+     char        desc_name[19];    /* descriptor name              */
+     int2        desc_occ;    /* size of sqlda structure      */
+     struct sqlda       *desc_next;    /* pointer to next sqlda struct */
+     void           *reserved;    /* reserved for future use */
+ } pg_sqlda_t;
+
+ #endif /* POSTGRES_SQLDA_H */
+
+ #line 5 "describe.pgc"
+
+
+ /* exec sql whenever sqlerror  stop ; */
+ #line 7 "describe.pgc"
+
+
+ pg_sqlda_t    *sqlda1, *sqlda2, *sqlda3;
+
+ int
+ main (void)
+ {
+ /* exec sql begin declare section */
+
+
+
+
+
+
+ #line 15 "describe.pgc"
+  char * stmt1 = "SELECT id, t FROM t1" ;
+
+ #line 16 "describe.pgc"
+  char * stmt2 = "SELECT id, t FROM t1 WHERE id = -1" ;
+
+ #line 17 "describe.pgc"
+  int i , count1 , count2 ;
+
+ #line 18 "describe.pgc"
+  char field_name1 [ 30 ] = "not set" ;
+
+ #line 19 "describe.pgc"
+  char field_name2 [ 30 ] = "not set" ;
+ /* exec sql end declare section */
+ #line 20 "describe.pgc"
+
+
+     char msg[128];
+
+     ECPGdebug(1, stderr);
+
+     strcpy(msg, "connect");
+     { ECPGconnect(__LINE__, 1, "regress1" , NULL, NULL , NULL, 0);
+ #line 27 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 27 "describe.pgc"
+
+
+     strcpy(msg, "set");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
+ #line 30 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 30 "describe.pgc"
+
+
+     strcpy(msg, "create");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "create table t1 ( id serial primary key , t text )",
ECPGt_EOIT,ECPGt_EORT); 
+ #line 33 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 33 "describe.pgc"
+
+
+     strcpy(msg, "insert");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'a' )",
ECPGt_EOIT,ECPGt_EORT); 
+ #line 36 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 36 "describe.pgc"
+
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'b' )",
ECPGt_EOIT,ECPGt_EORT); 
+ #line 37 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 37 "describe.pgc"
+
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'c' )",
ECPGt_EOIT,ECPGt_EORT); 
+ #line 38 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 38 "describe.pgc"
+
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'd' )",
ECPGt_EOIT,ECPGt_EORT); 
+ #line 39 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 39 "describe.pgc"
+
+
+     strcpy(msg, "commit");
+     { ECPGtrans(__LINE__, NULL, "commit");
+ #line 42 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 42 "describe.pgc"
+
+
+     /*
+      * Test DESCRIBE with a query producing tuples.
+      * DESCRIPTOR and SQL DESCRIPTOR are NOT the same in
+      * Informix-compat mode.
+      */
+
+     strcpy(msg, "allocate");
+     ECPGallocate_desc(__LINE__, "desc1");
+ #line 51 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 51 "describe.pgc"
+
+     ECPGallocate_desc(__LINE__, "desc2");
+ #line 52 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 52 "describe.pgc"
+
+
+     strcpy(msg, "prepare");
+     { ECPGprepare(__LINE__, NULL, 0, "st_id1", stmt1);
+ #line 55 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 55 "describe.pgc"
+
+
+     sqlda1 = sqlda2 = sqlda3 = NULL;
+
+     strcpy(msg, "describe");
+     { ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+     ECPGt_descriptor, "desc1", 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 60 "describe.pgc"
+
+     { ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+     ECPGt_descriptor, "desc2", 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 61 "describe.pgc"
+
+
+     { ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+     ECPGt_sqlda, & sqlda1 , 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 63 "describe.pgc"
+
+     { ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+     ECPGt_sqlda, & sqlda2 , 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 64 "describe.pgc"
+
+     { ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+     ECPGt_sqlda, &sqlda3, 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 65 "describe.pgc"
+
+
+     if (sqlda1 == NULL || sqlda1 == NULL || sqlda2 == NULL)
+         exit(1);
+
+     strcpy(msg, "get descriptor");
+     { ECPGget_desc_header(__LINE__, "desc1", &(count1));
+
+ #line 71 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 71 "describe.pgc"
+
+     { ECPGget_desc_header(__LINE__, "desc1", &(count2));
+
+ #line 72 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 72 "describe.pgc"
+
+
+     if (!(    count1 == count2 &&
+         count1 == sqlda1->sqld &&
+         count1 == sqlda2->sqld &&
+         count1 == sqlda3->sqld))
+         exit(1);
+
+     for (i = 1; i <= count1; i++)
+     {
+         { ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
+     ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+
+ #line 82 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 82 "describe.pgc"
+
+         { ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
+     ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+
+ #line 83 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 83 "describe.pgc"
+
+         printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
+             "sqlda1 '%s'\n\tsqlda2 '%s'\n\tsqlda3 '%s'\n",
+             i, field_name1, field_name2,
+             sqlda1->sqlvar[i-1].sqlname,
+             sqlda2->sqlvar[i-1].sqlname,
+             sqlda3->sqlvar[i-1].sqlname);
+     }
+
+     strcpy(msg, "deallocate");
+     ECPGdeallocate_desc(__LINE__, "desc1");
+ #line 93 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 93 "describe.pgc"
+
+     ECPGdeallocate_desc(__LINE__, "desc2");
+ #line 94 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 94 "describe.pgc"
+
+     free(sqlda1);
+     free(sqlda2);
+     free(sqlda3);
+
+     { ECPGdeallocate(__LINE__, 1, NULL, "st_id1");
+ #line 99 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 99 "describe.pgc"
+
+
+     /* Test DESCRIBE with a query not producing tuples */
+
+     strcpy(msg, "allocate");
+     ECPGallocate_desc(__LINE__, "desc1");
+ #line 104 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 104 "describe.pgc"
+
+     ECPGallocate_desc(__LINE__, "desc2");
+ #line 105 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 105 "describe.pgc"
+
+
+     strcpy(msg, "prepare");
+     { ECPGprepare(__LINE__, NULL, 0, "st_id2", stmt2);
+ #line 108 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 108 "describe.pgc"
+
+
+     sqlda1 = sqlda2 = sqlda3 = NULL;
+
+     strcpy(msg, "describe");
+     { ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+     ECPGt_descriptor, "desc1", 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 113 "describe.pgc"
+
+     { ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+     ECPGt_descriptor, "desc2", 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 114 "describe.pgc"
+
+
+     { ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+     ECPGt_sqlda, & sqlda1 , 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 116 "describe.pgc"
+
+     { ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+     ECPGt_sqlda, & sqlda2 , 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 117 "describe.pgc"
+
+     { ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+     ECPGt_sqlda, &sqlda3, 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 118 "describe.pgc"
+
+
+     if (sqlda1 == NULL || sqlda1 == NULL || sqlda2 == NULL)
+         exit(1);
+
+     strcpy(msg, "get descriptor");
+     { ECPGget_desc_header(__LINE__, "desc1", &(count1));
+
+ #line 124 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 124 "describe.pgc"
+
+     { ECPGget_desc_header(__LINE__, "desc1", &(count2));
+
+ #line 125 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 125 "describe.pgc"
+
+
+     if (!(    count1 == count2 &&
+         count1 == sqlda1->sqld &&
+         count1 == sqlda2->sqld &&
+         count1 == sqlda3->sqld))
+         exit(1);
+
+     for (i = 1; i <= count1; i++)
+     {
+         { ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
+     ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+
+ #line 135 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 135 "describe.pgc"
+
+         { ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
+     ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+
+ #line 136 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 136 "describe.pgc"
+
+         printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
+             "sqlda1 '%s'\n\tsqlda2 '%s'\n\tsqlda3 '%s'\n",
+             i, field_name1, field_name2,
+             sqlda1->sqlvar[i-1].sqlname,
+             sqlda2->sqlvar[i-1].sqlname,
+             sqlda3->sqlvar[i-1].sqlname);
+     }
+
+     strcpy(msg, "deallocate");
+     ECPGdeallocate_desc(__LINE__, "desc1");
+ #line 146 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 146 "describe.pgc"
+
+     ECPGdeallocate_desc(__LINE__, "desc2");
+ #line 147 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 147 "describe.pgc"
+
+     free(sqlda1);
+     free(sqlda2);
+     free(sqlda3);
+
+     { ECPGdeallocate(__LINE__, 1, NULL, "st_id2");
+ #line 152 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 152 "describe.pgc"
+
+
+     /* End test */
+
+     strcpy(msg, "drop");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT);
+ #line 157 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 157 "describe.pgc"
+
+
+     strcpy(msg, "commit");
+     { ECPGtrans(__LINE__, NULL, "commit");
+ #line 160 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 160 "describe.pgc"
+
+
+     strcpy(msg, "disconnect");
+     { ECPGdisconnect(__LINE__, "CURRENT");
+ #line 163 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 163 "describe.pgc"
+
+
+     return (0);
+ }
diff -dcrpN pgsql.sqlda/src/interfaces/ecpg/test/expected/compat_informix-describe.stderr
pgsql.describe/src/interfaces/ecpg/test/expected/compat_informix-describe.stderr
*** pgsql.sqlda/src/interfaces/ecpg/test/expected/compat_informix-describe.stderr    1970-01-01 01:00:00.000000000
+0100
--- pgsql.describe/src/interfaces/ecpg/test/expected/compat_informix-describe.stderr    2009-09-15 12:07:39.000000000
+0200
***************
*** 0 ****
--- 1,100 ----
+ [NO_PID]: ECPGdebug: set to 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 30: query: set datestyle to iso; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 30: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 30: OK: SET
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 33: query: create table t1 ( id serial primary key , t text ); with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 33: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 33: OK: CREATE TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: query: insert into t1 ( id , t ) values ( default , 'a' ); with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: query: insert into t1 ( id , t ) values ( default , 'b' ); with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: query: insert into t1 ( id , t ) values ( default , 'c' ); with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 39: query: insert into t1 ( id , t ) values ( default , 'd' ); with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 39: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 39: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 42: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 55: name st_id1; query: "SELECT id, t FROM t1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 99: name st_id1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 108: name st_id2; query: "SELECT id, t FROM t1 WHERE id = -1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 152: name st_id2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 157: query: drop table t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 157: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 157: OK: DROP TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 160: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection regress1 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
diff -dcrpN pgsql.sqlda/src/interfaces/ecpg/test/expected/compat_informix-describe.stdout
pgsql.describe/src/interfaces/ecpg/test/expected/compat_informix-describe.stdout
*** pgsql.sqlda/src/interfaces/ecpg/test/expected/compat_informix-describe.stdout    1970-01-01 01:00:00.000000000
+0100
--- pgsql.describe/src/interfaces/ecpg/test/expected/compat_informix-describe.stdout    2009-09-15 12:07:39.000000000
+0200
***************
*** 0 ****
--- 1,24 ----
+ 1
+     field_name1 'id'
+     field_name2 'id'
+     sqlda1 'id'
+     sqlda2 'id'
+     sqlda3 'id'
+ 2
+     field_name1 't'
+     field_name2 't'
+     sqlda1 't'
+     sqlda2 't'
+     sqlda3 't'
+ 1
+     field_name1 'id'
+     field_name2 'id'
+     sqlda1 'id'
+     sqlda2 'id'
+     sqlda3 'id'
+ 2
+     field_name1 't'
+     field_name2 't'
+     sqlda1 't'
+     sqlda2 't'
+     sqlda3 't'
diff -dcrpN pgsql.sqlda/src/interfaces/ecpg/test/expected/preproc-describe.c
pgsql.describe/src/interfaces/ecpg/test/expected/preproc-describe.c
*** pgsql.sqlda/src/interfaces/ecpg/test/expected/preproc-describe.c    1970-01-01 01:00:00.000000000 +0100
--- pgsql.describe/src/interfaces/ecpg/test/expected/preproc-describe.c    2009-09-15 12:07:39.000000000 +0200
***************
*** 0 ****
--- 1,481 ----
+ /* Processed by ecpg (regression mode) */
+ /* These include files are added by the preprocessor */
+ #include <ecpglib.h>
+ #include <ecpgerrno.h>
+ #include <sqlca.h>
+ /* End of automatic include section */
+ #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+
+ #line 1 "describe.pgc"
+ #include <stdlib.h>
+ #include <string.h>
+
+
+ #line 1 "regression.h"
+
+
+
+
+
+
+ #line 4 "describe.pgc"
+
+
+ /* exec sql whenever sqlerror  stop ; */
+ #line 6 "describe.pgc"
+
+
+ int
+ main (void)
+ {
+ /* exec sql begin declare section */
+
+
+
+
+
+
+
+
+ #line 12 "describe.pgc"
+  char * stmt1 = "SELECT id, t FROM t1" ;
+
+ #line 13 "describe.pgc"
+  char * stmt2 = "SELECT id, t FROM t1 WHERE id = -1" ;
+
+ #line 14 "describe.pgc"
+  int i , count1 , count2 , count3 , count4 ;
+
+ #line 15 "describe.pgc"
+  char field_name1 [ 30 ] = "not set" ;
+
+ #line 16 "describe.pgc"
+  char field_name2 [ 30 ] = "not set" ;
+
+ #line 17 "describe.pgc"
+  char field_name3 [ 30 ] = "not set" ;
+
+ #line 18 "describe.pgc"
+  char field_name4 [ 30 ] = "not set" ;
+ /* exec sql end declare section */
+ #line 19 "describe.pgc"
+
+
+     char msg[128];
+
+     ECPGdebug(1, stderr);
+
+     strcpy(msg, "connect");
+     { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0);
+ #line 26 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 26 "describe.pgc"
+
+
+     strcpy(msg, "set");
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
+ #line 29 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 29 "describe.pgc"
+
+
+     strcpy(msg, "create");
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table t1 ( id serial primary key , t text )",
ECPGt_EOIT,ECPGt_EORT); 
+ #line 32 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 32 "describe.pgc"
+
+
+     strcpy(msg, "insert");
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'a' )",
ECPGt_EOIT,ECPGt_EORT); 
+ #line 35 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 35 "describe.pgc"
+
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'b' )",
ECPGt_EOIT,ECPGt_EORT); 
+ #line 36 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 36 "describe.pgc"
+
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'c' )",
ECPGt_EOIT,ECPGt_EORT); 
+ #line 37 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 37 "describe.pgc"
+
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'd' )",
ECPGt_EOIT,ECPGt_EORT); 
+ #line 38 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 38 "describe.pgc"
+
+
+     strcpy(msg, "commit");
+     { ECPGtrans(__LINE__, NULL, "commit");
+ #line 41 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 41 "describe.pgc"
+
+
+     /*
+      * Test DESCRIBE with a query producing tuples.
+      * DESCRIPTOR and SQL DESCRIPTOR are the same in native mode.
+      */
+
+     strcpy(msg, "allocate");
+     ECPGallocate_desc(__LINE__, "desc1");
+ #line 49 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 49 "describe.pgc"
+
+     ECPGallocate_desc(__LINE__, "desc2");
+ #line 50 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 50 "describe.pgc"
+
+     ECPGallocate_desc(__LINE__, "desc3");
+ #line 51 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 51 "describe.pgc"
+
+     ECPGallocate_desc(__LINE__, "desc4");
+ #line 52 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 52 "describe.pgc"
+
+
+     strcpy(msg, "prepare");
+     { ECPGprepare(__LINE__, NULL, 0, "st_id1", stmt1);
+ #line 55 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 55 "describe.pgc"
+
+
+     strcpy(msg, "describe");
+     { ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+     ECPGt_descriptor, "desc1", 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 58 "describe.pgc"
+
+     { ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+     ECPGt_descriptor, "desc2", 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 59 "describe.pgc"
+
+     { ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+     ECPGt_descriptor, "desc3", 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 60 "describe.pgc"
+
+     { ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+     ECPGt_descriptor, "desc4", 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 61 "describe.pgc"
+
+
+     strcpy(msg, "get descriptor");
+     { ECPGget_desc_header(__LINE__, "desc1", &(count1));
+
+ #line 64 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 64 "describe.pgc"
+
+     { ECPGget_desc_header(__LINE__, "desc2", &(count2));
+
+ #line 65 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 65 "describe.pgc"
+
+     { ECPGget_desc_header(__LINE__, "desc3", &(count3));
+
+ #line 66 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 66 "describe.pgc"
+
+     { ECPGget_desc_header(__LINE__, "desc4", &(count4));
+
+ #line 67 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 67 "describe.pgc"
+
+
+     if (!(count1 == count2 && count1 == count3 && count1 == count4))
+         exit(1);
+
+     for (i = 1; i <= count1; i++)
+     {
+         { ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
+     ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+
+ #line 74 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 74 "describe.pgc"
+
+         { ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
+     ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+
+ #line 75 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 75 "describe.pgc"
+
+         { ECPGget_desc(__LINE__, "desc3", i,ECPGd_name,
+     ECPGt_char,(field_name3),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+
+ #line 76 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 76 "describe.pgc"
+
+         { ECPGget_desc(__LINE__, "desc4", i,ECPGd_name,
+     ECPGt_char,(field_name4),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+
+ #line 77 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 77 "describe.pgc"
+
+         printf("field_name 1 '%s' 2 '%s' 3 '%s' 4 '%s'\n",
+             field_name1, field_name2, field_name3, field_name4);
+     }
+
+     strcpy(msg, "deallocate");
+     ECPGdeallocate_desc(__LINE__, "desc1");
+ #line 83 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 83 "describe.pgc"
+
+     ECPGdeallocate_desc(__LINE__, "desc2");
+ #line 84 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 84 "describe.pgc"
+
+     ECPGdeallocate_desc(__LINE__, "desc3");
+ #line 85 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 85 "describe.pgc"
+
+     ECPGdeallocate_desc(__LINE__, "desc4");
+ #line 86 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 86 "describe.pgc"
+
+
+     { ECPGdeallocate(__LINE__, 0, NULL, "st_id1");
+ #line 88 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 88 "describe.pgc"
+
+
+     /* Test DESCRIBE with a query not producing tuples */
+
+     strcpy(msg, "allocate");
+     ECPGallocate_desc(__LINE__, "desc1");
+ #line 93 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 93 "describe.pgc"
+
+     ECPGallocate_desc(__LINE__, "desc2");
+ #line 94 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 94 "describe.pgc"
+
+     ECPGallocate_desc(__LINE__, "desc3");
+ #line 95 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 95 "describe.pgc"
+
+     ECPGallocate_desc(__LINE__, "desc4");
+ #line 96 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 96 "describe.pgc"
+
+
+     strcpy(msg, "prepare");
+     { ECPGprepare(__LINE__, NULL, 0, "st_id2", stmt2);
+ #line 99 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 99 "describe.pgc"
+
+
+     strcpy(msg, "describe");
+     { ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+     ECPGt_descriptor, "desc1", 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 102 "describe.pgc"
+
+     { ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+     ECPGt_descriptor, "desc2", 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 103 "describe.pgc"
+
+     { ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+     ECPGt_descriptor, "desc3", 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 104 "describe.pgc"
+
+     { ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+     ECPGt_descriptor, "desc4", 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 105 "describe.pgc"
+
+
+     strcpy(msg, "get descriptor");
+     { ECPGget_desc_header(__LINE__, "desc1", &(count1));
+
+ #line 108 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 108 "describe.pgc"
+
+     { ECPGget_desc_header(__LINE__, "desc2", &(count2));
+
+ #line 109 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 109 "describe.pgc"
+
+     { ECPGget_desc_header(__LINE__, "desc3", &(count3));
+
+ #line 110 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 110 "describe.pgc"
+
+     { ECPGget_desc_header(__LINE__, "desc4", &(count4));
+
+ #line 111 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 111 "describe.pgc"
+
+
+     if (!(count1 == count2 && count1 == count3 && count1 == count4))
+         exit(1);
+
+     for (i = 1; i <= count1; i++)
+     {
+         { ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
+     ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+
+ #line 118 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 118 "describe.pgc"
+
+         { ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
+     ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+
+ #line 119 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 119 "describe.pgc"
+
+         { ECPGget_desc(__LINE__, "desc3", i,ECPGd_name,
+     ECPGt_char,(field_name3),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+
+ #line 120 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 120 "describe.pgc"
+
+         { ECPGget_desc(__LINE__, "desc4", i,ECPGd_name,
+     ECPGt_char,(field_name4),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+
+ #line 121 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 121 "describe.pgc"
+
+         printf("field_name 1 '%s' 2 '%s' 3 '%s' 4 '%s'\n",
+             field_name1, field_name2, field_name3, field_name4);
+     }
+
+     strcpy(msg, "deallocate");
+     ECPGdeallocate_desc(__LINE__, "desc1");
+ #line 127 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 127 "describe.pgc"
+
+     ECPGdeallocate_desc(__LINE__, "desc2");
+ #line 128 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 128 "describe.pgc"
+
+     ECPGdeallocate_desc(__LINE__, "desc3");
+ #line 129 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 129 "describe.pgc"
+
+     ECPGdeallocate_desc(__LINE__, "desc4");
+ #line 130 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 130 "describe.pgc"
+
+
+     { ECPGdeallocate(__LINE__, 0, NULL, "st_id2");
+ #line 132 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 132 "describe.pgc"
+
+
+
+     /* End test */
+
+     strcpy(msg, "drop");
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT);
+ #line 138 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 138 "describe.pgc"
+
+
+     strcpy(msg, "commit");
+     { ECPGtrans(__LINE__, NULL, "commit");
+ #line 141 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 141 "describe.pgc"
+
+
+     strcpy(msg, "disconnect");
+     { ECPGdisconnect(__LINE__, "CURRENT");
+ #line 144 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 144 "describe.pgc"
+
+
+     return (0);
+ }
diff -dcrpN pgsql.sqlda/src/interfaces/ecpg/test/expected/preproc-describe.stderr
pgsql.describe/src/interfaces/ecpg/test/expected/preproc-describe.stderr
*** pgsql.sqlda/src/interfaces/ecpg/test/expected/preproc-describe.stderr    1970-01-01 01:00:00.000000000 +0100
--- pgsql.describe/src/interfaces/ecpg/test/expected/preproc-describe.stderr    2009-09-15 12:07:39.000000000 +0200
***************
*** 0 ****
--- 1,140 ----
+ [NO_PID]: ECPGdebug: set to 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 29: query: set datestyle to iso; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 29: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 29: OK: SET
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 32: query: create table t1 ( id serial primary key , t text ); with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 32: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 32: OK: CREATE TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 35: query: insert into t1 ( id , t ) values ( default , 'a' ); with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 35: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 35: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: query: insert into t1 ( id , t ) values ( default , 'b' ); with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: query: insert into t1 ( id , t ) values ( default , 'c' ); with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: query: insert into t1 ( id , t ) values ( default , 'd' ); with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 41: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 55: name st_id1; query: "SELECT id, t FROM t1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 88: name st_id1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 99: name st_id2; query: "SELECT id, t FROM t1 WHERE id = -1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 132: name st_id2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 138: query: drop table t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 138: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 138: OK: DROP TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 141: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection regress1 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
diff -dcrpN pgsql.sqlda/src/interfaces/ecpg/test/expected/preproc-describe.stdout
pgsql.describe/src/interfaces/ecpg/test/expected/preproc-describe.stdout
*** pgsql.sqlda/src/interfaces/ecpg/test/expected/preproc-describe.stdout    1970-01-01 01:00:00.000000000 +0100
--- pgsql.describe/src/interfaces/ecpg/test/expected/preproc-describe.stdout    2009-09-15 12:07:39.000000000 +0200
***************
*** 0 ****
--- 1,4 ----
+ field_name 1 'id' 2 'id' 3 'id' 4 'id'
+ field_name 1 't' 2 't' 3 't' 4 't'
+ field_name 1 'id' 2 'id' 3 'id' 4 'id'
+ field_name 1 't' 2 't' 3 't' 4 't'
diff -dcrpN pgsql.sqlda/src/interfaces/ecpg/test/preproc/describe.pgc
pgsql.describe/src/interfaces/ecpg/test/preproc/describe.pgc
*** pgsql.sqlda/src/interfaces/ecpg/test/preproc/describe.pgc    1970-01-01 01:00:00.000000000 +0100
--- pgsql.describe/src/interfaces/ecpg/test/preproc/describe.pgc    2009-09-15 12:07:39.000000000 +0200
***************
*** 0 ****
--- 1,147 ----
+ #include <stdlib.h>
+ #include <string.h>
+
+ exec sql include ../regression;
+
+ exec sql whenever sqlerror stop;
+
+ int
+ main (void)
+ {
+ exec sql begin declare section;
+     char    *stmt1 = "SELECT id, t FROM t1";
+     char    *stmt2 = "SELECT id, t FROM t1 WHERE id = -1";
+     int    i, count1, count2, count3, count4;
+     char    field_name1[30] = "not set";
+     char    field_name2[30] = "not set";
+     char    field_name3[30] = "not set";
+     char    field_name4[30] = "not set";
+ exec sql end declare section;
+
+     char msg[128];
+
+     ECPGdebug(1, stderr);
+
+     strcpy(msg, "connect");
+     exec sql connect to REGRESSDB1;
+
+     strcpy(msg, "set");
+     exec sql set datestyle to iso;
+
+     strcpy(msg, "create");
+     exec sql create table t1(id serial primary key, t text);
+
+     strcpy(msg, "insert");
+     exec sql insert into t1(id, t) values (default, 'a');
+     exec sql insert into t1(id, t) values (default, 'b');
+     exec sql insert into t1(id, t) values (default, 'c');
+     exec sql insert into t1(id, t) values (default, 'd');
+
+     strcpy(msg, "commit");
+     exec sql commit;
+
+     /*
+      * Test DESCRIBE with a query producing tuples.
+      * DESCRIPTOR and SQL DESCRIPTOR are the same in native mode.
+      */
+
+     strcpy(msg, "allocate");
+     exec sql allocate descriptor desc1;
+     exec sql allocate descriptor desc2;
+     exec sql allocate descriptor desc3;
+     exec sql allocate descriptor desc4;
+
+     strcpy(msg, "prepare");
+     exec sql prepare st_id1 FROM :stmt1;
+
+     strcpy(msg, "describe");
+     exec sql describe st_id1 into descriptor desc1;
+     exec sql describe st_id1 into sql descriptor desc2;
+     exec sql describe st_id1 using descriptor desc3;
+     exec sql describe st_id1 using sql descriptor desc4;
+
+     strcpy(msg, "get descriptor");
+     exec sql get descriptor desc1 :count1 = count;
+     exec sql get descriptor desc2 :count2 = count;
+     exec sql get descriptor desc3 :count3 = count;
+     exec sql get descriptor desc4 :count4 = count;
+
+     if (!(count1 == count2 && count1 == count3 && count1 == count4))
+         exit(1);
+
+     for (i = 1; i <= count1; i++)
+     {
+         exec sql get descriptor desc1 value :i :field_name1 = name;
+         exec sql get descriptor desc2 value :i :field_name2 = name;
+         exec sql get descriptor desc3 value :i :field_name3 = name;
+         exec sql get descriptor desc4 value :i :field_name4 = name;
+         printf("field_name 1 '%s' 2 '%s' 3 '%s' 4 '%s'\n",
+             field_name1, field_name2, field_name3, field_name4);
+     }
+
+     strcpy(msg, "deallocate");
+     exec sql deallocate descriptor desc1;
+     exec sql deallocate descriptor desc2;
+     exec sql deallocate descriptor desc3;
+     exec sql deallocate descriptor desc4;
+
+     exec sql deallocate prepare st_id1;
+
+     /* Test DESCRIBE with a query not producing tuples */
+
+     strcpy(msg, "allocate");
+     exec sql allocate descriptor desc1;
+     exec sql allocate descriptor desc2;
+     exec sql allocate descriptor desc3;
+     exec sql allocate descriptor desc4;
+
+     strcpy(msg, "prepare");
+     exec sql prepare st_id2 FROM :stmt2;
+
+     strcpy(msg, "describe");
+     exec sql describe st_id2 into descriptor desc1;
+     exec sql describe st_id2 into sql descriptor desc2;
+     exec sql describe st_id2 using descriptor desc3;
+     exec sql describe st_id2 using sql descriptor desc4;
+
+     strcpy(msg, "get descriptor");
+     exec sql get descriptor desc1 :count1 = count;
+     exec sql get descriptor desc2 :count2 = count;
+     exec sql get descriptor desc3 :count3 = count;
+     exec sql get descriptor desc4 :count4 = count;
+
+     if (!(count1 == count2 && count1 == count3 && count1 == count4))
+         exit(1);
+
+     for (i = 1; i <= count1; i++)
+     {
+         exec sql get descriptor desc1 value :i :field_name1 = name;
+         exec sql get descriptor desc2 value :i :field_name2 = name;
+         exec sql get descriptor desc3 value :i :field_name3 = name;
+         exec sql get descriptor desc4 value :i :field_name4 = name;
+         printf("field_name 1 '%s' 2 '%s' 3 '%s' 4 '%s'\n",
+             field_name1, field_name2, field_name3, field_name4);
+     }
+
+     strcpy(msg, "deallocate");
+     exec sql deallocate descriptor desc1;
+     exec sql deallocate descriptor desc2;
+     exec sql deallocate descriptor desc3;
+     exec sql deallocate descriptor desc4;
+
+     exec sql deallocate prepare st_id2;
+
+
+     /* End test */
+
+     strcpy(msg, "drop");
+     exec sql drop table t1;
+
+     strcpy(msg, "commit");
+     exec sql commit;
+
+     strcpy(msg, "disconnect");
+     exec sql disconnect;
+
+     return (0);
+ }
diff -dcrpN pgsql.sqlda/src/interfaces/ecpg/test/preproc/Makefile
pgsql.describe/src/interfaces/ecpg/test/preproc/Makefile
*** pgsql.sqlda/src/interfaces/ecpg/test/preproc/Makefile    2009-09-03 12:28:03.000000000 +0200
--- pgsql.describe/src/interfaces/ecpg/test/preproc/Makefile    2009-09-15 12:07:39.000000000 +0200
*************** TESTS = array_of_struct array_of_struct.
*** 8,13 ****
--- 8,14 ----
      autoprep autoprep.c \
      comment comment.c \
      cursor cursor.c \
+     describe describe.c \
      define define.c \
      init init.c \
      strings strings.c \

Re: ECPG patchset

From
Boszormenyi Zoltan
Date:
New patch - two decimal-related memory leak fixes.
Happens on 8.4 and 8.5, maybe on older trees as well.
One of the two chunks was in the SQLDA patch originally.
This is independent from any other patches.

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
http://www.postgresql.at/

diff -dcrpN pgsql.ifdef/src/interfaces/ecpg/compatlib/informix.c
pgsql.decimalfix/src/interfaces/ecpg/compatlib/informix.c
*** pgsql.ifdef/src/interfaces/ecpg/compatlib/informix.c    2009-09-03 12:25:47.000000000 +0200
--- pgsql.decimalfix/src/interfaces/ecpg/compatlib/informix.c    2009-09-15 12:35:48.000000000 +0200
*************** deccvasc(char *cp, int len, decimal *np)
*** 232,238 ****
          {
              int            i = PGTYPESnumeric_to_decimal(result, np);

!             free(result);
              if (i != 0)
                  ret = ECPG_INFORMIX_NUM_OVERFLOW;
          }
--- 232,238 ----
          {
              int            i = PGTYPESnumeric_to_decimal(result, np);

!             PGTYPESnumeric_free(result);
              if (i != 0)
                  ret = ECPG_INFORMIX_NUM_OVERFLOW;
          }
diff -dcrpN pgsql.dyncursor/src/interfaces/ecpg/ecpglib/data.c pgsql.sqlda/src/interfaces/ecpg/ecpglib/data.c
*** pgsql.dyncursor/src/interfaces/ecpg/ecpglib/data.c    2009-08-08 17:19:45.000000000 +0200
--- pgsql.sqlda/src/interfaces/ecpg/ecpglib/data.c    2009-09-03 12:56:36.000000000 +0200
*************** ecpg_get_data(const PGresult *results, i
*** 554,560 ****
                      else
                          PGTYPESnumeric_to_decimal(nres, (decimal *) (var + offset * act_tuple));

!                     free(nres);
                      break;

                  case ECPGt_interval:
--- 554,560 ----
                      else
                          PGTYPESnumeric_to_decimal(nres, (decimal *) (var + offset * act_tuple));

!                     PGTYPESnumeric_free(nres);
                      break;

                  case ECPGt_interval:

Re: ECPG patchset

From
Boszormenyi Zoltan
Date:
Disregard the previous one, correct one is attached.

Boszormenyi Zoltan írta:
> New version of the DESCRIBE patch
> Changes:
> - free(sqlda->sqlvar) as well if it's not in the same
>   allocation area as teh main sqlda
> - allow variable name for the prepared stmt in DESCRIBE
>
>
> ------------------------------------------------------------------------
>
>


--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
http://www.postgresql.at/

diff -dcrpN pgsql.sqlda/src/interfaces/ecpg/ecpglib/descriptor.c
pgsql.describe/src/interfaces/ecpg/ecpglib/descriptor.c
*** pgsql.sqlda/src/interfaces/ecpg/ecpglib/descriptor.c    2009-08-07 13:06:28.000000000 +0200
--- pgsql.describe/src/interfaces/ecpg/ecpglib/descriptor.c    2009-09-18 08:32:33.000000000 +0200
***************
*** 13,18 ****
--- 13,19 ----
  #include "ecpgerrno.h"
  #include "extern.h"
  #include "sqlca.h"
+ #include "sqlda.h"
  #include "sql3types.h"

  static void descriptor_free(struct descriptor * desc);
*************** get_char_item(int lineno, void *var, enu
*** 226,231 ****
--- 227,238 ----
      return (true);
  }

+ #define RETURN_IF_NO_DATA    if (ntuples < 1) \
+                 { \
+                     ecpg_raise(lineno, ECPG_NOT_FOUND, ECPG_SQLSTATE_NO_DATA, NULL); \
+                     return (false); \
+                 }
+
  bool
  ECPGget_desc(int lineno, const char *desc_name, int index,...)
  {
*************** ECPGget_desc(int lineno, const char *des
*** 244,254 ****
          return (false);

      ntuples = PQntuples(ECPGresult);
-     if (ntuples < 1)
-     {
-         ecpg_raise(lineno, ECPG_NOT_FOUND, ECPG_SQLSTATE_NO_DATA, NULL);
-         return (false);
-     }

      if (index < 1 || index > PQnfields(ECPGresult))
      {
--- 251,256 ----
*************** ECPGget_desc(int lineno, const char *des
*** 283,288 ****
--- 285,291 ----
          switch (type)
          {
              case (ECPGd_indicator):
+                 RETURN_IF_NO_DATA;
                  data_var.ind_type = vartype;
                  data_var.ind_pointer = var;
                  data_var.ind_varcharsize = varcharsize;
*************** ECPGget_desc(int lineno, const char *des
*** 295,300 ****
--- 298,304 ----
                  break;

              case ECPGd_data:
+                 RETURN_IF_NO_DATA;
                  data_var.type = vartype;
                  data_var.pointer = var;
                  data_var.varcharsize = varcharsize;
*************** ECPGget_desc(int lineno, const char *des
*** 377,382 ****
--- 381,387 ----
              case ECPGd_ret_length:
              case ECPGd_ret_octet:

+                 RETURN_IF_NO_DATA;
                  /*
                   * this is like ECPGstore_result
                   */
*************** ECPGget_desc(int lineno, const char *des
*** 480,485 ****
--- 485,491 ----
      sqlca->sqlerrd[2] = ntuples;
      return (true);
  }
+ #undef RETURN_IF_NO_DATA

  bool
  ECPGset_desc_header(int lineno, const char *desc_name, int count)
*************** ecpg_find_desc(int line, const char *nam
*** 722,730 ****
      return NULL;                /* not found */
  }

  bool
! ECPGdescribe(int line, bool input, const char *statement,...)
  {
!     ecpg_log("ECPGdescribe called on line %d for %s: %s\n", line, input ? "input" : "output", statement);
!     return false;
  }
--- 728,839 ----
      return NULL;                /* not found */
  }

+ static pg_sqlda_t*
+ build_sqlda(int lineno, bool input, const char *connection_name, const char *stmt_name)
+ {
+     struct connection *con;
+     PGresult    *res;
+     pg_sqlda_t    *sqlda = NULL;
+
+     con = ecpg_get_connection(connection_name);
+     res = PQdescribePrepared(con->connection, stmt_name);
+     if (!ecpg_check_PQresult(res, lineno, con->connection, ECPG_COMPAT_INFORMIX))
+         return NULL;
+
+     sqlda = ecpg_build_sqlda_for_PGresult(lineno, res, -1);
+
+     PQclear(res);
+     return sqlda;
+ }
+
  bool
! ECPGdescribe(int line, bool input, const char *connection_name, const char *stmt_name, ...)
  {
!     bool        ret = false;
!     va_list        args;
!
!     /* DESCRIBE INPUT is not yet supported */
!     if (input)
!         return false;
!
!     va_start(args, stmt_name);
!
!     for (;;)
!     {
!         enum ECPGttype    type, dummy_type;
!         void        *ptr, *dummy_ptr;
!         long        dummy;
!
!         /* variable type */
!         type = va_arg(args, enum ECPGttype);
!
!         if (type == ECPGt_EORT)
!             break;
!
!         /* rest of variable parameters*/
!         ptr = va_arg(args, void *);
!         dummy = va_arg(args, long);
!         dummy = va_arg(args, long);
!         dummy = va_arg(args, long);
!
!         /* variable indicator */
!         dummy_type = va_arg(args, enum ECPGttype);
!         dummy_ptr = va_arg(args, void *);
!         dummy = va_arg(args, long);
!         dummy = va_arg(args, long);
!         dummy = va_arg(args, long);
!
!         switch (type)
!         {
!             case ECPGt_descriptor:
!             {
!                 char    *name = ptr;
!                 struct connection *con = ecpg_get_connection(connection_name);
!                 struct descriptor *desc = ecpg_find_desc(line, name);
!                 PGresult    *res;
!                 ExecStatusType  ret;
!
!                 if (con == NULL)
!                     break;
!                 if (desc == NULL)
!                     break;
!
!                 res = PQdescribePrepared(con->connection, stmt_name);
!                 ret = PQresultStatus(res);
!                 if (ecpg_check_PQresult(res, line, con->connection, ECPG_COMPAT_PGSQL))
!                 {
!                     if (desc->result != NULL)
!                         PQclear(desc->result);
!                     desc->result = res;
!                     ret = true;
!                 }
!                 break;
!             }
!             case ECPGt_sqlda:
!             {
!                 pg_sqlda_t **_sqlda = ptr;
!                 pg_sqlda_t *sqlda;
!
!                 sqlda = build_sqlda(line, input, connection_name, stmt_name);
!                 if (sqlda)
!                 {
!                     pg_sqlda_t *sqlda_old = *_sqlda;
!                     if (sqlda_old)
!                     {
!                         if (sqlda->sqlvar != (pg_sqlvar_t *)(sqlda + 1))
!                             free(sqlda->sqlvar);
!                         free(sqlda_old);
!                     }
!                     *_sqlda = sqlda;
!                     ret = true;
!                 }
!                 break;
!             }
!             default:
!                 /* nothing else may come */
!                 ;
!         }
!     }
!
!     return ret;
  }
diff -dcrpN pgsql.sqlda/src/interfaces/ecpg/include/ecpglib.h pgsql.describe/src/interfaces/ecpg/include/ecpglib.h
*** pgsql.sqlda/src/interfaces/ecpg/include/ecpglib.h    2009-06-13 18:25:05.000000000 +0200
--- pgsql.describe/src/interfaces/ecpg/include/ecpglib.h    2009-09-18 08:32:33.000000000 +0200
*************** bool        ECPGset_desc(int, const char *, in
*** 83,89 ****

  void        ECPGset_noind_null(enum ECPGttype, void *);
  bool        ECPGis_noind_null(enum ECPGttype, void *);
! bool        ECPGdescribe(int, bool, const char *,...);

  /* dynamic result allocation */
  void        ECPGfree_auto_mem(void);
--- 83,89 ----

  void        ECPGset_noind_null(enum ECPGttype, void *);
  bool        ECPGis_noind_null(enum ECPGttype, void *);
! bool        ECPGdescribe(int, bool, const char *, const char *, ...);

  /* dynamic result allocation */
  void        ECPGfree_auto_mem(void);
diff -dcrpN pgsql.sqlda/src/interfaces/ecpg/preproc/ecpg.trailer
pgsql.describe/src/interfaces/ecpg/preproc/ecpg.trailer
*** pgsql.sqlda/src/interfaces/ecpg/preproc/ecpg.trailer    2009-09-18 08:31:59.000000000 +0200
--- pgsql.describe/src/interfaces/ecpg/preproc/ecpg.trailer    2009-09-18 09:36:27.000000000 +0200
*************** into_descriptor: INTO opt_sql SQL_DESCRI
*** 1057,1062 ****
--- 1057,1069 ----
          }
          ;

+ into_sqlda: INTO name
+         {
+             add_variable_to_head(&argsresult, sqlda_variable($2), &no_indicator);
+             $$ = EMPTY;
+         }
+         ;
+
  opt_sql: /*EMPTY*/        { $$ = EMPTY; }
          | SQL_SQL    { $$ = make_str("sql"); }
          ;
*************** UsingConst: Iconst            { $$ = $1; }
*** 1088,1113 ****
  /*
   * We accept descibe but do nothing with it so far.
   */
! ECPGDescribe: SQL_DESCRIBE INPUT_P name using_descriptor
      {
          const char *con = connection ? connection : "NULL";
          mmerror(PARSE_ERROR, ET_WARNING, "using unsupported DESCRIBE statement");
!         $$ = (char *) mm_alloc(sizeof("1, ECPGprepared_statement(, \"\", __LINE__)") + strlen(con) + strlen($3));
!         sprintf($$, "1, ECPGprepared_statement(%s, \"%s\", __LINE__)", con, $3);
      }
!     | SQL_DESCRIBE opt_output name using_descriptor
      {
          const char *con = connection ? connection : "NULL";
!         mmerror(PARSE_ERROR, ET_WARNING, "using unsupported DESCRIBE statement");
!         $$ = (char *) mm_alloc(sizeof("0, ECPGprepared_statement(, \"\", __LINE__)") + strlen(con) + strlen($3));
!         sprintf($$, "0, ECPGprepared_statement(%s, \"%s\", __LINE__)", con, $3);
      }
!     | SQL_DESCRIBE opt_output name into_descriptor
      {
          const char *con = connection ? connection : "NULL";
          mmerror(PARSE_ERROR, ET_WARNING, "using unsupported DESCRIBE statement");
!         $$ = (char *) mm_alloc(sizeof("0, ECPGprepared_statement(, \"\", __LINE__)") + strlen(con) + strlen($3));
!         sprintf($$, "0, ECPGprepared_statement(%s, \"%s\", __LINE__)", con, $3);
      }
      ;

--- 1095,1141 ----
  /*
   * We accept descibe but do nothing with it so far.
   */
! ECPGDescribe: SQL_DESCRIBE INPUT_P prepared_name using_descriptor
      {
          const char *con = connection ? connection : "NULL";
          mmerror(PARSE_ERROR, ET_WARNING, "using unsupported DESCRIBE statement");
!         $$ = (char *) mm_alloc(sizeof("1, , ") + strlen(con) + strlen($3));
!         sprintf($$, "1, %s, %s", con, $3);
      }
!     | SQL_DESCRIBE opt_output prepared_name using_descriptor
      {
          const char *con = connection ? connection : "NULL";
!         struct variable *var;
!
!         var = argsinsert->variable;
!         remove_variable_from_list(&argsinsert, var);
!         add_variable_to_head(&argsresult, var, &no_indicator);
!
!         $$ = (char *) mm_alloc(sizeof("0, , ") + strlen(con) + strlen($3));
!         sprintf($$, "0, %s, %s", con, $3);
      }
!     | SQL_DESCRIBE opt_output prepared_name into_descriptor
!     {
!         const char *con = connection ? connection : "NULL";
!         $$ = (char *) mm_alloc(sizeof("0, , ") + strlen(con) + strlen($3));
!         sprintf($$, "0, %s, %s", con, $3);
!     }
!     | SQL_DESCRIBE INPUT_P prepared_name into_sqlda
      {
          const char *con = connection ? connection : "NULL";
          mmerror(PARSE_ERROR, ET_WARNING, "using unsupported DESCRIBE statement");
!         if (!INFORMIX_MODE)
!             mmerror(PARSE_ERROR, ET_ERROR, "Not in Informix compatibility mode");
!         $$ = (char *) mm_alloc(sizeof("1, , ") + strlen(con) + strlen($3));
!         sprintf($$, "1, %s, %s", con, $3);
!     }
!     | SQL_DESCRIBE opt_output prepared_name into_sqlda
!     {
!         const char *con = connection ? connection : "NULL";
!         if (!INFORMIX_MODE)
!             mmerror(PARSE_ERROR, ET_ERROR, "Not in Informix compatibility mode");
!         $$ = (char *) mm_alloc(sizeof("0, , ") + strlen(con) + strlen($3));
!         sprintf($$, "0, %s, %s", con, $3);
      }
      ;

diff -dcrpN pgsql.sqlda/src/interfaces/ecpg/preproc/ecpg.type pgsql.describe/src/interfaces/ecpg/preproc/ecpg.type
*** pgsql.sqlda/src/interfaces/ecpg/preproc/ecpg.type    2009-09-18 08:31:59.000000000 +0200
--- pgsql.describe/src/interfaces/ecpg/preproc/ecpg.type    2009-09-18 08:32:33.000000000 +0200
***************
*** 73,78 ****
--- 73,79 ----
  %type <str> execute_rest
  %type <str> indicator
  %type <str> into_descriptor
+ %type <str> into_sqlda
  %type <str> Iresult
  %type <str> on_off
  %type <str> opt_bit_field
***************
*** 88,94 ****
  %type <str> opt_reference
  %type <str> opt_scale
  %type <str> opt_server
! %type <str> opt_sql
  %type <str> opt_user
  %type <str> opt_opt_value
  %type <str> ora_user
--- 89,95 ----
  %type <str> opt_reference
  %type <str> opt_scale
  %type <str> opt_server
! %type <str> opt_sql
  %type <str> opt_user
  %type <str> opt_opt_value
  %type <str> ora_user
diff -dcrpN pgsql.sqlda/src/interfaces/ecpg/test/compat_informix/describe.pgc
pgsql.describe/src/interfaces/ecpg/test/compat_informix/describe.pgc
*** pgsql.sqlda/src/interfaces/ecpg/test/compat_informix/describe.pgc    1970-01-01 01:00:00.000000000 +0100
--- pgsql.describe/src/interfaces/ecpg/test/compat_informix/describe.pgc    2009-09-18 08:32:33.000000000 +0200
***************
*** 0 ****
--- 1,166 ----
+ #include <stdlib.h>
+ #include <string.h>
+
+ exec sql include ../regression;
+ exec sql include sqlda.h;
+
+ exec sql whenever sqlerror stop;
+
+ pg_sqlda_t    *sqlda1, *sqlda2, *sqlda3;
+
+ int
+ main (void)
+ {
+ exec sql begin declare section;
+     char    *stmt1 = "SELECT id, t FROM t1";
+     char    *stmt2 = "SELECT id, t FROM t1 WHERE id = -1";
+     int    i, count1, count2;
+     char    field_name1[30] = "not set";
+     char    field_name2[30] = "not set";
+ exec sql end declare section;
+
+     char msg[128];
+
+     ECPGdebug(1, stderr);
+
+     strcpy(msg, "connect");
+     exec sql connect to REGRESSDB1;
+
+     strcpy(msg, "set");
+     exec sql set datestyle to iso;
+
+     strcpy(msg, "create");
+     exec sql create table t1(id serial primary key, t text);
+
+     strcpy(msg, "insert");
+     exec sql insert into t1(id, t) values (default, 'a');
+     exec sql insert into t1(id, t) values (default, 'b');
+     exec sql insert into t1(id, t) values (default, 'c');
+     exec sql insert into t1(id, t) values (default, 'd');
+
+     strcpy(msg, "commit");
+     exec sql commit;
+
+     /*
+      * Test DESCRIBE with a query producing tuples.
+      * DESCRIPTOR and SQL DESCRIPTOR are NOT the same in
+      * Informix-compat mode.
+      */
+
+     strcpy(msg, "allocate");
+     exec sql allocate descriptor desc1;
+     exec sql allocate descriptor desc2;
+
+     strcpy(msg, "prepare");
+     exec sql prepare st_id1 FROM :stmt1;
+
+     sqlda1 = sqlda2 = sqlda3 = NULL;
+
+     strcpy(msg, "describe");
+     exec sql describe st_id1 into sql descriptor desc1;
+     exec sql describe st_id1 using sql descriptor desc2;
+
+     exec sql describe st_id1 into descriptor sqlda1;
+     exec sql describe st_id1 using descriptor sqlda2;
+     exec sql describe st_id1 into sqlda3;
+
+     if (sqlda1 == NULL || sqlda1 == NULL || sqlda2 == NULL)
+         exit(1);
+
+     strcpy(msg, "get descriptor");
+     exec sql get descriptor desc1 :count1 = count;
+     exec sql get descriptor desc1 :count2 = count;
+
+     if (!(    count1 == count2 &&
+         count1 == sqlda1->sqld &&
+         count1 == sqlda2->sqld &&
+         count1 == sqlda3->sqld))
+         exit(1);
+
+     for (i = 1; i <= count1; i++)
+     {
+         exec sql get descriptor desc1 value :i :field_name1 = name;
+         exec sql get descriptor desc2 value :i :field_name2 = name;
+         printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
+             "sqlda1 '%s'\n\tsqlda2 '%s'\n\tsqlda3 '%s'\n",
+             i, field_name1, field_name2,
+             sqlda1->sqlvar[i-1].sqlname,
+             sqlda2->sqlvar[i-1].sqlname,
+             sqlda3->sqlvar[i-1].sqlname);
+     }
+
+     strcpy(msg, "deallocate");
+     exec sql deallocate descriptor desc1;
+     exec sql deallocate descriptor desc2;
+     free(sqlda1);
+     free(sqlda2);
+     free(sqlda3);
+
+     exec sql deallocate prepare st_id1;
+
+     /* Test DESCRIBE with a query not producing tuples */
+
+     strcpy(msg, "allocate");
+     exec sql allocate descriptor desc1;
+     exec sql allocate descriptor desc2;
+
+     strcpy(msg, "prepare");
+     exec sql prepare st_id2 FROM :stmt2;
+
+     sqlda1 = sqlda2 = sqlda3 = NULL;
+
+     strcpy(msg, "describe");
+     exec sql describe st_id2 into sql descriptor desc1;
+     exec sql describe st_id2 using sql descriptor desc2;
+
+     exec sql describe st_id2 into descriptor sqlda1;
+     exec sql describe st_id2 using descriptor sqlda2;
+     exec sql describe st_id2 into sqlda3;
+
+     if (sqlda1 == NULL || sqlda1 == NULL || sqlda2 == NULL)
+         exit(1);
+
+     strcpy(msg, "get descriptor");
+     exec sql get descriptor desc1 :count1 = count;
+     exec sql get descriptor desc1 :count2 = count;
+
+     if (!(    count1 == count2 &&
+         count1 == sqlda1->sqld &&
+         count1 == sqlda2->sqld &&
+         count1 == sqlda3->sqld))
+         exit(1);
+
+     for (i = 1; i <= count1; i++)
+     {
+         exec sql get descriptor desc1 value :i :field_name1 = name;
+         exec sql get descriptor desc2 value :i :field_name2 = name;
+         printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
+             "sqlda1 '%s'\n\tsqlda2 '%s'\n\tsqlda3 '%s'\n",
+             i, field_name1, field_name2,
+             sqlda1->sqlvar[i-1].sqlname,
+             sqlda2->sqlvar[i-1].sqlname,
+             sqlda3->sqlvar[i-1].sqlname);
+     }
+
+     strcpy(msg, "deallocate");
+     exec sql deallocate descriptor desc1;
+     exec sql deallocate descriptor desc2;
+     free(sqlda1);
+     free(sqlda2);
+     free(sqlda3);
+
+     exec sql deallocate prepare st_id2;
+
+     /* End test */
+
+     strcpy(msg, "drop");
+     exec sql drop table t1;
+
+     strcpy(msg, "commit");
+     exec sql commit;
+
+     strcpy(msg, "disconnect");
+     exec sql disconnect;
+
+     return (0);
+ }
diff -dcrpN pgsql.sqlda/src/interfaces/ecpg/test/compat_informix/Makefile
pgsql.describe/src/interfaces/ecpg/test/compat_informix/Makefile
*** pgsql.sqlda/src/interfaces/ecpg/test/compat_informix/Makefile    2009-09-18 08:31:59.000000000 +0200
--- pgsql.describe/src/interfaces/ecpg/test/compat_informix/Makefile    2009-09-18 08:32:33.000000000 +0200
*************** override LIBS := -lecpg_compat $(LIBS)
*** 13,18 ****
--- 13,19 ----
  TESTS = test_informix test_informix.c \
          test_informix2 test_informix2.c \
          cursor cursor.c \
+         describe describe.c \
          dec_test dec_test.c \
          rfmtdate rfmtdate.c \
          rfmtlong rfmtlong.c \
*************** test_informix2.c: test_informix2.pgc ../
*** 31,36 ****
--- 32,40 ----
  cursor.c: cursor.pgc ../regression.h
      $(ECPG) -o $@ -I$(srcdir) $<

+ describe.c: describe.pgc ../regression.h
+     $(ECPG) -o $@ -I$(srcdir) $<
+
  sqlda.c: sqlda.pgc ../regression.h
      $(ECPG) -o $@ -I$(srcdir) $<

diff -dcrpN pgsql.sqlda/src/interfaces/ecpg/test/ecpg_schedule pgsql.describe/src/interfaces/ecpg/test/ecpg_schedule
*** pgsql.sqlda/src/interfaces/ecpg/test/ecpg_schedule    2009-09-18 08:31:59.000000000 +0200
--- pgsql.describe/src/interfaces/ecpg/test/ecpg_schedule    2009-09-18 08:32:33.000000000 +0200
*************** test: compat_informix/rfmtlong
*** 5,10 ****
--- 5,11 ----
  test: compat_informix/rnull
  test: compat_informix/cursor
  test: compat_informix/sqlda
+ test: compat_informix/describe
  test: compat_informix/test_informix
  test: compat_informix/test_informix2
  test: connect/test2
*************** test: preproc/array_of_struct
*** 19,24 ****
--- 20,26 ----
  test: preproc/autoprep
  test: preproc/comment
  test: preproc/cursor
+ test: preproc/describe
  test: preproc/define
  test: preproc/init
  test: preproc/strings
diff -dcrpN pgsql.sqlda/src/interfaces/ecpg/test/ecpg_schedule_tcp
pgsql.describe/src/interfaces/ecpg/test/ecpg_schedule_tcp
*** pgsql.sqlda/src/interfaces/ecpg/test/ecpg_schedule_tcp    2009-09-18 08:31:59.000000000 +0200
--- pgsql.describe/src/interfaces/ecpg/test/ecpg_schedule_tcp    2009-09-18 08:32:33.000000000 +0200
*************** test: compat_informix/rfmtlong
*** 5,10 ****
--- 5,11 ----
  test: compat_informix/rnull
  test: compat_informix/cursor
  test: compat_informix/sqlda
+ test: compat_informix/describe
  test: compat_informix/test_informix
  test: compat_informix/test_informix2
  test: connect/test2
*************** test: preproc/array_of_struct
*** 19,24 ****
--- 20,26 ----
  test: preproc/autoprep
  test: preproc/comment
  test: preproc/cursor
+ test: preproc/describe
  test: preproc/define
  test: preproc/init
  test: preproc/strings
diff -dcrpN pgsql.sqlda/src/interfaces/ecpg/test/expected/compat_informix-describe.c
pgsql.describe/src/interfaces/ecpg/test/expected/compat_informix-describe.c
*** pgsql.sqlda/src/interfaces/ecpg/test/expected/compat_informix-describe.c    1970-01-01 01:00:00.000000000 +0100
--- pgsql.describe/src/interfaces/ecpg/test/expected/compat_informix-describe.c    2009-09-18 08:32:33.000000000 +0200
***************
*** 0 ****
--- 1,490 ----
+ /* Processed by ecpg (regression mode) */
+ /* These include files are added by the preprocessor */
+ #include <ecpglib.h>
+ #include <ecpgerrno.h>
+ #include <sqlca.h>
+ /* Needed for informix compatibility */
+ #include <ecpg_informix.h>
+ /* End of automatic include section */
+ #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+
+ #line 1 "describe.pgc"
+ #include <stdlib.h>
+ #include <string.h>
+
+
+ #line 1 "regression.h"
+
+
+
+
+
+
+ #line 4 "describe.pgc"
+
+
+ #line 1 "sqlda.h"
+ /*
+  * $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqlda.h,v 1.4 2009/06/11 14:49:13 momjian Exp $
+  */
+
+ #ifndef POSTGRES_SQLDA_H
+ #define POSTGRES_SQLDA_H
+
+ /* Define Informix "standard" types */
+ #ifndef C_H
+ typedef int        int4;
+ typedef    short        int2;
+ #endif
+ typedef    char        int1;
+
+ typedef    int        mint;
+ typedef    long        mlong;
+
+ typedef    short        MSHORT;
+ typedef    char        MCHAR;
+
+ typedef    unsigned int    uint4;
+ typedef    unsigned short    uint2;
+ typedef    unsigned char    uint1;
+
+ typedef    unsigned int    muint;
+ typedef    unsigned long    mulong;
+
+ typedef    unsigned short    MUSHORT;
+ typedef    unsigned char    MUCHAR;
+
+ #define MI_INT_SIZE     (sizeof(int)    * 8)
+ #define MI_LONG_SIZE    (sizeof(long)   * 8)
+ #define MI_PTR_SIZE     (sizeof(char *) * 8)
+
+ typedef struct sqlvar_struct
+ {
+     int2    sqltype;        /* variable type                */
+     int4    sqllen;            /* length in bytes              */
+     char       *sqldata;        /* pointer to data              */
+     int2       *sqlind;        /* pointer to indicator         */
+     char       *sqlname;        /* variable name                */
+     char       *sqlformat;        /* reserved for future use      */
+     int2    sqlitype;        /* ind variable type            */
+     int2    sqlilen;        /* ind length in bytes          */
+     char       *sqlidata;        /* ind data pointer             */
+     int4    sqlxid;            /* extended id type             */
+     char       *sqltypename;    /* extended type name           */
+     int2    sqltypelen;        /* length of extended type name */
+     int2    sqlownerlen;        /* length of owner name         */
+     int2    sqlsourcetype;        /* source type for distinct of built-ins */
+     char       *sqlownername;    /* owner name                   */
+     int4    sqlsourceid;        /* extended id of source type   */
+
+     /*
+      * sqlilongdata is new.  It supports data that exceeds the 32k
+      * limit.  sqlilen and sqlidata are for backward compatibility
+      * and they have maximum value of <32K.
+      */
+     char       *sqlilongdata;    /* for data field beyond 32K    */
+     int4    sqlflags;        /* for internal use only        */
+     void       *sqlreserved;    /* reserved for future use      */
+ } pg_sqlvar_t;
+
+ typedef struct sqlda
+ {
+     int2        sqld;
+     pg_sqlvar_t       *sqlvar;
+     char        desc_name[19];    /* descriptor name              */
+     int2        desc_occ;    /* size of sqlda structure      */
+     struct sqlda       *desc_next;    /* pointer to next sqlda struct */
+     void           *reserved;    /* reserved for future use */
+ } pg_sqlda_t;
+
+ #endif /* POSTGRES_SQLDA_H */
+
+ #line 5 "describe.pgc"
+
+
+ /* exec sql whenever sqlerror  stop ; */
+ #line 7 "describe.pgc"
+
+
+ pg_sqlda_t    *sqlda1, *sqlda2, *sqlda3;
+
+ int
+ main (void)
+ {
+ /* exec sql begin declare section */
+
+
+
+
+
+
+ #line 15 "describe.pgc"
+  char * stmt1 = "SELECT id, t FROM t1" ;
+
+ #line 16 "describe.pgc"
+  char * stmt2 = "SELECT id, t FROM t1 WHERE id = -1" ;
+
+ #line 17 "describe.pgc"
+  int i , count1 , count2 ;
+
+ #line 18 "describe.pgc"
+  char field_name1 [ 30 ] = "not set" ;
+
+ #line 19 "describe.pgc"
+  char field_name2 [ 30 ] = "not set" ;
+ /* exec sql end declare section */
+ #line 20 "describe.pgc"
+
+
+     char msg[128];
+
+     ECPGdebug(1, stderr);
+
+     strcpy(msg, "connect");
+     { ECPGconnect(__LINE__, 1, "regress1" , NULL, NULL , NULL, 0);
+ #line 27 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 27 "describe.pgc"
+
+
+     strcpy(msg, "set");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
+ #line 30 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 30 "describe.pgc"
+
+
+     strcpy(msg, "create");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "create table t1 ( id serial primary key , t text )",
ECPGt_EOIT,ECPGt_EORT); 
+ #line 33 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 33 "describe.pgc"
+
+
+     strcpy(msg, "insert");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'a' )",
ECPGt_EOIT,ECPGt_EORT); 
+ #line 36 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 36 "describe.pgc"
+
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'b' )",
ECPGt_EOIT,ECPGt_EORT); 
+ #line 37 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 37 "describe.pgc"
+
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'c' )",
ECPGt_EOIT,ECPGt_EORT); 
+ #line 38 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 38 "describe.pgc"
+
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'd' )",
ECPGt_EOIT,ECPGt_EORT); 
+ #line 39 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 39 "describe.pgc"
+
+
+     strcpy(msg, "commit");
+     { ECPGtrans(__LINE__, NULL, "commit");
+ #line 42 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 42 "describe.pgc"
+
+
+     /*
+      * Test DESCRIBE with a query producing tuples.
+      * DESCRIPTOR and SQL DESCRIPTOR are NOT the same in
+      * Informix-compat mode.
+      */
+
+     strcpy(msg, "allocate");
+     ECPGallocate_desc(__LINE__, "desc1");
+ #line 51 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 51 "describe.pgc"
+
+     ECPGallocate_desc(__LINE__, "desc2");
+ #line 52 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 52 "describe.pgc"
+
+
+     strcpy(msg, "prepare");
+     { ECPGprepare(__LINE__, NULL, 0, "st_id1", stmt1);
+ #line 55 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 55 "describe.pgc"
+
+
+     sqlda1 = sqlda2 = sqlda3 = NULL;
+
+     strcpy(msg, "describe");
+     { ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+     ECPGt_descriptor, "desc1", 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 60 "describe.pgc"
+
+     { ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+     ECPGt_descriptor, "desc2", 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 61 "describe.pgc"
+
+
+     { ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+     ECPGt_sqlda, & sqlda1 , 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 63 "describe.pgc"
+
+     { ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+     ECPGt_sqlda, & sqlda2 , 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 64 "describe.pgc"
+
+     { ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+     ECPGt_sqlda, &sqlda3, 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 65 "describe.pgc"
+
+
+     if (sqlda1 == NULL || sqlda1 == NULL || sqlda2 == NULL)
+         exit(1);
+
+     strcpy(msg, "get descriptor");
+     { ECPGget_desc_header(__LINE__, "desc1", &(count1));
+
+ #line 71 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 71 "describe.pgc"
+
+     { ECPGget_desc_header(__LINE__, "desc1", &(count2));
+
+ #line 72 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 72 "describe.pgc"
+
+
+     if (!(    count1 == count2 &&
+         count1 == sqlda1->sqld &&
+         count1 == sqlda2->sqld &&
+         count1 == sqlda3->sqld))
+         exit(1);
+
+     for (i = 1; i <= count1; i++)
+     {
+         { ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
+     ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+
+ #line 82 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 82 "describe.pgc"
+
+         { ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
+     ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+
+ #line 83 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 83 "describe.pgc"
+
+         printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
+             "sqlda1 '%s'\n\tsqlda2 '%s'\n\tsqlda3 '%s'\n",
+             i, field_name1, field_name2,
+             sqlda1->sqlvar[i-1].sqlname,
+             sqlda2->sqlvar[i-1].sqlname,
+             sqlda3->sqlvar[i-1].sqlname);
+     }
+
+     strcpy(msg, "deallocate");
+     ECPGdeallocate_desc(__LINE__, "desc1");
+ #line 93 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 93 "describe.pgc"
+
+     ECPGdeallocate_desc(__LINE__, "desc2");
+ #line 94 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 94 "describe.pgc"
+
+     free(sqlda1);
+     free(sqlda2);
+     free(sqlda3);
+
+     { ECPGdeallocate(__LINE__, 1, NULL, "st_id1");
+ #line 99 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 99 "describe.pgc"
+
+
+     /* Test DESCRIBE with a query not producing tuples */
+
+     strcpy(msg, "allocate");
+     ECPGallocate_desc(__LINE__, "desc1");
+ #line 104 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 104 "describe.pgc"
+
+     ECPGallocate_desc(__LINE__, "desc2");
+ #line 105 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 105 "describe.pgc"
+
+
+     strcpy(msg, "prepare");
+     { ECPGprepare(__LINE__, NULL, 0, "st_id2", stmt2);
+ #line 108 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 108 "describe.pgc"
+
+
+     sqlda1 = sqlda2 = sqlda3 = NULL;
+
+     strcpy(msg, "describe");
+     { ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+     ECPGt_descriptor, "desc1", 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 113 "describe.pgc"
+
+     { ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+     ECPGt_descriptor, "desc2", 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 114 "describe.pgc"
+
+
+     { ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+     ECPGt_sqlda, & sqlda1 , 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 116 "describe.pgc"
+
+     { ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+     ECPGt_sqlda, & sqlda2 , 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 117 "describe.pgc"
+
+     { ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+     ECPGt_sqlda, &sqlda3, 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 118 "describe.pgc"
+
+
+     if (sqlda1 == NULL || sqlda1 == NULL || sqlda2 == NULL)
+         exit(1);
+
+     strcpy(msg, "get descriptor");
+     { ECPGget_desc_header(__LINE__, "desc1", &(count1));
+
+ #line 124 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 124 "describe.pgc"
+
+     { ECPGget_desc_header(__LINE__, "desc1", &(count2));
+
+ #line 125 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 125 "describe.pgc"
+
+
+     if (!(    count1 == count2 &&
+         count1 == sqlda1->sqld &&
+         count1 == sqlda2->sqld &&
+         count1 == sqlda3->sqld))
+         exit(1);
+
+     for (i = 1; i <= count1; i++)
+     {
+         { ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
+     ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+
+ #line 135 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 135 "describe.pgc"
+
+         { ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
+     ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+
+ #line 136 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 136 "describe.pgc"
+
+         printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
+             "sqlda1 '%s'\n\tsqlda2 '%s'\n\tsqlda3 '%s'\n",
+             i, field_name1, field_name2,
+             sqlda1->sqlvar[i-1].sqlname,
+             sqlda2->sqlvar[i-1].sqlname,
+             sqlda3->sqlvar[i-1].sqlname);
+     }
+
+     strcpy(msg, "deallocate");
+     ECPGdeallocate_desc(__LINE__, "desc1");
+ #line 146 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 146 "describe.pgc"
+
+     ECPGdeallocate_desc(__LINE__, "desc2");
+ #line 147 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 147 "describe.pgc"
+
+     free(sqlda1);
+     free(sqlda2);
+     free(sqlda3);
+
+     { ECPGdeallocate(__LINE__, 1, NULL, "st_id2");
+ #line 152 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 152 "describe.pgc"
+
+
+     /* End test */
+
+     strcpy(msg, "drop");
+     { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT);
+ #line 157 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 157 "describe.pgc"
+
+
+     strcpy(msg, "commit");
+     { ECPGtrans(__LINE__, NULL, "commit");
+ #line 160 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 160 "describe.pgc"
+
+
+     strcpy(msg, "disconnect");
+     { ECPGdisconnect(__LINE__, "CURRENT");
+ #line 163 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 163 "describe.pgc"
+
+
+     return (0);
+ }
diff -dcrpN pgsql.sqlda/src/interfaces/ecpg/test/expected/compat_informix-describe.stderr
pgsql.describe/src/interfaces/ecpg/test/expected/compat_informix-describe.stderr
*** pgsql.sqlda/src/interfaces/ecpg/test/expected/compat_informix-describe.stderr    1970-01-01 01:00:00.000000000
+0100
--- pgsql.describe/src/interfaces/ecpg/test/expected/compat_informix-describe.stderr    2009-09-18 08:32:33.000000000
+0200
***************
*** 0 ****
--- 1,100 ----
+ [NO_PID]: ECPGdebug: set to 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 30: query: set datestyle to iso; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 30: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 30: OK: SET
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 33: query: create table t1 ( id serial primary key , t text ); with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 33: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 33: OK: CREATE TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: query: insert into t1 ( id , t ) values ( default , 'a' ); with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: query: insert into t1 ( id , t ) values ( default , 'b' ); with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: query: insert into t1 ( id , t ) values ( default , 'c' ); with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 39: query: insert into t1 ( id , t ) values ( default , 'd' ); with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 39: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 39: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 42: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 55: name st_id1; query: "SELECT id, t FROM t1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 99: name st_id1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 108: name st_id2; query: "SELECT id, t FROM t1 WHERE id = -1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 152: name st_id2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 157: query: drop table t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 157: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 157: OK: DROP TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 160: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection regress1 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
diff -dcrpN pgsql.sqlda/src/interfaces/ecpg/test/expected/compat_informix-describe.stdout
pgsql.describe/src/interfaces/ecpg/test/expected/compat_informix-describe.stdout
*** pgsql.sqlda/src/interfaces/ecpg/test/expected/compat_informix-describe.stdout    1970-01-01 01:00:00.000000000
+0100
--- pgsql.describe/src/interfaces/ecpg/test/expected/compat_informix-describe.stdout    2009-09-18 08:32:33.000000000
+0200
***************
*** 0 ****
--- 1,24 ----
+ 1
+     field_name1 'id'
+     field_name2 'id'
+     sqlda1 'id'
+     sqlda2 'id'
+     sqlda3 'id'
+ 2
+     field_name1 't'
+     field_name2 't'
+     sqlda1 't'
+     sqlda2 't'
+     sqlda3 't'
+ 1
+     field_name1 'id'
+     field_name2 'id'
+     sqlda1 'id'
+     sqlda2 'id'
+     sqlda3 'id'
+ 2
+     field_name1 't'
+     field_name2 't'
+     sqlda1 't'
+     sqlda2 't'
+     sqlda3 't'
diff -dcrpN pgsql.sqlda/src/interfaces/ecpg/test/expected/preproc-describe.c
pgsql.describe/src/interfaces/ecpg/test/expected/preproc-describe.c
*** pgsql.sqlda/src/interfaces/ecpg/test/expected/preproc-describe.c    1970-01-01 01:00:00.000000000 +0100
--- pgsql.describe/src/interfaces/ecpg/test/expected/preproc-describe.c    2009-09-18 08:32:33.000000000 +0200
***************
*** 0 ****
--- 1,481 ----
+ /* Processed by ecpg (regression mode) */
+ /* These include files are added by the preprocessor */
+ #include <ecpglib.h>
+ #include <ecpgerrno.h>
+ #include <sqlca.h>
+ /* End of automatic include section */
+ #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+
+ #line 1 "describe.pgc"
+ #include <stdlib.h>
+ #include <string.h>
+
+
+ #line 1 "regression.h"
+
+
+
+
+
+
+ #line 4 "describe.pgc"
+
+
+ /* exec sql whenever sqlerror  stop ; */
+ #line 6 "describe.pgc"
+
+
+ int
+ main (void)
+ {
+ /* exec sql begin declare section */
+
+
+
+
+
+
+
+
+ #line 12 "describe.pgc"
+  char * stmt1 = "SELECT id, t FROM t1" ;
+
+ #line 13 "describe.pgc"
+  char * stmt2 = "SELECT id, t FROM t1 WHERE id = -1" ;
+
+ #line 14 "describe.pgc"
+  int i , count1 , count2 , count3 , count4 ;
+
+ #line 15 "describe.pgc"
+  char field_name1 [ 30 ] = "not set" ;
+
+ #line 16 "describe.pgc"
+  char field_name2 [ 30 ] = "not set" ;
+
+ #line 17 "describe.pgc"
+  char field_name3 [ 30 ] = "not set" ;
+
+ #line 18 "describe.pgc"
+  char field_name4 [ 30 ] = "not set" ;
+ /* exec sql end declare section */
+ #line 19 "describe.pgc"
+
+
+     char msg[128];
+
+     ECPGdebug(1, stderr);
+
+     strcpy(msg, "connect");
+     { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0);
+ #line 26 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 26 "describe.pgc"
+
+
+     strcpy(msg, "set");
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
+ #line 29 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 29 "describe.pgc"
+
+
+     strcpy(msg, "create");
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table t1 ( id serial primary key , t text )",
ECPGt_EOIT,ECPGt_EORT); 
+ #line 32 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 32 "describe.pgc"
+
+
+     strcpy(msg, "insert");
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'a' )",
ECPGt_EOIT,ECPGt_EORT); 
+ #line 35 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 35 "describe.pgc"
+
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'b' )",
ECPGt_EOIT,ECPGt_EORT); 
+ #line 36 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 36 "describe.pgc"
+
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'c' )",
ECPGt_EOIT,ECPGt_EORT); 
+ #line 37 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 37 "describe.pgc"
+
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'd' )",
ECPGt_EOIT,ECPGt_EORT); 
+ #line 38 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 38 "describe.pgc"
+
+
+     strcpy(msg, "commit");
+     { ECPGtrans(__LINE__, NULL, "commit");
+ #line 41 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 41 "describe.pgc"
+
+
+     /*
+      * Test DESCRIBE with a query producing tuples.
+      * DESCRIPTOR and SQL DESCRIPTOR are the same in native mode.
+      */
+
+     strcpy(msg, "allocate");
+     ECPGallocate_desc(__LINE__, "desc1");
+ #line 49 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 49 "describe.pgc"
+
+     ECPGallocate_desc(__LINE__, "desc2");
+ #line 50 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 50 "describe.pgc"
+
+     ECPGallocate_desc(__LINE__, "desc3");
+ #line 51 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 51 "describe.pgc"
+
+     ECPGallocate_desc(__LINE__, "desc4");
+ #line 52 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 52 "describe.pgc"
+
+
+     strcpy(msg, "prepare");
+     { ECPGprepare(__LINE__, NULL, 0, "st_id1", stmt1);
+ #line 55 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 55 "describe.pgc"
+
+
+     strcpy(msg, "describe");
+     { ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+     ECPGt_descriptor, "desc1", 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 58 "describe.pgc"
+
+     { ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+     ECPGt_descriptor, "desc2", 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 59 "describe.pgc"
+
+     { ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+     ECPGt_descriptor, "desc3", 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 60 "describe.pgc"
+
+     { ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+     ECPGt_descriptor, "desc4", 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 61 "describe.pgc"
+
+
+     strcpy(msg, "get descriptor");
+     { ECPGget_desc_header(__LINE__, "desc1", &(count1));
+
+ #line 64 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 64 "describe.pgc"
+
+     { ECPGget_desc_header(__LINE__, "desc2", &(count2));
+
+ #line 65 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 65 "describe.pgc"
+
+     { ECPGget_desc_header(__LINE__, "desc3", &(count3));
+
+ #line 66 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 66 "describe.pgc"
+
+     { ECPGget_desc_header(__LINE__, "desc4", &(count4));
+
+ #line 67 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 67 "describe.pgc"
+
+
+     if (!(count1 == count2 && count1 == count3 && count1 == count4))
+         exit(1);
+
+     for (i = 1; i <= count1; i++)
+     {
+         { ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
+     ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+
+ #line 74 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 74 "describe.pgc"
+
+         { ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
+     ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+
+ #line 75 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 75 "describe.pgc"
+
+         { ECPGget_desc(__LINE__, "desc3", i,ECPGd_name,
+     ECPGt_char,(field_name3),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+
+ #line 76 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 76 "describe.pgc"
+
+         { ECPGget_desc(__LINE__, "desc4", i,ECPGd_name,
+     ECPGt_char,(field_name4),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+
+ #line 77 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 77 "describe.pgc"
+
+         printf("field_name 1 '%s' 2 '%s' 3 '%s' 4 '%s'\n",
+             field_name1, field_name2, field_name3, field_name4);
+     }
+
+     strcpy(msg, "deallocate");
+     ECPGdeallocate_desc(__LINE__, "desc1");
+ #line 83 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 83 "describe.pgc"
+
+     ECPGdeallocate_desc(__LINE__, "desc2");
+ #line 84 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 84 "describe.pgc"
+
+     ECPGdeallocate_desc(__LINE__, "desc3");
+ #line 85 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 85 "describe.pgc"
+
+     ECPGdeallocate_desc(__LINE__, "desc4");
+ #line 86 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 86 "describe.pgc"
+
+
+     { ECPGdeallocate(__LINE__, 0, NULL, "st_id1");
+ #line 88 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 88 "describe.pgc"
+
+
+     /* Test DESCRIBE with a query not producing tuples */
+
+     strcpy(msg, "allocate");
+     ECPGallocate_desc(__LINE__, "desc1");
+ #line 93 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 93 "describe.pgc"
+
+     ECPGallocate_desc(__LINE__, "desc2");
+ #line 94 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 94 "describe.pgc"
+
+     ECPGallocate_desc(__LINE__, "desc3");
+ #line 95 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 95 "describe.pgc"
+
+     ECPGallocate_desc(__LINE__, "desc4");
+ #line 96 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 96 "describe.pgc"
+
+
+     strcpy(msg, "prepare");
+     { ECPGprepare(__LINE__, NULL, 0, "st_id2", stmt2);
+ #line 99 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 99 "describe.pgc"
+
+
+     strcpy(msg, "describe");
+     { ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+     ECPGt_descriptor, "desc1", 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 102 "describe.pgc"
+
+     { ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+     ECPGt_descriptor, "desc2", 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 103 "describe.pgc"
+
+     { ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+     ECPGt_descriptor, "desc3", 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 104 "describe.pgc"
+
+     { ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+     ECPGt_descriptor, "desc4", 0L, 0L, 0L,
+     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 105 "describe.pgc"
+
+
+     strcpy(msg, "get descriptor");
+     { ECPGget_desc_header(__LINE__, "desc1", &(count1));
+
+ #line 108 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 108 "describe.pgc"
+
+     { ECPGget_desc_header(__LINE__, "desc2", &(count2));
+
+ #line 109 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 109 "describe.pgc"
+
+     { ECPGget_desc_header(__LINE__, "desc3", &(count3));
+
+ #line 110 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 110 "describe.pgc"
+
+     { ECPGget_desc_header(__LINE__, "desc4", &(count4));
+
+ #line 111 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 111 "describe.pgc"
+
+
+     if (!(count1 == count2 && count1 == count3 && count1 == count4))
+         exit(1);
+
+     for (i = 1; i <= count1; i++)
+     {
+         { ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
+     ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+
+ #line 118 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 118 "describe.pgc"
+
+         { ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
+     ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+
+ #line 119 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 119 "describe.pgc"
+
+         { ECPGget_desc(__LINE__, "desc3", i,ECPGd_name,
+     ECPGt_char,(field_name3),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+
+ #line 120 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 120 "describe.pgc"
+
+         { ECPGget_desc(__LINE__, "desc4", i,ECPGd_name,
+     ECPGt_char,(field_name4),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+
+ #line 121 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 121 "describe.pgc"
+
+         printf("field_name 1 '%s' 2 '%s' 3 '%s' 4 '%s'\n",
+             field_name1, field_name2, field_name3, field_name4);
+     }
+
+     strcpy(msg, "deallocate");
+     ECPGdeallocate_desc(__LINE__, "desc1");
+ #line 127 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 127 "describe.pgc"
+
+     ECPGdeallocate_desc(__LINE__, "desc2");
+ #line 128 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 128 "describe.pgc"
+
+     ECPGdeallocate_desc(__LINE__, "desc3");
+ #line 129 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 129 "describe.pgc"
+
+     ECPGdeallocate_desc(__LINE__, "desc4");
+ #line 130 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 130 "describe.pgc"
+
+
+     { ECPGdeallocate(__LINE__, 0, NULL, "st_id2");
+ #line 132 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 132 "describe.pgc"
+
+
+
+     /* End test */
+
+     strcpy(msg, "drop");
+     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT);
+ #line 138 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 138 "describe.pgc"
+
+
+     strcpy(msg, "commit");
+     { ECPGtrans(__LINE__, NULL, "commit");
+ #line 141 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 141 "describe.pgc"
+
+
+     strcpy(msg, "disconnect");
+     { ECPGdisconnect(__LINE__, "CURRENT");
+ #line 144 "describe.pgc"
+
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 144 "describe.pgc"
+
+
+     return (0);
+ }
diff -dcrpN pgsql.sqlda/src/interfaces/ecpg/test/expected/preproc-describe.stderr
pgsql.describe/src/interfaces/ecpg/test/expected/preproc-describe.stderr
*** pgsql.sqlda/src/interfaces/ecpg/test/expected/preproc-describe.stderr    1970-01-01 01:00:00.000000000 +0100
--- pgsql.describe/src/interfaces/ecpg/test/expected/preproc-describe.stderr    2009-09-18 08:32:33.000000000 +0200
***************
*** 0 ****
--- 1,140 ----
+ [NO_PID]: ECPGdebug: set to 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 29: query: set datestyle to iso; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 29: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 29: OK: SET
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 32: query: create table t1 ( id serial primary key , t text ); with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 32: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 32: OK: CREATE TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 35: query: insert into t1 ( id , t ) values ( default , 'a' ); with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 35: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 35: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: query: insert into t1 ( id , t ) values ( default , 'b' ); with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: query: insert into t1 ( id , t ) values ( default , 'c' ); with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: query: insert into t1 ( id , t ) values ( default , 'd' ); with 0 parameter(s) on
connectionregress1 
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 41: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 55: name st_id1; query: "SELECT id, t FROM t1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 88: name st_id1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 99: name st_id2; query: "SELECT id, t FROM t1 WHERE id = -1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 132: name st_id2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 138: query: drop table t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 138: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 138: OK: DROP TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 141: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection regress1 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
diff -dcrpN pgsql.sqlda/src/interfaces/ecpg/test/expected/preproc-describe.stdout
pgsql.describe/src/interfaces/ecpg/test/expected/preproc-describe.stdout
*** pgsql.sqlda/src/interfaces/ecpg/test/expected/preproc-describe.stdout    1970-01-01 01:00:00.000000000 +0100
--- pgsql.describe/src/interfaces/ecpg/test/expected/preproc-describe.stdout    2009-09-18 08:32:33.000000000 +0200
***************
*** 0 ****
--- 1,4 ----
+ field_name 1 'id' 2 'id' 3 'id' 4 'id'
+ field_name 1 't' 2 't' 3 't' 4 't'
+ field_name 1 'id' 2 'id' 3 'id' 4 'id'
+ field_name 1 't' 2 't' 3 't' 4 't'
diff -dcrpN pgsql.sqlda/src/interfaces/ecpg/test/preproc/describe.pgc
pgsql.describe/src/interfaces/ecpg/test/preproc/describe.pgc
*** pgsql.sqlda/src/interfaces/ecpg/test/preproc/describe.pgc    1970-01-01 01:00:00.000000000 +0100
--- pgsql.describe/src/interfaces/ecpg/test/preproc/describe.pgc    2009-09-18 08:32:33.000000000 +0200
***************
*** 0 ****
--- 1,147 ----
+ #include <stdlib.h>
+ #include <string.h>
+
+ exec sql include ../regression;
+
+ exec sql whenever sqlerror stop;
+
+ int
+ main (void)
+ {
+ exec sql begin declare section;
+     char    *stmt1 = "SELECT id, t FROM t1";
+     char    *stmt2 = "SELECT id, t FROM t1 WHERE id = -1";
+     int    i, count1, count2, count3, count4;
+     char    field_name1[30] = "not set";
+     char    field_name2[30] = "not set";
+     char    field_name3[30] = "not set";
+     char    field_name4[30] = "not set";
+ exec sql end declare section;
+
+     char msg[128];
+
+     ECPGdebug(1, stderr);
+
+     strcpy(msg, "connect");
+     exec sql connect to REGRESSDB1;
+
+     strcpy(msg, "set");
+     exec sql set datestyle to iso;
+
+     strcpy(msg, "create");
+     exec sql create table t1(id serial primary key, t text);
+
+     strcpy(msg, "insert");
+     exec sql insert into t1(id, t) values (default, 'a');
+     exec sql insert into t1(id, t) values (default, 'b');
+     exec sql insert into t1(id, t) values (default, 'c');
+     exec sql insert into t1(id, t) values (default, 'd');
+
+     strcpy(msg, "commit");
+     exec sql commit;
+
+     /*
+      * Test DESCRIBE with a query producing tuples.
+      * DESCRIPTOR and SQL DESCRIPTOR are the same in native mode.
+      */
+
+     strcpy(msg, "allocate");
+     exec sql allocate descriptor desc1;
+     exec sql allocate descriptor desc2;
+     exec sql allocate descriptor desc3;
+     exec sql allocate descriptor desc4;
+
+     strcpy(msg, "prepare");
+     exec sql prepare st_id1 FROM :stmt1;
+
+     strcpy(msg, "describe");
+     exec sql describe st_id1 into descriptor desc1;
+     exec sql describe st_id1 into sql descriptor desc2;
+     exec sql describe st_id1 using descriptor desc3;
+     exec sql describe st_id1 using sql descriptor desc4;
+
+     strcpy(msg, "get descriptor");
+     exec sql get descriptor desc1 :count1 = count;
+     exec sql get descriptor desc2 :count2 = count;
+     exec sql get descriptor desc3 :count3 = count;
+     exec sql get descriptor desc4 :count4 = count;
+
+     if (!(count1 == count2 && count1 == count3 && count1 == count4))
+         exit(1);
+
+     for (i = 1; i <= count1; i++)
+     {
+         exec sql get descriptor desc1 value :i :field_name1 = name;
+         exec sql get descriptor desc2 value :i :field_name2 = name;
+         exec sql get descriptor desc3 value :i :field_name3 = name;
+         exec sql get descriptor desc4 value :i :field_name4 = name;
+         printf("field_name 1 '%s' 2 '%s' 3 '%s' 4 '%s'\n",
+             field_name1, field_name2, field_name3, field_name4);
+     }
+
+     strcpy(msg, "deallocate");
+     exec sql deallocate descriptor desc1;
+     exec sql deallocate descriptor desc2;
+     exec sql deallocate descriptor desc3;
+     exec sql deallocate descriptor desc4;
+
+     exec sql deallocate prepare st_id1;
+
+     /* Test DESCRIBE with a query not producing tuples */
+
+     strcpy(msg, "allocate");
+     exec sql allocate descriptor desc1;
+     exec sql allocate descriptor desc2;
+     exec sql allocate descriptor desc3;
+     exec sql allocate descriptor desc4;
+
+     strcpy(msg, "prepare");
+     exec sql prepare st_id2 FROM :stmt2;
+
+     strcpy(msg, "describe");
+     exec sql describe st_id2 into descriptor desc1;
+     exec sql describe st_id2 into sql descriptor desc2;
+     exec sql describe st_id2 using descriptor desc3;
+     exec sql describe st_id2 using sql descriptor desc4;
+
+     strcpy(msg, "get descriptor");
+     exec sql get descriptor desc1 :count1 = count;
+     exec sql get descriptor desc2 :count2 = count;
+     exec sql get descriptor desc3 :count3 = count;
+     exec sql get descriptor desc4 :count4 = count;
+
+     if (!(count1 == count2 && count1 == count3 && count1 == count4))
+         exit(1);
+
+     for (i = 1; i <= count1; i++)
+     {
+         exec sql get descriptor desc1 value :i :field_name1 = name;
+         exec sql get descriptor desc2 value :i :field_name2 = name;
+         exec sql get descriptor desc3 value :i :field_name3 = name;
+         exec sql get descriptor desc4 value :i :field_name4 = name;
+         printf("field_name 1 '%s' 2 '%s' 3 '%s' 4 '%s'\n",
+             field_name1, field_name2, field_name3, field_name4);
+     }
+
+     strcpy(msg, "deallocate");
+     exec sql deallocate descriptor desc1;
+     exec sql deallocate descriptor desc2;
+     exec sql deallocate descriptor desc3;
+     exec sql deallocate descriptor desc4;
+
+     exec sql deallocate prepare st_id2;
+
+
+     /* End test */
+
+     strcpy(msg, "drop");
+     exec sql drop table t1;
+
+     strcpy(msg, "commit");
+     exec sql commit;
+
+     strcpy(msg, "disconnect");
+     exec sql disconnect;
+
+     return (0);
+ }
diff -dcrpN pgsql.sqlda/src/interfaces/ecpg/test/preproc/Makefile
pgsql.describe/src/interfaces/ecpg/test/preproc/Makefile
*** pgsql.sqlda/src/interfaces/ecpg/test/preproc/Makefile    2009-09-18 08:30:51.000000000 +0200
--- pgsql.describe/src/interfaces/ecpg/test/preproc/Makefile    2009-09-18 08:32:33.000000000 +0200
*************** TESTS = array_of_struct array_of_struct.
*** 8,13 ****
--- 8,14 ----
      autoprep autoprep.c \
      comment comment.c \
      cursor cursor.c \
+     describe describe.c \
      define define.c \
      init init.c \
      strings strings.c \