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

Commitb171033

Browse files
author
Michael Meskes
committed
Fixed parser and library to allow empty database names.
Streamlined connection name parsing.Added Joachim's patch to shorten paths before diffing.
1 parentba9f9bf commitb171033

40 files changed

+257
-160
lines changed

‎src/interfaces/ecpg/ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2126,5 +2126,10 @@ Su 27. Aug 17:54:36 CEST 2006
21262126

21272127
- Enabled single-quoted connection targets.
21282128
- Fixed a memory leak/segfault in unsuccessful connection.
2129+
2130+
Tu 29. Aug 14:21:31 CEST 2006
2131+
2132+
- Fixed parser and library to allow empty database names.
2133+
- Streamlined connection name parsing.
21292134
- Set ecpg library version to 5.2.
21302135
- Set ecpg version to 4.2.1.

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.34 2006/08/27 16:15:41 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.35 2006/08/29 12:24:51 meskes Exp $ */
22

33
#definePOSTGRES_ECPG_INTERNAL
44
#include"postgres_fe.h"
@@ -427,7 +427,8 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
427427
host=ECPGstrdup(tmp+1,lineno);
428428
*tmp='\0';
429429
}
430-
realname=ECPGstrdup(dbname,lineno);
430+
431+
realname= (strlen(dbname)>0) ?ECPGstrdup(dbname,lineno) :NULL;
431432
}
432433
}
433434
else

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

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.333 2006/08/27 16:15:41 meskes Exp $*/
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.334 2006/08/29 12:24:51 meskes Exp $*/
22

33
/* Copyright comment*/
44
%{
@@ -508,7 +508,7 @@ add_additional_variables(char *name, bool insert)
508508
%type<str>opt_insteadeventRuleActionListopt_usingCreateAssertStmt
509509
%type<str>RuleActionStmtOrEmptyRuleActionMultifunc_asreindex_type
510510
%type<str>RuleStmtopt_columnoper_argtypesNumConstvar_name
511-
%type<str>MathOpRemoveFuncStmtECPGunreserved_con
511+
%type<str>MathOpRemoveFuncStmtECPGunreserved_conopt_database_name
512512
%type<str>RemoveAggrStmtopt_proceduralselect_no_parensCreateCastStmt
513513
%type<str>RemoveOperStmtRenameStmtall_Opopt_trustedopt_lancompiler
514514
%type<str>VariableSetStmtvar_valuezone_valueVariableShowStmt
@@ -624,7 +624,7 @@ statement: ecpgstart opt_at stmt ';'{ connection = NULL; }
624624
|'}'{ remove_typedefs(braces_open); remove_variables(braces_open--); fputs("}", yyout); }
625625
;
626626

627-
opt_at:ATconnection_target
627+
opt_at:ATconnection_object
628628
{
629629
connection =$2;
630630
/*
@@ -677,7 +677,7 @@ stmt: AlterDatabaseStmt{ output_statement($1, 0, connection); }
677677
|ClusterStmt{ output_statement($1,0, connection); }
678678
|CommentStmt{ output_statement($1,0, connection); }
679679
|ConstraintsSetStmt{ output_statement($1,0, connection); }
680-
|CopyStmt{ output_statement($1,0, connection); }
680+
|CopyStmt{ output_statement($1,0, connection); }
681681
|CreateAsStmt{ output_statement($1,0, connection); }
682682
|CreateAssertStmt{ output_statement($1,0, connection); }
683683
|CreateCastStmt{ output_statement($1,0, connection); }
@@ -4616,7 +4616,7 @@ ECPGConnect: SQL_CONNECT TO connection_target opt_connection_name opt_user
46164616
{$$ = cat2_str($2, make_str(",NULL,NULL,NULL")); }
46174617
;
46184618

4619-
connection_target:database_nameopt_serveropt_port
4619+
connection_target:opt_database_nameopt_serveropt_port
46204620
{
46214621
/* old style: dbname[@server][:port]*/
46224622
if (strlen($2) >0 && *($2) !='@')
@@ -4628,7 +4628,7 @@ connection_target: database_name opt_server opt_port
46284628
else
46294629
$$ = make3_str(make_str("\""), make3_str($1,$2,$3), make_str("\""));
46304630
}
4631-
|db_prefix':'serveropt_port'/'database_nameopt_options
4631+
|db_prefix':'serveropt_port'/'opt_database_nameopt_options
46324632
{
46334633
/* new style: <tcp|unix>:postgresql://server[:port][/dbname]*/
46344634
if (strncmp($1,"unix:postgresql", strlen("unix:postgresql")) !=0 && strncmp($1,"tcp:postgresql", strlen("tcp:postgresql")) !=0)
@@ -4659,6 +4659,10 @@ connection_target: database_name opt_server opt_port
46594659
}
46604660
;
46614661

4662+
opt_database_name:database_name{$$ =$1; }
4663+
|/*EMPTY*/{$$ = EMPTY; }
4664+
;
4665+
46624666
db_prefix:identcvariable
46634667
{
46644668
if (strcmp($2,"postgresql") !=0 && strcmp($2,"postgres") !=0)
@@ -4690,10 +4694,10 @@ server_name: ColId{ $$ = $1; }
46904694
;
46914695

46924696
opt_port:':'PosIntConst{$$ = make2_str(make_str(":"),$2); }
4693-
|/*EMPTY*/{$$ = EMPTY; }
4697+
|/*EMPTY*/{$$ = EMPTY; }
46944698
;
46954699

4696-
opt_connection_name:ASconnection_target{$$ =$2; }
4700+
opt_connection_name:ASconnection_object{$$ =$2; }
46974701
|/*EMPTY*/{$$ = make_str("NULL"); }
46984702
;
46994703

@@ -5491,14 +5495,15 @@ ECPGDeclare: DECLARE STATEMENT ident
54915495
ECPGDisconnect:SQL_DISCONNECTdis_name {$$ =$2; }
54925496
;
54935497

5494-
dis_name:connection_object{$$ =$1; }
5495-
|SQL_CURRENT{$$ = make_str("\"CURRENT\""); }
5496-
|ALL{$$ = make_str("\"ALL\""); }
5497-
|/*EMPTY*/{$$ = make_str("\"CURRENT\""); }
5498+
dis_name:connection_object{$$ =$1; }
5499+
|SQL_CURRENT{$$ = make_str("\"CURRENT\""); }
5500+
|ALL{$$ = make_str("\"ALL\""); }
5501+
|/*EMPTY*/{$$ = make_str("\"CURRENT\""); }
54985502
;
54995503

5500-
connection_object:connection_target{$$ =$1; }
5501-
|DEFAULT{$$ = make_str("\"DEFAULT\""); }
5504+
connection_object:database_name{$$ = make3_str(make_str("\""),$1, make_str("\"")); }
5505+
|DEFAULT{$$ = make_str("\"DEFAULT\""); }
5506+
|char_variable{$$ =$1; }
55025507
;
55035508

55045509
/*

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,25 @@ exec sql end declare section;
2626
exec sql connect to connectdb@localhost as main;
2727
exec sql disconnect main;
2828

29+
exec sql connect to @localhost as main;
30+
exec sql disconnect main;
31+
2932
exec sql connect to connectdb@localhost:@TEMP_PORT@ as main;
3033
exec sql disconnect main;
3134

35+
exec sql connect to @localhost:@TEMP_PORT@ as main;
36+
exec sql disconnect main;
37+
3238
exec sql connect to connectdb:@TEMP_PORT@ as main;
3339
exec sql disconnect main;
3440

41+
exec sql connect to :@TEMP_PORT@ as main;
42+
exec sql disconnect main;
43+
3544
exec sql connect to tcp:postgresql://localhost:@TEMP_PORT@/connectdb user connectuser identified by connectpw;
36-
exec sql disconnect nonexistant;
45+
exec sql disconnect;
46+
47+
exec sql connect to tcp:postgresql://localhost:@TEMP_PORT@/ user connectdb;
3748
exec sql disconnect;
3849

3950
strcpy(pw, "connectpw");

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ exec sql end declare section;
3737
exec sql connect to 'connectdb' as main;
3838
exec sql disconnect main;
3939

40+
exec sql connect to as main user connectdb;
41+
exec sql disconnect main;
42+
4043
exec sql connect to connectdb as main user connectuser/connectdb;
4144
exec sql disconnect main;
4245

@@ -52,12 +55,16 @@ exec sql end declare section;
5255
exec sql connect to "unix:postgresql://200.46.204.71/connectdb" as main user connectuser;
5356
exec sql disconnect main;
5457

55-
exec sql disconnect nonexistant;
58+
exec sql connect to unix:postgresql://localhost/ as main user connectdb;
59+
exec sql disconnect main;
5660

5761
/* connect twice */
5862
exec sql connect to connectdb as main;
5963
exec sql connect to connectdb as main;
6064
exec sql disconnect main;
6165

66+
/* not connected */
67+
exec sql disconnect nonexistant;
68+
6269
return (0);
6370
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include<sqltypes.h>
1818

1919

20-
#line 1 "./../regression.h"
20+
#line 1 "regression.h"
2121

2222

2323

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include<stdlib.h>
1414
#
1515

16-
#line 1 "./../regression.h"
16+
#line 1 "regression.h"
1717

1818

1919

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include<stdlib.h>
1414
#
1515

16-
#line 1 "./../regression.h"
16+
#line 1 "regression.h"
1717

1818

1919

@@ -66,7 +66,7 @@ if (sqlca.sqlcode < 0) dosqlprint ( );}
6666

6767
/* this INSERT works */
6868
rsetnull(CDECIMALTYPE, (char*)&j);
69-
{ECPGdo(__LINE__,1,1,NULL,"insert into test ( i , j ) values( 7 , ? )",
69+
{ECPGdo(__LINE__,1,1,NULL,"insert into test ( i , j ) values( 7 , ? )",
7070
ECPGt_decimal,&(j),(long)1,(long)1,sizeof(decimal),
7171
ECPGt_NO_INDICATOR,NULL ,0L,0L,0L,ECPGt_EOIT,ECPGt_EORT);
7272
#line 27 "test_informix.pgc"
@@ -82,7 +82,7 @@ if (sqlca.sqlcode < 0) dosqlprint ( );}
8282

8383

8484
/* this INSERT should fail because i is a unique column */
85-
{ECPGdo(__LINE__,1,1,NULL,"insert into test ( i , j ) values( 7 , 12 )",ECPGt_EOIT,ECPGt_EORT);
85+
{ECPGdo(__LINE__,1,1,NULL,"insert into test ( i , j ) values( 7 , 12 )",ECPGt_EOIT,ECPGt_EORT);
8686
#line 31 "test_informix.pgc"
8787

8888
if (sqlca.sqlcode<0)dosqlprint ( );}
@@ -96,7 +96,7 @@ if (sqlca.sqlcode < 0) dosqlprint ( );}
9696
#line 33 "test_informix.pgc"
9797

9898

99-
{ECPGdo(__LINE__,1,1,NULL,"insert into test ( i , j ) values( ? , 1 )",
99+
{ECPGdo(__LINE__,1,1,NULL,"insert into test ( i , j ) values( ? , 1 )",
100100
ECPGt_int,&(i),(long)1,(long)1,sizeof(int),
101101
ECPGt_NO_INDICATOR,NULL ,0L,0L,0L,ECPGt_EOIT,ECPGt_EORT);
102102
#line 35 "test_informix.pgc"
@@ -177,7 +177,7 @@ if (sqlca.sqlcode < 0) dosqlprint ( );}
177177
deccvint(7,&j);
178178
deccvint(14,&m);
179179
decadd(&j,&m,&n);
180-
{ECPGdo(__LINE__,1,1,NULL,"delete from test where i = ?",
180+
{ECPGdo(__LINE__,1,1,NULL,"delete from test where i = ?",
181181
ECPGt_decimal,&(n),(long)1,(long)1,sizeof(decimal),
182182
ECPGt_NO_INDICATOR,NULL ,0L,0L,0L,ECPGt_EOIT,ECPGt_EORT);
183183
#line 72 "test_informix.pgc"

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include"sqltypes.h"
1515

1616

17-
#line 1 "./../../include/sqlca.h"
17+
#line 1 "sqlca.h"
1818
#ifndefPOSTGRES_SQLCA_H
1919
#definePOSTGRES_SQLCA_H
2020

@@ -85,7 +85,7 @@ struct sqlca_t *ECPGget_sqlca(void);
8585
#line 5 "test_informix2.pgc"
8686

8787

88-
#line 1 "./../regression.h"
88+
#line 1 "regression.h"
8989

9090

9191

@@ -194,7 +194,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
194194

195195
sql_check("main","create",0);
196196

197-
{ECPGdo(__LINE__,1,1,NULL,"insert into history ( customerid , timestamp , action_taken , narrative ) values( 1 , '2003-05-07 13:28:34 CEST' , 'test' , 'test' )",ECPGt_EOIT,ECPGt_EORT);
197+
{ECPGdo(__LINE__,1,1,NULL,"insert into history ( customerid , timestamp , action_taken , narrative ) values( 1 , '2003-05-07 13:28:34 CEST' , 'test' , 'test' )",ECPGt_EOIT,ECPGt_EORT);
198198
#line 73 "test_informix2.pgc"
199199

200200
if (sqlca.sqlcode<0)sqlprint();}
@@ -233,7 +233,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
233233

234234
c++;
235235

236-
{ECPGdo(__LINE__,1,1,NULL,"insert into history ( customerid , timestamp , action_taken , narrative ) values( ? , ? , 'test' , 'test' )",
236+
{ECPGdo(__LINE__,1,1,NULL,"insert into history ( customerid , timestamp , action_taken , narrative ) values( ? , ? , 'test' , 'test' )",
237237
ECPGt_int,&(c),(long)1,(long)1,sizeof(int),
238238
ECPGt_NO_INDICATOR,NULL ,0L,0L,0L,
239239
ECPGt_timestamp,&(e),(long)1,(long)1,sizeof(timestamp),

‎src/interfaces/ecpg/test/expected/complex-test1.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include<stdio.h>
1414

1515

16-
#line 1 "./../regression.h"
16+
#line 1 "regression.h"
1717

1818

1919

@@ -374,7 +374,7 @@ if (sqlca.sqlcode < 0) PrintAndStop ( msg );}
374374
amount[i]+=1000;
375375

376376
strcpy(msg,"insert");
377-
{ECPGdo(__LINE__,0,1,"pm","insert into \"Test\" ( name , amount , letter ) values( ? , ? , ? )",
377+
{ECPGdo(__LINE__,0,1,"pm","insert into \"Test\" ( name , amount , letter ) values( ? , ? , ? )",
378378
ECPGt_char,(n),(long)8,(long)1,(8)*sizeof(char),
379379
ECPGt_NO_INDICATOR,NULL ,0L,0L,0L,
380380
ECPGt_int,&(amount[i]),(long)1,(long)1,sizeof(int),
@@ -534,7 +534,7 @@ if (sqlca.sqlcode < 0) PrintAndStop ( msg );}
534534

535535
name_letter[4].amount=1407;
536536
strcpy(msg,"insert");
537-
{ECPGdo(__LINE__,0,1,NULL,"insert into \"Test\" ( name , amount , letter ) values( ? , ? , ? )",
537+
{ECPGdo(__LINE__,0,1,NULL,"insert into \"Test\" ( name , amount , letter ) values( ? , ? , ? )",
538538
ECPGt_char,&(name_letter[4].name),(long)8,(long)1,(8)*sizeof(char),
539539
ECPGt_NO_INDICATOR,NULL ,0L,0L,0L,
540540
ECPGt_int,&(name_letter[4].amount),(long)1,(long)1,sizeof(int),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp