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

Commitee14711

Browse files
author
Michael Meskes
committed
- Fixed variable handling in AT statement.
- Fixed bug that caused segfault when given incorrect DB name. - Fixed bug in ecpglib causing indicator to list the size of the variable instead of the size of the data.
1 parent1579046 commitee14711

File tree

5 files changed

+41
-19
lines changed

5 files changed

+41
-19
lines changed

‎src/interfaces/ecpg/ChangeLog

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,5 +1154,12 @@ Wed Nov 14 11:50:27 CET 2001
11541154
Tue Dec 4 13:30:32 CET 2001
11551155

11561156
- Fixed dumping of structures without indicators.
1157+
1158+
Wed Dec 5 12:27:25 CET 2001
1159+
1160+
- Fixed variable handling in AT statement.
1161+
- Fixed bug that caused segfault when given incorrect DB name.
1162+
- Fixed bug in ecpglib causing indicator to list the size of the
1163+
variable instead of the size of the data.
11571164
- Set ecpg version to 2.9.0.
11581165
- Set library version to 3.3.0.

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/connect.c,v 1.15 2001/11/14 11:11:49 meskes Exp $ */
1+
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/connect.c,v 1.16 2001/12/05 15:32:06 meskes Exp $ */
22

33
#include"postgres_fe.h"
44

@@ -387,6 +387,10 @@ ECPGconnect(int lineno, const char *name, const char *user, const char *passwd,
387387
host=strdup(dbname+offset);
388388

389389
}
390+
else
391+
{
392+
realname=strdup(dbname);
393+
}
390394
}
391395
else
392396
realname=strdup(dbname);

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/data.c,v 1.19 2001/11/14 11:11:49 meskes Exp $ */
1+
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/data.c,v 1.20 2001/12/05 15:32:06 meskes Exp $ */
22

33
#include"postgres_fe.h"
44

@@ -277,15 +277,15 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
277277
{
278278
caseECPGt_short:
279279
caseECPGt_unsigned_short:
280-
((short*)ind)[act_tuple]=varcharsize;
280+
((short*)ind)[act_tuple]=strlen(pval);
281281
break;
282282
caseECPGt_int:
283283
caseECPGt_unsigned_int:
284-
((int*)ind)[act_tuple]=varcharsize;
284+
((int*)ind)[act_tuple]=strlen(pval);
285285
break;
286286
caseECPGt_long:
287287
caseECPGt_unsigned_long:
288-
((long*)ind)[act_tuple]=varcharsize;
288+
((long*)ind)[act_tuple]=strlen(pval);
289289
break;
290290
default:
291291
break;
@@ -300,28 +300,28 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
300300
structECPGgeneric_varchar*variable=
301301
(structECPGgeneric_varchar*) ((long)var+offset*act_tuple);
302302

303+
variable->len=strlen(pval);
303304
if (varcharsize==0)
304-
strncpy(variable->arr,pval,strlen(pval));
305+
strncpy(variable->arr,pval,variable->len);
305306
else
306307
strncpy(variable->arr,pval,varcharsize);
307308

308-
variable->len=strlen(pval);
309309
if (varcharsize>0&&variable->len>varcharsize)
310310
{
311311
/* truncation */
312312
switch (ind_type)
313313
{
314314
caseECPGt_short:
315315
caseECPGt_unsigned_short:
316-
((short*)ind)[act_tuple]=varcharsize;
316+
((short*)ind)[act_tuple]=variable->len;
317317
break;
318318
caseECPGt_int:
319319
caseECPGt_unsigned_int:
320-
((int*)ind)[act_tuple]=varcharsize;
320+
((int*)ind)[act_tuple]=variable->len;
321321
break;
322322
caseECPGt_long:
323323
caseECPGt_unsigned_long:
324-
((long*)ind)[act_tuple]=varcharsize;
324+
((long*)ind)[act_tuple]=variable->len;
325325
break;
326326
default:
327327
break;

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

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,16 @@ statement: ecpgstart opt_at stmt ';'{ connection = NULL; }
392392
|blockend{ fputs($1, yyout); free($1); }
393393
;
394394

395-
opt_at:ATconnection_target{ connection =$2; };
395+
opt_at:ATconnection_target{
396+
connection =$2;
397+
/*
398+
if we have a variable as connection
399+
target, remove it from the variable
400+
list or else it will be used twice
401+
*/
402+
if (argsinsert !=NULL)
403+
argsinsert =NULL;
404+
};
396405

397406
stmt:AlterSchemaStmt { output_statement($1,0, connection); }
398407
|AlterTableStmt{ output_statement($1,0, connection); }
@@ -3877,6 +3886,13 @@ connection_target: database_name opt_server opt_port
38773886
|db_prefix':'serveropt_port'/'database_nameopt_options
38783887
{
38793888
/* new style: <tcp|unix>:postgresql://server[:port][/dbname]*/
3889+
printf("%s\n", $1);
3890+
if (strncmp($1,"unix:postgresql", strlen("unix:postgresql")) !=0 && strncmp($1,"tcp:postgresql", strlen("tcp:postgresql")) !=0)
3891+
{
3892+
sprintf(errortext,"only protocols 'tcp' and 'unix' and database type 'postgresql' are supported");
3893+
mmerror(ET_ERROR, errortext);
3894+
}
3895+
38803896
if (strncmp($3,"//", strlen("//")) !=0)
38813897
{
38823898
sprintf(errortext,"Expected '://', found '%s'", $3);
@@ -3890,12 +3906,6 @@ connection_target: database_name opt_server opt_port
38903906
sprintf(errortext,"unix domain sockets only work on 'localhost' but not on '%9.9s'", $3 +strlen("//"));
38913907
mmerror(ET_ERROR, errortext);
38923908
}
3893-
3894-
if (strncmp($1,"unix", strlen("unix")) !=0 && strncmp($1,"tcp", strlen("tcp")) !=0)
3895-
{
3896-
sprintf(errortext,"only protocols 'tcp' and 'unix' are supported");
3897-
mmerror(ET_ERROR, errortext);
3898-
}
38993909

39003910
$$ = make3_str(make3_str(make_str("\""),$1, make_str(":")),$3, make3_str(make3_str($4, make_str("/"),$6),$7, make_str("\"")));
39013911
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ exec sql begin declare section;
3535
char name[AMOUNT][8];
3636
char letter[AMOUNT][1];
3737
char command[128];
38+
char *connection="pm";
3839
exec sql end declare section;
3940
exec sql var name is string(AMOUNT);
4041
char msg[128];
@@ -94,7 +95,7 @@ exec sql end declare section;
9495
exec sql at pm begin transaction;
9596

9697
strcpy(msg, "select");
97-
exec sql selectname, amount, letter into :name, :amount, :letter from "Test";
98+
exec sql select* into :name, :amount, :letter from "Test";
9899

99100
printf("Database: mm\n");
100101
for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
@@ -113,7 +114,7 @@ exec sql end declare section;
113114
}
114115

115116
strcpy(msg, "select");
116-
exec sql atpm select* into :name, :amount, :letter from "Test";
117+
exec sql at:connection selectname, amount, letter into :name, :amount, :letter from "Test";
117118

118119
printf("Database: pm\n");
119120
for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp