Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc9ecf3d

Browse files
author
Michael Meskes
committed
Applied two bug fixes by Christof Petig.
1 parent234599e commitc9ecf3d

File tree

4 files changed

+92
-46
lines changed

4 files changed

+92
-46
lines changed

‎src/interfaces/ecpg/ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,5 +1047,9 @@ Tue Jan 23 08:54:14 CET 2001
10471047
Thu Jan 25 21:14:38 CET 2001
10481048

10491049
- Synced gram.y and preproc.y.
1050+
1051+
Wed Jan 31 17:11:04 CET 2001
1052+
1053+
- Added two bug fixes by Christof Petig.
10501054
- Set ecpg version to 2.8.0.
10511055
- Set library version to 3.2.0.

‎src/interfaces/ecpg/lib/execute.c

Lines changed: 63 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -288,48 +288,52 @@ ECPGis_type_an_array(int type,const struct statement * stmt,const struct variabl
288288

289289
if ((stmt->connection->cache_head)==NULL)
290290
{
291+
/* Text like types are not an array for ecpg, but postgres counts them as
292+
an array. This define reminds you to not 'correct' these values. */
293+
#definenot_an_array_in_ecpg false
294+
291295
/* populate cache with well known types to speed things up */
292-
ECPGtypeinfocache_push(&(stmt->connection->cache_head),BOOLOID, false,stmt->lineno);
293-
ECPGtypeinfocache_push(&(stmt->connection->cache_head),BYTEAOID,true,stmt->lineno);
294-
ECPGtypeinfocache_push(&(stmt->connection->cache_head),CHAROID, false,stmt->lineno);
295-
ECPGtypeinfocache_push(&(stmt->connection->cache_head),NAMEOID,true,stmt->lineno);
296-
ECPGtypeinfocache_push(&(stmt->connection->cache_head),INT8OID, false,stmt->lineno);
297-
ECPGtypeinfocache_push(&(stmt->connection->cache_head),INT2OID, false,stmt->lineno);
298-
ECPGtypeinfocache_push(&(stmt->connection->cache_head),INT2VECTOROID, true,stmt->lineno);
299-
ECPGtypeinfocache_push(&(stmt->connection->cache_head),INT4OID, false,stmt->lineno);
300-
ECPGtypeinfocache_push(&(stmt->connection->cache_head),REGPROCOID, false,stmt->lineno);
301-
ECPGtypeinfocache_push(&(stmt->connection->cache_head),TEXTOID,true,stmt->lineno);
302-
ECPGtypeinfocache_push(&(stmt->connection->cache_head),OIDOID, false,stmt->lineno);
303-
ECPGtypeinfocache_push(&(stmt->connection->cache_head),TIDOID, false,stmt->lineno);
304-
ECPGtypeinfocache_push(&(stmt->connection->cache_head),XIDOID, false,stmt->lineno);
305-
ECPGtypeinfocache_push(&(stmt->connection->cache_head),CIDOID, false,stmt->lineno);
306-
ECPGtypeinfocache_push(&(stmt->connection->cache_head),OIDVECTOROID, true,stmt->lineno);
307-
ECPGtypeinfocache_push(&(stmt->connection->cache_head),POINTOID, true,stmt->lineno);
308-
ECPGtypeinfocache_push(&(stmt->connection->cache_head),LSEGOID, true,stmt->lineno);
309-
ECPGtypeinfocache_push(&(stmt->connection->cache_head),PATHOID,true,stmt->lineno);
310-
ECPGtypeinfocache_push(&(stmt->connection->cache_head),BOXOID, true,stmt->lineno);
311-
ECPGtypeinfocache_push(&(stmt->connection->cache_head),POLYGONOID, false,stmt->lineno);
312-
ECPGtypeinfocache_push(&(stmt->connection->cache_head),LINEOID, true,stmt->lineno);
313-
ECPGtypeinfocache_push(&(stmt->connection->cache_head),FLOAT4OID, false,stmt->lineno);
314-
ECPGtypeinfocache_push(&(stmt->connection->cache_head),FLOAT8OID, false,stmt->lineno);
315-
ECPGtypeinfocache_push(&(stmt->connection->cache_head),ABSTIMEOID, false,stmt->lineno);
316-
ECPGtypeinfocache_push(&(stmt->connection->cache_head),RELTIMEOID, false,stmt->lineno);
317-
ECPGtypeinfocache_push(&(stmt->connection->cache_head),TINTERVALOID, false,stmt->lineno);
318-
ECPGtypeinfocache_push(&(stmt->connection->cache_head),UNKNOWNOID,true,stmt->lineno);
319-
ECPGtypeinfocache_push(&(stmt->connection->cache_head),CIRCLEOID, false,stmt->lineno);
320-
ECPGtypeinfocache_push(&(stmt->connection->cache_head),CASHOID, false,stmt->lineno);
321-
ECPGtypeinfocache_push(&(stmt->connection->cache_head),INETOID, false,stmt->lineno);
322-
ECPGtypeinfocache_push(&(stmt->connection->cache_head),CIDROID, false,stmt->lineno);
323-
ECPGtypeinfocache_push(&(stmt->connection->cache_head),BPCHAROID, false,stmt->lineno);
324-
ECPGtypeinfocache_push(&(stmt->connection->cache_head),VARCHAROID, false,stmt->lineno);
325-
ECPGtypeinfocache_push(&(stmt->connection->cache_head),DATEOID, false,stmt->lineno);
326-
ECPGtypeinfocache_push(&(stmt->connection->cache_head),TIMEOID, false,stmt->lineno);
327-
ECPGtypeinfocache_push(&(stmt->connection->cache_head),TIMESTAMPOID, false,stmt->lineno);
328-
ECPGtypeinfocache_push(&(stmt->connection->cache_head),INTERVALOID, false,stmt->lineno);
329-
ECPGtypeinfocache_push(&(stmt->connection->cache_head),TIMETZOID, false,stmt->lineno);
330-
ECPGtypeinfocache_push(&(stmt->connection->cache_head),ZPBITOID, false,stmt->lineno);
331-
ECPGtypeinfocache_push(&(stmt->connection->cache_head),VARBITOID, false,stmt->lineno);
332-
ECPGtypeinfocache_push(&(stmt->connection->cache_head),NUMERICOID, false,stmt->lineno);
296+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),BOOLOID, false,stmt->lineno);
297+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),BYTEAOID,not_an_array_in_ecpg,stmt->lineno);
298+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),CHAROID, false,stmt->lineno);
299+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),NAMEOID,not_an_array_in_ecpg,stmt->lineno);
300+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),INT8OID, false,stmt->lineno);
301+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),INT2OID, false,stmt->lineno);
302+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),INT2VECTOROID, true,stmt->lineno);
303+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),INT4OID, false,stmt->lineno);
304+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),REGPROCOID, false,stmt->lineno);
305+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),TEXTOID,not_an_array_in_ecpg,stmt->lineno);
306+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),OIDOID, false,stmt->lineno);
307+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),TIDOID, false,stmt->lineno);
308+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),XIDOID, false,stmt->lineno);
309+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),CIDOID, false,stmt->lineno);
310+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),OIDVECTOROID, true,stmt->lineno);
311+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),POINTOID, true,stmt->lineno);
312+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),LSEGOID, true,stmt->lineno);
313+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),PATHOID,not_an_array_in_ecpg,stmt->lineno);
314+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),BOXOID, true,stmt->lineno);
315+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),POLYGONOID, false,stmt->lineno);
316+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),LINEOID, true,stmt->lineno);
317+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),FLOAT4OID, false,stmt->lineno);
318+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),FLOAT8OID, false,stmt->lineno);
319+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),ABSTIMEOID, false,stmt->lineno);
320+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),RELTIMEOID, false,stmt->lineno);
321+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),TINTERVALOID, false,stmt->lineno);
322+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),UNKNOWNOID,not_an_array_in_ecpg,stmt->lineno);
323+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),CIRCLEOID, false,stmt->lineno);
324+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),CASHOID, false,stmt->lineno);
325+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),INETOID, false,stmt->lineno);
326+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),CIDROID, false,stmt->lineno);
327+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),BPCHAROID, false,stmt->lineno);
328+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),VARCHAROID, false,stmt->lineno);
329+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),DATEOID, false,stmt->lineno);
330+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),TIMEOID, false,stmt->lineno);
331+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),TIMESTAMPOID, false,stmt->lineno);
332+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),INTERVALOID, false,stmt->lineno);
333+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),TIMETZOID, false,stmt->lineno);
334+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),ZPBITOID, false,stmt->lineno);
335+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),VARBITOID, false,stmt->lineno);
336+
ECPGtypeinfocache_push(&(stmt->connection->cache_head),NUMERICOID, false,stmt->lineno);
333337
}
334338

335339
for (cache_entry= (stmt->connection->cache_head);cache_entry!=NULL;cache_entry=cache_entry->next)
@@ -630,13 +634,27 @@ ECPGexecute(struct statement * stmt)
630634
{
631635
strncpy(mallocedval,"'{",sizeof("'{"));
632636

633-
for (element=0;element<var->arrsize;element++)
634-
sprintf(mallocedval+strlen(mallocedval),"%c,", (((char*)var->value)[element]) ?'t' :'f');
637+
if (var->offset==sizeof(char))
638+
for (element=0;element<var->arrsize;element++)
639+
sprintf(mallocedval+strlen(mallocedval),"%c,", (((char*)var->value)[element]) ?'t' :'f');
640+
// this is necessary since sizeof(C++'s bool)==sizeof(int)
641+
elseif (var->offset==sizeof(int))
642+
for (element=0;element<var->arrsize;element++)
643+
sprintf(mallocedval+strlen(mallocedval),"%c,", (((int*)var->value)[element]) ?'t' :'f');
644+
else
645+
ECPGraise(stmt->lineno,ECPG_CONVERT_BOOL,"different size");
635646

636647
strncpy(mallocedval+strlen(mallocedval)-1,"}'",sizeof("}'"));
637648
}
638649
else
639-
sprintf(mallocedval,"'%c'", (*((char*)var->value)) ?'t' :'f');
650+
{
651+
if (var->offset==sizeof(char))
652+
sprintf(mallocedval,"'%c'", (*((char*)var->value)) ?'t' :'f');
653+
elseif (var->offset==sizeof(int))
654+
sprintf(mallocedval,"'%c'", (*((int*)var->value)) ?'t' :'f');
655+
else
656+
ECPGraise(stmt->lineno,ECPG_CONVERT_BOOL,"different size");
657+
}
640658

641659
tobeinserted=mallocedval;
642660
break;
@@ -1006,7 +1024,7 @@ ECPGdo(int lineno, const char *connection_name, char *query,...)
10061024
*
10071025
* Copyright (c) 2000, Christof Petig <christof.petig@wtal.de>
10081026
*
1009-
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/execute.c,v 1.16 2001/01/02 22:03:02 momjian Exp $
1027+
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/execute.c,v 1.17 2001/01/31 16:12:34 meskes Exp $
10101028
*/
10111029

10121030
PGconn*ECPG_internal_get_connection(char*name);

‎src/interfaces/ecpg/test/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ dyntest2: dyntest2.c
1818
test_code100: test_code100.c
1919
test_notice: test_notice.c
2020
test_init: test_init.c
21+
test_text: test_text.c
2122

2223
.pgc.c:
2324
$(ECPG)$?
2425

2526
clean:
26-
rm -f test1 test2 test3 test4 perftest*.c log dyntest dyntest2 test_notice test_code100 test_init
27+
rm -f test1 test2 test3 test4 perftest*.c log dyntest dyntest2 test_notice test_code100 test_init test_text
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// $Id: test_text.pgc,v 1.1 2001/01/31 16:12:34 meskes Exp $
2+
3+
exec sql include sqlca;
4+
#include <stdio.h>
5+
6+
int main(int argc, char **argv)
7+
{ exec sql begin declare section;
8+
int index;
9+
char lab[15];
10+
exec sql end declare section;
11+
12+
ECPGdebug(1,stdout);
13+
14+
exec sql connect to mm;
15+
if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
16+
17+
exec sql select 'a1234567890'::text into :lab;
18+
if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
19+
20+
exec sql disconnect;
21+
if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
22+
return 0;
23+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp