Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
b53955f3
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,发现更多精彩内容 >>
提交
b53955f3
编写于
1月 27, 2000
作者:
M
Michael Meskes
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
*** empty log message ***
上级
dd979f66
变更
14
展开全部
隐藏空白更改
内联
并排
Showing
14 changed file
with
277 addition
and
323 deletion
+277
-323
src/interfaces/ecpg/ChangeLog
src/interfaces/ecpg/ChangeLog
+16
-0
src/interfaces/ecpg/lib/ecpglib.c
src/interfaces/ecpg/lib/ecpglib.c
+5
-2
src/interfaces/ecpg/preproc/c_keywords.c
src/interfaces/ecpg/preproc/c_keywords.c
+15
-14
src/interfaces/ecpg/preproc/ecpg.c
src/interfaces/ecpg/preproc/ecpg.c
+1
-1
src/interfaces/ecpg/preproc/extern.h
src/interfaces/ecpg/preproc/extern.h
+1
-0
src/interfaces/ecpg/preproc/pgc.l
src/interfaces/ecpg/preproc/pgc.l
+18
-11
src/interfaces/ecpg/preproc/preproc.y
src/interfaces/ecpg/preproc/preproc.y
+119
-289
src/interfaces/ecpg/preproc/type.h
src/interfaces/ecpg/preproc/type.h
+2
-0
src/interfaces/ecpg/test/Makefile
src/interfaces/ecpg/test/Makefile
+10
-2
src/interfaces/ecpg/test/stp.pgc
src/interfaces/ecpg/test/stp.pgc
+16
-0
src/interfaces/ecpg/test/test1.pgc
src/interfaces/ecpg/test/test1.pgc
+9
-0
src/interfaces/ecpg/test/test2.pgc
src/interfaces/ecpg/test/test2.pgc
+1
-1
src/interfaces/ecpg/test/test3.pgc
src/interfaces/ecpg/test/test3.pgc
+3
-3
src/interfaces/ecpg/test/test5.pgc
src/interfaces/ecpg/test/test5.pgc
+61
-0
未找到文件。
src/interfaces/ecpg/ChangeLog
浏览文件 @
b53955f3
...
@@ -775,5 +775,21 @@ Mon Jan 17 21:55:40 CET 2000
...
@@ -775,5 +775,21 @@ Mon Jan 17 21:55:40 CET 2000
- Synced preproc.y with gram.y.
- Synced preproc.y with gram.y.
- Changed FETCH syntax using Rene's final patch. Made it more
- Changed FETCH syntax using Rene's final patch. Made it more
standard compliant.
standard compliant.
Thu Jan 20 10:00:50 CET 2000
- Synced preproc.y with gram.y.
Fri Jan 21 14:52:27 CET 2000
- Added more log output to ecpglib.
Thu Jan 27 08:12:05 CET 2000
- Added another patch by Rene Hogendoorn.
- Fixed error messages in pgc.l.
- Improved variable parsing.
- Synced preproc.y with gram.y.
- Set library version to 3.0.10.
- Set library version to 3.0.10.
- Set ecpg version to 2.7.0.
- Set ecpg version to 2.7.0.
src/interfaces/ecpg/lib/ecpglib.c
浏览文件 @
b53955f3
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
slightly modified)
slightly modified)
*/
*/
/* Taken over as part of PostgreSQL by Michael Meskes <meskes@
debian
.org>
/* Taken over as part of PostgreSQL by Michael Meskes <meskes@
postgresql
.org>
on Feb. 5th, 1998 */
on Feb. 5th, 1998 */
#include <stdio.h>
#include <stdio.h>
...
@@ -724,6 +724,9 @@ ECPGexecute(struct statement * stmt)
...
@@ -724,6 +724,9 @@ ECPGexecute(struct statement * stmt)
*
((
void
**
)
var
->
pointer
)
=
var
->
value
;
*
((
void
**
)
var
->
pointer
)
=
var
->
value
;
add_mem
(
var
->
value
,
stmt
->
lineno
);
add_mem
(
var
->
value
,
stmt
->
lineno
);
}
}
ECPGlog
(
"ECPGexecute line %d: TYPE db: %d c: %d
\n
"
,
stmt
->
lineno
,
PQftype
(
results
,
act_field
),
var
->
type
);
for
(
act_tuple
=
0
;
act_tuple
<
ntuples
&&
status
;
act_tuple
++
)
for
(
act_tuple
=
0
;
act_tuple
<
ntuples
&&
status
;
act_tuple
++
)
{
{
...
@@ -764,7 +767,7 @@ ECPGexecute(struct statement * stmt)
...
@@ -764,7 +767,7 @@ ECPGexecute(struct statement * stmt)
status
=
false
;
status
=
false
;
break
;
break
;
}
}
switch
(
var
->
type
)
switch
(
var
->
type
)
{
{
long
res
;
long
res
;
...
...
src/interfaces/ecpg/preproc/c_keywords.c
浏览文件 @
b53955f3
...
@@ -19,25 +19,26 @@
...
@@ -19,25 +19,26 @@
*/
*/
static
ScanKeyword
ScanKeywords
[]
=
{
static
ScanKeyword
ScanKeywords
[]
=
{
/* name value */
/* name value */
{
"VARCHAR"
,
S_
VARCHAR
},
{
"VARCHAR"
,
VARCHAR
},
{
"auto"
,
S_AUTO
},
{
"auto"
,
S_AUTO
},
{
"bool"
,
S_BOOL
},
{
"bool"
,
S
QL
_BOOL
},
{
"char"
,
S_
CHAR
},
{
"char"
,
CHAR
},
{
"const"
,
S_CONST
},
{
"const"
,
S_CONST
},
{
"double"
,
S_
DOUBLE
},
{
"double"
,
DOUBLE
},
{
"enum"
,
S_ENUM
},
{
"enum"
,
S
QL
_ENUM
},
{
"extern"
,
S_EXTERN
},
{
"extern"
,
S_EXTERN
},
{
"float"
,
S_
FLOAT
},
{
"float"
,
FLOAT
},
{
"int"
,
S_INT
},
{
"int"
,
S
QL
_INT
},
{
"long"
,
S_LONG
},
{
"long"
,
S
QL
_LONG
},
{
"register"
,
S_REGISTER
},
{
"register"
,
S_REGISTER
},
{
"short"
,
S_SHORT
},
{
"short"
,
S
QL
_SHORT
},
{
"signed"
,
S_SIGNED
},
{
"signed"
,
S
QL
_SIGNED
},
{
"static"
,
S_STATIC
},
{
"static"
,
S_STATIC
},
{
"struct"
,
S_STRUCT
},
{
"struct"
,
SQL_STRUCT
},
{
"union"
,
S_UNION
},
{
"union"
,
UNION
},
{
"unsigned"
,
S_UNSIGNED
},
{
"unsigned"
,
SQL_UNSIGNED
},
{
"varchar"
,
S_VARCHAR
},
{
"varchar"
,
VARCHAR
},
{
"volatile"
,
S_VOLATILE
},
};
};
ScanKeyword
*
ScanKeyword
*
...
...
src/interfaces/ecpg/preproc/ecpg.c
浏览文件 @
b53955f3
/* New main for ecpg, the PostgreSQL embedded SQL precompiler. */
/* New main for ecpg, the PostgreSQL embedded SQL precompiler. */
/* (C) Michael Meskes <meskes@
debian
.org> Feb 5th, 1998 */
/* (C) Michael Meskes <meskes@
postgresql
.org> Feb 5th, 1998 */
/* Placed under the same copyright as PostgresSQL */
/* Placed under the same copyright as PostgresSQL */
#include <unistd.h>
#include <unistd.h>
...
...
src/interfaces/ecpg/preproc/extern.h
浏览文件 @
b53955f3
...
@@ -40,6 +40,7 @@ extern int yylex(void);
...
@@ -40,6 +40,7 @@ extern int yylex(void);
extern
void
yyerror
(
char
*
);
extern
void
yyerror
(
char
*
);
extern
void
*
mm_alloc
(
size_t
),
*
mm_realloc
(
void
*
,
size_t
);
extern
void
*
mm_alloc
(
size_t
),
*
mm_realloc
(
void
*
,
size_t
);
extern
char
*
mm_strdup
(
const
char
*
);
extern
char
*
mm_strdup
(
const
char
*
);
extern
void
mmerror
(
enum
errortype
,
char
*
);
ScanKeyword
*
ScanECPGKeywordLookup
(
char
*
);
ScanKeyword
*
ScanECPGKeywordLookup
(
char
*
);
ScanKeyword
*
ScanCKeywordLookup
(
char
*
);
ScanKeyword
*
ScanCKeywordLookup
(
char
*
);
...
...
src/interfaces/ecpg/preproc/pgc.l
浏览文件 @
b53955f3
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.
49 2000/01/26 05:58:41 momjian
Exp $
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.
50 2000/01/27 19:00:39 meskes
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -246,7 +246,7 @@ cppline {space}*#(.*\\{line_end})*.*
...
@@ -246,7 +246,7 @@ cppline {space}*#(.*\\{line_end})*.*
errno = 0;
errno = 0;
yylval.ival = strtol(literalbuf, &endptr, 2);
yylval.ival = strtol(literalbuf, &endptr, 2);
if (*endptr != '\0' || errno == ERANGE)
if (*endptr != '\0' || errno == ERANGE)
yyerror("ERROR:
Bad binary integer input!");
mmerror(ET_ERROR, "
Bad binary integer input!");
return ICONST;
return ICONST;
}
}
<xh>{xhinside} |
<xh>{xhinside} |
...
@@ -268,7 +268,7 @@ cppline {space}*#(.*\\{line_end})*.*
...
@@ -268,7 +268,7 @@ cppline {space}*#(.*\\{line_end})*.*
errno = 0;
errno = 0;
yylval.ival = strtol(literalbuf, &endptr, 16);
yylval.ival = strtol(literalbuf, &endptr, 16);
if (*endptr != '\0' || errno == ERANGE)
if (*endptr != '\0' || errno == ERANGE)
yyerror("ERROR:
Bad hexadecimal integer input");
mmerror(ET_ERROR, "
Bad hexadecimal integer input");
return ICONST;
return ICONST;
}
}
...
@@ -355,7 +355,7 @@ cppline {space}*#(.*\\{line_end})*.*
...
@@ -355,7 +355,7 @@ cppline {space}*#(.*\\{line_end})*.*
errno = 0;
errno = 0;
yylval.dval = strtod((char *)yytext,&endptr);
yylval.dval = strtod((char *)yytext,&endptr);
if (*endptr != '\0' || errno == ERANGE)
if (*endptr != '\0' || errno == ERANGE)
yyerror("ERROR:
Bad float8 input");
mmerror(ET_ERROR, "
Bad float8 input");
return FCONST;
return FCONST;
}
}
yylval.str = mm_strdup((char*)yytext);
yylval.str = mm_strdup((char*)yytext);
...
@@ -367,7 +367,7 @@ cppline {space}*#(.*\\{line_end})*.*
...
@@ -367,7 +367,7 @@ cppline {space}*#(.*\\{line_end})*.*
errno = 0;
errno = 0;
yylval.dval = strtod((char *)yytext,&endptr);
yylval.dval = strtod((char *)yytext,&endptr);
if (*endptr != '\0' || errno == ERANGE)
if (*endptr != '\0' || errno == ERANGE)
yyerror("ERROR:
Bad float input");
mmerror(ET_ERROR, "
Bad float input");
return FCONST;
return FCONST;
}
}
<SQL>:{identifier}(("->"|\.){identifier})* {
<SQL>:{identifier}(("->"|\.){identifier})* {
...
@@ -385,6 +385,13 @@ cppline {space}*#(.*\\{line_end})*.*
...
@@ -385,6 +385,13 @@ cppline {space}*#(.*\\{line_end})*.*
if (isascii((unsigned char)lower_text[i]) && isupper(lower_text[i]))
if (isascii((unsigned char)lower_text[i]) && isupper(lower_text[i]))
lower_text[i] = tolower(lower_text[i]);
lower_text[i] = tolower(lower_text[i]);
if (i >= NAMEDATALEN)
{
sprintf(errortext, "Identifier \"%s\" will be truncated to \"%.*s\"", yytext, NAMEDATALEN-1, yytext);
mmerror (ET_WARN, errortext);
yytext[NAMEDATALEN-1] = '\0';
}
keyword = ScanKeywordLookup((char*)lower_text);
keyword = ScanKeywordLookup((char*)lower_text);
if (keyword != NULL) {
if (keyword != NULL) {
return keyword->value;
return keyword->value;
...
@@ -509,10 +516,10 @@ cppline {space}*#(.*\\{line_end})*.*
...
@@ -509,10 +516,10 @@ cppline {space}*#(.*\\{line_end})*.*
<C,xskip>{exec_sql}{elif}{space_or_nl}* { /* pop stack */
<C,xskip>{exec_sql}{elif}{space_or_nl}* { /* pop stack */
if ( preproc_tos == 0 ) {
if ( preproc_tos == 0 ) {
yyerror("ERROR: m
issing matching 'EXEC SQL IFDEF / EXEC SQL IFNDEF'");
mmerror(ET_FATAL, "M
issing matching 'EXEC SQL IFDEF / EXEC SQL IFNDEF'");
}
}
else if ( stacked_if_value[preproc_tos].else_branch ) {
else if ( stacked_if_value[preproc_tos].else_branch ) {
yyerror("ERROR: m
issing 'EXEC SQL ENDIF;'");
mmerror(ET_FATAL, "M
issing 'EXEC SQL ENDIF;'");
}
}
else {
else {
preproc_tos--;
preproc_tos--;
...
@@ -523,7 +530,7 @@ cppline {space}*#(.*\\{line_end})*.*
...
@@ -523,7 +530,7 @@ cppline {space}*#(.*\\{line_end})*.*
<C,xskip>{exec_sql}{else}{space_or_nl}*";" { /* only exec sql endif pops the stack, so take care of duplicated 'else' */
<C,xskip>{exec_sql}{else}{space_or_nl}*";" { /* only exec sql endif pops the stack, so take care of duplicated 'else' */
if ( stacked_if_value[preproc_tos].else_branch ) {
if ( stacked_if_value[preproc_tos].else_branch ) {
yyerror("ERROR: d
uplicated 'EXEC SQL ELSE;'");
mmerror(ET_FATAL, "D
uplicated 'EXEC SQL ELSE;'");
}
}
else {
else {
stacked_if_value[preproc_tos].else_branch = TRUE;
stacked_if_value[preproc_tos].else_branch = TRUE;
...
@@ -541,7 +548,7 @@ cppline {space}*#(.*\\{line_end})*.*
...
@@ -541,7 +548,7 @@ cppline {space}*#(.*\\{line_end})*.*
}
}
<C,xskip>{exec_sql}{endif}{space_or_nl}*";" {
<C,xskip>{exec_sql}{endif}{space_or_nl}*";" {
if ( preproc_tos == 0 ) {
if ( preproc_tos == 0 ) {
yyerror("ERROR: u
nmatched 'EXEC SQL ENDIF;'");
mmerror(ET_FATAL, "U
nmatched 'EXEC SQL ENDIF;'");
}
}
else {
else {
preproc_tos--;
preproc_tos--;
...
@@ -559,7 +566,7 @@ cppline {space}*#(.*\\{line_end})*.*
...
@@ -559,7 +566,7 @@ cppline {space}*#(.*\\{line_end})*.*
<xcond>{identifier}{space_or_nl}*";" {
<xcond>{identifier}{space_or_nl}*";" {
if ( preproc_tos >= MAX_NESTED_IF-1 ) {
if ( preproc_tos >= MAX_NESTED_IF-1 ) {
yyerror("ERROR: t
oo many nested 'EXEC SQL IFDEF' conditions");
mmerror(ET_FATAL, "T
oo many nested 'EXEC SQL IFDEF' conditions");
}
}
else {
else {
struct _defines *defptr;
struct _defines *defptr;
...
@@ -680,7 +687,7 @@ cppline {space}*#(.*\\{line_end})*.*
...
@@ -680,7 +687,7 @@ cppline {space}*#(.*\\{line_end})*.*
if ( preproc_tos > 0 ) {
if ( preproc_tos > 0 ) {
preproc_tos = 0;
preproc_tos = 0;
yyerror("ERROR: m
issing 'EXEC SQL ENDIF;'");
mmerror(ET_FATAL, "M
issing 'EXEC SQL ENDIF;'");
}
}
if (yy_buffer == NULL)
if (yy_buffer == NULL)
...
...
src/interfaces/ecpg/preproc/preproc.y
浏览文件 @
b53955f3
此差异已折叠。
点击以展开。
src/interfaces/ecpg/preproc/type.h
浏览文件 @
b53955f3
...
@@ -138,3 +138,5 @@ struct arguments
...
@@ -138,3 +138,5 @@ struct arguments
struct
variable
*
indicator
;
struct
variable
*
indicator
;
struct
arguments
*
next
;
struct
arguments
*
next
;
};
};
enum
errortype
{
ET_WARN
,
ET_ERROR
,
ET_FATAL
};
src/interfaces/ecpg/test/Makefile
浏览文件 @
b53955f3
all
:
test1 test2 test3 test4
perftest
all
:
stp.so test1 test2 test3 test4 test5
perftest
#LDFLAGS=-g -I /usr/local/pgsql/include -L/usr/local/pgsql/lib -lecpg -lpq -lcrypt
#LDFLAGS=-g -I /usr/local/pgsql/include -L/usr/local/pgsql/lib -lecpg -lpq -lcrypt
LDFLAGS
=
-g
-I
../include
-I
/usr/include/postgresql
-L
/usr/lib/postgresql
-L
../lib
-lecpg
-lpq
-lcrypt
LDFLAGS
=
-g
-I
../include
-I
/usr/include/postgresql
-L
/usr/lib/postgresql
-L
../lib
-lecpg
-lpq
-lcrypt
#LDFLAGS=-g -I/usr/include/postgresql -lecpg -lpq -lcrypt
#ECPG=/usr/local/pgsql/bin/ecpg
#ECPG=/usr/local/pgsql/bin/ecpg
ECPG
=
../preproc/ecpg
-I
../include
ECPG
=
../preproc/ecpg
-I
../include
#ECPG=/usr/bin/ecpg -I/usr/include/postgresql
.SUFFIXES
:
.pgc .c
.SUFFIXES
:
.pgc .c
...
@@ -12,10 +14,16 @@ test1: test1.c
...
@@ -12,10 +14,16 @@ test1: test1.c
test2
:
test2.c
test2
:
test2.c
test3
:
test3.c
test3
:
test3.c
test4
:
test4.c
test4
:
test4.c
test5
:
test5.c
perftest
:
perftest.c
perftest
:
perftest.c
.pgc.c
:
.pgc.c
:
$(ECPG)
$?
$(ECPG)
$?
stp.so
:
stp.c
cc
-fPIC
-I
../include
-I
/usr/include/postgresql
-c
-o
stp.o stp.c
cc
-shared
-Wl
,-soname,stp.so
-o
stp.so stp.o
-lpq
-lecpg
clean
:
clean
:
-
/bin/rm test1 test2 test3 test4
perftest
*
.c log
-
/bin/rm test1 test2 test3 test4
test5 perftest
*
.c log stp.o stp.so
src/interfaces/ecpg/test/stp.pgc
0 → 100644
浏览文件 @
b53955f3
EXEC SQL INCLUDE sqlca;
int my_fun (void)
{
EXEC SQL BEGIN DECLARE SECTION;
int sql_index = 0;
EXEC SQL END DECLARE SECTION;
EXEC SQL WHENEVER SQLERROR GOTO Error;
EXEC SQL SELECT MIN(index) INTO :sql_index FROM tab;
return (sql_index);
Error:
return (sqlca.sqlcode);
}
src/interfaces/ecpg/test/test1.pgc
浏览文件 @
b53955f3
...
@@ -94,11 +94,20 @@ exec sql end declare section;
...
@@ -94,11 +94,20 @@ exec sql end declare section;
strcpy(msg, "select");
strcpy(msg, "select");
exec sql select name, amount, letter into :name, :amount, :letter from "Test";
exec sql select name, amount, letter into :name, :amount, :letter from "Test";
printf("Database: mm\n");
for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
{
printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, name[i], i, amount[i],i, letter[i][0]);
printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, name[i], i, amount[i],i, letter[i][0]);
amount[i]+=1000;
}
strcpy(msg, "insert");
exec sql at pm insert into "Test" (name, amount, letter) values (:name, :amount, :letter);
strcpy(msg, "select");
exec sql at pm select * into :name, :amount, :letter from "Test";
exec sql at pm select * into :name, :amount, :letter from "Test";
printf("Database: pm\n");
for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, name[i], i, amount[i],i, letter[i][0]);
printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, name[i], i, amount[i],i, letter[i][0]);
...
...
src/interfaces/ecpg/test/test2.pgc
浏览文件 @
b53955f3
...
@@ -62,7 +62,7 @@ exec sql end declare section;
...
@@ -62,7 +62,7 @@ exec sql end declare section;
while (1) {
while (1) {
strcpy(msg, "fetch");
strcpy(msg, "fetch");
exec sql fetch
from
cur into :personal:ind_personal, :married:ind_married, :children.integer:ind_children.smallint;
exec sql fetch cur into :personal:ind_personal, :married:ind_married, :children.integer:ind_children.smallint;
printf("%8.8s", personal.name.arr);
printf("%8.8s", personal.name.arr);
if (ind_personal.ind_birth.born >= 0)
if (ind_personal.ind_birth.born >= 0)
printf(", born %d", personal.birth.born);
printf(", born %d", personal.birth.born);
...
...
src/interfaces/ecpg/test/test3.pgc
浏览文件 @
b53955f3
...
@@ -19,7 +19,7 @@ exec sql begin declare section;
...
@@ -19,7 +19,7 @@ exec sql begin declare section;
int ind_children;
int ind_children;
str *married = NULL;
str *married = NULL;
char *wifesname="Petra";
char *wifesname="Petra";
char *query="select * from meskes where name =
:var1
";
char *query="select * from meskes where name =
?
";
exec sql end declare section;
exec sql end declare section;
exec sql declare cur cursor for
exec sql declare cur cursor for
...
@@ -54,7 +54,7 @@ exec sql end declare section;
...
@@ -54,7 +54,7 @@ exec sql end declare section;
while (1) {
while (1) {
strcpy(msg, "fetch");
strcpy(msg, "fetch");
exec sql fetch cur into :personal:ind_personal, :married:ind_married, :children:ind_children;
exec sql fetch
from
cur into :personal:ind_personal, :married:ind_married, :children:ind_children;
printf("%8.8s", personal.name.arr);
printf("%8.8s", personal.name.arr);
if (ind_personal.ind_birth.born >= 0)
if (ind_personal.ind_birth.born >= 0)
printf(", born %d", personal.birth.born);
printf(", born %d", personal.birth.born);
...
@@ -74,7 +74,7 @@ exec sql end declare section;
...
@@ -74,7 +74,7 @@ exec sql end declare section;
exec sql close cur;
exec sql close cur;
/* and now a query with prepare */
/* and now a query with prepare */
exec sql prepare MM from
"select name, born, age, married, children from meskes where name = ?"
;
exec sql prepare MM from
:query
;
exec sql declare prep cursor for MM;
exec sql declare prep cursor for MM;
strcpy(msg, "open");
strcpy(msg, "open");
...
...
src/interfaces/ecpg/test/test5.pgc
0 → 100644
浏览文件 @
b53955f3
#include <stdlib.h>
#include <stdio.h>
EXEC SQL INCLUDE sqlca;
static void ErrorExit (void);
int main (void)
{
EXEC SQL BEGIN DECLARE SECTION;
int result;
int values[2], i;
EXEC SQL END DECLARE SECTION;
FILE *dbgs;
if ((dbgs = fopen("log", "w")) != NULL)
ECPGdebug(1, dbgs);
EXEC SQL WHENEVER SQLERROR DO ErrorExit();
EXEC SQL CONNECT TO 'mm';
EXEC SQL CREATE TABLE tab (index int);
EXEC SQL INSERT INTO tab(index) values(14);
EXEC SQL INSERT INTO tab(index) values(7);
EXEC SQL COMMIT;
EXEC SQL CREATE FUNCTION my_fun () RETURNS int AS
'/home/postgres/pgsql/src/interfaces/ecpg.mm/test/stp.so' LANGUAGE 'C';
EXEC SQL COMMIT;
EXEC SQL SELECT index INTO :values FROM tab;
for (i = 0; i < 2; i++)
printf("tab[%d] = %d\n", i, values[i]);
EXEC SQL SELECT my_fun () INTO :result;
printf ("result = %d\n", result);
EXEC SQL DROP TABLE tab;
EXEC SQL DROP FUNCTION my_fun ();
EXEC SQL COMMIT;
EXEC SQL DISCONNECT;
if (dbgs != NULL)
fclose(dbgs);
exit (0);
}
static void ErrorExit (void)
{
EXEC SQL WHENEVER SQLERROR CONTINUE;
sqlprint();
EXEC SQL DROP TABLE tab;
EXEC SQL DROP FUNCTION my_fun ();
EXEC SQL COMMIT;
EXEC SQL DISCONNECT;
exit (-1);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录