Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit80f7c41

Browse files
committed
Here's my next patch to bring ecpg to version 1.1. It now correctly
handles all transaction commands and the exec sql include command.Michael Meskes
1 parent561aead commit80f7c41

File tree

14 files changed

+270
-90
lines changed

14 files changed

+270
-90
lines changed

‎src/interfaces/ecpg/ChangeLog

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,18 @@ Fri Feb 27 12:00:55 CET 1998
7171
- removed all shift/reduce conflicts
7272
- allow syntax 'fetch cursor' as well as 'fetch in cursor'
7373

74+
Fri Mar 13 11:37:16 CET 1998
75+
76+
- finished transaction handling, needs only one function in ecpglib now
77+
old functions are still supported for compatibility
78+
- set library to version 1.1.0
79+
80+
Fri Mar 13 13:35:13 CET 1998
81+
82+
- exec sql include includes files during parsing
83+
- set parser to version 1.1.0
84+
- added -I option to ecpg to set include path
85+
86+
Mon Mar 16 15:09:10 CET 1998
87+
88+
- fixed parser to print correct filename and line number

‎src/interfaces/ecpg/TODO

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,7 @@ There is no way yet to fill a complete array with one call except arrays of
5959

6060
ecpg cannot use pointer variables except [unsigned] char *
6161

62-
List all commands as sqlcommand, not just S_SYMBOL
62+
List all commands as sqlcommand, not just S_SYMBOL or even better rewrite
63+
pareser to be equivalent to backend�s parser.
64+
65+
Set standard include paths.

‎src/interfaces/ecpg/include/ecpglib.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
#include<c.h>
22

3+
#ifdef__cplusplus
4+
extern"C" {
5+
#endif
6+
37
voidECPGdebug(int,FILE*);
48
boolECPGconnect(constchar*dbname);
59
boolECPGdo(int,char*,...);
6-
boolECPGcommit(int);
7-
boolECPGrollback(int);
10+
boolECPGtrans(int,constchar*);
811
boolECPGfinish(void);
912
boolECPGstatus(void);
1013

1114
voidECPGlog(constchar*format,...);
1215

16+
/* These functions are only kept for compatibility reasons. */
17+
/* Use ECPGtrans instead. */
18+
boolECPGcommit(int);
19+
boolECPGrollback(int);
20+
1321
#ifdefLIBPQ_FE_H
1422
boolECPGsetdb(PGconn*);
1523

@@ -32,3 +40,7 @@ voidsqlprint(void);
3240
/* define this for simplicity as well as compatibility */
3341

3442
#defineSQLCODE sqlca.sqlcode
43+
44+
#ifdef__cplusplus
45+
}
46+
#endif

‎src/interfaces/ecpg/include/ecpgtype.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929
*/
3030
#include<stdio.h>
3131

32+
#ifdef__cplusplus
33+
extern"C" {
34+
#endif
35+
3236
enumECPGttype
3337
{
3438
ECPGt_char=1,ECPGt_unsigned_char,ECPGt_short,ECPGt_unsigned_short,
@@ -45,3 +49,7 @@ enum ECPGttype
4549
#defineIS_SIMPLE_TYPE(type) ((type) >= ECPGt_char && (type) <= ECPGt_varchar2)
4650

4751
constchar*ECPGtype_name(enumECPGttype);
52+
53+
#ifdef__cplusplus
54+
}
55+
#endif

‎src/interfaces/ecpg/include/sqlca.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#ifndefPOSTGRES_SQLCA_H
22
#definePOSTGRES_SQLCA_H
33

4+
#ifdef__cplusplus
5+
extern"C" {
6+
#endif
7+
48
structsqlca
59
{
610
intsqlcode;
@@ -12,3 +16,8 @@ struct sqlca
1216
}sqlca;
1317

1418
#endif
19+
20+
#ifdef__cplusplus
21+
}
22+
#endif
23+

‎src/interfaces/ecpg/lib/Makefile.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ include $(SRCDIR)/Makefile.global
44
PQ_INCLUDE=-I$(SRCDIR)/interfaces/libpq
55

66
SO_MAJOR_VERSION=1
7-
SO_MINOR_VERSION=0
7+
SO_MINOR_VERSION=1
88

99
PORTNAME=@PORTNAME@
1010

‎src/interfaces/ecpg/lib/ecpglib.c

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -572,38 +572,33 @@ ECPGdo(int lineno, char *query,...)
572572

573573

574574
bool
575-
ECPGcommit(intlineno)
575+
ECPGtrans(intlineno,constchar*transaction)
576576
{
577577
PGresult*res;
578578

579-
ECPGlog("ECPGcommit line %d\n",lineno);
580-
if ((res=PQexec(simple_connection,"end"))==NULL)
579+
ECPGlog("ECPGtrans line %d action = %s\n",lineno,transaction);
580+
if ((res=PQexec(simple_connection,transaction))==NULL)
581581
{
582-
register_error(-1,"Errorcommitting line %d.",lineno);
582+
register_error(-1,"Errorin transaction processing line %d.",lineno);
583583
return (FALSE);
584584
}
585585
PQclear(res);
586586
committed=1;
587587
return (TRUE);
588588
}
589589

590+
/* include these for compatibility */
590591
bool
591-
ECPGrollback(intlineno)
592+
ECPGcommit(intlineno)
592593
{
593-
PGresult*res;
594-
595-
ECPGlog("ECPGrollback line %d\n",lineno);
596-
if ((res=PQexec(simple_connection,"abort"))==NULL)
597-
{
598-
register_error(-1,"Error rolling back line %d.",lineno);
599-
return (FALSE);
600-
}
601-
PQclear(res);
602-
committed=1;
603-
return (TRUE);
594+
return(ECPGtrans(lineno,"end"));
604595
}
605596

606-
597+
bool
598+
ECPGrollback(intlineno)
599+
{
600+
return(ECPGtrans(lineno,"abort"));
601+
}
607602

608603
bool
609604
ECPGsetdb(PGconn*newcon)

‎src/interfaces/ecpg/preproc/Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ SRCDIR= ../../..
22
include$(SRCDIR)/Makefile.global
33

44
MAJOR_VERSION=1
5-
MINOR_VERSION=0
5+
MINOR_VERSION=1
66
PATCHLEVEL=0
77

8-
CFLAGS+=-I../include -DMAJOR_VERSION=$(MAJOR_VERSION) -DMINOR_VERSION=$(MINOR_VERSION) -DPATCHLEVEL=$(PATCHLEVEL)
8+
CFLAGS+=-I../include -DMAJOR_VERSION=$(MAJOR_VERSION)\
9+
-DMINOR_VERSION=$(MINOR_VERSION) -DPATCHLEVEL=$(PATCHLEVEL)\
10+
-DINCLUDE_PATH=\"$(DESTDIR)$(HEADERDIR)\"
911

1012
all:: ecpg
1113

‎src/interfaces/ecpg/preproc/ecpg.c

Lines changed: 64 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include<getopt.h>
1010
#else
1111
#include<unistd.h>
12+
externintoptind;
13+
externchar*optarg;
1214
#endif
1315
#include<stdlib.h>
1416
#if defined(HAVE_STRING_H)
@@ -19,19 +21,37 @@
1921

2022
#include"extern.h"
2123

24+
struct_include_path*include_paths;
25+
2226
staticvoid
2327
usage(char*progname)
2428
{
2529
fprintf(stderr,"ecpg - the postgresql preprocessor, version: %d.%d.%d\n",MAJOR_VERSION,MINOR_VERSION,PATCHLEVEL);
26-
fprintf(stderr,"Usage: %s: [-v] [-d] [ -o outout file name] file1 [file2] ...\n",progname);
30+
fprintf(stderr,"Usage: %s: [-v] [-d] [-I include path] [ -o output file name] file1 [file2] ...\n",progname);
31+
}
32+
33+
staticvoid
34+
add_include_path(char*path)
35+
{
36+
struct_include_path*ip=include_paths;
37+
38+
include_paths=mm_alloc(sizeof(struct_include_path));
39+
include_paths->path=path;
40+
include_paths->next=ip;
2741
}
2842

2943
int
3044
main(intargc,char*constargv[])
3145
{
3246
intfnr,c,out_option=0;
33-
34-
while ((c=getopt(argc,argv,"vdo:"))!=EOF)
47+
struct_include_path*ip;
48+
49+
add_include_path("/usr/include");
50+
add_include_path(INCLUDE_PATH);
51+
add_include_path("/usr/local/include");
52+
add_include_path(".");
53+
54+
while ((c=getopt(argc,argv,"vdo:I:"))!=EOF)
3555
{
3656
switch (c)
3757
{
@@ -45,64 +65,71 @@ main(int argc, char *const argv[])
4565
case'd':
4666
debugging=1;
4767
break;
68+
case'I':
69+
add_include_path(optarg);
70+
break;
4871
case'v':
72+
fprintf(stderr,"ecpg - the postgresql preprocessor, version: %d.%d.%d\n",MAJOR_VERSION,MINOR_VERSION,PATCHLEVEL);
73+
fprintf(stderr,"exec sql include ... search starts here:\n");
74+
for (ip=include_paths;ip!=NULL;ip=ip->next)
75+
fprintf(stderr," %s\n",ip->path);
76+
fprintf(stderr,"End of search list.\n");
77+
return (0);
4978
default:
5079
usage(argv[0]);
80+
return (1);
5181
}
5282
}
5383

5484
if (optind >=argc)/* no files specified */
85+
{
5586
usage(argv[0]);
87+
return(1);
88+
}
5689
else
5790
{
5891
/* after the options there must not be anything but filenames */
5992
for (fnr=optind;fnr<argc;fnr++)
6093
{
61-
char*filename,
62-
*ptr2ext;
63-
intext=0;
94+
char*output_filename,*ptr2ext;
6495

65-
filename=mm_alloc(strlen(argv[fnr])+4);
96+
input_filename=mm_alloc(strlen(argv[fnr])+5);
6697

67-
strcpy(filename,argv[fnr]);
98+
strcpy(input_filename,argv[fnr]);
6899

69-
ptr2ext=strrchr(filename,'.');
70-
/* no extension or extension not equal .pgc */
71-
if (ptr2ext==NULL||strcmp(ptr2ext,".pgc")!=0)
100+
ptr2ext=strrchr(input_filename,'.');
101+
/* no extension? */
102+
if (ptr2ext==NULL)
72103
{
73-
if (ptr2ext==NULL)
74-
ext=1;/* we need this information a while later */
75-
ptr2ext=filename+strlen(filename);
104+
ptr2ext=input_filename+strlen(input_filename);
105+
106+
/* no extension => add .pgc */
76107
ptr2ext[0]='.';
108+
ptr2ext[1]='p';
109+
ptr2ext[2]='g';
110+
ptr2ext[3]='c';
111+
ptr2ext[4]='\0';
77112
}
78113

79-
/* make extension = .c */
80-
ptr2ext[1]='c';
81-
ptr2ext[2]='\0';
82-
83114
if (out_option==0)/* calculate the output name */
84115
{
85-
yyout=fopen(filename,"w");
116+
output_filename=strdup(input_filename);
117+
118+
ptr2ext=strrchr(output_filename,'.');
119+
/* make extension = .c */
120+
ptr2ext[1]='c';
121+
ptr2ext[2]='\0';
122+
123+
yyout=fopen(output_filename,"w");
86124
if (yyout==NULL)
87125
{
88-
perror(filename);
89-
free(filename);
126+
perror(output_filename);
127+
free(output_filename);
128+
free(input_filename);
90129
continue;
91130
}
92131
}
93132

94-
if (ext==1)
95-
{
96-
/* no extension => add .pgc */
97-
ptr2ext=strrchr(filename,'.');
98-
ptr2ext[1]='p';
99-
ptr2ext[2]='g';
100-
ptr2ext[3]='c';
101-
ptr2ext[4]='\0';
102-
input_filename=filename;
103-
}
104-
else
105-
input_filename=argv[fnr];
106133
yyin=fopen(input_filename,"r");
107134
if (yyin==NULL)
108135
perror(argv[fnr]);
@@ -117,12 +144,14 @@ main(int argc, char *const argv[])
117144
/* and parse the source */
118145
yyparse();
119146

120-
fclose(yyin);
147+
if (yyin!=NULL)
148+
fclose(yyin);
121149
if (out_option==0)
122150
fclose(yyout);
123151
}
124152

125-
free(filename);
153+
free(output_filename);
154+
free(input_filename);
126155
}
127156
}
128157
return (0);

‎src/interfaces/ecpg/preproc/extern.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ extern intyylineno,
88
externFILE*yyin,
99
*yyout;
1010

11+
struct_include_path {char*path;
12+
struct_include_path*next;
13+
};
14+
15+
externstruct_include_path*include_paths;
1116

1217
/* functions */
1318

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp