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

Commit9bade3f

Browse files
author
Michael Meskes
committed
Replaced double-quote-fix with a hopefully better version.
Use initializer string length as size for character strings.Added ecpg_config.h file that is created via configure.
1 parentefdec1a commit9bade3f

21 files changed

+10234
-7501
lines changed

‎configure

Lines changed: 9979 additions & 7251 deletions
Large diffs are not rendered by default.

‎configure.in

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dnl Process this file with autoconf to produce a configure script.
2-
dnl $PostgreSQL: pgsql/configure.in,v 1.472 2006/08/17 17:25:43 petere Exp $
2+
dnl $PostgreSQL: pgsql/configure.in,v 1.473 2006/08/23 12:01:52 meskes Exp $
33
dnl
44
dnl Developers, please strive to achieve this order:
55
dnl
@@ -1448,6 +1448,9 @@ AC_CONFIG_HEADERS([src/include/pg_config.h],
14481448
echo >src/include/stamp-h
14491449
])
14501450

1451+
AC_CONFIG_HEADERS([src/interfaces/ecpg/include/ecpg_config.h])
1452+
1453+
14511454
#
14521455
# Warn about unknown options
14531456
#

‎src/Makefile.global.in

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*-makefile-*-
2-
# $PostgreSQL: pgsql/src/Makefile.global.in,v 1.225 2006/07/24 16:32:44 petere Exp $
2+
# $PostgreSQL: pgsql/src/Makefile.global.in,v 1.226 2006/08/23 12:01:52 meskes Exp $
33

44
#------------------------------------------------------------------------------
55
# All PostgreSQL makefiles include this file and use the variables it sets,
@@ -488,6 +488,11 @@ $(top_builddir)/src/include/pg_config.h: $(top_builddir)/src/include/stamp-h
488488
$(top_builddir)/src/include/stamp-h:$(top_srcdir)/src/include/pg_config.h.in$(top_builddir)/config.status
489489
cd$(top_builddir)&& ./config.status src/include/pg_config.h
490490

491+
# Also remake ecpg_config.h from ecpg_config.h.in if the latter changed. Values in it can
492+
# only change if pg_config.h has changed, so include this file to its dependencies.
493+
$(top_builddir)/src/interfaces/ecpg/include/ecpg_config.h:$(top_builddir)/src/include/pg_config.h$(top_builddir)/src/interfaces/ecpg/include/ecpg_config.h.in$(top_builddir)/config.status
494+
cd$(top_builddir)&& ./config.status src/interfaces/ecpg/include/ecpg_config.h
495+
491496
# When configure changes, rerun configure with the same options as
492497
# last time. To change configure, you need to run autoconf manually.
493498
$(top_builddir)/config.status:$(top_srcdir)/configure

‎src/interfaces/ecpg/ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2110,5 +2110,11 @@ Sa 19. Aug 14:11:32 CEST 2006
21102110
Tu 22. Aug 13:54:08 CEST 2006
21112111

21122112
- Descriptor values were quoted twice.
2113+
2114+
We 23. Aug 09:32:14 CEST 2006
2115+
2116+
- Replaced double-quote-fix with a hopefully better version.
2117+
- Use initializer string length as size for character strings.
2118+
- Added ecpg_config.h file that is created via configure.
21132119
- Set ecpg library version to 5.2.
21142120
- Set ecpg version to 4.2.1.

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

Lines changed: 41 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.60 2006/08/22 12:46:17 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.61 2006/08/23 12:01:52 meskes Exp $ */
22

33
/*
44
* The aim is to get a simpler inteface to the database routines.
@@ -36,47 +36,43 @@
3636
*escaped.
3737
*/
3838
staticchar*
39-
quote_postgres(char*arg,intlineno)
39+
quote_postgres(char*arg,boolquote,intlineno)
4040
{
41-
char*res= (char*)ECPGalloc(2*strlen(arg)+3,lineno);
42-
inti,quoted= false,
43-
ri=0;
44-
if (!res)
45-
return (res);
41+
char*res;
42+
inti,ri=0;
4643

47-
/*
48-
*We don't know if the target database is using
49-
*standard_conforming_strings, so we always use E'' strings.
50-
*/
51-
if (strchr(arg,'\\')!=NULL)
52-
res[ri++]=ESCAPE_STRING_SYNTAX;
53-
54-
i=0;
55-
res[ri++]='\'';
56-
/* do not quote the string if it is already quoted */
57-
if (*arg=='\''&&arg[strlen(arg)-1]=='\'')
44+
/* if quote is false we just need to store things in a descriptor
45+
* they will be quoted once they are inserted in a statement */
46+
if (!quote)
47+
returnres=ECPGstrdup(arg,lineno);
48+
else
5849
{
59-
quoted=true;
60-
i=1;
61-
}
50+
res=(char*)ECPGalloc(2*strlen(arg)+3,lineno);
51+
if (!res)
52+
return (res);
6253

63-
for (;arg[i];i++,ri++)
64-
{
65-
if (SQL_STR_DOUBLE(arg[i], true))
66-
res[ri++]=arg[i];
67-
res[ri]=arg[i];
68-
}
54+
/*
55+
*We don't know if the target database is using
56+
*standard_conforming_strings, so we always use E'' strings.
57+
*/
58+
if (strchr(arg,'\\')!=NULL)
59+
res[ri++]=ESCAPE_STRING_SYNTAX;
6960

70-
/* do not quote the string if it is already quoted */
71-
if (quoted)
72-
ri--;
73-
else
7461
res[ri++]='\'';
7562

76-
res[ri]='\0';
63+
for (i=0;arg[i];i++,ri++)
64+
{
65+
if (SQL_STR_DOUBLE(arg[i], true))
66+
res[ri++]=arg[i];
67+
res[ri]=arg[i];
68+
}
69+
70+
res[ri++]='\'';
71+
res[ri]='\0';
7772

78-
ECPGfree(arg);
79-
returnres;
73+
ECPGfree(arg);
74+
returnres;
75+
}
8076
}
8177

8278
#if defined(__GNUC__)&& (defined (__powerpc__)|| defined(__amd64__)|| defined(__x86_64__))
@@ -522,7 +518,7 @@ ECPGstore_result(const PGresult *results, int act_field,
522518

523519
bool
524520
ECPGstore_input(constintlineno,constboolforce_indicator,conststructvariable*var,
525-
constchar**tobeinserted_p,bool*malloced_p)
521+
constchar**tobeinserted_p,bool*malloced_p,boolquote)
526522
{
527523
char*mallocedval=NULL;
528524
char*newcopy=NULL;
@@ -839,7 +835,7 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia
839835
strncpy(newcopy, (char*)var->value,slen);
840836
newcopy[slen]='\0';
841837

842-
mallocedval=quote_postgres(newcopy,lineno);
838+
mallocedval=quote_postgres(newcopy,quote,lineno);
843839
if (!mallocedval)
844840
return false;
845841

@@ -873,7 +869,7 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia
873869
strncpy(newcopy,variable->arr,variable->len);
874870
newcopy[variable->len]='\0';
875871

876-
mallocedval=quote_postgres(newcopy,lineno);
872+
mallocedval=quote_postgres(newcopy,quote,lineno);
877873
if (!mallocedval)
878874
return false;
879875

@@ -961,7 +957,7 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia
961957
{
962958
for (element=0;element<var->arrsize;element++)
963959
{
964-
str=quote_postgres(PGTYPESinterval_to_asc((interval*) ((var+var->offset*element)->value)),lineno);
960+
str=quote_postgres(PGTYPESinterval_to_asc((interval*) ((var+var->offset*element)->value)),quote,lineno);
965961
if (!str)
966962
return false;
967963
slen=strlen(str);
@@ -984,7 +980,7 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia
984980
}
985981
else
986982
{
987-
str=quote_postgres(PGTYPESinterval_to_asc((interval*) (var->value)),lineno);
983+
str=quote_postgres(PGTYPESinterval_to_asc((interval*) (var->value)),quote,lineno);
988984
if (!str)
989985
return false;
990986
slen=strlen(str);
@@ -1015,7 +1011,7 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia
10151011
{
10161012
for (element=0;element<var->arrsize;element++)
10171013
{
1018-
str=quote_postgres(PGTYPESdate_to_asc(*(date*) ((var+var->offset*element)->value)),lineno);
1014+
str=quote_postgres(PGTYPESdate_to_asc(*(date*) ((var+var->offset*element)->value)),quote,lineno);
10191015
if (!str)
10201016
return false;
10211017
slen=strlen(str);
@@ -1038,7 +1034,7 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia
10381034
}
10391035
else
10401036
{
1041-
str=quote_postgres(PGTYPESdate_to_asc(*(date*) (var->value)),lineno);
1037+
str=quote_postgres(PGTYPESdate_to_asc(*(date*) (var->value)),quote,lineno);
10421038
if (!str)
10431039
return false;
10441040
slen=strlen(str);
@@ -1069,7 +1065,7 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia
10691065
{
10701066
for (element=0;element<var->arrsize;element++)
10711067
{
1072-
str=quote_postgres(PGTYPEStimestamp_to_asc(*(timestamp*) ((var+var->offset*element)->value)),lineno);
1068+
str=quote_postgres(PGTYPEStimestamp_to_asc(*(timestamp*) ((var+var->offset*element)->value)),quote,lineno);
10731069
if (!str)
10741070
return false;
10751071

@@ -1093,7 +1089,7 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia
10931089
}
10941090
else
10951091
{
1096-
str=quote_postgres(PGTYPEStimestamp_to_asc(*(timestamp*) (var->value)),lineno);
1092+
str=quote_postgres(PGTYPEStimestamp_to_asc(*(timestamp*) (var->value)),quote,lineno);
10971093
if (!str)
10981094
return false;
10991095
slen=strlen(str);
@@ -1212,7 +1208,7 @@ ECPGexecute(struct statement * stmt)
12121208
desc_inlist.ind_varcharsize=desc_inlist.ind_arrsize=1;
12131209
desc_inlist.ind_offset=0;
12141210
}
1215-
if (!ECPGstore_input(stmt->lineno,stmt->force_indicator,&desc_inlist,&tobeinserted,&malloced))
1211+
if (!ECPGstore_input(stmt->lineno,stmt->force_indicator,&desc_inlist,&tobeinserted,&malloced, true))
12161212
{
12171213
ECPGfree(copiedquery);
12181214
return false;
@@ -1230,7 +1226,7 @@ ECPGexecute(struct statement * stmt)
12301226
}
12311227
else
12321228
{
1233-
if (!ECPGstore_input(stmt->lineno,stmt->force_indicator,var,&tobeinserted,&malloced))
1229+
if (!ECPGstore_input(stmt->lineno,stmt->force_indicator,var,&tobeinserted,&malloced, true))
12341230
return false;
12351231
}
12361232

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/extern.h,v 1.18 2006/08/04 03:23:37 momjian Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/extern.h,v 1.19 2006/08/23 12:01:52 meskes Exp $ */
22

33
#ifndef_ECPG_LIB_EXTERN_H
44
#define_ECPG_LIB_EXTERN_H
@@ -129,7 +129,7 @@ PGresult **ECPGdescriptor_lvalue(int line, const char *descriptor);
129129

130130
boolECPGstore_result(constPGresult*results,intact_field,
131131
conststructstatement*stmt,structvariable*var);
132-
boolECPGstore_input(constint,constbool,conststructvariable*,constchar**,bool*);
132+
boolECPGstore_input(constint,constbool,conststructvariable*,constchar**,bool*,bool);
133133

134134
#if defined(__GNUC__)&& (defined (__powerpc__)|| defined(__amd64__)|| defined(__x86_64__))
135135
/* work around a gcc/ABI bug with va_lists on ppc+amd64 */

‎src/interfaces/ecpg/include/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,7 @@ installdirs:
2424
uninstall:
2525
rm -f$(addprefix '$(DESTDIR)$(includedir)'/,$(ecpg_headers))
2626
rm -f$(addprefix '$(DESTDIR)$(informix_esql_dir)'/,$(informix_headers))
27+
28+
distcleanmaintainer-clean:
29+
rm -f ecpg_config.h
30+

‎src/interfaces/ecpg/include/pgtypes_interval.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/include/pgtypes_interval.h,v 1.9 2006/03/11 04:38:39 momjian Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/include/pgtypes_interval.h,v 1.10 2006/08/23 12:01:52 meskes Exp $ */
22

33
#ifndefPGTYPES_INTERVAL
44
#definePGTYPES_INTERVAL
55

6+
#include<ecpg_config.h>
7+
8+
#if defined(USE_INTEGER_DATETIMES)&& (defined(HAVE_LONG_INT_64)|| defined(HAVE_LONG_LONG_INT_64))
9+
#defineHAVE_INT64_TIMESTAMP
10+
#endif
11+
612
typedefstruct
713
{
814
#ifdefHAVE_INT64_TIMESTAMP

‎src/interfaces/ecpg/include/pgtypes_timestamp.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/include/pgtypes_timestamp.h,v 1.10 2006/03/11 04:38:39 momjian Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/include/pgtypes_timestamp.h,v 1.11 2006/08/23 12:01:52 meskes Exp $ */
22

33
#ifndefPGTYPES_TIMESTAMP
44
#definePGTYPES_TIMESTAMP
55

6+
/* pgtypes_interval.h includes ecpg_config.h */
67
#include<pgtypes_interval.h>
78

89
#ifdefHAVE_INT64_TIMESTAMP

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.329 2006/08/18 15:59:35 meskes Exp $*/
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.330 2006/08/23 12:01:52 meskes Exp $*/
22

33
/* Copyright comment*/
44
%{
@@ -5414,7 +5414,18 @@ variable: opt_pointer ECPGColLabel opt_array_bounds opt_bit_field opt_initialize
54145414
case ECPGt_char:
54155415
case ECPGt_unsigned_char:
54165416
if (atoi(dimension) == -1)
5417+
{
5418+
int i = strlen($5);
5419+
5420+
if (atoi(length) == -1 && i >0)/* char <var>[] = "string"*/
5421+
{
5422+
/* if we have an initializer but no string size set, let's use the initializer's length*/
5423+
free(length);
5424+
length = mm_alloc(i+sizeof("sizeof()"));
5425+
sprintf(length,"sizeof(%s)+1", $5+2);
5426+
}
54175427
type = ECPGmake_simple_type(actual_type[struct_level].type_enum, length);
5428+
}
54185429
else
54195430
type = ECPGmake_array_type(ECPGmake_simple_type(actual_type[struct_level].type_enum, length), dimension);
54205431

‎src/interfaces/ecpg/test/compat_informix/dec_test.pgc

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -101,21 +101,6 @@ main(void)
101101
r = dectodbl(dec, &dbl);
102102
if (r) check_errno();
103103
printf("dec[%d,10]: %2.7f (r: %d)\n", i, r?0.0:dbl, r);
104-
if (r == 0)
105-
{
106-
r = deccvdbl(dbl, din);
107-
if (r)
108-
{
109-
check_errno();
110-
printf("dec[%d,11(f)]: - (r: %d)\n", i, r);
111-
}
112-
else
113-
{
114-
dectoasc(din, buf, BUFSIZE-1, 2);
115-
q = deccmp(dec, din);
116-
printf("dec[%d,11]: %s (r: %d - cmp: %d)\n", i, buf, r, q);
117-
}
118-
}
119104

120105
PGTYPESdecimal_free(din);
121106
printf("\n");

‎src/interfaces/ecpg/test/expected/compat_informix-dec_test.c

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -121,21 +121,6 @@ main(void)
121121
r=dectodbl(dec,&dbl);
122122
if (r)check_errno();
123123
printf("dec[%d,10]: %2.7f (r: %d)\n",i,r?0.0:dbl,r);
124-
if (r==0)
125-
{
126-
r=deccvdbl(dbl,din);
127-
if (r)
128-
{
129-
check_errno();
130-
printf("dec[%d,11(f)]: - (r: %d)\n",i,r);
131-
}
132-
else
133-
{
134-
dectoasc(din,buf,BUFSIZE-1,2);
135-
q=deccmp(dec,din);
136-
printf("dec[%d,11]: %s (r: %d - cmp: %d)\n",i,buf,r,q);
137-
}
138-
}
139124

140125
PGTYPESdecimal_free(din);
141126
printf("\n");

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp