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
03842eb0
Commit
03842eb0
authored
Mar 05, 1999
by
Michael Meskes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
*** empty log message ***
parent
9db6b7f3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
43 deletions
+44
-43
src/interfaces/ecpg/lib/ecpglib.c
src/interfaces/ecpg/lib/ecpglib.c
+12
-22
src/interfaces/ecpg/preproc/preproc.y
src/interfaces/ecpg/preproc/preproc.y
+18
-13
src/interfaces/ecpg/test/Makefile
src/interfaces/ecpg/test/Makefile
+6
-2
src/interfaces/ecpg/test/test2.pgc
src/interfaces/ecpg/test/test2.pgc
+8
-6
No files found.
src/interfaces/ecpg/lib/ecpglib.c
View file @
03842eb0
...
...
@@ -113,7 +113,7 @@ register_error(long code, char *fmt,...)
va_end
(
args
);
sqlca
.
sqlerrm
.
sqlerrml
=
strlen
(
sqlca
.
sqlerrm
.
sqlerrmc
);
/* free all memory we
allocate
for the user */
/* free all memory we
have allocated
for the user */
for
(
am
=
auto_allocs
;
am
;)
{
struct
auto_mem
*
act
=
am
;
...
...
@@ -178,7 +178,7 @@ ECPGfinish(struct connection * act)
static
char
*
ecpg_alloc
(
long
size
,
int
lineno
)
{
char
*
new
=
(
char
*
)
malloc
(
size
);
char
*
new
=
(
char
*
)
calloc
(
1L
,
size
);
if
(
!
new
)
{
...
...
@@ -344,7 +344,7 @@ create_statement(int lineno, struct connection *connection, struct statement **
var
->
varcharsize
=
va_arg
(
ap
,
long
);
var
->
arrsize
=
va_arg
(
ap
,
long
);
var
->
offset
=
va_arg
(
ap
,
long
);
if
(
var
->
arrsize
==
0
||
var
->
varcharsize
==
0
)
var
->
value
=
*
((
void
**
)(
var
->
pointer
));
else
...
...
@@ -710,6 +710,8 @@ ECPGexecute(struct statement * stmt)
*/
if
(
var
->
arrsize
==
0
||
var
->
varcharsize
==
0
)
{
int
len
=
0
;
switch
(
var
->
type
)
{
case
ECPGt_char
:
...
...
@@ -720,38 +722,26 @@ ECPGexecute(struct statement * stmt)
/* check strlen for each tuple */
for
(
act_tuple
=
0
;
act_tuple
<
ntuples
;
act_tuple
++
)
{
int
len
=
strlen
(
PQgetvalue
(
results
,
act_tuple
,
act_field
));
int
len
=
strlen
(
PQgetvalue
(
results
,
act_tuple
,
act_field
))
+
1
;
if
(
len
>
var
->
varcharsize
)
var
->
varcharsize
=
len
;
}
var
->
offset
*=
var
->
varcharsize
;
add_mem
((
void
*
)(
var
->
value
)
=
*
((
void
**
)(
var
->
pointer
))
=
(
void
*
)
ecpg_alloc
(
var
->
offset
*
ntuples
,
stmt
->
lineno
),
stmt
->
lineno
)
;
len
=
var
->
offset
*
ntuples
;
}
break
;
#if 0
case
ECPGt_varchar
:
if (((struct ECPGgeneric_varchar *)var->value)->arr == NULL)
{
var->varcharsize = 0;
/* check strlen for each tuple */
for (act_tuple = 0; act_tuple < ntuples; act_tuple++)
{
int len = strlen(PQgetvalue(results, act_tuple, act_field));
if (len > var->varcharsize)
var->varcharsize = len;
((struct ECPGgeneric_varchar *) ((long) var->value + var->offset * act_tuple))->arr = (char *) ecpg_alloc(len, stmt->lineno);
}
}
if
(
var
->
value
==
NULL
)
len
=
ntuples
*
(
var
->
varcharsize
+
sizeof
(
int
));
break
;
#endif
default:
if
(
var
->
value
==
NULL
)
add_mem
((
void
*
)(
var
->
value
)
=
*
((
void
**
)(
var
->
pointer
))
=
(
void
*
)
ecpg_alloc
(
var
->
offset
*
ntuples
,
stmt
->
lineno
),
stmt
->
lineno
)
;
len
=
var
->
offset
*
ntuples
;
break
;
}
add_mem
((
void
*
)(
var
->
value
)
=
*
((
void
**
)(
var
->
pointer
))
=
(
void
*
)
ecpg_alloc
(
len
,
stmt
->
lineno
),
stmt
->
lineno
);
}
for
(
act_tuple
=
0
;
act_tuple
<
ntuples
&&
status
;
act_tuple
++
)
...
...
src/interfaces/ecpg/preproc/preproc.y
View file @
03842eb0
...
...
@@ -573,6 +573,9 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim
*dimension = type_dimension;
}
if (*length >= 0 && *dimension >= 0 && pointer)
yyerror("No multi-dimensional array support");
switch (type_enum)
{
case ECPGt_struct:
...
...
@@ -589,9 +592,9 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim
break;
case ECPGt_varchar:
/* pointer has to get
length
0 */
/* pointer has to get
dimension
0 */
if (pointer)
*
length=
0;
*
dimension =
0;
/* one index is the string length */
if (*length < 0)
...
...
@@ -3721,11 +3724,11 @@ a_expr: attr opt_indirection
}
| a_expr IN '(' in_expr ')'
{
$$ = make4_str($1, make1_str("in ("), $4, make1_str(")"));
$$ = make4_str($1, make1_str("
in ("), $4, make1_str(")"));
}
| a_expr NOT IN '(' not_in_expr ')'
{
$$ = make4_str($1, make1_str("not in ("), $5, make1_str(")"));
$$ = make4_str($1, make1_str("
not in ("), $5, make1_str(")"));
}
| a_expr Op '(' SubSelect ')'
{
...
...
@@ -4838,7 +4841,8 @@ type: simple_type
{
$$.type_str = $1;
$$.type_enum = ECPGt_int;
$$.type_dimension = -1;
$$.type_dimension = -1;
$$.type_index = -1;
}
| symbol
...
...
@@ -4846,7 +4850,7 @@ type: simple_type
/* this is for typedef'ed types */
struct typedefs *this = get_typedef($1);
$$.type_str = mm_strdup(this->name);
$$.type_str =
(this->type->type_enum == ECPGt_varchar) ? make1_str("") :
mm_strdup(this->name);
$$.type_enum = this->type->type_enum;
$$.type_dimension = this->type->type_dimension;
$$.type_index = this->type->type_index;
...
...
@@ -4945,8 +4949,6 @@ variable: opt_pointer symbol opt_array_bounds opt_initializer
switch(dimension)
{
case 0:
strcpy(dim, "[]");
break;
case -1:
case 1:
*dim = '\0';
...
...
@@ -4957,11 +4959,14 @@ variable: opt_pointer symbol opt_array_bounds opt_initializer
}
sprintf(ascii_len, "%d", length);
if (length > 0)
$$ = make4_str(make5_str(mm_strdup(actual_storage[struct_level]), make1_str(" struct varchar_"), mm_strdup($2), make1_str(" { int len; char arr["), mm_strdup(ascii_len)), make1_str("]; } "), mm_strdup($2), mm_strdup(dim));
else
yyerror ("pointer to varchar are not implemented yet");
/* $$ = make4_str(make3_str(mm_strdup(actual_storage[struct_level]), make1_str(" struct varchar_"), mm_strdup($2)), make1_str(" { int len; char *arr; }"), mm_strdup($2), mm_strdup(dim));*/
if (length == 0)
yyerror ("pointer to varchar are not implemented");
if (dimension == 0)
$$ = make4_str(make5_str(mm_strdup(actual_storage[struct_level]), make1_str(" struct varchar_"), mm_strdup($2), make1_str(" { int len; char arr["), mm_strdup(ascii_len)), make1_str("]; } *"), mm_strdup($2), $4);
else
$$ = make5_str(make5_str(mm_strdup(actual_storage[struct_level]), make1_str(" struct varchar_"), mm_strdup($2), make1_str(" { int len; char arr["), mm_strdup(ascii_len)), make1_str("]; } "), mm_strdup($2), mm_strdup(dim), $4);
break;
case ECPGt_char:
case ECPGt_unsigned_char:
...
...
src/interfaces/ecpg/test/Makefile
View file @
03842eb0
all
:
test1 test2 perftest
all
:
test1 test2
test3
perftest
LDFLAGS
=
-g
-I
/usr/local/pgsql/include
-L
/usr/local/pgsql/lib
-lecpg
-lpq
-lcrypt
...
...
@@ -10,9 +10,13 @@ test2: test2.c
test2.c
:
test2.pgc
/usr/local/pgsql/bin/ecpg
$?
test3
:
test3.c
test3.c
:
test3.pgc
/usr/local/pgsql/bin/ecpg
$?
perftest
:
perftest.c
perftest.c
:
perftest.pgc
/usr/local/pgsql/bin/ecpg
$?
clean
:
-
/bin/rm test1 test2 perftest
*
.c log
-
/bin/rm test1 test2
test3
perftest
*
.c log
src/interfaces/ecpg/test/test2.pgc
View file @
03842eb0
...
...
@@ -8,19 +8,21 @@ typedef char* c;
exec sql type ind is union { int integer; short smallint; };
typedef union { int integer; short smallint; } ind;
exec sql type str is varchar[8];
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 {
varchar name[8]
;
struct personal_struct {
str name
;
birthinfo birth;
} personal;
struct personal_indicator { int ind_name;
birthinfo ind_birth;
} ind_personal;
in
t ind_married;
floa
t ind_married;
ind children;
ind ind_children;
char *married = NULL;
...
...
@@ -68,8 +70,8 @@ exec sql end declare section;
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.10
s", married);
if (
(long)
ind_married >= 0)
printf(", married %s", married);
if (ind_children.smallint >= 0)
printf(", children = %d", children.integer);
putchar('\n');
...
...
@@ -98,8 +100,8 @@ exec sql end declare section;
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.10
s", married);
if (
(long)
ind_married >= 0)
printf(", married %s", married);
if (ind_children.smallint >= 0)
printf(", children = %d", children.integer);
putchar('\n');
...
...
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