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
9a8d15bd
Commit
9a8d15bd
authored
Aug 17, 2010
by
Michael Meskes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Applied Zoltan's patch to fix a few memleaks in ecpg's pgtypeslib.
parent
7b243aa6
Changes
18
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
63 additions
and
18 deletions
+63
-18
src/interfaces/ecpg/pgtypeslib/numeric.c
src/interfaces/ecpg/pgtypeslib/numeric.c
+6
-3
src/interfaces/ecpg/test/compat_informix/dec_test.pgc
src/interfaces/ecpg/test/compat_informix/dec_test.pgc
+4
-0
src/interfaces/ecpg/test/expected/compat_informix-dec_test.c
src/interfaces/ecpg/test/expected/compat_informix-dec_test.c
+4
-0
src/interfaces/ecpg/test/expected/pgtypeslib-dt_test.c
src/interfaces/ecpg/test/expected/pgtypeslib-dt_test.c
+5
-4
src/interfaces/ecpg/test/expected/pgtypeslib-dt_test.stderr
src/interfaces/ecpg/test/expected/pgtypeslib-dt_test.stderr
+1
-1
src/interfaces/ecpg/test/expected/pgtypeslib-dt_test2.c
src/interfaces/ecpg/test/expected/pgtypeslib-dt_test2.c
+2
-0
src/interfaces/ecpg/test/expected/pgtypeslib-nan_test.c
src/interfaces/ecpg/test/expected/pgtypeslib-nan_test.c
+6
-4
src/interfaces/ecpg/test/expected/pgtypeslib-nan_test.stderr
src/interfaces/ecpg/test/expected/pgtypeslib-nan_test.stderr
+1
-1
src/interfaces/ecpg/test/expected/pgtypeslib-num_test.c
src/interfaces/ecpg/test/expected/pgtypeslib-num_test.c
+7
-4
src/interfaces/ecpg/test/expected/pgtypeslib-num_test.stderr
src/interfaces/ecpg/test/expected/pgtypeslib-num_test.stderr
+1
-1
src/interfaces/ecpg/test/expected/pgtypeslib-num_test2.c
src/interfaces/ecpg/test/expected/pgtypeslib-num_test2.c
+7
-0
src/interfaces/ecpg/test/expected/sql-array.c
src/interfaces/ecpg/test/expected/sql-array.c
+2
-0
src/interfaces/ecpg/test/pgtypeslib/dt_test.pgc
src/interfaces/ecpg/test/pgtypeslib/dt_test.pgc
+1
-0
src/interfaces/ecpg/test/pgtypeslib/dt_test2.pgc
src/interfaces/ecpg/test/pgtypeslib/dt_test2.pgc
+2
-0
src/interfaces/ecpg/test/pgtypeslib/nan_test.pgc
src/interfaces/ecpg/test/pgtypeslib/nan_test.pgc
+2
-0
src/interfaces/ecpg/test/pgtypeslib/num_test.pgc
src/interfaces/ecpg/test/pgtypeslib/num_test.pgc
+3
-0
src/interfaces/ecpg/test/pgtypeslib/num_test2.pgc
src/interfaces/ecpg/test/pgtypeslib/num_test2.pgc
+7
-0
src/interfaces/ecpg/test/sql/array.pgc
src/interfaces/ecpg/test/sql/array.pgc
+2
-0
No files found.
src/interfaces/ecpg/pgtypeslib/numeric.c
View file @
9a8d15bd
/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/numeric.c,v 1.3
5 2010/02/02 16:09:12
meskes Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/numeric.c,v 1.3
6 2010/08/17 09:36:04
meskes Exp $ */
#include "postgres_fe.h"
#include <ctype.h>
...
...
@@ -417,7 +417,7 @@ PGTYPESnumeric_from_asc(char *str, char **endptr)
ret
=
set_var_from_str
(
str
,
ptr
,
value
);
if
(
ret
)
{
free
(
value
);
PGTYPESnumeric_
free
(
value
);
return
(
NULL
);
}
...
...
@@ -1602,8 +1602,12 @@ PGTYPESnumeric_to_long(numeric *nv, long *lp)
errno
=
0
;
*
lp
=
strtol
(
s
,
&
endptr
,
10
);
if
(
endptr
==
s
)
{
/* this should not happen actually */
free
(
s
);
return
-
1
;
}
free
(
s
);
if
(
errno
==
ERANGE
)
{
if
(
*
lp
==
LONG_MIN
)
...
...
@@ -1612,7 +1616,6 @@ PGTYPESnumeric_to_long(numeric *nv, long *lp)
errno
=
PGTYPES_NUM_OVERFLOW
;
return
-
1
;
}
free
(
s
);
return
0
;
}
...
...
src/interfaces/ecpg/test/compat_informix/dec_test.pgc
View file @
9a8d15bd
...
...
@@ -60,6 +60,7 @@ main(void)
{
check_errno();
printf("dec[%d,0]: r: %d\n", i, r);
PGTYPESdecimal_free(dec);
continue;
}
decarr = realloc(decarr, sizeof(decimal *) * (count + 1));
...
...
@@ -200,7 +201,10 @@ main(void)
{
dectoasc(decarr[i], buf, BUFSIZE-1, -1);
printf("%d: %s\n", i, buf);
PGTYPESdecimal_free(decarr[i]);
}
free(decarr);
return (0);
}
...
...
src/interfaces/ecpg/test/expected/compat_informix-dec_test.c
View file @
9a8d15bd
...
...
@@ -80,6 +80,7 @@ main(void)
{
check_errno
();
printf
(
"dec[%d,0]: r: %d
\n
"
,
i
,
r
);
PGTYPESdecimal_free
(
dec
);
continue
;
}
decarr
=
realloc
(
decarr
,
sizeof
(
decimal
*
)
*
(
count
+
1
));
...
...
@@ -220,7 +221,10 @@ main(void)
{
dectoasc
(
decarr
[
i
],
buf
,
BUFSIZE
-
1
,
-
1
);
printf
(
"%d: %s
\n
"
,
i
,
buf
);
PGTYPESdecimal_free
(
decarr
[
i
]);
}
free
(
decarr
);
return
(
0
);
}
...
...
src/interfaces/ecpg/test/expected/pgtypeslib-dt_test.c
View file @
9a8d15bd
...
...
@@ -123,6 +123,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
PGTYPESinterval_copy
(
iv1
,
&
iv2
);
text
=
PGTYPESinterval_to_asc
(
&
iv2
);
printf
(
"interval: %s
\n
"
,
text
);
PGTYPESinterval_free
(
iv1
);
free
(
text
);
PGTYPESdate_mdyjul
(
mdy
,
&
date2
);
...
...
@@ -430,16 +431,16 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
free
(
text
);
{
ECPGtrans
(
__LINE__
,
NULL
,
"rollback"
);
#line 35
8
"dt_test.pgc"
#line 35
9
"dt_test.pgc"
if
(
sqlca
.
sqlcode
<
0
)
sqlprint
(
);}
#line 35
8
"dt_test.pgc"
#line 35
9
"dt_test.pgc"
{
ECPGdisconnect
(
__LINE__
,
"CURRENT"
);
#line 3
59
"dt_test.pgc"
#line 3
60
"dt_test.pgc"
if
(
sqlca
.
sqlcode
<
0
)
sqlprint
(
);}
#line 3
59
"dt_test.pgc"
#line 3
60
"dt_test.pgc"
return
(
0
);
...
...
src/interfaces/ecpg/test/expected/pgtypeslib-dt_test.stderr
View file @
9a8d15bd
...
...
@@ -42,7 +42,7 @@
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data on line 38: RESULT: 2000-07-12 17:34:29 offset: -1; array: no
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGtrans on line 35
8
: action "rollback"; connection "regress1"
[NO_PID]: ECPGtrans on line 35
9
: action "rollback"; connection "regress1"
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_finish: connection regress1 closed
[NO_PID]: sqlca: code: 0, state: 00000
src/interfaces/ecpg/test/expected/pgtypeslib-dt_test2.c
View file @
9a8d15bd
...
...
@@ -139,6 +139,7 @@ main(void)
printf
(
"TS[%d,%d]: %s
\n
"
,
i
,
j
,
errno
?
"-"
:
text
);
free
(
text
);
free
(
t
);
}
}
}
...
...
@@ -169,6 +170,7 @@ main(void)
printf
(
"interval_copy[%d]: %s
\n
"
,
i
,
text
?
text
:
"-"
);
free
(
text
);
PGTYPESinterval_free
(
ic
);
PGTYPESinterval_free
(
i1
);
}
return
(
0
);
...
...
src/interfaces/ecpg/test/expected/pgtypeslib-nan_test.c
View file @
9a8d15bd
...
...
@@ -252,17 +252,19 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
#line 84 "nan_test.pgc"
PGTYPESnumeric_free
(
num
);
{
ECPGtrans
(
__LINE__
,
NULL
,
"rollback"
);
#line 8
6
"nan_test.pgc"
#line 8
8
"nan_test.pgc"
if
(
sqlca
.
sqlcode
<
0
)
sqlprint
(
);}
#line 8
6
"nan_test.pgc"
#line 8
8
"nan_test.pgc"
{
ECPGdisconnect
(
__LINE__
,
"CURRENT"
);
#line 8
7
"nan_test.pgc"
#line 8
9
"nan_test.pgc"
if
(
sqlca
.
sqlcode
<
0
)
sqlprint
(
);}
#line 8
7
"nan_test.pgc"
#line 8
9
"nan_test.pgc"
return
(
0
);
...
...
src/interfaces/ecpg/test/expected/pgtypeslib-nan_test.stderr
View file @
9a8d15bd
...
...
@@ -354,7 +354,7 @@
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 84: OK: CLOSE CURSOR
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGtrans on line 8
6
: action "rollback"; connection "regress1"
[NO_PID]: ECPGtrans on line 8
8
: action "rollback"; connection "regress1"
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_finish: connection regress1 closed
[NO_PID]: sqlca: code: 0, state: 00000
src/interfaces/ecpg/test/expected/pgtypeslib-num_test.c
View file @
9a8d15bd
...
...
@@ -131,6 +131,9 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
PGTYPESnumeric_to_double
(
res
,
&
d
);
printf
(
"div = %s %e
\n
"
,
text
,
d
);
PGTYPESnumeric_free
(
value1
);
PGTYPESnumeric_free
(
value2
);
value1
=
PGTYPESnumeric_from_asc
(
"2E7"
,
NULL
);
value2
=
PGTYPESnumeric_from_asc
(
"14"
,
NULL
);
i
=
PGTYPESnumeric_to_long
(
value1
,
&
l1
)
|
PGTYPESnumeric_to_long
(
value2
,
&
l2
);
...
...
@@ -142,16 +145,16 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
PGTYPESnumeric_free
(
res
);
{
ECPGtrans
(
__LINE__
,
NULL
,
"rollback"
);
#line 9
0
"num_test.pgc"
#line 9
3
"num_test.pgc"
if
(
sqlca
.
sqlcode
<
0
)
sqlprint
(
);}
#line 9
0
"num_test.pgc"
#line 9
3
"num_test.pgc"
{
ECPGdisconnect
(
__LINE__
,
"CURRENT"
);
#line 9
1
"num_test.pgc"
#line 9
4
"num_test.pgc"
if
(
sqlca
.
sqlcode
<
0
)
sqlprint
(
);}
#line 9
1
"num_test.pgc"
#line 9
4
"num_test.pgc"
return
(
0
);
...
...
src/interfaces/ecpg/test/expected/pgtypeslib-num_test.stderr
View file @
9a8d15bd
...
...
@@ -26,7 +26,7 @@
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data on line 66: RESULT: 2369.7000000 offset: -1; array: no
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGtrans on line 9
0
: action "rollback"; connection "regress1"
[NO_PID]: ECPGtrans on line 9
3
: action "rollback"; connection "regress1"
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_finish: connection regress1 closed
[NO_PID]: sqlca: code: 0, state: 00000
src/interfaces/ecpg/test/expected/pgtypeslib-num_test2.c
View file @
9a8d15bd
...
...
@@ -211,6 +211,11 @@ main(void)
printf
(
"num[d,%d,%d]: %s
\n
"
,
i
,
j
,
text
);
free
(
text
);
}
PGTYPESnumeric_free
(
a
);
PGTYPESnumeric_free
(
s
);
PGTYPESnumeric_free
(
m
);
PGTYPESnumeric_free
(
d
);
}
}
...
...
@@ -219,7 +224,9 @@ main(void)
text
=
PGTYPESnumeric_to_asc
(
numarr
[
i
],
-
1
);
printf
(
"%d: %s
\n
"
,
i
,
text
);
free
(
text
);
PGTYPESnumeric_free
(
numarr
[
i
]);
}
free
(
numarr
);
return
(
0
);
}
...
...
src/interfaces/ecpg/test/expected/sql-array.c
View file @
9a8d15bd
...
...
@@ -273,5 +273,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
#line 74 "array.pgc"
free
(
t
);
return
(
0
);
}
src/interfaces/ecpg/test/pgtypeslib/dt_test.pgc
View file @
9a8d15bd
...
...
@@ -49,6 +49,7 @@ main(void)
PGTYPESinterval_copy(iv1, &iv2);
text = PGTYPESinterval_to_asc(&iv2);
printf ("interval: %s\n", text);
PGTYPESinterval_free(iv1);
free(text);
PGTYPESdate_mdyjul(mdy, &date2);
...
...
src/interfaces/ecpg/test/pgtypeslib/dt_test2.pgc
View file @
9a8d15bd
...
...
@@ -104,6 +104,7 @@ main(void)
printf("TS[%d,%d]: %s\n",
i, j, errno ? "-" : text);
free(text);
free(t);
}
}
}
...
...
@@ -134,6 +135,7 @@ main(void)
printf("interval_copy[%d]: %s\n", i, text ? text : "-");
free(text);
PGTYPESinterval_free(ic);
PGTYPESinterval_free(i1);
}
return (0);
...
...
src/interfaces/ecpg/test/pgtypeslib/nan_test.pgc
View file @
9a8d15bd
...
...
@@ -83,6 +83,8 @@ main(void)
}
exec sql close cur1;
PGTYPESnumeric_free(num);
exec sql rollback;
exec sql disconnect;
...
...
src/interfaces/ecpg/test/pgtypeslib/num_test.pgc
View file @
9a8d15bd
...
...
@@ -77,6 +77,9 @@ main(void)
PGTYPESnumeric_to_double(res, &d);
printf("div = %s %e\n", text, d);
PGTYPESnumeric_free(value1);
PGTYPESnumeric_free(value2);
value1 = PGTYPESnumeric_from_asc("2E7", NULL);
value2 = PGTYPESnumeric_from_asc("14", NULL);
i = PGTYPESnumeric_to_long(value1, &l1) | PGTYPESnumeric_to_long(value2, &l2);
...
...
src/interfaces/ecpg/test/pgtypeslib/num_test2.pgc
View file @
9a8d15bd
...
...
@@ -193,6 +193,11 @@ main(void)
printf("num[d,%d,%d]: %s\n", i, j, text);
free(text);
}
PGTYPESnumeric_free(a);
PGTYPESnumeric_free(s);
PGTYPESnumeric_free(m);
PGTYPESnumeric_free(d);
}
}
...
...
@@ -201,7 +206,9 @@ main(void)
text = PGTYPESnumeric_to_asc(numarr[i], -1);
printf("%d: %s\n", i, text);
free(text);
PGTYPESnumeric_free(numarr[i]);
}
free(numarr);
return (0);
}
...
...
src/interfaces/ecpg/test/sql/array.pgc
View file @
9a8d15bd
...
...
@@ -73,5 +73,7 @@ EXEC SQL END DECLARE SECTION;
EXEC SQL DISCONNECT;
free(t);
return (0);
}
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