Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
6f66fd8c
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,发现更多精彩内容 >>
提交
6f66fd8c
编写于
3月 07, 1999
作者:
M
Michael Meskes
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
*** empty log message ***
上级
60bb92af
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
267 addition
and
23 deletion
+267
-23
src/interfaces/ecpg/ChangeLog
src/interfaces/ecpg/ChangeLog
+6
-2
src/interfaces/ecpg/lib/ecpglib.c
src/interfaces/ecpg/lib/ecpglib.c
+9
-9
src/interfaces/ecpg/preproc/Makefile
src/interfaces/ecpg/preproc/Makefile
+2
-2
src/interfaces/ecpg/preproc/preproc.y
src/interfaces/ecpg/preproc/preproc.y
+9
-9
src/interfaces/ecpg/test/test1.pgc
src/interfaces/ecpg/test/test1.pgc
+1
-1
src/interfaces/ecpg/test/test3.pgc
src/interfaces/ecpg/test/test3.pgc
+240
-0
未找到文件。
src/interfaces/ecpg/ChangeLog
浏览文件 @
6f66fd8c
...
...
@@ -472,7 +472,7 @@ Mon Feb 22 19:47:45 CET 1999
- Added 'at <db_connection>' option to all commands it is apllicable
to. Due to changing the API of some libecpg functions this
requires me to increase the major version number.
requires me to increase the major version number
of libecpg
.
- Synced pgc.l with scan.l.
- Added support for unions.
...
...
@@ -498,5 +498,9 @@ Thu Mar 4 19:49:28 CET 1999
- Switched memory allocation to calloc() to make sure memory is
cleared.
- Fixed varchar auto-allocating.
Sat Mar 6 14:06:07 CET 1999
- Replaced placeholder ';;' by '?' since this is what standard says.
- Set library version to 3.0.0
- Set ecpg version to
3.0
.0
- Set ecpg version to
2.6
.0
src/interfaces/ecpg/lib/ecpglib.c
浏览文件 @
6f66fd8c
...
...
@@ -129,7 +129,7 @@ register_error(long code, char *fmt,...)
static
struct
connection
*
get_connection
(
const
char
*
connection_name
)
{
struct
connection
*
con
=
all_connections
;
;
struct
connection
*
con
=
all_connections
;
if
(
connection_name
==
NULL
||
strcmp
(
connection_name
,
"CURRENT"
)
==
0
)
return
actual_connection
;
...
...
@@ -377,11 +377,11 @@ next_insert(char *text)
char
*
ptr
=
text
;
bool
string
=
false
;
for
(;
ptr
[
1
]
!=
'\0'
&&
(
ptr
[
0
]
!=
';'
||
ptr
[
1
]
!=
';
'
||
string
);
ptr
++
)
if
(
ptr
[
0
]
==
'\''
)
for
(;
*
ptr
!=
'\0'
&&
(
*
ptr
!=
'?
'
||
string
);
ptr
++
)
if
(
*
ptr
==
'\''
)
string
=
string
?
false
:
true
;
return
(
ptr
[
1
]
==
'\0'
)
?
NULL
:
ptr
;
return
(
*
ptr
==
'\0'
)
?
NULL
:
ptr
;
}
static
bool
...
...
@@ -604,7 +604,7 @@ ECPGexecute(struct statement * stmt)
strcat
(
newcopy
,
copiedquery
+
(
p
-
newcopy
)
+
sizeof
(
"
;;
"
)
-
1
/* don't count the '\0' */
);
+
sizeof
(
"
?
"
)
-
1
/* don't count the '\0' */
);
}
/*
...
...
@@ -675,7 +675,7 @@ ECPGexecute(struct statement * stmt)
{
ECPGlog
(
"ECPGexecute line %d: Incorrect number of matches: %d
\n
"
,
stmt
->
lineno
,
ntuples
);
register_error
(
ECPG_NOT_FOUND
,
"
Data not
found line %d."
,
stmt
->
lineno
);
register_error
(
ECPG_NOT_FOUND
,
"
No data
found line %d."
,
stmt
->
lineno
);
status
=
false
;
break
;
}
...
...
@@ -1266,8 +1266,8 @@ replace_variables(char *text)
if
(
!
string
&&
*
ptr
==
':'
)
{
ptr
[
0
]
=
ptr
[
1
]
=
';
'
;
for
(
ptr
+=
2
;
*
ptr
&&
isvarchar
(
*
ptr
);
ptr
++
)
*
ptr
=
'?
'
;
for
(
++
ptr
;
*
ptr
&&
isvarchar
(
*
ptr
);
ptr
++
)
*
ptr
=
' '
;
}
}
...
...
@@ -1307,7 +1307,7 @@ ECPGprepare(int lineno, char *name, char *variable)
stmt
->
command
=
ecpg_strdup
(
variable
,
lineno
);
stmt
->
inlist
=
stmt
->
outlist
=
NULL
;
/* if we have C variables in our statment replace them with '
;;
' */
/* if we have C variables in our statment replace them with '
?
' */
replace_variables
(
stmt
->
command
);
/* add prepared statement to our list */
...
...
src/interfaces/ecpg/preproc/Makefile
浏览文件 @
6f66fd8c
SRCDIR
=
../../..
include
$(SRCDIR)/Makefile.global
MAJOR_VERSION
=
3
MINOR_VERSION
=
0
MAJOR_VERSION
=
2
MINOR_VERSION
=
6
PATCHLEVEL
=
0
CFLAGS
+=
-I
../include
-DMAJOR_VERSION
=
$(MAJOR_VERSION)
\
...
...
src/interfaces/ecpg/preproc/preproc.y
浏览文件 @
6f66fd8c
...
...
@@ -1097,7 +1097,7 @@ user_group_clause: IN GROUP user_group_list { $$ = cat2_str(make1_str("in group
| /*EMPTY*/ { $$ = make1_str(""); }
;
user_valid_clause: VALID UNTIL Sconst { $$ = cat2_str(make1_str("valid until"), $3);
;
}
user_valid_clause: VALID UNTIL Sconst { $$ = cat2_str(make1_str("valid until"), $3); }
| /*EMPTY*/ { $$ = make1_str(""); }
;
...
...
@@ -2221,7 +2221,7 @@ set_opt: SETOF { $$ = make1_str("setof"); }
RemoveStmt: DROP remove_type name
{
$$ = cat3_str(make1_str("drop"), $2, $3);
;
$$ = cat3_str(make1_str("drop"), $2, $3);
}
;
...
...
@@ -2931,7 +2931,7 @@ opt_select_limit: LIMIT select_limit_value ',' select_offset_value
| LIMIT select_limit_value OFFSET select_offset_value
{ $$ = cat4_str(make1_str("limit"), $2, make1_str("offset"), $4); }
| LIMIT select_limit_value
{ $$ = cat2_str(make1_str("limit"), $2);
;
}
{ $$ = cat2_str(make1_str("limit"), $2); }
| OFFSET select_offset_value LIMIT select_limit_value
{ $$ = cat4_str(make1_str("offset"), $2, make1_str("limit"), $4); }
| OFFSET select_offset_value
...
...
@@ -3835,7 +3835,7 @@ a_expr: attr opt_indirection
| case_expr
{ $$ = $1; }
| cinputvariable
{ $$ = make1_str("
;;
"); }
{ $$ = make1_str("
?
"); }
;
/* Restricted expressions
...
...
@@ -3982,7 +3982,7 @@ extract_list: extract_arg FROM a_expr
| /* EMPTY */
{ $$ = make1_str(""); }
| cinputvariable
{ $$ = make1_str("
;;
"); }
{ $$ = make1_str("
?
"); }
;
extract_arg: datetime { $$ = $1; }
...
...
@@ -4734,7 +4734,7 @@ ECPGCursorStmt: DECLARE name opt_cursor CURSOR FOR ident cursor_clause
this->next = cur;
this->name = $2;
this->connection = connection;
this->command = cat5_str(make1_str("declare"), mm_strdup($2), $3, make1_str("cursor for
;;
"), $7);
this->command = cat5_str(make1_str("declare"), mm_strdup($2), $3, make1_str("cursor for
?
"), $7);
this->argsresult = NULL;
thisquery->type = &ecpg_query;
...
...
@@ -5037,7 +5037,7 @@ ECPGExecute : EXECUTE SQL_IMMEDIATE execstring
add_variable(&argsinsert, thisquery, &no_indicator);
$$ = make1_str("
;;
");
$$ = make1_str("
?
");
}
| EXECUTE ident
{
...
...
@@ -5052,7 +5052,7 @@ ECPGExecute : EXECUTE SQL_IMMEDIATE execstring
add_variable(&argsinsert, thisquery, &no_indicator);
} opt_using
{
$$ = make1_str("
;;
");
$$ = make1_str("
?
");
}
execstring: char_variable |
...
...
@@ -5860,7 +5860,7 @@ cinputvariable : cvariable indicator {
civariableonly : cvariable {
add_variable(&argsinsert, find_variable($1), &no_indicator);
$$ = make1_str("
;;
");
$$ = make1_str("
?
");
}
cvariable: CVARIABLE { $$ = $1; }
...
...
src/interfaces/ecpg/test/test1.pgc
浏览文件 @
6f66fd8c
...
...
@@ -63,7 +63,7 @@ exec sql end declare section;
printf("Inserted %d tuples via execute immediate\n", sqlca.sqlerrd[2]);
strcpy(msg, "execute insert 4");
sprintf(command, "insert into test(name, amount, letter) select name, amount+
;;
, letter from test");
sprintf(command, "insert into test(name, amount, letter) select name, amount+
?
, letter from test");
exec sql prepare I from :command;
exec sql at pm execute I using :increment;
...
...
src/interfaces/ecpg/test/test3.pgc
0 → 100644
浏览文件 @
6f66fd8c
#include <stdio.h>
exec sql include header_test;
exec sql type str is varchar[10];
int
main ()
{
typedef struct { long born; short age; } birthinfo;
exec sql type birthinfo is struct { long born; short age; };
exec sql begin declare section;
struct personal_struct { str name;
birthinfo birth;
} personal;
struct personal_indicator { int ind_name;
birthinfo ind_birth;
} ind_personal;
int *ind_married = NULL;
int children;
int ind_children;
str *married = NULL;
char *testname="Petra";
char *query="select name, born, age, married, children from meskes where name = :var1";
exec sql end declare section;
exec sql declare cur cursor for
select name, born, age, married, children from meskes;
char msg[128], command[128];
FILE *dbgs;
if ((dbgs = fopen("log", "w")) != NULL)
ECPGdebug(1, dbgs);
strcpy(msg, "connect");
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, 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);
exec sql insert into meskes(name, born, age) values ('Chris', 19970923, 1);
strcpy(msg, "commit");
exec sql commit;
strcpy(msg, "open");
exec sql open cur;
exec sql whenever not found do break;
while (1) {
strcpy(msg, "fetch");
exec sql fetch in cur into :personal:ind_personal, :married:ind_married, :children:ind_children;
printf("%8.8s", personal.name.arr);
if (ind_personal.ind_birth.born >= 0)
printf(", born %d", personal.birth.born);
if (ind_personal.ind_birth.age >= 0)
printf(", age = %d", personal.birth.age);
if (ind_married >= 0)
printf(", married %10.10s", married->arr);
if (ind_children >= 0)
printf(", children = %d", children);
putchar('\n');
free(married);
married = NULL;
}
strcpy(msg, "close");
exec sql close cur;
/* and now the same query with prepare */
exec sql prepare MM from :query;
exec sql declare prep cursor for MM;
strcpy(msg, "open");
exec sql open prep using :testname;
exec sql whenever not found do break;
while (1) {
strcpy(msg, "fetch");
exec sql fetch in prep into :personal:ind_personal, :married:ind_married, :children:ind_children;
printf("%8.8s", personal.name.arr);
if (ind_personal.ind_birth.born >= 0)
printf(", born %d", personal.birth.born);
if (ind_personal.ind_birth.age >= 0)
printf(", age = %d", personal.birth.age);
if (ind_married >= 0)
printf(", married %10.10s", married->arr);
if (ind_children >= 0)
printf(", children = %d", children);
putchar('\n');
}
free(married);
strcpy(msg, "close");
exec sql close prep;
strcpy(msg, "drop");
exec sql drop table meskes;
strcpy(msg, "commit");
exec sql commit;
strcpy(msg, "disconnect");
exec sql disconnect;
if (dbgs != NULL)
fclose(dbgs);
return (0);
}
#include <stdio.h>
exec sql include header_test;
exec sql type str is varchar[10];
int
main ()
{
typedef struct { long born; short age; } birthinfo;
exec sql type birthinfo is struct { long born; short age; };
exec sql begin declare section;
struct personal_struct { str name;
birthinfo birth;
} personal;
struct personal_indicator { int ind_name;
birthinfo ind_birth;
} ind_personal;
int *ind_married = NULL;
int children;
int ind_children;
str *married = NULL;
char *testname="Petra";
char *query="select name, born, age, married, children from meskes where name = :var1";
exec sql end declare section;
exec sql declare cur cursor for
select name, born, age, married, children from meskes;
char msg[128], command[128];
FILE *dbgs;
if ((dbgs = fopen("log", "w")) != NULL)
ECPGdebug(1, dbgs);
strcpy(msg, "connect");
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, 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);
exec sql insert into meskes(name, born, age) values ('Chris', 19970923, 1);
strcpy(msg, "commit");
exec sql commit;
strcpy(msg, "open");
exec sql open cur;
exec sql whenever not found do break;
while (1) {
strcpy(msg, "fetch");
exec sql fetch in cur into :personal:ind_personal, :married:ind_married, :children:ind_children;
printf("%8.8s", personal.name.arr);
if (ind_personal.ind_birth.born >= 0)
printf(", born %d", personal.birth.born);
if (ind_personal.ind_birth.age >= 0)
printf(", age = %d", personal.birth.age);
if (ind_married >= 0)
printf(", married %10.10s", married->arr);
if (ind_children >= 0)
printf(", children = %d", children);
putchar('\n');
free(married);
married = NULL;
}
strcpy(msg, "close");
exec sql close cur;
/* and now the same query with prepare */
exec sql prepare MM from :query;
exec sql declare prep cursor for MM;
strcpy(msg, "open");
exec sql open prep using :testname;
exec sql whenever not found do break;
while (1) {
strcpy(msg, "fetch");
exec sql fetch in prep into :personal:ind_personal, :married:ind_married, :children:ind_children;
printf("%8.8s", personal.name.arr);
if (ind_personal.ind_birth.born >= 0)
printf(", born %d", personal.birth.born);
if (ind_personal.ind_birth.age >= 0)
printf(", age = %d", personal.birth.age);
if (ind_married >= 0)
printf(", married %10.10s", married->arr);
if (ind_children >= 0)
printf(", children = %d", children);
putchar('\n');
}
free(married);
strcpy(msg, "close");
exec sql close prep;
strcpy(msg, "drop");
exec sql drop table meskes;
strcpy(msg, "commit");
exec sql commit;
strcpy(msg, "disconnect");
exec sql disconnect;
if (dbgs != NULL)
fclose(dbgs);
return (0);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录