Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
9b0e2057
G
Gpdb
项目概览
Greenplum
/
Gpdb
通知
7
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gpdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9b0e2057
编写于
6月 29, 1999
作者:
M
Michael Meskes
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
*** empty log message ***
上级
49f68a85
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
24 addition
and
62 deletion
+24
-62
src/interfaces/ecpg/TODO
src/interfaces/ecpg/TODO
+2
-0
src/interfaces/ecpg/lib/ecpglib.c
src/interfaces/ecpg/lib/ecpglib.c
+1
-45
src/interfaces/ecpg/preproc/Makefile
src/interfaces/ecpg/preproc/Makefile
+2
-1
src/interfaces/ecpg/preproc/pgc.l
src/interfaces/ecpg/preproc/pgc.l
+6
-3
src/interfaces/ecpg/test/test1.pgc
src/interfaces/ecpg/test/test1.pgc
+9
-9
src/interfaces/ecpg/test/test3.pgc
src/interfaces/ecpg/test/test3.pgc
+4
-4
未找到文件。
src/interfaces/ecpg/TODO
浏览文件 @
9b0e2057
...
...
@@ -13,6 +13,8 @@ support for dynamic SQL with unknown number of variables with DESCRIPTORS
The line numbering is not exact.
Inside an SQL statement quoting only works with SQL92 style double quotes: ''.
Missing statements:
- exec sql allocate
- exec sql deallocate
...
...
src/interfaces/ecpg/lib/ecpglib.c
浏览文件 @
9b0e2057
...
...
@@ -241,41 +241,6 @@ quote_postgres(char *arg, int lineno)
return
res
;
}
/* This function returns a newly malloced string that has the \
in the strings inside the argument quoted with another \.
*/
static
char
*
quote_strings
(
char
*
arg
,
int
lineno
)
{
char
*
res
=
(
char
*
)
ecpg_alloc
(
2
*
strlen
(
arg
)
+
1
,
lineno
);
int
i
,
ri
;
bool
string
=
false
;
if
(
!
res
)
return
(
res
);
for
(
i
=
0
,
ri
=
0
;
arg
[
i
];
i
++
,
ri
++
)
{
switch
(
arg
[
i
])
{
case
'\''
:
string
=
string
?
false
:
true
;
break
;
case
'\\'
:
res
[
ri
++
]
=
'\\'
;
default:
;
}
res
[
ri
]
=
arg
[
i
];
}
res
[
ri
]
=
'\0'
;
return
res
;
}
/*
* create a list of variables
* The variables are listed with input variables preceeding outputvariables
...
...
@@ -544,17 +509,8 @@ ECPGexecute(struct statement * stmt)
strncpy
(
newcopy
,
(
char
*
)
var
->
value
,
slen
);
newcopy
[
slen
]
=
'\0'
;
if
(
!
(
mallocedval
=
(
char
*
)
ecpg_alloc
(
2
*
strlen
(
newcopy
)
+
1
,
stmt
->
lineno
)))
return
false
;
tmp
=
quote_strings
(
newcopy
,
stmt
->
lineno
);
if
(
!
tmp
)
return
false
;
strcat
(
mallocedval
,
tmp
);
free
(
newcopy
);
tobeinserted
=
mallocedval
;
tobeinserted
=
newcopy
;
}
break
;
case
ECPGt_varchar
:
...
...
src/interfaces/ecpg/preproc/Makefile
浏览文件 @
9b0e2057
...
...
@@ -9,8 +9,9 @@ CFLAGS+=-I../include -DMAJOR_VERSION=$(MAJOR_VERSION) \
-DMINOR_VERSION
=
$(MINOR_VERSION)
-DPATCHLEVEL
=
$(PATCHLEVEL)
\
-DINCLUDE_PATH
=
\"
$(HEADERDIR)
\"
OBJ
=
preproc.o pgc.o type.o ecpg.o ecpg_keywords.o
../../../backend/parser/scansup.o
\
OBJ
=
preproc.o pgc.o type.o ecpg.o ecpg_keywords.o
\
keywords.o c_keywords.o ../lib/typename.o
#../../../backend/parser/scansup.o
all
::
ecpg
...
...
src/interfaces/ecpg/preproc/pgc.l
浏览文件 @
9b0e2057
...
...
@@ -248,7 +248,8 @@ cppline {space}*#.*(\\{space}*\n)*\n*
}
<xq>{xqstop} {
BEGIN(SQL);
yylval.str = mm_strdup(scanstr(literal));
/* yylval.str = mm_strdup(scanstr(literal));*/
yylval.str = mm_strdup(literal);
return SCONST;
}
<xq>{xqdouble} |
...
...
@@ -609,7 +610,8 @@ cppline {space}*#.*(\\{space}*\n)*\n*
if (strcmp(old, ptr->old) == 0)
{
free(ptr->new);
ptr->new = mm_strdup(scanstr(literal));
/* ptr->new = mm_strdup(scanstr(literal));*/
ptr->new = mm_strdup(literal);
}
}
if (ptr == NULL)
...
...
@@ -618,7 +620,8 @@ cppline {space}*#.*(\\{space}*\n)*\n*
/* initial definition */
this->old = old;
this->new = mm_strdup(scanstr(literal));
/* this->new = mm_strdup(scanstr(literal));*/
this->new = mm_strdup(literal);
this->next = defines;
defines = this;
}
...
...
src/interfaces/ecpg/test/test1.pgc
浏览文件 @
9b0e2057
...
...
@@ -6,7 +6,7 @@ exec sql include sqlca;
exec sql define AMOUNT 4;
exec sql type intarray is int[AMOUNT];
exec sql type string is char(
6
);
exec sql type string is char(
8
);
typedef int intarray[AMOUNT];
...
...
@@ -16,7 +16,7 @@ main ()
exec sql begin declare section;
intarray amount;
int increment=100;
char name[AMOUNT][
6
];
char name[AMOUNT][
8
];
char letter[AMOUNT][1];
char command[128];
exec sql end declare section;
...
...
@@ -35,8 +35,8 @@ exec sql end declare section;
exec sql connect to pm;
strcpy(msg, "create");
exec sql at main create table test(name char(
6
), amount int, letter char(1));
exec sql create table test(name char(
6
), amount int, letter char(1));
exec sql at main create table test(name char(
8
), amount int, letter char(1));
exec sql create table test(name char(
8
), amount int, letter char(1));
strcpy(msg, "commit");
exec sql at main commit;
...
...
@@ -46,13 +46,13 @@ exec sql end declare section;
exec sql set connection to main;
strcpy(msg, "execute insert 1");
sprintf(command, "insert into test(name, amount, letter) values ('db:
mm
', 1, 'f')");
sprintf(command, "insert into test(name, amount, letter) values ('db:
''mm''
', 1, 'f')");
exec sql execute immediate :command;
sprintf(command, "insert into test(name, amount, letter) values ('db:
mm
', 2, 't')");
sprintf(command, "insert into test(name, amount, letter) values ('db:
''mm''
', 2, 't')");
exec sql execute immediate :command;
strcpy(msg, "execute insert 2");
sprintf(command, "insert into test(name, amount, letter) values ('db:
pm
', 1, 'f')");
sprintf(command, "insert into test(name, amount, letter) values ('db:
''pm''
', 1, 'f')");
exec sql at pm execute immediate :command;
strcpy(msg, "execute insert 3");
...
...
@@ -78,12 +78,12 @@ exec sql end declare section;
exec sql select name, amount, letter into :name, :amount, :letter from test;
for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
printf("name[%d]=%
6.6
s\tamount[%d]=%d\tletter[%d]=%c\n", i, name[i], i, amount[i],i, letter[i][0]);
printf("name[%d]=%
8.8
s\tamount[%d]=%d\tletter[%d]=%c\n", i, name[i], i, amount[i],i, letter[i][0]);
exec sql at pm select name, amount, letter into :name, :amount, :letter from test;
for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
printf("name[%d]=%
6.6
s\tamount[%d]=%d\tletter[%d]=%c\n", i, name[i], i, amount[i],i, letter[i][0]);
printf("name[%d]=%
8.8
s\tamount[%d]=%d\tletter[%d]=%c\n", i, name[i], i, amount[i],i, letter[i][0]);
strcpy(msg, "drop");
exec sql drop table test;
...
...
src/interfaces/ecpg/test/test3.pgc
浏览文件 @
9b0e2057
...
...
@@ -18,7 +18,7 @@ exec sql begin declare section;
int children;
int ind_children;
str *married = NULL;
char *
test
name="Petra";
char *
wifes
name="Petra";
char *query="select name, born, age, married, children from meskes where name = :var1";
exec sql end declare section;
...
...
@@ -32,13 +32,13 @@ exec sql end declare section;
ECPGdebug(1, dbgs);
strcpy(msg, "connect");
exec sql connect to unix:postgresql://localhost:5432/mm;
exec sql connect to unix:postgresql://localhost:5432/mm;
strcpy(msg, "create");
exec sql create table meskes(name char(8), born integer, age smallint, married date, children integer);
strcpy(msg, "insert");
exec sql insert into meskes(name, married, children) values (
'Petra'
, '19900404', 3);
exec sql insert into meskes(name, married, children) values (
:wifesname
, '19900404', 3);
exec sql insert into meskes(name, born, age, married, children) values ('Michael', 19660117, 33, '19900404', 3);
exec sql insert into meskes(name, born, age) values ('Carsten', 19910103, 8);
exec sql insert into meskes(name, born, age) values ('Marc', 19930907, 5);
...
...
@@ -78,7 +78,7 @@ exec sql end declare section;
exec sql declare prep cursor for MM;
strcpy(msg, "open");
exec sql open prep using :
test
name;
exec sql open prep using :
wifes
name;
exec sql whenever not found do break;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录