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

Commit9fb20f1

Browse files
author
Michael Meskes
committed
*** empty log message ***
1 parent5f39ba8 commit9fb20f1

File tree

9 files changed

+64
-41
lines changed

9 files changed

+64
-41
lines changed

‎src/interfaces/ecpg/ChangeLog

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -894,5 +894,13 @@ Mon Apr 3 21:20:27 CEST 2000
894894
- Made sure pointers are correctly inserted by libecpg. My thanks go
895895
to Jan Urbanek <jan@urbanek.cz> for findin many bugs before the
896896
release.
897+
898+
Wed Apr 5 07:54:56 CEST 2000
899+
900+
- Added patch by Peter Eisentraut <e99re41@DoCS.UU.SE> to fix some
901+
duplicate definittions in preproc.y.
902+
- Removed duplicate ',' in execute.c.
903+
- Changed error message for backend errors so it fits into sqlca.
904+
- Fixed array handling.
897905
- Set library version to 3.1.0.
898906
- Set ecpg version to 2.7.0.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ extern"C"
3434
constchar*descriptor,constchar*query);
3535
boolECPGdeallocate_desc(intline,constchar*name);
3636
boolECPGallocate_desc(intline,constchar*name);
37-
voidECPGraise(intline,intcode,constchar*str);
37+
voidECPGraise(intline,intcode,char*str);
3838
boolECPGget_desc_header(int,char*,int*);
3939
boolECPGget_desc(int,char*,int, ...);
4040

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
#include<sqlca.h>
88

99
void
10-
ECPGraise(intline,intcode,constchar*str)
10+
ECPGraise(intline,intcode,char*str)
1111
{
1212
sqlca.sqlcode=code;
13+
1314
switch (code)
1415
{
1516
caseECPG_NOT_FOUND:
@@ -117,9 +118,13 @@ ECPGraise(int line, int code, const char *str)
117118
"Variable is not a character type in line %d.",line);
118119
break;
119120

120-
caseECPG_PGSQL:
121+
caseECPG_PGSQL:
122+
/* strip trailing newline */
123+
if (str[strlen(str)-1]=='\n')
124+
str[strlen(str)-1]='\0';
125+
121126
snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
122-
"Postgres error'%s' in line %d.",str,line);
127+
"'%s' in line %d.",str,line);
123128
break;
124129

125130
caseECPG_TRANS:
@@ -134,12 +139,12 @@ ECPGraise(int line, int code, const char *str)
134139

135140
default:
136141
snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
137-
"SQL error #%d in line %d.",code,line);
142+
"SQL error #%d in line %d.",code,line);
138143
break;
139144
}
140145

141146
sqlca.sqlerrm.sqlerrml=strlen(sqlca.sqlerrm.sqlerrmc);
142-
147+
143148
/* free all memory we have allocated for the user */
144149
free_auto_mem();
145150
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ ECPGexecute(struct statement * stmt)
479479
strncpy(mallocedval+strlen(mallocedval)-1,"}'",sizeof("}'"));
480480
}
481481
else
482-
sprintf(mallocedval,"%c,", (*((char*)var->value)) ?'t' :'f');
482+
sprintf(mallocedval,"%c", (*((char*)var->value)) ?'t' :'f');
483483

484484
tobeinserted=mallocedval;
485485
break;
@@ -541,7 +541,7 @@ ECPGexecute(struct statement * stmt)
541541

542542
default:
543543
/* Not implemented yet */
544-
ECPGraise(stmt->lineno,ECPG_UNSUPPORTED,ECPGtype_name(var->type));
544+
ECPGraise(stmt->lineno,ECPG_UNSUPPORTED,(char*)ECPGtype_name(var->type));
545545
return false;
546546
break;
547547
}
@@ -859,7 +859,7 @@ ECPGdo(int lineno, const char *connection_name, char *query, ...)
859859
*
860860
* Copyright (c) 2000, Christof Petig <christof.petig@wtal.de>
861861
*
862-
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/execute.c,v 1.3 2000/04/03 19:34:25 meskes Exp $
862+
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/execute.c,v 1.4 2000/04/05 09:05:28 meskes Exp $
863863
*/
864864

865865
PGconn*ECPG_internal_get_connection(char*name);
@@ -1024,6 +1024,6 @@ bool ECPGdo_descriptor(int line,const char *connection,
10241024
}
10251025
}
10261026

1027-
ECPGraise(line,ECPG_UNKNOWN_DESCRIPTOR,descriptor);
1027+
ECPGraise(line,ECPG_UNKNOWN_DESCRIPTOR,(char*)descriptor);
10281028
return false;
10291029
}

‎src/interfaces/ecpg/preproc/pgc.l

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*
1313
*
1414
* IDENTIFICATION
15-
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.57 2000/03/30 11:41:40 meskes Exp $
15+
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.58 2000/04/05 09:05:34 meskes Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -827,6 +827,7 @@ lex_init(void)
827827
braces_open =0;
828828

829829
preproc_tos =0;
830+
yylineno =0;
830831
ifcond =TRUE;
831832
stacked_if_value[preproc_tos].condition = ifcond;
832833
stacked_if_value[preproc_tos].else_branch =FALSE;

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -325,15 +325,15 @@ make_name(void)
325325
%type<str>TriggerActionTimeCreateTrigStmtDropPLangStmtPLangTrusted
326326
%type<str>CreatePLangStmtIntegerOnlyTriggerFuncArgsTriggerFuncArg
327327
%type<str>ViewStmtLoadStmtCreatedbStmtcreatedb_opt_encoding
328-
%type<str>createdb_opt_locationopt_encodingAlterTableStmt
328+
%type<str>createdb_opt_locationopt_encoding
329329
%type<str>DropdbStmtClusterStmtgranteeRevokeStmttable_exprBitbit
330330
%type<str>GrantStmtprivilegesoperation_commalistoperation
331331
%type<str>opt_cursoropt_lmodeConstraintsSetStmtcomment_tg
332332
%type<str>case_exprwhen_clause_listcase_defaultcase_argwhen_clause
333333
%type<str>select_clauseopt_select_limitselect_limit_valueConstraintTimeSpec
334334
%type<str>select_offset_valueusing_exprjoin_exprReindexStmt
335335
%type<str>using_listfrom_exprjoin_clausejoin_type
336-
%type<str>join_qualupdate_listjoin_clausejoin_clause_with_union
336+
%type<str>join_qualupdate_listjoin_clause_with_union
337337
%type<str>opt_levelopt_locklock_typeusers_in_new_group_clause
338338
%type<str>OptConstrFromTablecomment_opOptTempTableName
339339
%type<str>constraints_set_listconstraints_set_namelistcomment_fn
@@ -359,7 +359,7 @@ make_name(void)
359359
%type<str>enum_typecivariableonlyECPGCursorStmtECPGDeallocate
360360
%type<str>ECPGFreeECPGDeclareECPGVaropt_atenum_definition
361361
%type<str>struct_types_structdeclarationdeclarationsvariable_declarations
362-
%type<str>s_structs_unionunion_typeECPGSetAutocommiton_off
362+
%type<str>s_unionunion_typeECPGSetAutocommiton_off
363363
%type<str>ECPGAllocateDescrECPGDeallocateDescrsymbolopt_symbol
364364
%type<str>ECPGGetDescriptorHeaderECPGColIdECPGColLabelECPGTypeName
365365
%type<str>ECPGLabelTypeName
@@ -4349,7 +4349,7 @@ variable: opt_pointer ECPGColLabel opt_array_bounds opt_initializer
43494349
$$ = cat_str(4,$1, mm_strdup($2),$3.str,$4);
43504350
break;
43514351
case ECPGt_varchar:
4352-
if (dimension== -1)
4352+
if (dimension<0)
43534353
type = ECPGmake_simple_type(actual_type[struct_level].type_enum, length);
43544354
else
43554355
type = ECPGmake_array_type(ECPGmake_simple_type(actual_type[struct_level].type_enum, length), dimension);

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

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -198,13 +198,6 @@ static void ECPGdump_a_struct(FILE *o, const char *name, const char *ind_name, l
198198
void
199199
ECPGdump_a_type(FILE*o,constchar*name,structECPGtype*typ,constchar*ind_name,structECPGtype*ind_typ,constchar*prefix,constchar*ind_prefix)
200200
{
201-
#if0
202-
if (ind_typ==NULL)
203-
{
204-
ind_typ=&ecpg_no_indicator;
205-
ind_name="no_indicator";
206-
}
207-
#endif
208201
switch (typ->typ)
209202
{
210203
caseECPGt_array:
@@ -273,23 +266,35 @@ ECPGdump_a_simple(FILE *o, const char *name, enum ECPGttype typ,
273266
char*variable= (char*)mm_alloc(strlen(name)+ ((prefix==NULL) ?0 :strlen(prefix))+4);
274267
char*offset= (char*)mm_alloc(strlen(name)+strlen("sizeof(struct varchar_)")+1);
275268

276-
/* we have to use the pointer except for arrays with given bounds */
277-
if (arrsize>0)
278-
sprintf(variable,"(%s%s)",prefix ?prefix :"",name);
279-
else
280-
sprintf(variable,"&(%s%s)",prefix ?prefix :"",name);
281-
282269
switch (typ)
283270
{
284271
caseECPGt_varchar:
272+
/* we have to use the pointer except for arrays with given bounds */
273+
if (arrsize>0)
274+
sprintf(variable,"(%s%s)",prefix ?prefix :"",name);
275+
else
276+
sprintf(variable,"&(%s%s)",prefix ?prefix :"",name);
277+
285278
sprintf(offset,"sizeof(struct varchar_%s)",name);
286279
break;
287280
caseECPGt_char:
288281
caseECPGt_unsigned_char:
289282
caseECPGt_char_variable:
283+
/* we have to use the pointer except for arrays with given bounds */
284+
if (varcharsize>1||arrsize>0)
285+
sprintf(variable,"(%s%s)",prefix ?prefix :"",name);
286+
else
287+
sprintf(variable,"&(%s%s)",prefix ?prefix :"",name);
288+
290289
sprintf(offset,"%ld*sizeof(char)",varcharsize==0 ?1 :varcharsize);
291290
break;
292291
default:
292+
/* we have to use the pointer except for arrays with given bounds */
293+
if (arrsize>0)
294+
sprintf(variable,"(%s%s)",prefix ?prefix :"",name);
295+
else
296+
sprintf(variable,"&(%s%s)",prefix ?prefix :"",name);
297+
293298
sprintf(offset,"sizeof(%s)",ECPGtype_name(typ));
294299
break;
295300
}

‎src/interfaces/ecpg/test/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
all: test1 test2 test3 test4 perftest dyntest dyntest2
22

3-
#LDFLAGS=-g -I /usr/local/pgsql/include -L/usr/local/pgsql/lib -lecpg -lpq -lcrypt
4-
LDFLAGS=-g -I../include -I/usr/include/postgresql -L../lib -L/usr/lib/postgresql -lecpg -lpq -lcrypt
3+
LDFLAGS=-g -I /usr/local/pgsql/include -L/usr/local/pgsql/lib -lecpg -lpq -lcrypt
4+
#LDFLAGS=-g -I../include -I/usr/include/postgresql -L../lib -L/usr/lib/postgresql -lecpg -lpq -lcrypt
55
#LDFLAGS=-g -I/usr/include/postgresql -lecpg -lpq -lcrypt
66

77
#ECPG=/usr/local/pgsql/bin/ecpg

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

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ EXEC SQL BEGIN DECLARE SECTION;
1111
int i = 3;
1212
int *did = &i;
1313
int a[10] = {9,8,7,6,5,4,3,2,1,0};
14+
char text[10] = "klmnopqrst";
15+
char *t = "uvwxyz1234";
1416
double f;
1517
EXEC SQL END DECLARE SECTION;
1618
FILE *dbgs;
@@ -26,34 +28,36 @@ EXEC SQL END DECLARE SECTION;
2628

2729
EXEC SQL BEGIN WORK;
2830

29-
/*EXEC SQL CREATE TABLE test (f decimal(8,2), i int, a int[10]);*/
30-
EXEC SQL CREATE TABLE test (f float, i int, a int[10]);
31+
EXEC SQL CREATE TABLE test (f float, i int, a int[10], text char(10));
3132

32-
EXEC SQL INSERT INTO test(f,i,a) VALUES(404.90,1,'{0,1,2,3,4,5,6,7,8,9}');
33+
EXEC SQL INSERT INTO test(f,i,a,text) VALUES(404.90,1,'{0,1,2,3,4,5,6,7,8,9}','abcdefghij');
3334

34-
EXEC SQL INSERT INTO test(f,i,a) VALUES(140787.0,2,:a);
35+
EXEC SQL INSERT INTO test(f,i,a,text) VALUES(140787.0,2,:a,:text);
3536

36-
EXEC SQL INSERT INTO test(f,i,a) VALUES(14.07,:did,:a);
37+
EXEC SQL INSERT INTO test(f,i,a,text) VALUES(14.07,:did,:a,:t);
3738

3839
EXEC SQL COMMIT;
3940

4041
EXEC SQL BEGIN WORK;
4142

42-
EXEC SQL SELECT f
43-
INTO :f
43+
EXEC SQL SELECT f,text
44+
INTO :f,:text
4445
FROM test
45-
WHERE i =:i;
46+
WHERE i =1;
4647

47-
printf("Found f=%f\n", f);
48+
printf("Found f=%f text=%10.10s\n", f, text);
4849

49-
EXEC SQL SELECT a
50-
INTO :a
50+
f=14.07;
51+
EXEC SQL SELECT a,text
52+
INTO :a,:t
5153
FROM test
5254
WHERE f = :f;
5355

5456
for (i = 0; i < 10; i++)
5557
printf("Found a[%d] = %d\n", i, a[i]);
5658

59+
printf("Found text=%10.10s\n", t);
60+
5761
EXEC SQL DROP TABLE test;
5862

5963
EXEC SQL COMMIT;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp