Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
b53955f3
Commit
b53955f3
authored
Jan 27, 2000
by
Michael Meskes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
*** empty log message ***
parent
dd979f66
Changes
14
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
277 additions
and
323 deletions
+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
No files found.
src/interfaces/ecpg/ChangeLog
View file @
b53955f3
...
...
@@ -775,5 +775,21 @@ Mon Jan 17 21:55:40 CET 2000
- Synced preproc.y with gram.y.
- Changed FETCH syntax using Rene's final patch. Made it more
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 ecpg version to 2.7.0.
src/interfaces/ecpg/lib/ecpglib.c
View file @
b53955f3
...
...
@@ -9,7 +9,7 @@
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 */
#include <stdio.h>
...
...
@@ -724,6 +724,9 @@ ECPGexecute(struct statement * stmt)
*
((
void
**
)
var
->
pointer
)
=
var
->
value
;
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
++
)
{
...
...
@@ -764,7 +767,7 @@ ECPGexecute(struct statement * stmt)
status
=
false
;
break
;
}
switch
(
var
->
type
)
{
long
res
;
...
...
src/interfaces/ecpg/preproc/c_keywords.c
View file @
b53955f3
...
...
@@ -19,25 +19,26 @@
*/
static
ScanKeyword
ScanKeywords
[]
=
{
/* name value */
{
"VARCHAR"
,
S_
VARCHAR
},
{
"VARCHAR"
,
VARCHAR
},
{
"auto"
,
S_AUTO
},
{
"bool"
,
S_BOOL
},
{
"char"
,
S_
CHAR
},
{
"bool"
,
S
QL
_BOOL
},
{
"char"
,
CHAR
},
{
"const"
,
S_CONST
},
{
"double"
,
S_
DOUBLE
},
{
"enum"
,
S_ENUM
},
{
"double"
,
DOUBLE
},
{
"enum"
,
S
QL
_ENUM
},
{
"extern"
,
S_EXTERN
},
{
"float"
,
S_
FLOAT
},
{
"int"
,
S_INT
},
{
"long"
,
S_LONG
},
{
"float"
,
FLOAT
},
{
"int"
,
S
QL
_INT
},
{
"long"
,
S
QL
_LONG
},
{
"register"
,
S_REGISTER
},
{
"short"
,
S_SHORT
},
{
"signed"
,
S_SIGNED
},
{
"short"
,
S
QL
_SHORT
},
{
"signed"
,
S
QL
_SIGNED
},
{
"static"
,
S_STATIC
},
{
"struct"
,
S_STRUCT
},
{
"union"
,
S_UNION
},
{
"unsigned"
,
S_UNSIGNED
},
{
"varchar"
,
S_VARCHAR
},
{
"struct"
,
SQL_STRUCT
},
{
"union"
,
UNION
},
{
"unsigned"
,
SQL_UNSIGNED
},
{
"varchar"
,
VARCHAR
},
{
"volatile"
,
S_VOLATILE
},
};
ScanKeyword
*
...
...
src/interfaces/ecpg/preproc/ecpg.c
View file @
b53955f3
/* 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 */
#include <unistd.h>
...
...
src/interfaces/ecpg/preproc/extern.h
View file @
b53955f3
...
...
@@ -40,6 +40,7 @@ extern int yylex(void);
extern
void
yyerror
(
char
*
);
extern
void
*
mm_alloc
(
size_t
),
*
mm_realloc
(
void
*
,
size_t
);
extern
char
*
mm_strdup
(
const
char
*
);
extern
void
mmerror
(
enum
errortype
,
char
*
);
ScanKeyword
*
ScanECPGKeywordLookup
(
char
*
);
ScanKeyword
*
ScanCKeywordLookup
(
char
*
);
...
...
src/interfaces/ecpg/preproc/pgc.l
View file @
b53955f3
...
...
@@ -12,7 +12,7 @@
*
*
* 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})*.*
errno = 0;
yylval.ival = strtol(literalbuf, &endptr, 2);
if (*endptr != '\0' || errno == ERANGE)
yyerror("ERROR:
Bad binary integer input!");
mmerror(ET_ERROR, "
Bad binary integer input!");
return ICONST;
}
<xh>{xhinside} |
...
...
@@ -268,7 +268,7 @@ cppline {space}*#(.*\\{line_end})*.*
errno = 0;
yylval.ival = strtol(literalbuf, &endptr, 16);
if (*endptr != '\0' || errno == ERANGE)
yyerror("ERROR:
Bad hexadecimal integer input");
mmerror(ET_ERROR, "
Bad hexadecimal integer input");
return ICONST;
}
...
...
@@ -355,7 +355,7 @@ cppline {space}*#(.*\\{line_end})*.*
errno = 0;
yylval.dval = strtod((char *)yytext,&endptr);
if (*endptr != '\0' || errno == ERANGE)
yyerror("ERROR:
Bad float8 input");
mmerror(ET_ERROR, "
Bad float8 input");
return FCONST;
}
yylval.str = mm_strdup((char*)yytext);
...
...
@@ -367,7 +367,7 @@ cppline {space}*#(.*\\{line_end})*.*
errno = 0;
yylval.dval = strtod((char *)yytext,&endptr);
if (*endptr != '\0' || errno == ERANGE)
yyerror("ERROR:
Bad float input");
mmerror(ET_ERROR, "
Bad float input");
return FCONST;
}
<SQL>:{identifier}(("->"|\.){identifier})* {
...
...
@@ -385,6 +385,13 @@ cppline {space}*#(.*\\{line_end})*.*
if (isascii((unsigned char)lower_text[i]) && isupper(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);
if (keyword != NULL) {
return keyword->value;
...
...
@@ -509,10 +516,10 @@ cppline {space}*#(.*\\{line_end})*.*
<C,xskip>{exec_sql}{elif}{space_or_nl}* { /* pop stack */
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 ) {
yyerror("ERROR: m
issing 'EXEC SQL ENDIF;'");
mmerror(ET_FATAL, "M
issing 'EXEC SQL ENDIF;'");
}
else {
preproc_tos--;
...
...
@@ -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' */
if ( stacked_if_value[preproc_tos].else_branch ) {
yyerror("ERROR: d
uplicated 'EXEC SQL ELSE;'");
mmerror(ET_FATAL, "D
uplicated 'EXEC SQL ELSE;'");
}
else {
stacked_if_value[preproc_tos].else_branch = TRUE;
...
...
@@ -541,7 +548,7 @@ cppline {space}*#(.*\\{line_end})*.*
}
<C,xskip>{exec_sql}{endif}{space_or_nl}*";" {
if ( preproc_tos == 0 ) {
yyerror("ERROR: u
nmatched 'EXEC SQL ENDIF;'");
mmerror(ET_FATAL, "U
nmatched 'EXEC SQL ENDIF;'");
}
else {
preproc_tos--;
...
...
@@ -559,7 +566,7 @@ cppline {space}*#(.*\\{line_end})*.*
<xcond>{identifier}{space_or_nl}*";" {
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 {
struct _defines *defptr;
...
...
@@ -680,7 +687,7 @@ cppline {space}*#(.*\\{line_end})*.*
if ( 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)
...
...
src/interfaces/ecpg/preproc/preproc.y
View file @
b53955f3
This diff is collapsed.
Click to expand it.
src/interfaces/ecpg/preproc/type.h
View file @
b53955f3
...
...
@@ -138,3 +138,5 @@ struct arguments
struct
variable
*
indicator
;
struct
arguments
*
next
;
};
enum
errortype
{
ET_WARN
,
ET_ERROR
,
ET_FATAL
};
src/interfaces/ecpg/test/Makefile
View file @
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
../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
=
../preproc/ecpg
-I
../include
#ECPG=/usr/bin/ecpg -I/usr/include/postgresql
.SUFFIXES
:
.pgc .c
...
...
@@ -12,10 +14,16 @@ test1: test1.c
test2
:
test2.c
test3
:
test3.c
test4
:
test4.c
test5
:
test5.c
perftest
:
perftest.c
.pgc.c
:
$(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
:
-
/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
View file @
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
View file @
b53955f3
...
...
@@ -94,11 +94,20 @@ exec sql end declare section;
strcpy(msg, "select");
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++)
{
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";
printf("Database: pm\n");
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]);
...
...
src/interfaces/ecpg/test/test2.pgc
View file @
b53955f3
...
...
@@ -62,7 +62,7 @@ exec sql end declare section;
while (1) {
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);
if (ind_personal.ind_birth.born >= 0)
printf(", born %d", personal.birth.born);
...
...
src/interfaces/ecpg/test/test3.pgc
View file @
b53955f3
...
...
@@ -19,7 +19,7 @@ exec sql begin declare section;
int ind_children;
str *married = NULL;
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 declare cur cursor for
...
...
@@ -54,7 +54,7 @@ exec sql end declare section;
while (1) {
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);
if (ind_personal.ind_birth.born >= 0)
printf(", born %d", personal.birth.born);
...
...
@@ -74,7 +74,7 @@ exec sql end declare section;
exec sql close cur;
/* 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;
strcpy(msg, "open");
...
...
src/interfaces/ecpg/test/test5.pgc
0 → 100644
View file @
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);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment