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

Commit2b55612

Browse files
author
Michael Meskes
committed
- Added additional test case.
- Fixed bug that reversed string length in typedefs.- Added portability file to pgtypeslib.
1 parenta90b2a0 commit2b55612

File tree

7 files changed

+91
-14
lines changed

7 files changed

+91
-14
lines changed

‎src/interfaces/ecpg/ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1784,6 +1784,12 @@ Wed May 5 11:51:47 CEST 2004
17841784
variables.
17851785
- Synced parser again.
17861786
- Synced lexer.
1787+
1788+
Fri May 7 15:34:05 CEST 2004
1789+
1790+
- Added portability file to pgtypeslib.
1791+
- Fixed bug that reversed string length in typedefs.
1792+
- Added additional test case.
17871793
- Set pgtypes library version to 1.2.
17881794
- Set ecpg version to 3.2.0.
17891795
- Set compat library version to 1.2.

‎src/interfaces/ecpg/pgtypeslib/Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# Copyright (c) 1994, Regents of the University of California
66
#
7-
# $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/Makefile,v 1.18 2004/04/30 04:14:06 momjian Exp $
7+
# $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/Makefile,v 1.19 2004/05/07 13:42:48 meskes Exp $
88
#
99
#-------------------------------------------------------------------------
1010

@@ -23,7 +23,7 @@ override CPPFLAGS := -I$(top_srcdir)/src/interfaces/ecpg/include \
2323
SHLIB_LINK += -lm
2424

2525
OBJS= numeric.o datetime.o common.o dt_common.o timestamp.o interval.o\
26-
$(filter rint.o,$(LIBOBJS))
26+
$(filter rint.o,$(LIBOBJS))$(filter pgstrcasecmp.o,$(LIBOBJS))
2727

2828
all: all-lib
2929

@@ -33,6 +33,9 @@ include $(top_srcdir)/src/Makefile.shlib
3333
rint.c:%.c :$(top_srcdir)/src/port/%.c
3434
rm -f$@&&$(LN_S)$<.
3535

36+
pgstrcasecmp.c:%.c :$(top_srcdir)/src/port/%.c
37+
rm -f$@&&$(LN_S)$<.
38+
3639
install: all installdirs install-lib
3740

3841
installdirs:

‎src/interfaces/ecpg/preproc/extern.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ extern void add_variable_to_head(struct arguments **, struct variable *, struct
7979
externvoidadd_variable_to_tail(structarguments**,structvariable*,structvariable*);
8080
externvoiddump_variables(structarguments*,int);
8181
externstructtypedefs*get_typedef(char*);
82-
externvoidadjust_array(enumECPGttype,char**,char**,char*,char*,int);
82+
externvoidadjust_array(enumECPGttype,char**,char**,char*,char*,int,bool);
8383
externvoidreset_variables(void);
8484
externvoidcheck_indicator(structECPGtype*);
8585
externvoidremove_variables(int);

‎src/interfaces/ecpg/preproc/preproc.y

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.280 2004/05/0700:24:59 tgl Exp $*/
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.281 2004/05/0713:42:49 meskes Exp $*/
22

33
/* Copyright comment*/
44
%{
@@ -4574,8 +4574,7 @@ type_declaration: S_TYPEDEF
45744574
mmerror(PARSE_ERROR, ET_ERROR, errortext);
45754575
}
45764576
}
4577-
4578-
adjust_array($3.type_enum, &dimension, &length, $3.type_dimension, $3.type_index, *$4?1:0);
4577+
adjust_array($3.type_enum, &dimension, &length, $3.type_dimension, $3.type_index, *$4?1:0,true);
45794578

45804579
this = (structtypedefs *) mm_alloc(sizeof(structtypedefs));
45814580

@@ -5021,7 +5020,7 @@ variable: opt_pointer ECPGColLabel opt_array_bounds opt_initializer
50215020
char *length =$3.index2;/* length of string*/
50225021
char dim[14L];
50235022

5024-
adjust_array(actual_type[struct_level].type_enum, &dimension, &length, actual_type[struct_level].type_dimension, actual_type[struct_level].type_index, strlen($1));
5023+
adjust_array(actual_type[struct_level].type_enum, &dimension, &length, actual_type[struct_level].type_dimension, actual_type[struct_level].type_index, strlen($1), false);
50255024

50265025
switch (actual_type[struct_level].type_enum)
50275026
{
@@ -5411,7 +5410,7 @@ ECPGTypedef: TYPE_P
54115410
}
54125411
}
54135412

5414-
adjust_array($5.type_enum, &dimension, &length, $5.type_dimension, $5.type_index, *$7?1:0);
5413+
adjust_array($5.type_enum, &dimension, &length, $5.type_dimension, $5.type_index, *$7?1:0,false);
54155414

54165415
this = (structtypedefs *) mm_alloc(sizeof(structtypedefs));
54175416

@@ -5469,7 +5468,7 @@ ECPGVar: SQL_VAR
54695468
mmerror(PARSE_ERROR, ET_ERROR,"Initializer not allowed in EXEC SQL VAR command");
54705469
else
54715470
{
5472-
adjust_array($5.type_enum, &dimension, &length, $5.type_dimension, $5.type_index, *$7?1:0);
5471+
adjust_array($5.type_enum, &dimension, &length, $5.type_dimension, $5.type_index, *$7?1:0,false);
54735472

54745473
switch ($5.type_enum)
54755474
{

‎src/interfaces/ecpg/preproc/variable.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ get_typedef(char *name)
459459
}
460460

461461
void
462-
adjust_array(enumECPGttypetype_enum,char**dimension,char**length,char*type_dimension,char*type_index,intpointer_len)
462+
adjust_array(enumECPGttypetype_enum,char**dimension,char**length,char*type_dimension,char*type_index,intpointer_len,booltype_definition)
463463
{
464464
if (atoi(type_index) >=0)
465465
{
@@ -484,7 +484,6 @@ adjust_array(enum ECPGttype type_enum, char **dimension, char **length, char *ty
484484
{
485485
snprintf(errortext,sizeof(errortext),"No multilevel (more than 2) pointer supported %d",pointer_len);
486486
mmerror(PARSE_ERROR,ET_FATAL,errortext);
487-
/*mmerror(PARSE_ERROR, ET_FATAL, "No multilevel (more than 2) pointer supported %d",pointer_len);*/
488487
}
489488

490489
if (pointer_len>1&&type_enum!=ECPGt_char&&type_enum!=ECPGt_unsigned_char)
@@ -544,7 +543,11 @@ adjust_array(enum ECPGttype type_enum, char **dimension, char **length, char *ty
544543
* make sure we return length = -1 for arrays without
545544
* given bounds
546545
*/
547-
if (atoi(*dimension)<0)
546+
if (atoi(*dimension)<0&& !type_definition)
547+
/*
548+
* do not change this for typedefs
549+
* since it will be changed later on when the variable is defined
550+
*/
548551
*length=make_str("1");
549552
elseif (atoi(*dimension)==0)
550553
*length=make_str("-1");

‎src/interfaces/ecpg/test/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $PostgreSQL: pgsql/src/interfaces/ecpg/test/Makefile,v 1.47 2004/04/30 04:14:06 momjian Exp $
1+
# $PostgreSQL: pgsql/src/interfaces/ecpg/test/Makefile,v 1.48 2004/05/07 13:42:49 meskes Exp $
22

33
subdir = src/interfaces/ecpg/test
44
top_builddir = ../../../..
@@ -9,7 +9,7 @@ override CFLAGS += $(PTHREAD_CFLAGS)
99

1010
ECPG = ../preproc/ecpg -I$(srcdir)/../include
1111

12-
TESTS = test1 test2 test3 test4 perftest dyntest dyntest2 test_notice\
12+
TESTS = test1 test2 test3 test4test5perftest dyntest dyntest2 test_notice\
1313
test_code100 test_init testdynalloc num_test dt_test test_informix
1414
ifeq ($(enable_thread_safety), yes)
1515
TESTS += test_thread test_thread_implicit

‎src/interfaces/ecpg/test/test5.pgc

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#include <stdio.h>
2+
#include <stdlib.h>
3+
4+
EXEC SQL typedef long mmInteger;
5+
EXEC SQL typedef char mmChar;
6+
EXEC SQL typedef short mmSmallInt;
7+
8+
EXEC SQL BEGIN DECLARE SECTION;
9+
struct TBempl
10+
{
11+
mmInteger idnum;
12+
mmChar name[21];
13+
mmSmallInt accs;
14+
};
15+
EXEC SQL END DECLARE SECTION;
16+
17+
int main()
18+
{
19+
EXEC SQL BEGIN DECLARE SECTION;
20+
struct TBempl empl;
21+
EXEC SQL END DECLARE SECTION;
22+
FILE *dbgs;
23+
24+
if ((dbgs = fopen("log", "w")) != NULL)
25+
ECPGdebug(1, dbgs);
26+
27+
empl.idnum = 1;
28+
EXEC SQL connect to mm;
29+
if (sqlca.sqlcode)
30+
{
31+
printf("connect error = %ld\n", sqlca.sqlcode);
32+
exit(sqlca.sqlcode);
33+
}
34+
35+
EXEC SQL create table empl
36+
(
37+
idnum integer,
38+
name char(20),
39+
accs smallint
40+
);
41+
if (sqlca.sqlcode)
42+
{
43+
printf("select error = %ld\n", sqlca.sqlcode);
44+
exit(sqlca.sqlcode);
45+
}
46+
47+
EXEC SQL insert into empl values (1, 'first user', 20);
48+
if (sqlca.sqlcode)
49+
{
50+
printf("select error = %ld\n", sqlca.sqlcode);
51+
exit(sqlca.sqlcode);
52+
}
53+
54+
EXEC SQL select name, accs
55+
into :empl.name, :empl.accs
56+
from empl where idnum = :empl.idnum;
57+
if (sqlca.sqlcode)
58+
{
59+
printf("select error = %ld\n", sqlca.sqlcode);
60+
exit(sqlca.sqlcode);
61+
}
62+
printf("name=%s, accs=%d\n", empl.name, empl.accs);
63+
EXEC SQL disconnect;
64+
fclose(dbgs);
65+
exit(0);
66+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp