1- /* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.30 2006/01/17 19:49:23 meskes Exp $ */
1+ /* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.31 2006/06/06 11:31:55 meskes Exp $ */
22
33#define POSTGRES_ECPG_INTERNAL
44#include "postgres_fe.h"
@@ -462,7 +462,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
462462nres = PGTYPESnumeric_from_asc (pval ,& scan_length );
463463
464464/* did we get an error? */
465- if (errno != 0 )
465+ if (nres == NULL )
466466{
467467ECPGlog ("ECPGget_data line %d: RESULT: %s errno %d\n" ,lineno ,pval ?pval :"" ,errno );
468468
@@ -487,6 +487,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
487487
488488if (garbage_left (isarray ,scan_length ,compat ))
489489{
490+ free (nres );
490491ECPGraise (lineno ,ECPG_NUMERIC_FORMAT ,ECPG_SQLSTATE_DATATYPE_MISMATCH ,pval );
491492return (false);
492493}
@@ -500,6 +501,8 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
500501PGTYPESnumeric_copy (nres , (numeric * ) (var + offset * act_tuple ));
501502else
502503PGTYPESnumeric_to_decimal (nres , (decimal * ) (var + offset * act_tuple ));
504+
505+ free (nres );
503506break ;
504507
505508case ECPGt_interval :
@@ -511,7 +514,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
511514ires = PGTYPESinterval_from_asc (pval ,& scan_length );
512515
513516/* did we get an error? */
514- if (errno != 0 )
517+ if (ires == NULL )
515518{
516519if (INFORMIX_MODE (compat ))
517520{
@@ -534,6 +537,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
534537
535538if (garbage_left (isarray ,scan_length ,compat ))
536539{
540+ free (ires );
537541ECPGraise (lineno ,ECPG_INTERVAL_FORMAT ,ECPG_SQLSTATE_DATATYPE_MISMATCH ,pval );
538542return (false);
539543}
@@ -544,6 +548,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
544548ires = PGTYPESinterval_from_asc ("0 seconds" ,NULL );
545549
546550PGTYPESinterval_copy (ires , (interval * ) (var + offset * act_tuple ));
551+ free (ires );
547552break ;
548553case ECPGt_date :
549554if (pval )