-/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.1 2003/03/16 10:42:53 meskes Exp $ */
+/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.2 2003/03/18 10:46:39 meskes Exp $ */
/*
* The aim is to get a simpler inteface to the database routines.
}
else
{
- *str = PGTYPESnumeric_ntoa((NumericVar *)(var->value));
+ str = PGTYPESnumeric_ntoa((NumericVar *)(var->value));
slen = strlen (str);
if (!(mallocedval = ECPGalloc(slen + 1, stmt->lineno)))
--- /dev/null
+#include <pgtypes_numeric.h>
+
+#ifndef dec_t
+#define dec_t NumericVar
+#endif /* dec_t */
#define PGTYPES_OVERFLOW 201
#define PGTYPES_BAD_NUMERIC 202
#define PGTYPES_DIVIDE_ZERO 203
+
+#define PGTYPES_BAD_DATE 300
+
return (new);
}
+#if 0
/* ----------
* apply_typmod() -
*
var->dscale = scale;
return (0);
}
+#endif
/* ----------
* alloc_var() -
{
NumericVar *value = (NumericVar *)pgtypes_alloc(sizeof(NumericVar));
int ret;
+#if 0
long typmod = -1;
+#endif
char *realptr;
char **ptr = (endptr != NULL) ? endptr : &realptr;
if (ret)
return (NULL);
+#if 0
ret = apply_typmod(value, typmod);
if (ret)
return (NULL);
-
+#endif
return(value);
}
-# $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Makefile,v 1.90 2003/02/14 13:17:13 meskes Exp $
+# $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Makefile,v 1.91 2003/03/18 10:46:39 meskes Exp $
subdir = src/interfaces/ecpg/preproc
top_builddir = ../../../..
endif
OBJS=preproc.o type.o ecpg.o ecpg_keywords.o output.o\
- keywords.o c_keywords.o ../lib/typename.o descriptor.o variable.o
+ keywords.o c_keywords.o ../ecpglib/typename.o descriptor.o variable.o
all: submake-libpgport ecpg
-/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.62 2003/03/16 10:42:54 meskes Exp $ */
+/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.63 2003/03/18 10:46:39 meskes Exp $ */
/* New main for ecpg, the PostgreSQL embedded SQL precompiler. */
/* (C) Michael Meskes <meskes@postgresql.org> Feb 5th, 1998 */
#include "postgres_fe.h"
#include <unistd.h>
+#include <string.h>
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#endif
add_preprocessor_define(char *define)
{
struct _defines *pd = defines;
-
+ char *ptr, *define_copy = mm_strdup(define);
+
defines = mm_alloc(sizeof(struct _defines));
- defines->old = strdup(define);
- defines->new = strdup("");
+
+ /* look for = sign */
+ ptr = strchr(define_copy, '=');
+ if (ptr != NULL)
+ {
+ char *tmp;
+
+ /* symbol gets a value */
+ for (tmp=ptr-1; *tmp == ' '; tmp--);
+ tmp[1] = '\0';
+ defines->old = define_copy;
+ defines->new = ptr+1;
+ }
+ else
+ {
+ defines->old = define_copy;
+ defines->new = mm_strdup("");
+ }
defines->pertinent = true;
defines->next = pd;
}
break;
case 'C':
if (strcmp(optarg, "INFORMIX") == 0)
+ {
compat = ECPG_COMPAT_INFORMIX;
+ add_preprocessor_define("dec_t=NumericVar");
+ }
else
{
fprintf(stderr, "Try '%s --help' for more information.\n", argv[0]);
lex_init();
/* we need several includes */
- fprintf(yyout, "/* Processed by ecpg (%d.%d.%d) */\n/* These four include files are added by the preprocessor */\n#include <ecpgtype.h>\n#include <ecpglib.h>\n#include <ecpgerrno.h>\n#include <sqlca.h>\n#include <pgtypes_numeric.h>\n#line 1 \"%s\"\n", MAJOR_VERSION, MINOR_VERSION, PATCHLEVEL, input_filename);
+ fprintf(yyout, "/* Processed by ecpg (%d.%d.%d) */\n/* These four include files are added by the preprocessor */\n#include <ecpgtype.h>\n#include <ecpglib.h>\n#include <ecpgerrno.h>\n#include <sqlca.h>\n#line 1 \"%s\"\n", MAJOR_VERSION, MINOR_VERSION, PATCHLEVEL, input_filename);
/* add some compatibility headers */
if (compat == ECPG_COMPAT_INFORMIX)
#include <stdio.h>
+#include <pgtypes_numeric.h>
int
main()
{
char *text="error\n";
- NumericVar *value1, *value2, *res;
+ NumericVar *value1, *value2, *res;
exec sql begin declare section;
decimal(14,7) des = {0, 0, 0, 0, 0, NULL, NULL} ;
exec sql end declare section;
text = PGTYPESnumeric_ntoa(value1);
printf("long = %s\n", text);
- value1 = PGTYPESnumeric_aton("2369.7", -1);
- value2 = PGTYPESnumeric_aton("10.0", -1);
+ value1 = PGTYPESnumeric_aton("2369.7", NULL);
+ value2 = PGTYPESnumeric_aton("10.0", NULL);
res = PGTYPESnew();
decadd(value1, value2, res);
text = PGTYPESnumeric_ntoa(res);
PGTYPESnumeric_copy(res, &des);
exec sql insert into test (text, num) values ('test', :des);
- value2 = PGTYPESnumeric_aton("2369.7", -1);
+ value2 = PGTYPESnumeric_aton("2369.7", NULL);
PGTYPESnumeric_mul(value1, value2, res);
exec sql select num into :des from test where text = 'test';
text = PGTYPESnumeric_ntoa(res);
printf("mul = %s\n", text);
- value2 = PGTYPESnumeric_aton("10000", -1);
+ value2 = PGTYPESnumeric_aton("10000", NULL);
PGTYPESnumeric_div(res, value2, res);
text = PGTYPESnumeric_ntoa(res);
PGTYPESnumeric_ntod(res, &d);
char *connection="pm";
int how_many;
exec sql end declare section;
- exec sql var name is string(AMOUNT);
+ exec sql var name is string[AMOUNT];
char msg[128];
FILE *dbgs;
int i,j;