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

Commit9b0e205

Browse files
author
Michael Meskes
committed
*** empty log message ***
1 parent49f68a8 commit9b0e205

File tree

6 files changed

+24
-62
lines changed

6 files changed

+24
-62
lines changed

‎src/interfaces/ecpg/TODO

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ support for dynamic SQL with unknown number of variables with DESCRIPTORS
1313

1414
The line numbering is not exact.
1515

16+
Inside an SQL statement quoting only works with SQL92 style double quotes: ''.
17+
1618
Missing statements:
1719
- exec sql allocate
1820
- exec sql deallocate

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

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -241,41 +241,6 @@ quote_postgres(char *arg, int lineno)
241241
returnres;
242242
}
243243

244-
/* This function returns a newly malloced string that has the \
245-
in the strings inside the argument quoted with another \.
246-
*/
247-
static
248-
char*
249-
quote_strings(char*arg,intlineno)
250-
{
251-
char*res= (char*)ecpg_alloc(2*strlen(arg)+1,lineno);
252-
inti,
253-
ri;
254-
boolstring= false;
255-
256-
if (!res)
257-
return (res);
258-
259-
for (i=0,ri=0;arg[i];i++,ri++)
260-
{
261-
switch (arg[i])
262-
{
263-
case'\'':
264-
string=string ? false : true;
265-
break;
266-
case'\\':
267-
res[ri++]='\\';
268-
default:
269-
;
270-
}
271-
272-
res[ri]=arg[i];
273-
}
274-
res[ri]='\0';
275-
276-
returnres;
277-
}
278-
279244
/*
280245
* create a list of variables
281246
* The variables are listed with input variables preceeding outputvariables
@@ -544,17 +509,8 @@ ECPGexecute(struct statement * stmt)
544509

545510
strncpy(newcopy, (char*)var->value,slen);
546511
newcopy[slen]='\0';
547-
if (!(mallocedval= (char*)ecpg_alloc(2*strlen(newcopy)+1,stmt->lineno)))
548-
return false;
549-
550-
tmp=quote_strings(newcopy,stmt->lineno);
551-
if (!tmp)
552-
return false;
553512

554-
strcat(mallocedval,tmp);
555-
free(newcopy);
556-
557-
tobeinserted=mallocedval;
513+
tobeinserted=newcopy;
558514
}
559515
break;
560516
caseECPGt_varchar:

‎src/interfaces/ecpg/preproc/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ CFLAGS+=-I../include -DMAJOR_VERSION=$(MAJOR_VERSION) \
99
-DMINOR_VERSION=$(MINOR_VERSION) -DPATCHLEVEL=$(PATCHLEVEL)\
1010
-DINCLUDE_PATH=\"$(HEADERDIR)\"
1111

12-
OBJ=preproc.o pgc.o type.o ecpg.o ecpg_keywords.o../../../backend/parser/scansup.o\
12+
OBJ=preproc.o pgc.o type.o ecpg.o ecpg_keywords.o\
1313
keywords.o c_keywords.o ../lib/typename.o
14+
#../../../backend/parser/scansup.o
1415

1516
all:: ecpg
1617

‎src/interfaces/ecpg/preproc/pgc.l

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,8 @@ cppline{space}*#.*(\\{space}*\n)*\n*
248248
}
249249
<xq>{xqstop}{
250250
BEGIN(SQL);
251-
yylval.str =mm_strdup(scanstr(literal));
251+
/* yylval.str = mm_strdup(scanstr(literal));*/
252+
yylval.str =mm_strdup(literal);
252253
return SCONST;
253254
}
254255
<xq>{xqdouble}|
@@ -609,7 +610,8 @@ cppline{space}*#.*(\\{space}*\n)*\n*
609610
if (strcmp(old, ptr->old) ==0)
610611
{
611612
free(ptr->new);
612-
ptr->new =mm_strdup(scanstr(literal));
613+
/* ptr->new = mm_strdup(scanstr(literal));*/
614+
ptr->new =mm_strdup(literal);
613615
}
614616
}
615617
if (ptr ==NULL)
@@ -618,7 +620,8 @@ cppline{space}*#.*(\\{space}*\n)*\n*
618620

619621
/* initial definition */
620622
this->old = old;
621-
this->new =mm_strdup(scanstr(literal));
623+
/* this->new = mm_strdup(scanstr(literal));*/
624+
this->new =mm_strdup(literal);
622625
this->next = defines;
623626
defines =this;
624627
}

‎src/interfaces/ecpg/test/test1.pgc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ exec sql include sqlca;
66
exec sql define AMOUNT 4;
77

88
exec sql type intarray is int[AMOUNT];
9-
exec sql type string is char(6);
9+
exec sql type string is char(8);
1010

1111
typedef int intarray[AMOUNT];
1212

@@ -16,7 +16,7 @@ main ()
1616
exec sql begin declare section;
1717
intarray amount;
1818
int increment=100;
19-
char name[AMOUNT][6];
19+
char name[AMOUNT][8];
2020
char letter[AMOUNT][1];
2121
char command[128];
2222
exec sql end declare section;
@@ -35,8 +35,8 @@ exec sql end declare section;
3535
exec sql connect to pm;
3636

3737
strcpy(msg, "create");
38-
exec sql at main create table test(name char(6), amount int, letter char(1));
39-
exec sql create table test(name char(6), amount int, letter char(1));
38+
exec sql at main create table test(name char(8), amount int, letter char(1));
39+
exec sql create table test(name char(8), amount int, letter char(1));
4040

4141
strcpy(msg, "commit");
4242
exec sql at main commit;
@@ -46,13 +46,13 @@ exec sql end declare section;
4646
exec sql set connection to main;
4747

4848
strcpy(msg, "execute insert 1");
49-
sprintf(command, "insert into test(name, amount, letter) values ('db:mm', 1, 'f')");
49+
sprintf(command, "insert into test(name, amount, letter) values ('db:''mm''', 1, 'f')");
5050
exec sql execute immediate :command;
51-
sprintf(command, "insert into test(name, amount, letter) values ('db:mm', 2, 't')");
51+
sprintf(command, "insert into test(name, amount, letter) values ('db:''mm''', 2, 't')");
5252
exec sql execute immediate :command;
5353

5454
strcpy(msg, "execute insert 2");
55-
sprintf(command, "insert into test(name, amount, letter) values ('db:pm', 1, 'f')");
55+
sprintf(command, "insert into test(name, amount, letter) values ('db:''pm''', 1, 'f')");
5656
exec sql at pm execute immediate :command;
5757

5858
strcpy(msg, "execute insert 3");
@@ -78,12 +78,12 @@ exec sql end declare section;
7878
exec sql select name, amount, letter into :name, :amount, :letter from test;
7979

8080
for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
81-
printf("name[%d]=%6.6s\tamount[%d]=%d\tletter[%d]=%c\n", i, name[i], i, amount[i],i, letter[i][0]);
81+
printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, name[i], i, amount[i],i, letter[i][0]);
8282

8383
exec sql at pm select name, amount, letter into :name, :amount, :letter from test;
8484

8585
for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
86-
printf("name[%d]=%6.6s\tamount[%d]=%d\tletter[%d]=%c\n", i, name[i], i, amount[i],i, letter[i][0]);
86+
printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, name[i], i, amount[i],i, letter[i][0]);
8787

8888
strcpy(msg, "drop");
8989
exec sql drop table test;

‎src/interfaces/ecpg/test/test3.pgc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ exec sql begin declare section;
1818
int children;
1919
int ind_children;
2020
str *married = NULL;
21-
char *testname="Petra";
21+
char *wifesname="Petra";
2222
char *query="select name, born, age, married, children from meskes where name = :var1";
2323
exec sql end declare section;
2424

@@ -32,13 +32,13 @@ exec sql end declare section;
3232
ECPGdebug(1, dbgs);
3333

3434
strcpy(msg, "connect");
35-
exec sql connect to unix:postgresql://localhost:5432/mm;
35+
exec sql connect to unix:postgresql://localhost:5432/mm;
3636

3737
strcpy(msg, "create");
3838
exec sql create table meskes(name char(8), born integer, age smallint, married date, children integer);
3939

4040
strcpy(msg, "insert");
41-
exec sql insert into meskes(name, married, children) values ('Petra', '19900404', 3);
41+
exec sql insert into meskes(name, married, children) values (:wifesname, '19900404', 3);
4242
exec sql insert into meskes(name, born, age, married, children) values ('Michael', 19660117, 33, '19900404', 3);
4343
exec sql insert into meskes(name, born, age) values ('Carsten', 19910103, 8);
4444
exec sql insert into meskes(name, born, age) values ('Marc', 19930907, 5);
@@ -78,7 +78,7 @@ exec sql end declare section;
7878
exec sql declare prep cursor for MM;
7979

8080
strcpy(msg, "open");
81-
exec sql open prep using :testname;
81+
exec sql open prep using :wifesname;
8282

8383
exec sql whenever not found do break;
8484

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp