Skip to content

Commit e895eb1

Browse files
author
Michael Meskes
committed
- Synced preproc.y with gram.y
- Init sqlca in ECPGprepare(). - Added CLOSE DATABASE for Informix compatibility.
1 parent cbdda3e commit e895eb1

File tree

3 files changed

+36
-21
lines changed

3 files changed

+36
-21
lines changed

src/interfaces/ecpg/ecpglib/prepare.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/prepare.c,v 1.5 2003/06/26 11:37:05 meskes Exp $ */
1+
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/prepare.c,v 1.6 2003/07/14 10:16:44 meskes Exp $ */
22

33
#define POSTGRES_ECPG_INTERNAL
44
#include "postgres_fe.h"
@@ -59,7 +59,9 @@ ECPGprepare(int lineno, char *name, char *variable)
5959
{
6060
struct statement *stmt;
6161
struct prepared_statement *this;
62+
struct sqlca_t *sqlca = ECPGget_sqlca();
6263

64+
ECPGinit_sqlca(sqlca);
6365
/* check if we already have prepared this statement */
6466
for (this = prep_stmts; this != NULL && strcmp(this->name, name) != 0; this = this->next);
6567
if (this)

src/interfaces/ecpg/preproc/preproc.y

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Attic/preproc.y,v 1.246 2003/07/09 14:53:18 meskes Exp $ */
1+
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Attic/preproc.y,v 1.247 2003/07/14 10:16:44 meskes Exp $ */
22

33
/* Copyright comment */
44
%{
@@ -567,7 +567,28 @@ stmt: AlterDatabaseSetStmt { output_statement($1, 0, connection); }
567567
| AlterUserStmt { output_statement($1, 0, connection); }
568568
| AnalyzeStmt { output_statement($1, 0, connection); }
569569
| CheckPointStmt { output_statement($1, 0, connection); }
570-
| ClosePortalStmt { output_statement($1, 0, connection); }
570+
| ClosePortalStmt
571+
{
572+
if (INFORMIX_MODE)
573+
{
574+
/* Informix also has a CLOSE DATABASE command that
575+
essantially works like a DISCONNECT CURRENT
576+
as far as I know. */
577+
if (strcasecmp($1+strlen("close "), "database") == 0)
578+
{
579+
if (connection)
580+
mmerror(PARSE_ERROR, ET_ERROR, "no at option for close database statement.\n");
581+
582+
fprintf(yyout, "{ ECPGdisconnect(__LINE__, \"CURRENT\");");
583+
whenever_action(2);
584+
free($1);
585+
}
586+
else
587+
output_statement($1, 0, connection);
588+
}
589+
else
590+
output_statement($1, 0, connection);
591+
}
571592
| ClusterStmt { output_statement($1, 0, connection); }
572593
| CommentStmt { output_statement($1, 0, connection); }
573594
| ConstraintsSetStmt { output_statement($1, 0, connection); }
@@ -2596,8 +2617,11 @@ prep_type_list: Typename { $$ = $1; }
25962617
| prep_type_list ',' Typename { $$ = cat_str(3, $1, make_str(","), $3); }
25972618
;
25982619
2599-
ExecuteStmt: EXECUTE name execute_param_clause into_clause
2600-
{ $$ = cat_str(4, make_str("execute"), $2, $3, $4); }
2620+
ExecuteStmt: EXECUTE name execute_param_clause
2621+
{ $$ = cat_str(3, make_str("execute"), $2, $3); }
2622+
| CREATE OptTemp TABLE qualified_name OptCreateAs AS EXECUTE name execute_param_clause
2623+
{ $$ = cat_str(8, make_str("create"), $2, make_str("table"), $4, $5, make_str("as execute"), $8, $9); }
2624+
26012625
;
26022626
26032627
execute_param_clause: '(' expr_list ')' { $$ = cat_str(3, make_str("("), $2, make_str(")")); }
@@ -2878,23 +2902,12 @@ opt_select_limit: select_limit { $$ = $1; }
28782902
| /*EMPTY*/ { $$ = EMPTY; }
28792903
;
28802904

2881-
select_limit_value: PosIntConst
2882-
{
2883-
if (atoi($1) < 0)
2884-
mmerror(PARSE_ERROR, ET_ERROR, "LIMIT must not be negative");
2885-
$$ = $1;
2886-
}
2887-
| ALL { $$ = make_str("all"); }
2888-
| PARAM { $$ = make_name(); }
2905+
select_limit_value: a_expr { $$ = $1; }
2906+
| ALL { $$ = make_str("all"); }
2907+
| PARAM { $$ = make_name(); }
28892908
;
28902909

2891-
select_offset_value: PosIntConst
2892-
{
2893-
if (atoi($1) < 0)
2894-
mmerror(PARSE_ERROR, ET_ERROR, "OFFSET must not be negative");
2895-
$$ = $1;
2896-
}
2897-
| PARAM { $$ = make_name(); }
2910+
select_offset_value: a_expr { $$ = $1; }
28982911
;
28992912

29002913
/*

src/interfaces/ecpg/test/test_informix.pgc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ int main()
5757
$drop table test;
5858
$commit;
5959

60-
$disconnect;
60+
$close database;
6161

6262
return 0;
6363
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy