Commit 38201e21 authored by Marc G. Fournier's avatar Marc G. Fournier

Erk, the whole directory structure changed on us here...

parent a8313f96
# Generated automatically from Makefile.in by configure.
SRCDIR= ../../..
include $(SRCDIR)/Makefile.global
all clean::
@echo Nothing to be done.
install::
install ecpglib.h $(HEADERDIR)
install ecpgtype.h $(HEADERDIR)
install sqlca.h $(HEADERDIR)
uninstall::
rm -f $(HEADERDIR)/ecpglib.h
rm -f $(HEADERDIR)/ecpgtype.h
rm -f $(HEADERDIR)/sqlca.h
SRCDIR= ../../..
include $(SRCDIR)/Makefile.global
all clean::
@echo Nothing to be done.
install::
install ecpglib.h $(HEADERDIR)
install ecpgtype.h $(HEADERDIR)
install sqlca.h $(HEADERDIR)
uninstall::
rm -f $(HEADERDIR)/ecpglib.h
rm -f $(HEADERDIR)/ecpgtype.h
rm -f $(HEADERDIR)/sqlca.h
#include <c.h> #include <c.h>
void ECPGdebug(int); void ECPGdebug(int, FILE *);
bool ECPGconnect(const char * dbname); bool ECPGconnect(const char * dbname);
bool ECPGdo(int, char *, ...); bool ECPGdo(int, char *, ...);
bool ECPGcommit(int); bool ECPGcommit(int);
......
...@@ -32,13 +32,13 @@ ...@@ -32,13 +32,13 @@
enum ECPGttype { enum ECPGttype {
ECPGt_char = 1, ECPGt_unsigned_char, ECPGt_short, ECPGt_unsigned_short, ECPGt_char = 1, ECPGt_unsigned_char, ECPGt_short, ECPGt_unsigned_short,
ECPGt_int, ECPGt_unsigned_int, ECPGt_long, ECPGt_unsigned_long, ECPGt_int, ECPGt_unsigned_int, ECPGt_long, ECPGt_unsigned_long,
ECPGt_bool,
ECPGt_float, ECPGt_double, ECPGt_float, ECPGt_double,
ECPGt_varchar, ECPGt_varchar2, ECPGt_varchar, ECPGt_varchar2,
ECPGt_array, ECPGt_array,
ECPGt_record, ECPGt_record,
ECPGt_EOIT, /* End of insert types. */ ECPGt_EOIT, /* End of insert types. */
ECPGt_EORT /* End of result types. */ ECPGt_EORT /* End of result types. */
}; };
#define IS_SIMPLE_TYPE(type) ((type) >= ECPGt_char && (type) <= ECPGt_varchar2) #define IS_SIMPLE_TYPE(type) ((type) >= ECPGt_char && (type) <= ECPGt_varchar2)
# Generated automatically from Makefile.in by configure. # Generated automatically from Makefile.in by configure.
TOPDIR=/home/meskes/data/computer/databases/postgres/pgsql/src/interfaces/ecpg/../.. SRCDIR= ../../..
PQ_INCLUDE=-I$(TOPDIR)/include -I$(TOPDIR)/interfaces/libpq include $(SRCDIR)/Makefile.global
POSTGRES_LIB=$(POSTGRESTOP)/lib
PQ_INCLUDE=-I$(SRCDIR)/include -I$(SRCDIR)/interfaces/libpq
all: lib all: lib
lib: libecpg.a lib: libecpg.a
clean:: clean:
rm -f *.o *.a core a.out *~ rm -f *.o *.a core a.out *~
install:: libecpg.a install: libecpg.a
install -m644 libecpg.a $(POSTGRES_LIB) install -m 644 libecpg.a $(LIBDIR)
uninstall:: uninstall::
rm -f $(POSTGRES_LIB)/libecpg.a rm -f $(LIBDIR)/libecpg.a
# Rules that do something # Rules that do something
libecpg.a : libecpg.a(ecpglib.o) libecpg.a(typename.o) libecpg.a : libecpg.a(ecpglib.o) libecpg.a(typename.o)
......
TOPDIR=@TOPSRC@ SRCDIR= ../../..
PQ_INCLUDE=-I$(TOPDIR)/include -I$(TOPDIR)/interfaces/libpq include $(SRCDIR)/Makefile.global
POSTGRES_LIB=$(POSTGRESTOP)/lib
PQ_INCLUDE=-I$(SRCDIR)/include -I$(SRCDIR)/interfaces/libpq
all: lib all: lib
lib: libecpg.a lib: libecpg.a
clean:: clean:
rm -f *.o *.a core a.out *~ rm -f *.o *.a core a.out *~
install:: libecpg.a install: libecpg.a
install -m644 libecpg.a $(POSTGRES_LIB) install -m 644 libecpg.a $(LIBDIR)
uninstall:: uninstall::
rm -f $(POSTGRES_LIB)/libecpg.a rm -f $(LIBDIR)/libecpg.a
# Rules that do something # Rules that do something
libecpg.a : libecpg.a(ecpglib.o) libecpg.a(typename.o) libecpg.a : libecpg.a(ecpglib.o) libecpg.a(typename.o)
......
This diff is collapsed.
...@@ -17,6 +17,7 @@ ECPGtype_name(enum ECPGttype typ) ...@@ -17,6 +17,7 @@ ECPGtype_name(enum ECPGttype typ)
case ECPGt_unsigned_long: return "unsigned long"; case ECPGt_unsigned_long: return "unsigned long";
case ECPGt_float: return "float"; case ECPGt_float: return "float";
case ECPGt_double: return "double"; case ECPGt_double: return "double";
case ECPGt_bool: return "bool";
default: default:
abort(); abort();
} }
......
# Generated automatically from Makefile.in by configure. # Generated automatically from Makefile.in by configure.
POSTGRESTOP=@POSTGRESERVER@ SRCDIR= ../../..
POSTGRES_BIN=$(POSTGRESTOP)/bin include $(SRCDIR)/Makefile.global
POSTGRES_LIB=$(POSTGRESTOP)/lib
CC=gcc CC=gcc
LEX=flex LEX=flex
LEXLIB=-lfl LEXLIB=-lfl
YACC=bison -y YACC=/usr/bin/bison
YFLAGS=-y -d
CFLAGS=-I../include -O2 -g -Wall CFLAGS=-I../include -O2 -g -Wall
all:: ecpg all:: ecpg
clean:: clean:
rm -f *.o core a.out ecpg y.tab.h y.tab.c *~ rm -f *.o core a.out ecpg preproc.tab.h y.tab.c *~
install:: all install: all
install -c -d -m755 $(POSTGRES_LIB)/ecpg install -c -m 755 ecpg $(BINDIR)
install -c -m555 preproc $(POSTGRES_LIB)/ecpg
install -c -m555 ecpg $(POSTGRES_BIN)
uninstall:: uninstall:
rm -f $(POSTGRES_BIN)/ecpg rm -f $(BINDIR)/ecpg
rm -f $(POSTGRES_LIB)/ecpg/preproc
# Rule that really do something. # Rule that really do something.
ecpg: y.tab.o pgc.o type.o ecpg.o ecpg: y.tab.o pgc.o type.o ecpg.o
$(CC) -g -O2 -Wall -o ecpg y.tab.o pgc.o type.o ecpg.o -L../lib -lecpg $(LEXLIB) $(CC) -g -O2 -Wall -o ecpg y.tab.o pgc.o type.o ecpg.o -L../lib -lecpg $(LEXLIB)
y.tab.h y.tab.c: preproc.y y.tab.h y.tab.c: preproc.y
$(YACC) -d $< $(YACC) $(YFLAGS) $<
y.tab.o : y.tab.h ../include/ecpgtype.h y.tab.o : y.tab.h ../include/ecpgtype.h
type.o : ../include/ecpgtype.h type.o : ../include/ecpgtype.h
......
POSTGRESTOP=@POSTGRESERVER@ SRCDIR= ../../..
POSTGRES_BIN=$(POSTGRESTOP)/bin include $(SRCDIR)/Makefile.global
POSTGRES_LIB=$(POSTGRESTOP)/lib
CC=@CC@ CC=@CC@
LEX=@LEX@ LEX=@LEX@
LEXLIB=@LEXLIB@ LEXLIB=@LEXLIB@
YACC=@YACC@ YACC=@YACC@
YFLAGS=@YFLAGS@
CFLAGS=-I../include -O2 -g -Wall CFLAGS=-I../include -O2 -g -Wall
all:: ecpg all:: ecpg
clean:: clean:
rm -f *.o core a.out ecpg y.tab.h y.tab.c *~ rm -f *.o core a.out ecpg preproc.tab.h y.tab.c *~
install:: all install: all
install -c -d -m755 $(POSTGRES_LIB)/ecpg install -c -m 755 ecpg $(BINDIR)
install -c -m555 preproc $(POSTGRES_LIB)/ecpg
install -c -m555 ecpg $(POSTGRES_BIN)
uninstall:: uninstall:
rm -f $(POSTGRES_BIN)/ecpg rm -f $(BINDIR)/ecpg
rm -f $(POSTGRES_LIB)/ecpg/preproc
# Rule that really do something. # Rule that really do something.
ecpg: y.tab.o pgc.o type.o ecpg.o ecpg: y.tab.o pgc.o type.o ecpg.o
$(CC) -g -O2 -Wall -o ecpg y.tab.o pgc.o type.o ecpg.o -L../lib -lecpg $(LEXLIB) $(CC) -g -O2 -Wall -o ecpg y.tab.o pgc.o type.o ecpg.o -L../lib -lecpg $(LEXLIB)
y.tab.h y.tab.c: preproc.y y.tab.h y.tab.c: preproc.y
$(YACC) -d $< $(YACC) $(YFLAGS) $<
y.tab.o : y.tab.h ../include/ecpgtype.h y.tab.o : y.tab.h ../include/ecpgtype.h
type.o : ../include/ecpgtype.h type.o : ../include/ecpgtype.h
......
...@@ -8,10 +8,9 @@ ...@@ -8,10 +8,9 @@
#include <strings.h> #include <strings.h>
extern void lex_init(void); extern void lex_init(void);
extern FILE *yyin, extern FILE *yyin, *yyout;
*yyout; extern char * input_filename;
extern int yyparse(void);
int yyparse(void);
static void static void
usage(char *progname) usage(char *progname)
...@@ -22,7 +21,8 @@ usage(char *progname) ...@@ -22,7 +21,8 @@ usage(char *progname)
int int
main(int argc, char *const argv[]) main(int argc, char *const argv[])
{ {
char c, out_option = 0; char c,
out_option = 0;
int fnr; int fnr;
while ((c = getopt(argc, argv, "o:")) != EOF) while ((c = getopt(argc, argv, "o:")) != EOF)
...@@ -58,7 +58,8 @@ main(int argc, char *const argv[]) ...@@ -58,7 +58,8 @@ main(int argc, char *const argv[])
ptr2ext = strrchr(filename, '.'); ptr2ext = strrchr(filename, '.');
/* no extension or extension not equal .pgc */ /* no extension or extension not equal .pgc */
if (ptr2ext == NULL || strcmp(ptr2ext, ".pgc") != 0) { if (ptr2ext == NULL || strcmp(ptr2ext, ".pgc") != 0)
{
ptr2ext = filename + strlen(filename); ptr2ext = filename + strlen(filename);
ptr2ext[0] = '.'; ptr2ext[0] = '.';
} }
...@@ -67,17 +68,18 @@ main(int argc, char *const argv[]) ...@@ -67,17 +68,18 @@ main(int argc, char *const argv[])
ptr2ext[1] = 'c'; ptr2ext[1] = 'c';
ptr2ext[2] = '\0'; ptr2ext[2] = '\0';
if (out_option == 0) /* calculate the output name */ if (out_option == 0) /* calculate the output name */
{ {
yyout = fopen(filename, "w"); yyout = fopen(filename, "w");
if (yyout == NULL) { if (yyout == NULL)
{
perror(filename); perror(filename);
free(filename); free(filename);
continue; continue;
} }
} }
yyin = fopen(argv[fnr], "r"); yyin = fopen(input_filename = argv[fnr], "r");
if (yyin == NULL) if (yyin == NULL)
{ {
perror(argv[fnr]); perror(argv[fnr]);
...@@ -95,7 +97,7 @@ main(int argc, char *const argv[]) ...@@ -95,7 +97,7 @@ main(int argc, char *const argv[])
fclose(yyin); fclose(yyin);
if (out_option == 0) if (out_option == 0)
fclose (yyout); fclose(yyout);
} }
free(filename); free(filename);
......
...@@ -3,8 +3,11 @@ ...@@ -3,8 +3,11 @@
#include "type.h" #include "type.h"
#include "y.tab.h" #include "y.tab.h"
#define dbg(arg) fprintf(stderr, "DEBUG: %s\n", #arg); extern int debugging;
#define dbg(arg) if (debugging) fprintf(stderr, "DEBUG, %d: %s\n", yylineno, #arg);
%} %}
%option yylineno
%s C SQL %s C SQL
ccomment \/\*([^*]|\*[^/]|\*\*[^/])*\*\/ ccomment \/\*([^*]|\*[^/]|\*\*[^/])*\*\/
ws ([ \t\n][ \t\n]*|{ccomment})* ws ([ \t\n][ \t\n]*|{ccomment})*
...@@ -53,7 +56,8 @@ int { dbg(S_INT); return S_INT; } ...@@ -53,7 +56,8 @@ int { dbg(S_INT); return S_INT; }
char { dbg(S_CHAR); return S_CHAR; } char { dbg(S_CHAR); return S_CHAR; }
float { dbg(S_FLOAT); return S_FLOAT; } float { dbg(S_FLOAT); return S_FLOAT; }
double { dbg(S_DOUBLE); return S_DOUBLE; } double { dbg(S_DOUBLE); return S_DOUBLE; }
bool { dbg(S_BOOL); return S_BOOL; }
{string} { dbg(SQL_STRING); return SQL_STRING; } {string} { dbg(SQL_STRING); return SQL_STRING; }
<SQL>{ws} ; <SQL>{ws} ;
{symbol} { dbg(S_SYMBOL); return S_SYMBOL; } {symbol} { dbg(S_SYMBOL); return S_SYMBOL; }
...@@ -100,12 +104,12 @@ double { dbg(S_DOUBLE); return S_DOUBLE; } ...@@ -100,12 +104,12 @@ double { dbg(S_DOUBLE); return S_DOUBLE; }
. { dbg(.); return S_ANYTHING; } . { dbg(.); return S_ANYTHING; }
%% %%
void void
lex_init() lex_init(void)
{ {
BEGIN C; BEGIN C;
} }
int yywrap() int yywrap(void)
{ {
return 1; return 1;
} }
......
...@@ -8,8 +8,26 @@ ...@@ -8,8 +8,26 @@
void yyerror(char *); void yyerror(char *);
extern FILE * yyout; extern FILE * yyout;
extern char * yytext; extern char * yytext;
extern int yylineno;
extern int yyleng; extern int yyleng;
/*
* Variables containing simple states.
*/
int debugging = 0;
/*
* Handle the filename and line numbering.
*/
char * input_filename = NULL;
void
output_line_number()
{
if (input_filename)
fprintf(yyout, "\n#line %d \"%s\"\n", yylineno, input_filename);
}
/* /*
* Handling of the variables. * Handling of the variables.
*/ */
...@@ -144,7 +162,7 @@ dump_variables(struct arguments * list) ...@@ -144,7 +162,7 @@ dump_variables(struct arguments * list)
%token <tagname> S_VARCHAR S_VARCHAR2 %token <tagname> S_VARCHAR S_VARCHAR2
%token <tagname> S_EXTERN S_STATIC %token <tagname> S_EXTERN S_STATIC
%token <tagname> S_UNSIGNED S_SIGNED %token <tagname> S_UNSIGNED S_SIGNED
%token <tagname> S_LONG S_SHORT S_INT S_CHAR S_FLOAT S_DOUBLE %token <tagname> S_LONG S_SHORT S_INT S_CHAR S_FLOAT S_DOUBLE S_BOOL
%token <tagname> '[' ']' ';' ',' %token <tagname> '[' ']' ';' ','
%type <type> type type_detailed varchar_type simple_type array_type %type <type> type type_detailed varchar_type simple_type array_type
...@@ -175,10 +193,12 @@ sqldeclaration : sql_startdeclare ...@@ -175,10 +193,12 @@ sqldeclaration : sql_startdeclare
sql_enddeclare; sql_enddeclare;
sql_startdeclare : SQL_START SQL_BEGIN SQL_DECLARE SQL_SECTION SQL_SEMI { sql_startdeclare : SQL_START SQL_BEGIN SQL_DECLARE SQL_SECTION SQL_SEMI {
printf("/* exec sql begin declare section */\n"); fprintf(yyout, "/* exec sql begin declare section */\n");
output_line_number();
}; };
sql_enddeclare : SQL_START SQL_END SQL_DECLARE SQL_SECTION SQL_SEMI { sql_enddeclare : SQL_START SQL_END SQL_DECLARE SQL_SECTION SQL_SEMI {
printf("/* exec sql end declare section */\n"); fprintf(yyout,"/* exec sql end declare section */\n");
output_line_number();
}; };
variable_declarations : /* empty */ variable_declarations : /* empty */
...@@ -235,7 +255,8 @@ simple_tag : S_CHAR { $<type_enum>$ = ECPGt_char; } ...@@ -235,7 +255,8 @@ simple_tag : S_CHAR { $<type_enum>$ = ECPGt_char; }
| S_LONG { $<type_enum>$ = ECPGt_long; } | S_LONG { $<type_enum>$ = ECPGt_long; }
| S_UNSIGNED S_LONG { $<type_enum>$ = ECPGt_unsigned_long; } | S_UNSIGNED S_LONG { $<type_enum>$ = ECPGt_unsigned_long; }
| S_FLOAT { $<type_enum>$ = ECPGt_float; } | S_FLOAT { $<type_enum>$ = ECPGt_float; }
| S_DOUBLE { $<type_enum>$ = ECPGt_double; }; | S_DOUBLE { $<type_enum>$ = ECPGt_double; }
| S_BOOL { $<type_enum>$ = ECPGt_bool; };
maybe_storage_clause : S_EXTERN { fwrite(yytext, yyleng, 1, yyout); } maybe_storage_clause : S_EXTERN { fwrite(yytext, yyleng, 1, yyout); }
| S_STATIC { fwrite(yytext, yyleng, 1, yyout); } | S_STATIC { fwrite(yytext, yyleng, 1, yyout); }
...@@ -248,17 +269,17 @@ index : '[' length ']' { ...@@ -248,17 +269,17 @@ index : '[' length ']' {
length : S_LENGTH { $<indexsize>$ = atoi(yytext); } length : S_LENGTH { $<indexsize>$ = atoi(yytext); }
sqlinclude : SQL_START SQL_INCLUDE { fprintf(yyout, "#include \""); } sqlinclude : SQL_START SQL_INCLUDE { fprintf(yyout, "#include \""); }
filename SQL_SEMI { fprintf(yyout, ".h\""); }; filename SQL_SEMI { fprintf(yyout, ".h\""); output_line_number(); };
filename : cthing filename : cthing
| filename cthing; | filename cthing;
sqlconnect : SQL_START SQL_CONNECT { fprintf(yyout, "ECPGconnect(\""); } sqlconnect : SQL_START SQL_CONNECT { fprintf(yyout, "ECPGconnect(\""); }
SQL_STRING { fwrite(yytext + 1, yyleng - 2, 1, yyout); } SQL_STRING { fwrite(yytext + 1, yyleng - 2, 1, yyout); }
SQL_SEMI { fprintf(yyout, "\");"); }; SQL_SEMI { fprintf(yyout, "\");"); output_line_number(); };
/* Open is an open cursor. Removed. */ /* Open is an open cursor. Removed. */
sqlopen : SQL_START SQL_OPEN sqlgarbage SQL_SEMI { }; sqlopen : SQL_START SQL_OPEN sqlgarbage SQL_SEMI { output_line_number(); };
sqlgarbage : /* Empty */ sqlgarbage : /* Empty */
| sqlgarbage sqlanything; | sqlgarbage sqlanything;
...@@ -266,9 +287,11 @@ sqlgarbage : /* Empty */ ...@@ -266,9 +287,11 @@ sqlgarbage : /* Empty */
sqlcommit : SQL_START SQL_COMMIT SQL_SEMI { sqlcommit : SQL_START SQL_COMMIT SQL_SEMI {
fprintf(yyout, "ECPGcommit(__LINE__);"); fprintf(yyout, "ECPGcommit(__LINE__);");
output_line_number();
}; };
sqlrollback : SQL_START SQL_ROLLBACK SQL_SEMI { sqlrollback : SQL_START SQL_ROLLBACK SQL_SEMI {
fprintf(yyout, "ECPGrollback(__LINE__);"); fprintf(yyout, "ECPGrollback(__LINE__);");
output_line_number();
}; };
sqlstatement : SQL_START { /* Reset stack */ sqlstatement : SQL_START { /* Reset stack */
...@@ -283,6 +306,7 @@ sqlstatement : SQL_START { /* Reset stack */ ...@@ -283,6 +306,7 @@ sqlstatement : SQL_START { /* Reset stack */
fprintf(yyout, "ECPGt_EOIT, "); fprintf(yyout, "ECPGt_EOIT, ");
dump_variables(argsresult); dump_variables(argsresult);
fprintf(yyout, "ECPGt_EORT );"); fprintf(yyout, "ECPGt_EORT );");
output_line_number();
}; };
sqlstatement_words : sqlstatement_word sqlstatement_words : sqlstatement_word
......
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdlib.h>
#include "type.h" #include "type.h"
...@@ -134,55 +133,59 @@ ECPGdump_a_simple(FILE * o, const char * name, enum ECPGttype typ, ...@@ -134,55 +133,59 @@ ECPGdump_a_simple(FILE * o, const char * name, enum ECPGttype typ,
switch (typ) switch (typ)
{ {
case ECPGt_char: case ECPGt_char:
fprintf(o, "ECPGt_char,&%s,0,%d,%s, ", name, arrsiz, fprintf(o, "\n\tECPGt_char,&%s,0,%d,%s, ", name, arrsiz,
siz == NULL ? "sizeof(char)" : siz); siz == NULL ? "sizeof(char)" : siz);
break; break;
case ECPGt_unsigned_char: case ECPGt_unsigned_char:
fprintf(o, "ECPGt_unsigned_char,&%s,0,%d,%s, ", name, arrsiz, fprintf(o, "\n\tECPGt_unsigned_char,&%s,0,%d,%s, ", name, arrsiz,
siz == NULL ? "sizeof(unsigned char)" : siz); siz == NULL ? "sizeof(unsigned char)" : siz);
break; break;
case ECPGt_short: case ECPGt_short:
fprintf(o, "ECPGt_short,&%s,0,%d,%s, ", name, arrsiz, fprintf(o, "\n\tECPGt_short,&%s,0,%d,%s, ", name, arrsiz,
siz == NULL ? "sizeof(short)" : siz); siz == NULL ? "sizeof(short)" : siz);
break; break;
case ECPGt_unsigned_short: case ECPGt_unsigned_short:
fprintf(o, fprintf(o,
"ECPGt_unsigned_short,&%s,0,%d,%s, ", name, arrsiz, "\n\tECPGt_unsigned_short,&%s,0,%d,%s, ", name, arrsiz,
siz == NULL ? "sizeof(unsigned short)" : siz); siz == NULL ? "sizeof(unsigned short)" : siz);
break; break;
case ECPGt_int: case ECPGt_int:
fprintf(o, "ECPGt_int,&%s,0,%d,%s, ", name, arrsiz, fprintf(o, "\n\tECPGt_int,&%s,0,%d,%s, ", name, arrsiz,
siz == NULL ? "sizeof(int)" : siz); siz == NULL ? "sizeof(int)" : siz);
break; break;
case ECPGt_unsigned_int: case ECPGt_unsigned_int:
fprintf(o, "ECPGt_unsigned_int,&%s,0,%d,%s, ", name, arrsiz, fprintf(o, "\n\tECPGt_unsigned_int,&%s,0,%d,%s, ", name, arrsiz,
siz == NULL ? "sizeof(unsigned int)" : siz); siz == NULL ? "sizeof(unsigned int)" : siz);
break; break;
case ECPGt_long: case ECPGt_long:
fprintf(o, "ECPGt_long,&%s,0,%d,%s, ", name, arrsiz, fprintf(o, "\n\tECPGt_long,&%s,0,%d,%s, ", name, arrsiz,
siz == NULL ? "sizeof(long)" : siz); siz == NULL ? "sizeof(long)" : siz);
break; break;
case ECPGt_unsigned_long: case ECPGt_unsigned_long:
fprintf(o, "ECPGt_unsigned_int,&%s,0,%d,%s, ", name, arrsiz, fprintf(o, "\n\tECPGt_unsigned_int,&%s,0,%d,%s, ", name, arrsiz,
siz == NULL ? "sizeof(unsigned int)" : siz); siz == NULL ? "sizeof(unsigned int)" : siz);
break; break;
case ECPGt_float: case ECPGt_float:
fprintf(o, "ECPGt_float,&%s,0,%d,%s, ", name, arrsiz, fprintf(o, "\n\tECPGt_float,&%s,0,%d,%s, ", name, arrsiz,
siz == NULL ? "sizeof(float)" : siz); siz == NULL ? "sizeof(float)" : siz);
break; break;
case ECPGt_double: case ECPGt_double:
fprintf(o, "ECPGt_double,&%s,0,%d,%s, ", name, arrsiz, fprintf(o, "\n\tECPGt_double,&%s,0,%d,%s, ", name, arrsiz,
siz == NULL ? "sizeof(double)" : siz); siz == NULL ? "sizeof(double)" : siz);
break; break;
case ECPGt_bool:
fprintf(o, "\n\tECPGt_bool,&%s,0,%d,%s, ", name, arrsiz,
siz == NULL ? "sizeof(bool)" : siz);
break;
case ECPGt_varchar: case ECPGt_varchar:
case ECPGt_varchar2: case ECPGt_varchar2:
if (siz == NULL) if (siz == NULL)
fprintf(o, "ECPGt_varchar,&%s,%d,%d,sizeof(struct varchar_%s), ", fprintf(o, "\n\tECPGt_varchar,&%s,%d,%d,sizeof(struct varchar_%s), ",
name, name,
varcharsize, varcharsize,
arrsiz, name); arrsiz, name);
else else
fprintf(o, "ECPGt_varchar,&%s,%d,%d,%s, ", fprintf(o, "\n\tECPGt_varchar,&%s,%d,%d,%s, ",
name, name,
varcharsize, varcharsize,
arrsiz, siz); arrsiz, siz);
......
typedef union {
int tagname;
struct ECPGtemp_type type;
char * symbolname;
int indexsize;
enum ECPGttype type_enum;
} YYSTYPE;
#define SQL_START 258
#define SQL_SEMI 259
#define SQL_STRING 260
#define SQL_INTO 261
#define SQL_BEGIN 262
#define SQL_END 263
#define SQL_DECLARE 264
#define SQL_SECTION 265
#define SQL_INCLUDE 266
#define SQL_CONNECT 267
#define SQL_OPEN 268
#define SQL_COMMIT 269
#define SQL_ROLLBACK 270
#define S_SYMBOL 271
#define S_LENGTH 272
#define S_ANYTHING 273
#define S_VARCHAR 274
#define S_VARCHAR2 275
#define S_EXTERN 276
#define S_STATIC 277
#define S_UNSIGNED 278
#define S_SIGNED 279
#define S_LONG 280
#define S_SHORT 281
#define S_INT 282
#define S_CHAR 283
#define S_FLOAT 284
#define S_DOUBLE 285
#define S_BOOL 286
extern YYSTYPE yylval;
# Generated automatically from Makefile.in by configure.
POSTGRESTOP=@POSTGRESERVER@
POSTGRES_INCLUDE=$(POSTGRESTOP)/include
all clean::
@echo Nothing to be done.
install::
install ecpglib.h $(POSTGRES_INCLUDE)
install ecpgtype.h $(POSTGRES_INCLUDE)
install sqlca.h $(POSTGRES_INCLUDE)
uninstall::
rm -f $(POSTGRES_INCLUDE)/ecpglib.h
rm -f $(POSTGRES_INCLUDE)/ecpgtype.h
rm -f $(POSTGRES_INCLUDE)/sqlca.h
POSTGRESTOP=@POSTGRESERVER@
POSTGRES_INCLUDE=$(POSTGRESTOP)/include
all clean::
@echo Nothing to be done.
install::
install ecpglib.h $(POSTGRES_INCLUDE)
install ecpgtype.h $(POSTGRES_INCLUDE)
install sqlca.h $(POSTGRES_INCLUDE)
uninstall::
rm -f $(POSTGRES_INCLUDE)/ecpglib.h
rm -f $(POSTGRES_INCLUDE)/ecpgtype.h
rm -f $(POSTGRES_INCLUDE)/sqlca.h
This diff is collapsed.
#!/bin/sh
INFILE=
OUTFILE=
for arg
do
case "$arg" in
iname=*)
INFILE=`expr substr $arg 7 1000`
;;
oname=*)
OUTFILE=`expr substr $arg 7 1000`
;;
*)
echo Wrong argument $arg
exit 1;
;;
esac
done
if [ -n "$INFILE" -a -n "$OUTFILE" ]
then
exec @POSTGRESERVER@/lib/ecpg/preproc < $INFILE > $OUTFILE
else
echo Missing arguments.
echo usage: $0 iname=file oname=outfile
exit 1;
fi
exit 0;
all: test2 perftest
test2: test2.c test2: test2.c
gcc -g -I ../include -I ../../../libpq -o test2 test2.c ../lib/libecpg.a ../../../libpq/libpq.a -lcrypt gcc -g -I ../include -I ../../../libpq -o test2 test2.c ../lib/libecpg.a ../../../libpq/libpq.a -lcrypt
test2.c: test2.pgc test2.c: test2.pgc
../preproc/ecpg test2.pgc ../preproc/ecpg test2.pgc
perftest: perftest.c
gcc -g -I ../include -I ../../../libpq -o perftest perftest.c ../lib/libecpg.a ../../../libpq/libpq.a -lcrypt
perftest.c: perftest.pgc
../preproc/ecpg perftest.pgc
clean: clean:
/bin/rm test2 test2.c /bin/rm test2 test2.c perftest perftest.c
#include <stdio.h>
#include <sys/time.h>
#include <unistd.h>
exec sql include sqlca;
#define SQLCODE sqlca.sqlcode
void
db_error (char *msg)
{
sqlca.sqlerrm.sqlerrmc[sqlca.sqlerrm.sqlerrml] = '\0';
printf ("%s: db error %s\n", msg, sqlca.sqlerrm.sqlerrmc);
exit (1);
}
int
main ()
{
exec sql begin declare section;
long i;
exec sql end declare section;
struct timeval tvs, tve;
gettimeofday(&tvs, NULL);
exec sql connect 'mm';
if (SQLCODE)
db_error ("connect");
exec sql create table perftest(number int4, ascii char16);
if (SQLCODE)
db_error ("create t");
exec sql create unique index number on perftest(number);
if (SQLCODE)
db_error ("create i");
for (i = 0;i < 1407; i++)
{
exec sql begin declare section;
char text[16];
exec sql end declare section;
sprintf(text, "%ld", i);
exec sql insert into perftest(number, ascii) values (:i, :text);
if (SQLCODE)
db_error ("insert");
exec sql commit;
if (SQLCODE)
db_error ("commit");
}
exec sql drop index number;
if (SQLCODE)
db_error ("drop i");
exec sql drop table perftest;
if (SQLCODE)
db_error ("drop t");
exec sql commit;
if (SQLCODE)
db_error ("commit");
gettimeofday(&tve, NULL);
printf("I needed %ld seconds and %ld microseconds for this test\n", tve.tv_sec - tvs.tv_sec, tve.tv_usec - tvs.tv_usec);
return (0);
}
exec sql include sqlca;
#define SQLCODE sqlca.sqlcode
void
db_error (char *msg)
{
sqlca.sqlerrm.sqlerrmc[sqlca.sqlerrm.sqlerrml] = '\0';
printf ("%s: db error %s\n", msg, sqlca.sqlerrm.sqlerrmc);
exit (1);
}
int
main ()
{
exec sql begin declare section;
varchar text[8];
int count;
double control;
exec sql end declare section;
exec sql connect 'mm';
if (SQLCODE)
db_error ("connect");
exec sql declare cur cursor for
select text, control, count from test;
if (SQLCODE) db_error ("declare");
exec sql open cur;
if (SQLCODE)
db_error ("open");
while (1) {
exec sql fetch in cur into :text, :control, :count;
if (SQLCODE)
break;
printf ("%8.8s %d %f\n", text.arr, count, control);
}
if (SQLCODE < 0)
db_error ("fetch");
exec sql close cur;
if (SQLCODE) db_error ("close");
exec sql commit;
if (SQLCODE) db_error ("commit");
return (0);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment