Commit c80ba6a1 authored by Michael Meskes's avatar Michael Meskes

*** empty log message ***

parent 4cd086ce
...@@ -758,5 +758,22 @@ Thu Dec 23 13:25:05 CET 1999 ...@@ -758,5 +758,22 @@ Thu Dec 23 13:25:05 CET 1999
Thu Jan 6 09:52:27 CET 2000 Thu Jan 6 09:52:27 CET 2000
- Synced preproc.y with gram.y. - Synced preproc.y with gram.y.
- Made sure Bruce's additions also make it into my source tree.
- Set ecpg version to 2.6.14. - Set ecpg version to 2.6.14.
Wed Jan 12 15:50:39 CET 2000
- Made sure Rene Hogendoorn's patches make it into ecpg completely
except for the FETCH syntax change.
Fri Jan 14 21:17:46 CET 2000
- Applied a minor patch to ecpglib.c.
- Fixed initialization bugs.
Mon Jan 17 21:55:40 CET 2000
- Synced preproc.y with gram.y.
- Changed FETCH syntax using Rene's final patch. Made it more
standard compliant.
- Set library version to 3.0.10.
- Set ecpg version to 2.7.0.
...@@ -13,19 +13,17 @@ stderr. Instead it should be listed as a warning. ...@@ -13,19 +13,17 @@ stderr. Instead it should be listed as a warning.
The error handling has to be improved by adding additional error-rules to The error handling has to be improved by adding additional error-rules to
the parser. the parser.
it would be nice to be able to use :var[:index] as cvariable it would be nice to be able to use :var[:index] as cvariable for an array var
support for dynamic SQL with unknown number of variables with DESCRIPTORS How can one insert arrays from c variables?
The line numbering is not exact. support for dynamic SQL with unknown number of variables with DESCRIPTORS
What happens to the output variable during read if there was an What happens to the output variable during read if there was an
indicator-error? indicator-error?
Add a semantic check level, e.g. check if a table really exists. Add a semantic check level, e.g. check if a table really exists.
How can one insert arrays from c variables?
Missing statements: Missing statements:
- exec sql ifdef - exec sql ifdef
- exec sql allocate - exec sql allocate
......
...@@ -6,13 +6,13 @@ ...@@ -6,13 +6,13 @@
# Copyright (c) 1994, Regents of the University of California # Copyright (c) 1994, Regents of the University of California
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/Makefile.in,v 1.55 2000/01/10 15:41:27 momjian Exp $ # $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/Makefile.in,v 1.56 2000/01/18 13:03:47 meskes Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
NAME= ecpg NAME= ecpg
SO_MAJOR_VERSION= 3 SO_MAJOR_VERSION= 3
SO_MINOR_VERSION= 1.0 SO_MINOR_VERSION= 0.10
SRCDIR= @top_srcdir@ SRCDIR= @top_srcdir@
include $(SRCDIR)/Makefile.global include $(SRCDIR)/Makefile.global
......
...@@ -3,7 +3,7 @@ include $(SRCDIR)/Makefile.global ...@@ -3,7 +3,7 @@ include $(SRCDIR)/Makefile.global
MAJOR_VERSION=2 MAJOR_VERSION=2
MINOR_VERSION=7 MINOR_VERSION=7
PATCHLEVEL=14 PATCHLEVEL=0
CFLAGS+=-I../include -DMAJOR_VERSION=$(MAJOR_VERSION) \ CFLAGS+=-I../include -DMAJOR_VERSION=$(MAJOR_VERSION) \
-DMINOR_VERSION=$(MINOR_VERSION) -DPATCHLEVEL=$(PATCHLEVEL) \ -DMINOR_VERSION=$(MINOR_VERSION) -DPATCHLEVEL=$(PATCHLEVEL) \
......
...@@ -17,12 +17,11 @@ struct cursor *cur = NULL; ...@@ -17,12 +17,11 @@ struct cursor *cur = NULL;
struct typedefs *types = NULL; struct typedefs *types = NULL;
struct _defines *defines = NULL; struct _defines *defines = NULL;
static void static void
usage(char *progname) usage(char *progname)
{ {
fprintf(stderr, "ecpg - the postgresql preprocessor, version: %d.%d.%d\n", MAJOR_VERSION, MINOR_VERSION, PATCHLEVEL); fprintf(stderr, "ecpg - the postgresql preprocessor, version: %d.%d.%d\n", MAJOR_VERSION, MINOR_VERSION, PATCHLEVEL);
fprintf(stderr, "Usage: %s: [-v] [-t] [-I include path] [ -o output file name] file1 [file2] ...\n", progname); fprintf(stderr, "Usage: %s: [-v] [-t] [-I include path] [ -o output file name] [-D define name] file1 [file2] ...\n", progname);
} }
static void static void
...@@ -35,6 +34,18 @@ add_include_path(char *path) ...@@ -35,6 +34,18 @@ add_include_path(char *path)
include_paths->next = ip; include_paths->next = ip;
} }
static void
add_preprocessor_define(char *define)
{
struct _defines *pd = defines;
defines = mm_alloc(sizeof(struct _defines));
defines->old = strdup(define);
defines->new = strdup("");
defines->pertinent = true;
defines->next = pd;
}
int int
main(int argc, char *const argv[]) main(int argc, char *const argv[])
{ {
...@@ -49,7 +60,7 @@ main(int argc, char *const argv[]) ...@@ -49,7 +60,7 @@ main(int argc, char *const argv[])
add_include_path("/usr/local/include"); add_include_path("/usr/local/include");
add_include_path("."); add_include_path(".");
while ((c = getopt(argc, argv, "vo:I:t")) != EOF) while ((c = getopt(argc, argv, "vo:I:tD:")) != EOF)
{ {
switch (c) switch (c)
{ {
...@@ -73,6 +84,9 @@ main(int argc, char *const argv[]) ...@@ -73,6 +84,9 @@ main(int argc, char *const argv[])
case 'v': case 'v':
verbose = true; verbose = true;
break; break;
case 'D':
add_preprocessor_define(optarg);
break;
default: default:
usage(argv[0]); usage(argv[0]);
return ILLEGAL_OPTION; return ILLEGAL_OPTION;
...@@ -106,7 +120,10 @@ main(int argc, char *const argv[]) ...@@ -106,7 +120,10 @@ main(int argc, char *const argv[])
strcpy(input_filename, argv[fnr]); strcpy(input_filename, argv[fnr]);
ptr2ext = strrchr(input_filename, '.'); /* take care of relative paths */
ptr2ext = strrchr(input_filename, '/');
ptr2ext = (ptr2ext ? strrchr(ptr2ext, '.') : strrchr(input_filename, '.'));
/* no extension? */ /* no extension? */
if (ptr2ext == NULL) if (ptr2ext == NULL)
{ {
...@@ -120,7 +137,7 @@ main(int argc, char *const argv[]) ...@@ -120,7 +137,7 @@ main(int argc, char *const argv[])
ptr2ext[4] = '\0'; ptr2ext[4] = '\0';
} }
if (out_option == 0)/* calculate the output name */ if (out_option == 0) /* calculate the output name */
{ {
output_filename = strdup(input_filename); output_filename = strdup(input_filename);
...@@ -179,17 +196,30 @@ main(int argc, char *const argv[]) ...@@ -179,17 +196,30 @@ main(int argc, char *const argv[])
ptr = ptr->next; ptr = ptr->next;
free(this); free(this);
} }
cur = NULL;
/* remove old defines as well */ /* remove non-pertinent old defines as well */
for (defptr = defines; defptr != NULL;) while ( defines && !defines->pertinent ) {
{ defptr = defines;
struct _defines *this = defptr; defines = defines->next;
free(defptr->new); free(defptr->new);
free(defptr->old); free(defptr->old);
defptr = defptr->next; free(defptr);
}
for (defptr = defines; defptr != NULL; defptr = defptr->next )
{
struct _defines *this = defptr->next;
if ( this && !this->pertinent ) {
defptr->next = this->next;
free(this->new);
free(this->old);
free(this); free(this);
} }
}
/* and old typedefs */ /* and old typedefs */
for (typeptr = types; typeptr != NULL;) for (typeptr = types; typeptr != NULL;)
...@@ -197,17 +227,25 @@ main(int argc, char *const argv[]) ...@@ -197,17 +227,25 @@ main(int argc, char *const argv[])
struct typedefs *this = typeptr; struct typedefs *this = typeptr;
free(typeptr->name); free(typeptr->name);
free(typeptr->type);
ECPGfree_struct_member(typeptr->struct_member_list); ECPGfree_struct_member(typeptr->struct_member_list);
free(typeptr->type);
typeptr = typeptr->next; typeptr = typeptr->next;
free(this); free(this);
} }
types = NULL;
/* initialize whenever structures */
memset(&when_error, 0, sizeof(struct when));
memset(&when_nf, 0, sizeof(struct when));
memset(&when_warn, 0, sizeof(struct when));
/* and structure member lists */
memset(struct_member_list, 0, sizeof(struct_member_list));
/* initialize lex */ /* initialize lex */
lex_init(); lex_init();
/* we need two includes */ /* we need two includes */
fprintf(yyout, "/* Processed by ecpg (%d.%d.%d) */\n/* These two include files are added by the preprocessor */\n#include <ecpgtype.h>\n#include <ecpglib.h>\n\n", MAJOR_VERSION, MINOR_VERSION, PATCHLEVEL); fprintf(yyout, "/* Processed by ecpg (%d.%d.%d) */\n/* These two include files are added by the preprocessor */\n#include <ecpgtype.h>\n#include <ecpglib.h>\n#line 1 \"%s\"\n", MAJOR_VERSION, MINOR_VERSION, PATCHLEVEL, input_filename);
/* and parse the source */ /* and parse the source */
yyparse(); yyparse();
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
#include "type.h" #include "type.h"
#include <errno.h> #include <errno.h>
/* defines */
#define STRUCT_DEPTH 128
/* variables */ /* variables */
extern int braces_open, extern int braces_open,
...@@ -23,6 +27,8 @@ extern struct ECPGtype ecpg_no_indicator; ...@@ -23,6 +27,8 @@ extern struct ECPGtype ecpg_no_indicator;
extern struct variable no_indicator; extern struct variable no_indicator;
extern struct arguments *argsinsert; extern struct arguments *argsinsert;
extern struct arguments *argsresult; extern struct arguments *argsresult;
extern struct when when_error, when_nf, when_warn;
extern struct ECPGstruct_member *struct_member_list[STRUCT_DEPTH];
/* functions */ /* functions */
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include "mb/pg_wchar.h" #include "mb/pg_wchar.h"
#endif #endif
#define STRUCT_DEPTH 128
#define EMPTY make_str("") #define EMPTY make_str("")
/* /*
...@@ -27,6 +26,7 @@ static char *connection = NULL; ...@@ -27,6 +26,7 @@ static char *connection = NULL;
static int QueryIsRule = 0, ForUpdateNotAllowed = 0, FoundInto = 0; static int QueryIsRule = 0, ForUpdateNotAllowed = 0, FoundInto = 0;
static struct this_type actual_type[STRUCT_DEPTH]; static struct this_type actual_type[STRUCT_DEPTH];
static char *actual_storage[STRUCT_DEPTH]; static char *actual_storage[STRUCT_DEPTH];
static char *actual_startline[STRUCT_DEPTH];
/* temporarily store struct members while creating the data structure */ /* temporarily store struct members while creating the data structure */
struct ECPGstruct_member *struct_member_list[STRUCT_DEPTH] = { NULL }; struct ECPGstruct_member *struct_member_list[STRUCT_DEPTH] = { NULL };
...@@ -69,7 +69,7 @@ void ...@@ -69,7 +69,7 @@ void
output_line_number() output_line_number()
{ {
if (input_filename) if (input_filename)
fprintf(yyout, "\n#line %d \"%s\"\n", yylineno + 1, input_filename); fprintf(yyout, "\n#line %d \"%s\"\n", yylineno, input_filename);
} }
static void static void
...@@ -83,7 +83,7 @@ output_simple_statement(char *cmd) ...@@ -83,7 +83,7 @@ output_simple_statement(char *cmd)
/* /*
* store the whenever action here * store the whenever action here
*/ */
static struct when when_error, when_nf, when_warn; struct when when_error, when_nf, when_warn;
static void static void
print_action(struct when *w) print_action(struct when *w)
...@@ -479,6 +479,20 @@ make_name(void) ...@@ -479,6 +479,20 @@ make_name(void)
return(name); return(name);
} }
static char *
hashline_number()
{
if (input_filename)
{
char* line = mm_alloc(strlen("\n#line %d \"%s\"\n") + 21 + strlen(input_filename));
sprintf(line, "\n#line %d \"%s\"\n", yylineno, input_filename);
return line;
}
return EMPTY;
}
static void static void
output_statement(char * stmt, int mode) output_statement(char * stmt, int mode)
{ {
...@@ -742,8 +756,8 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim ...@@ -742,8 +756,8 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim
%type <str> file_name AexprConst ParamNo TypeId com_expr %type <str> file_name AexprConst ParamNo TypeId com_expr
%type <str> in_expr_nodes a_expr b_expr TruncateStmt CommentStmt %type <str> in_expr_nodes a_expr b_expr TruncateStmt CommentStmt
%type <str> opt_indirection expr_list extract_list extract_arg %type <str> opt_indirection expr_list extract_list extract_arg
%type <str> position_list substr_list substr_from %type <str> position_list substr_list substr_from alter_column_action
%type <str> trim_list in_expr substr_for attr attrs %type <str> trim_list in_expr substr_for attr attrs drop_behavior
%type <str> Typename SimpleTypename Generic Numeric generic opt_float opt_numeric %type <str> Typename SimpleTypename Generic Numeric generic opt_float opt_numeric
%type <str> opt_decimal Character character opt_varying opt_charset %type <str> opt_decimal Character character opt_varying opt_charset
%type <str> opt_collate Datetime datetime opt_timezone opt_interval %type <str> opt_collate Datetime datetime opt_timezone opt_interval
...@@ -757,7 +771,7 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim ...@@ -757,7 +771,7 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim
%type <str> columnList DeleteStmt LockStmt UpdateStmt CursorStmt %type <str> columnList DeleteStmt LockStmt UpdateStmt CursorStmt
%type <str> NotifyStmt columnElem copy_dirn UnlistenStmt copy_null %type <str> NotifyStmt columnElem copy_dirn UnlistenStmt copy_null
%type <str> copy_delimiter ListenStmt CopyStmt copy_file_name opt_binary %type <str> copy_delimiter ListenStmt CopyStmt copy_file_name opt_binary
%type <str> opt_with_copy FetchStmt opt_direction fetch_how_many opt_portal_name %type <str> opt_with_copy FetchStmt direction fetch_how_many from_in
%type <str> ClosePortalStmt DropStmt VacuumStmt opt_verbose %type <str> ClosePortalStmt DropStmt VacuumStmt opt_verbose
%type <str> opt_analyze opt_va_list va_list ExplainStmt index_params %type <str> opt_analyze opt_va_list va_list ExplainStmt index_params
%type <str> index_list func_index index_elem opt_type opt_class access_method_clause %type <str> index_list func_index index_elem opt_type opt_class access_method_clause
...@@ -771,16 +785,17 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim ...@@ -771,16 +785,17 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim
%type <str> RemoveAggrStmt remove_type RemoveStmt ExtendStmt %type <str> RemoveAggrStmt remove_type RemoveStmt ExtendStmt
%type <str> RemoveOperStmt RenameStmt all_Op user_valid_clause %type <str> RemoveOperStmt RenameStmt all_Op user_valid_clause
%type <str> VariableSetStmt var_value zone_value VariableShowStmt %type <str> VariableSetStmt var_value zone_value VariableShowStmt
%type <str> VariableResetStmt AddAttrStmt alter_clause DropUserStmt %type <str> VariableResetStmt AlterTableStmt DropUserStmt
%type <str> user_passwd_clause user_createdb_clause opt_trans %type <str> user_passwd_clause user_createdb_clause opt_trans
%type <str> user_createuser_clause user_group_list user_group_clause %type <str> user_createuser_clause user_list user_group_clause
%type <str> CreateUserStmt AlterUserStmt CreateSeqStmt OptSeqList %type <str> CreateUserStmt AlterUserStmt CreateSeqStmt OptSeqList
%type <str> OptSeqElem TriggerForSpec TriggerForOpt TriggerForType %type <str> OptSeqElem TriggerForSpec TriggerForOpt TriggerForType
%type <str> DropTrigStmt TriggerOneEvent TriggerEvents RuleActionStmt %type <str> DropTrigStmt TriggerOneEvent TriggerEvents RuleActionStmt
%type <str> TriggerActionTime CreateTrigStmt DropPLangStmt PLangTrusted %type <str> TriggerActionTime CreateTrigStmt DropPLangStmt PLangTrusted
%type <str> CreatePLangStmt IntegerOnly TriggerFuncArgs TriggerFuncArg %type <str> CreatePLangStmt IntegerOnly TriggerFuncArgs TriggerFuncArg
%type <str> ViewStmt LoadStmt CreatedbStmt opt_database1 opt_database2 location %type <str> ViewStmt LoadStmt CreatedbStmt createdb_opt_encoding
%type <str> DropdbStmt ClusterStmt grantee RevokeStmt encoding %type <str> createdb_opt_location opt_encoding AlterTableStmt
%type <str> DropdbStmt ClusterStmt grantee RevokeStmt
%type <str> GrantStmt privileges operation_commalist operation %type <str> GrantStmt privileges operation_commalist operation
%type <str> opt_cursor opt_lmode ConstraintsSetStmt comment_tg %type <str> opt_cursor opt_lmode ConstraintsSetStmt comment_tg
%type <str> case_expr when_clause_list case_default case_arg when_clause %type <str> case_expr when_clause_list case_default case_arg when_clause
...@@ -808,7 +823,7 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim ...@@ -808,7 +823,7 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim
%type <str> enum_type civariableonly ECPGCursorStmt ECPGDeallocate %type <str> enum_type civariableonly ECPGCursorStmt ECPGDeallocate
%type <str> ECPGFree ECPGDeclare ECPGVar sql_variable_declarations %type <str> ECPGFree ECPGDeclare ECPGVar sql_variable_declarations
%type <str> sql_declaration sql_variable_list sql_variable opt_at %type <str> sql_declaration sql_variable_list sql_variable opt_at
%type <str> struct_type s_struct declaration variable_declarations %type <str> struct_type s_struct declaration declarations variable_declarations
%type <str> s_struct s_union union_type ECPGSetAutocommit on_off %type <str> s_struct s_union union_type ECPGSetAutocommit on_off
%type <type_enum> simple_type varchar_type %type <type_enum> simple_type varchar_type
...@@ -836,7 +851,7 @@ statement: ecpgstart opt_at stmt ';' { connection = NULL; } ...@@ -836,7 +851,7 @@ statement: ecpgstart opt_at stmt ';' { connection = NULL; }
opt_at: SQL_AT connection_target { connection = $2; } opt_at: SQL_AT connection_target { connection = $2; }
stmt: AddAttrStmt { output_statement($1, 0); } stmt: AlterTableStmt { output_statement($1, 0); }
| AlterGroupStmt { output_statement($1, 0); } | AlterGroupStmt { output_statement($1, 0); }
| AlterUserStmt { output_statement($1, 0); } | AlterUserStmt { output_statement($1, 0); }
| ClosePortalStmt { output_statement($1, 0); } | ClosePortalStmt { output_statement($1, 0); }
...@@ -1033,15 +1048,14 @@ CreateUserStmt: CREATE USER UserId ...@@ -1033,15 +1048,14 @@ CreateUserStmt: CREATE USER UserId
*****************************************************************************/ *****************************************************************************/
AlterUserStmt: ALTER USER UserId user_createdb_clause AlterUserStmt: ALTER USER UserId user_createdb_clause
user_createuser_clause user_group_clause user_valid_clause user_createuser_clause user_valid_clause
{ {
$$ = cat_str(6, make_str("alter user"), $3, $4, $5, $6, $7); $$ = cat_str(5, make_str("alter user"), $3, $4, $5, $6);
} }
|ALTER USER UserId WITH sysid_clause user_passwd_clause |ALTER USER UserId WITH PASSWORD Sconst
user_createdb_clause user_createuser_clause user_group_clause user_createdb_clause user_createuser_clause user_valid_clause
user_valid_clause
{ {
$$ = cat_str(9, make_str("alter user"), $3, make_str("with"), $5, $6, $7, $8, $9, $10); $$ = cat_str(7, make_str("alter user"), $3, make_str("with password"), $6, $7, $8, $9);
} }
; ;
...@@ -1052,17 +1066,20 @@ AlterUserStmt: ALTER USER UserId user_createdb_clause ...@@ -1052,17 +1066,20 @@ AlterUserStmt: ALTER USER UserId user_createdb_clause
* *
*****************************************************************************/ *****************************************************************************/
DropUserStmt: DROP USER UserId DropUserStmt: DROP USER user_list
{ {
$$ = cat2_str(make_str("drop user"), $3); $$ = cat2_str(make_str("drop user"), $3);
} }
; ;
user_passwd_clause: PASSWORD UserId { $$ = cat2_str(make_str("password") , $2); } user_passwd_clause: PASSWORD Sconst { $$ = cat2_str(make_str("password") , $2); }
| /*EMPTY*/ { $$ = EMPTY; } | /*EMPTY*/ { $$ = EMPTY; }
; ;
sysid_clause: SYSID Iconst { $$ = cat2_str(make_str("sysid"), $2); } sysid_clause: SYSID Iconst { if (atoi($2) <= 0)
mmerror(ET_ERROR, "sysid must be positive");
$$ = cat2_str(make_str("sysid"), $2); }
| /*EMPTY*/ { $$ = EMPTY; } | /*EMPTY*/ { $$ = EMPTY; }
; ;
...@@ -1088,7 +1105,7 @@ user_createuser_clause: CREATEUSER ...@@ -1088,7 +1105,7 @@ user_createuser_clause: CREATEUSER
| /*EMPTY*/ { $$ = NULL; } | /*EMPTY*/ { $$ = NULL; }
; ;
user_group_list: user_group_list ',' UserId user_list: user_list ',' UserId
{ {
$$ = cat_str(3, $1, make_str(","), $3); $$ = cat_str(3, $1, make_str(","), $3);
} }
...@@ -1098,7 +1115,7 @@ user_group_list: user_group_list ',' UserId ...@@ -1098,7 +1115,7 @@ user_group_list: user_group_list ',' UserId
} }
; ;
user_group_clause: IN GROUP user_group_list user_group_clause: IN GROUP user_list
{ {
$$ = cat2_str(make_str("in group"), $3); $$ = cat2_str(make_str("in group"), $3);
} }
...@@ -1126,7 +1143,7 @@ CreateGroupStmt: CREATE GROUP UserId ...@@ -1126,7 +1143,7 @@ CreateGroupStmt: CREATE GROUP UserId
} }
; ;
users_in_new_group_clause: USER user_group_list { $$ = cat2_str(make_str("user"), $2); } users_in_new_group_clause: USER user_list { $$ = cat2_str(make_str("user"), $2); }
| /* EMPTY */ { $$ = EMPTY; } | /* EMPTY */ { $$ = EMPTY; }
; ;
...@@ -1137,17 +1154,12 @@ users_in_new_group_clause: USER user_group_list { $$ = cat2_str(make_str("use ...@@ -1137,17 +1154,12 @@ users_in_new_group_clause: USER user_group_list { $$ = cat2_str(make_str("use
* *
* *
*****************************************************************************/ *****************************************************************************/
AlterGroupStmt: ALTER GROUP UserId WITH SYSID Iconst AlterGroupStmt: ALTER GROUP UserId ADD USER user_list
{
$$ = cat_str(4, make_str("alter group"), $3, make_str("with sysid"), $6);
}
|
ALTER GROUP UserId ADD USER user_group_list
{ {
$$ = cat_str(4, make_str("alter group"), $3, make_str("add user"), $6); $$ = cat_str(4, make_str("alter group"), $3, make_str("add user"), $6);
} }
| |
ALTER GROUP UserId DROP USER user_group_list ALTER GROUP UserId DROP USER user_list
{ {
$$ = cat_str(4, make_str("alter group"), $3, make_str("drop user"), $6); $$ = cat_str(4, make_str("alter group"), $3, make_str("drop user"), $6);
} }
...@@ -1191,12 +1203,12 @@ VariableSetStmt: SET ColId TO var_value ...@@ -1191,12 +1203,12 @@ VariableSetStmt: SET ColId TO var_value
{ {
$$ = cat2_str(make_str("set transaction isolation level"), $5); $$ = cat2_str(make_str("set transaction isolation level"), $5);
} }
| SET NAMES encoding | SET NAMES opt_encoding
{ {
#ifdef MULTIBYTE #ifdef MULTIBYTE
$$ = cat2_str(make_str("set names"), $3); $$ = cat2_str(make_str("set names"), $3);
#else #else
mmerror(ET_ERROR, "SET NAMES is not supported"); mmerror(ET_ERROR, "SET NAMES is not supported.");
#endif #endif
} }
; ;
...@@ -1215,6 +1227,11 @@ zone_value: Sconst { $$ = $1; } ...@@ -1215,6 +1227,11 @@ zone_value: Sconst { $$ = $1; }
| LOCAL { $$ = make_str("local"); } | LOCAL { $$ = make_str("local"); }
; ;
opt_encoding: Sconst { $$ = $1; }
| DEFAULT { $$ = make_str("default"); }
| /*EMPTY*/ { $$ = EMPTY; }
;
VariableShowStmt: SHOW ColId VariableShowStmt: SHOW ColId
{ {
$$ = cat2_str(make_str("show"), $2); $$ = cat2_str(make_str("show"), $2);
...@@ -1283,32 +1300,49 @@ constraints_set_mode: DEFERRED ...@@ -1283,32 +1300,49 @@ constraints_set_mode: DEFERRED
/***************************************************************************** /*****************************************************************************
* *
* QUERY : * QUERY :
* addattr ( attr1 = type1 .. attrn = typen ) to <relname> [*] *
* ALTER TABLE variations
* *
*****************************************************************************/ *****************************************************************************/
AddAttrStmt: ALTER TABLE relation_name opt_inh_star alter_clause AlterTableStmt:
/* ALTER TABLE <name> ADD [COLUMN] <coldef> */
ALTER TABLE relation_name opt_inh_star ADD opt_column columnDef
{ {
$$ = cat_str(4, make_str("alter table"), $3, $4, $5); $$ = cat_str(5, make_str("alter table"), $3, $4, make_str("add"), $6, $7);
} }
; /* ALTER TABLE <name> ALTER [COLUMN] <colname> {SET DEFAULT <expr>|DROP
DEFAULT} */
alter_clause: ADD opt_column columnDef | ALTER TABLE relation_name opt_inh_star ALTER opt_column ColId
alter_column_action
{
$$ = cat_str(6, make_str("alter table"), $3, $4, make_str("alter"), $6, $7, $8);
}
/* ALTER TABLE <name> DROP [COLUMN] <name> {RESTRICT|CASCADE} */
| ALTER TABLE relation_name opt_inh_star DROP opt_column ColId
drop_behavior
{ {
$$ = cat_str(3, make_str("add"), $2, $3); $$ = cat_str(6, make_str("alter table"), $3, $4, make_str("drop"), $6, $7, $8);
} }
| ADD '(' OptTableElementList ')' /* ALTER TABLE <name> ADD CONSTRAINT ... */
| ALTER TABLE relation_name opt_inh_star ADD TableConstraint
{ {
$$ = cat_str(2, make_str("add("), $3, make_str(")")); $$ = cat_str(4, make_str("alter table"), $3, $4, make_str("add"), $6);
}
/* ALTER TABLE <name> DROP CONSTRAINT ... */
| ALTER TABLE relation_name opt_inh_star DROP CONSTRAINT name drop_behavior
{
$$ = cat_str(5, make_str("alter table"), $3, $4, make_str("drop constraint"), $7, $8);
} }
| DROP opt_column ColId ;
{ mmerror(ET_ERROR, "ALTER TABLE/DROP COLUMN not yet implemented"); }
| ALTER opt_column ColId SET DEFAULT a_expr alter_column_action:
{ mmerror(ET_ERROR, "ALTER TABLE/ALTER COLUMN/SET DEFAULT not yet implemented"); } SET DEFAULT a_expr_or_null { $$ = cat2_str(make_str("set default"), $3); }
| ALTER opt_column ColId DROP DEFAULT | DROP DEFAULT { $$ = make_str("drop default"); }
{ mmerror(ET_ERROR, "ALTER TABLE/ALTER COLUMN/DROP DEFAULT not yet implemented"); } ;
| ADD ConstraintElem
{ mmerror(ET_ERROR, "ALTER TABLE/ADD CONSTRAINT not yet implemented"); } drop_behavior: CASCADE { $$ = make_str("cascade"); }
| RESTRICT { $$ = make_str("restrict"); }
; ;
/***************************************************************************** /*****************************************************************************
...@@ -1927,28 +1961,58 @@ TruncateStmt: TRUNCATE TABLE relation_name ...@@ -1927,28 +1961,58 @@ TruncateStmt: TRUNCATE TABLE relation_name
* *
*****************************************************************************/ *****************************************************************************/
FetchStmt: FETCH opt_direction fetch_how_many opt_portal_name INTO into_list FetchStmt: FETCH direction fetch_how_many from_in name INTO into_list
{ {
if (strcmp($2, "relative") == 0 && atol($3) == 0L) if (strcmp($2, "relative") == 0 && atol($3) == 0L)
mmerror(ET_ERROR, "FETCH/RELATIVE at current position is not supported"); mmerror(ET_ERROR, "FETCH/RELATIVE at current position is not supported");
$$ = cat_str(5, make_str("fetch"), $2, $3, $4, $5);
}
| FETCH fetch_how_many from_in name INTO into_list
{
$$ = cat_str(4, make_str("fetch"), $2, $3, $4); $$ = cat_str(4, make_str("fetch"), $2, $3, $4);
} }
| MOVE opt_direction fetch_how_many opt_portal_name | FETCH direction from_in name INTO into_list
{ {
$$ = cat_str(4, make_str("fetch"), $2, $3, $4); $$ = cat_str(4, make_str("fetch"), $2, $3, $4);
} }
| FETCH from_in name INTO into_list
{
$$ = cat_str(3, make_str("fetch"), $2, $3);
}
| FETCH name INTO into_list
{
$$ = cat2_str(make_str("fetch"), $2);
}
| MOVE direction fetch_how_many from_in name
{
$$ = cat_str(5, make_str("move"), $2, $3, $4, $5);
}
| MOVE fetch_how_many from_in name
{
$$ = cat_str(4, make_str("move"), $2, $3, $4);
}
| MOVE direction from_in name
{
$$ = cat_str(4, make_str("move"), $2, $3, $4);
}
| MOVE from_in name
{
$$ = cat_str(3, make_str("move"), $2, $3);
}
| MOVE name
{
$$ = cat2_str(make_str("move"), $2);
}
; ;
opt_direction: FORWARD { $$ = make_str("forward"); } direction: FORWARD { $$ = make_str("forward"); }
| BACKWARD { $$ = make_str("backward"); } | BACKWARD { $$ = make_str("backward"); }
| RELATIVE { $$ = make_str("relative"); } | RELATIVE { $$ = make_str("relative"); }
| ABSOLUTE | ABSOLUTE {
{
mmerror(ET_WARN, "FETCH/ABSOLUTE not supported, backend will use RELATIVE"); mmerror(ET_WARN, "FETCH/ABSOLUTE not supported, backend will use RELATIVE");
$$ = make_str("absolute"); $$ = make_str("absolute");
} }
| /*EMPTY*/ { $$ = EMPTY; /* default */ }
; ;
fetch_how_many: Iconst { $$ = $1; } fetch_how_many: Iconst { $$ = $1; }
...@@ -1956,13 +2020,10 @@ fetch_how_many: Iconst { $$ = $1; } ...@@ -1956,13 +2020,10 @@ fetch_how_many: Iconst { $$ = $1; }
| ALL { $$ = make_str("all"); } | ALL { $$ = make_str("all"); }
| NEXT { $$ = make_str("next"); } | NEXT { $$ = make_str("next"); }
| PRIOR { $$ = make_str("prior"); } | PRIOR { $$ = make_str("prior"); }
| /*EMPTY*/ { $$ = EMPTY; /*default*/ }
; ;
opt_portal_name: IN name { $$ = cat2_str(make_str("in"), $2); } from_in: IN { $$ = make_str("in"); }
| FROM name { $$ = cat2_str(make_str("from"), $2); } | FROM { $$ = make_str("from"); }
/* | name { $$ = cat2_str(make_str("in"), $1); }*/
| /*EMPTY*/ { $$ = EMPTY; }
; ;
/***************************************************************************** /*****************************************************************************
...@@ -2498,19 +2559,15 @@ LoadStmt: LOAD file_name ...@@ -2498,19 +2559,15 @@ LoadStmt: LOAD file_name
/***************************************************************************** /*****************************************************************************
* *
* QUERY: * CREATE DATABASE
* createdb dbname *
* *
*****************************************************************************/ *****************************************************************************/
CreatedbStmt: CREATE DATABASE database_name WITH opt_database1 opt_database2 CreatedbStmt: CREATE DATABASE database_name WITH createdb_opt_location createdb_opt_encoding
{ {
if (strlen($5) == 0 || strlen($6) == 0) if (strlen($5) == 0 || strlen($6) == 0)
mmerror(ET_ERROR, "CREATE DATABASE WITH requires at least an option"); mmerror(ET_ERROR, "CREATE DATABASE WITH requires at least an option");
#ifndef MULTIBYTE
if (strlen($6) != 0)
mmerror(ET_ERROR, "WITH ENCODING is not supported");
#endif
$$ = cat_str(5, make_str("create database"), $3, make_str("with"), $5, $6); $$ = cat_str(5, make_str("create database"), $3, make_str("with"), $5, $6);
} }
| CREATE DATABASE database_name | CREATE DATABASE database_name
...@@ -2519,28 +2576,39 @@ CreatedbStmt: CREATE DATABASE database_name WITH opt_database1 opt_database2 ...@@ -2519,28 +2576,39 @@ CreatedbStmt: CREATE DATABASE database_name WITH opt_database1 opt_database2
} }
; ;
opt_database1: LOCATION '=' location { $$ = cat2_str(make_str("location ="), $3); } createdb_opt_location: LOCATION '=' Sconst { $$ = cat2_str(make_str("location ="), $3); }
| LOCATION '=' DEFAULT { $$ = make_str("location = default"); }
| /*EMPTY*/ { $$ = EMPTY; } | /*EMPTY*/ { $$ = EMPTY; }
; ;
opt_database2: ENCODING '=' encoding { $$ = cat2_str(make_str("encoding ="), $3); } createdb_opt_encoding: ENCODING '=' Sconst
{
#ifndef MULTIBYTE
mmerror(ET_ERROR, "WITH ENCODING is not supported.");
#endif
$$ = cat2_str(make_str("encoding ="), $3);
}
| ENCODING '=' Iconst
{
#ifndef MULTIBYTE
mmerror(ET_ERROR, "WITH ENCODING is not supported.");
#endif
$$ = cat2_str(make_str("encoding ="), $3);
}
| ENCODING '=' DEFAULT
{
#ifndef MULTIBYTE
mmerror(ET_ERROR, "WITH ENCODING is not supported.");
#endif
$$ = make_str("encoding = default");
}
| /*EMPTY*/ { $$ = NULL; } | /*EMPTY*/ { $$ = NULL; }
; ;
location: Sconst { $$ = $1; }
| DEFAULT { $$ = make_str("default"); }
| /*EMPTY*/ { $$ = EMPTY; }
;
encoding: Sconst { $$ = $1; }
| DEFAULT { $$ = make_str("default"); }
| /*EMPTY*/ { $$ = EMPTY; }
;
/***************************************************************************** /*****************************************************************************
* *
* QUERY: * DROP DATABASE
* dropdb dbname *
* *
*****************************************************************************/ *****************************************************************************/
...@@ -4257,6 +4325,7 @@ ColLabel: ColId { $$ = $1; } ...@@ -4257,6 +4325,7 @@ ColLabel: ColId { $$ = $1; }
| CONSTRAINT { $$ = make_str("constraint"); } | CONSTRAINT { $$ = make_str("constraint"); }
| COPY { $$ = make_str("copy"); } | COPY { $$ = make_str("copy"); }
| CURRENT { $$ = make_str("current"); } | CURRENT { $$ = make_str("current"); }
| DECIMAL { $$ = make_str("decimal"); }
| DO { $$ = make_str("do"); } | DO { $$ = make_str("do"); }
| ELSE { $$ = make_str("else"); } | ELSE { $$ = make_str("else"); }
| END_TRANS { $$ = make_str("end"); } | END_TRANS { $$ = make_str("end"); }
...@@ -4272,6 +4341,7 @@ ColLabel: ColId { $$ = $1; } ...@@ -4272,6 +4341,7 @@ ColLabel: ColId { $$ = $1; }
| NEW { $$ = make_str("new"); } | NEW { $$ = make_str("new"); }
| NONE { $$ = make_str("none"); } | NONE { $$ = make_str("none"); }
| NULLIF { $$ = make_str("nullif"); } | NULLIF { $$ = make_str("nullif"); }
| NUMERIC { $$ = make_str("numeric"); }
| ORDER { $$ = make_str("order"); } | ORDER { $$ = make_str("order"); }
| POSITION { $$ = make_str("position"); } | POSITION { $$ = make_str("position"); }
| PRECISION { $$ = make_str("precision"); } | PRECISION { $$ = make_str("precision"); }
...@@ -4532,7 +4602,6 @@ ECPGDeallocate: SQL_DEALLOCATE SQL_PREPARE ident { $$ = cat_str(3, make_str("ECP ...@@ -4532,7 +4602,6 @@ ECPGDeallocate: SQL_DEALLOCATE SQL_PREPARE ident { $$ = cat_str(3, make_str("ECP
ECPGDeclaration: sql_startdeclare ECPGDeclaration: sql_startdeclare
{ {
fputs("/* exec sql begin declare section */", yyout); fputs("/* exec sql begin declare section */", yyout);
output_line_number();
} }
variable_declarations sql_enddeclare variable_declarations sql_enddeclare
{ {
...@@ -4545,18 +4614,16 @@ sql_startdeclare : ecpgstart BEGIN_TRANS DECLARE SQL_SECTION ';' {} ...@@ -4545,18 +4614,16 @@ sql_startdeclare : ecpgstart BEGIN_TRANS DECLARE SQL_SECTION ';' {}
sql_enddeclare: ecpgstart END_TRANS DECLARE SQL_SECTION ';' {} sql_enddeclare: ecpgstart END_TRANS DECLARE SQL_SECTION ';' {}
variable_declarations: /* empty */ variable_declarations: /* empty */ { $$ = EMPTY; }
{ | declarations { $$ = $1; }
$$ = EMPTY;
} declarations: declaration { $$ = $1; }
| declaration variable_declarations | declarations declaration { $$ = cat2_str($1, $2); }
{
$$ = cat2_str($1, $2);
}
declaration: storage_clause declaration: storage_clause
{ {
actual_storage[struct_level] = mm_strdup($1); actual_storage[struct_level] = mm_strdup($1);
actual_startline[struct_level] = hashline_number();
} }
type type
{ {
...@@ -4566,7 +4633,7 @@ declaration: storage_clause ...@@ -4566,7 +4633,7 @@ declaration: storage_clause
} }
variable_list ';' variable_list ';'
{ {
$$ = cat_str(4, $1, $3.type_str, $5, make_str(";\n")); $$ = cat_str(5, actual_startline[struct_level], $1, $3.type_str, $5, make_str(";\n"));
} }
storage_clause : S_EXTERN { $$ = make_str("extern"); } storage_clause : S_EXTERN { $$ = make_str("extern"); }
...@@ -4928,7 +4995,8 @@ ECPGTypedef: TYPE_P symbol IS ctype opt_type_array_bounds opt_reference ...@@ -4928,7 +4995,8 @@ ECPGTypedef: TYPE_P symbol IS ctype opt_type_array_bounds opt_reference
this->type->type_str = mm_strdup($2); this->type->type_str = mm_strdup($2);
this->type->type_dimension = dimension; /* dimension of array */ this->type->type_dimension = dimension; /* dimension of array */
this->type->type_index = length; /* lenght of string */ this->type->type_index = length; /* lenght of string */
this->struct_member_list = struct_member_list[struct_level]; this->struct_member_list = ($4.type_enum == ECPGt_struct || $4.type_enum == ECPGt_union) ?
struct_member_list[struct_level] : NULL;
if ($4.type_enum != ECPGt_varchar && if ($4.type_enum != ECPGt_varchar &&
$4.type_enum != ECPGt_char && $4.type_enum != ECPGt_char &&
...@@ -5473,7 +5541,7 @@ c_stuff: c_anything { $$ = $1; } ...@@ -5473,7 +5541,7 @@ c_stuff: c_anything { $$ = $1; }
} }
c_list: c_term { $$ = $1; } c_list: c_term { $$ = $1; }
| c_term ',' c_list { $$ = cat_str(3, $1, make_str(","), $3); } | c_list ',' c_term { $$ = cat_str(3, $1, make_str(","), $3); }
c_term: c_stuff { $$ = $1; } c_term: c_stuff { $$ = $1; }
| '{' c_list '}' { $$ = cat_str(3, make_str("{"), $2, make_str("}")); } | '{' c_list '}' { $$ = cat_str(3, make_str("{"), $2, make_str("}")); }
......
...@@ -377,7 +377,7 @@ ECPGfree_type(struct ECPGtype * typ) ...@@ -377,7 +377,7 @@ ECPGfree_type(struct ECPGtype * typ)
case ECPGt_union: case ECPGt_union:
/* Array of structs. */ /* Array of structs. */
ECPGfree_struct_member(typ->u.element->u.members); ECPGfree_struct_member(typ->u.element->u.members);
free(typ->u.members); free(typ->u.element);
break; break;
default: default:
if (!IS_SIMPLE_TYPE(typ->u.element->typ)) if (!IS_SIMPLE_TYPE(typ->u.element->typ))
...@@ -389,7 +389,6 @@ ECPGfree_type(struct ECPGtype * typ) ...@@ -389,7 +389,6 @@ ECPGfree_type(struct ECPGtype * typ)
case ECPGt_struct: case ECPGt_struct:
case ECPGt_union: case ECPGt_union:
ECPGfree_struct_member(typ->u.members); ECPGfree_struct_member(typ->u.members);
free(typ->u.members);
break; break;
default: default:
sprintf(errortext, "illegal variable type %d\n", typ->typ); sprintf(errortext, "illegal variable type %d\n", typ->typ);
......
exec sql include sqlca; exec sql include sqlca;
exec sql whenever sqlerror do PrintAndStop(msg); void Finish(msg)
exec sql whenever sqlwarning do warn();
void PrintAndStop(msg)
{ {
fprintf(stderr, "Error in statement '%s':\n", msg); fprintf(stderr, "Error in statement '%s':\n", msg);
sqlprint(); sqlprint();
/* finish transaction */
exec sql rollback;
/* and remove test table */
exec sql drop table meskes;
exec sql commit;
exec sql disconnect;
exit(-1); exit(-1);
} }
...@@ -14,3 +21,6 @@ void warn(void) ...@@ -14,3 +21,6 @@ void warn(void)
{ {
fprintf(stderr, "Warning: At least one column was truncated\n"); fprintf(stderr, "Warning: At least one column was truncated\n");
} }
exec sql whenever sqlerror do Finish(msg);
exec sql whenever sqlwarning do warn();
...@@ -38,6 +38,12 @@ exec sql end declare section; ...@@ -38,6 +38,12 @@ exec sql end declare section;
exec sql create unique index number2 on perftest2(number); exec sql create unique index number2 on perftest2(number);
exec sql commit;
exec sql set autocommit to on;
exec sql begin transaction;
gettimeofday(&tvs, NULL); gettimeofday(&tvs, NULL);
for (i = 0;i < 1407; i++) for (i = 0;i < 1407; i++)
...@@ -49,14 +55,16 @@ exec sql end declare section; ...@@ -49,14 +55,16 @@ exec sql end declare section;
sprintf(text, "%ld", i); sprintf(text, "%ld", i);
exec sql insert into perftest1(number, ascii) values (:i, :text); exec sql insert into perftest1(number, ascii) values (:i, :text);
exec sql insert into perftest2(number, next_number) values (:i, :i+1); exec sql insert into perftest2(number, next_number) values (:i, :i+1);
}
exec sql commit; exec sql commit;
}
gettimeofday(&tve, NULL); gettimeofday(&tve, NULL);
print_result(tve.tv_sec - tvs.tv_sec, tve.tv_usec - tvs.tv_usec, "insert"); print_result(tve.tv_sec - tvs.tv_sec, tve.tv_usec - tvs.tv_usec, "insert");
exec sql begin transaction;
gettimeofday(&tvs, NULL); gettimeofday(&tvs, NULL);
for (i = 0;i < 1407; i++) for (i = 0;i < 1407; i++)
...@@ -66,14 +74,16 @@ exec sql end declare section; ...@@ -66,14 +74,16 @@ exec sql end declare section;
exec sql end declare section; exec sql end declare section;
exec sql select ascii into :text from perftest1 where number = :i; exec sql select ascii into :text from perftest1 where number = :i;
}
exec sql commit; exec sql commit;
}
gettimeofday(&tve, NULL); gettimeofday(&tve, NULL);
print_result(tve.tv_sec - tvs.tv_sec, tve.tv_usec - tvs.tv_usec, "selection&projection"); print_result(tve.tv_sec - tvs.tv_sec, tve.tv_usec - tvs.tv_usec, "selection&projection");
exec sql begin transaction;
gettimeofday(&tvs, NULL); gettimeofday(&tvs, NULL);
for (i = 0;i < 1407; i++) for (i = 0;i < 1407; i++)
...@@ -83,14 +93,16 @@ exec sql end declare section; ...@@ -83,14 +93,16 @@ exec sql end declare section;
exec sql end declare section; exec sql end declare section;
exec sql select perftest1.ascii into :text from perftest1, perftest2 where perftest1.number = perftest2.number and perftest2.number = :i; exec sql select perftest1.ascii into :text from perftest1, perftest2 where perftest1.number = perftest2.number and perftest2.number = :i;
}
exec sql commit; exec sql commit;
}
gettimeofday(&tve, NULL); gettimeofday(&tve, NULL);
print_result(tve.tv_sec - tvs.tv_sec, tve.tv_usec - tvs.tv_usec, "join"); print_result(tve.tv_sec - tvs.tv_sec, tve.tv_usec - tvs.tv_usec, "join");
exec sql begin transaction;
gettimeofday(&tvs, NULL); gettimeofday(&tvs, NULL);
exec sql update perftest2 set next_number = next_number + 1; exec sql update perftest2 set next_number = next_number + 1;
...@@ -101,6 +113,8 @@ exec sql end declare section; ...@@ -101,6 +113,8 @@ exec sql end declare section;
print_result(tve.tv_sec - tvs.tv_sec, tve.tv_usec - tvs.tv_usec, "update"); print_result(tve.tv_sec - tvs.tv_sec, tve.tv_usec - tvs.tv_usec, "update");
exec sql begin transaction;
gettimeofday(&tvs, NULL); gettimeofday(&tvs, NULL);
exec sql delete from perftest2; exec sql delete from perftest2;
...@@ -111,6 +125,8 @@ exec sql end declare section; ...@@ -111,6 +125,8 @@ exec sql end declare section;
print_result(tve.tv_sec - tvs.tv_sec, tve.tv_usec - tvs.tv_usec, "delete"); print_result(tve.tv_sec - tvs.tv_sec, tve.tv_usec - tvs.tv_usec, "delete");
exec sql set autocommit = off;
exec sql drop index number2; exec sql drop index number2;
exec sql drop table perftest2; exec sql drop table perftest2;
......
exec sql include header_test; exec sql include sqlca;
exec sql whenever sqlerror do PrintAndStop(msg);
exec sql whenever sqlwarning do warn();
void PrintAndStop(msg)
{
fprintf(stderr, "Error in statement '%s':\n", msg);
sqlprint();
exit(-1);
}
void warn(void)
{
fprintf(stderr, "Warning: At least one column was truncated\n");
}
exec sql include sqlca; exec sql include sqlca;
......
...@@ -62,7 +62,7 @@ exec sql end declare section; ...@@ -62,7 +62,7 @@ exec sql end declare section;
while (1) { while (1) {
strcpy(msg, "fetch"); strcpy(msg, "fetch");
exec sql fetch in cur into :personal:ind_personal, :married:ind_married, :children.integer:ind_children.smallint; exec sql fetch from cur into :personal:ind_personal, :married:ind_married, :children.integer:ind_children.smallint;
printf("%8.8s", personal.name.arr); printf("%8.8s", personal.name.arr);
if (ind_personal.ind_birth.born >= 0) if (ind_personal.ind_birth.born >= 0)
printf(", born %d", personal.birth.born); printf(", born %d", personal.birth.born);
...@@ -81,7 +81,7 @@ exec sql end declare section; ...@@ -81,7 +81,7 @@ exec sql end declare section;
strcpy(msg, "close"); strcpy(msg, "close");
exec sql close cur; exec sql close cur;
/* and now the same query with prepare */ /* and now a same query with prepare */
exec sql prepare MM from :query; exec sql prepare MM from :query;
exec sql declare prep cursor for MM; exec sql declare prep cursor for MM;
......
...@@ -54,7 +54,7 @@ exec sql end declare section; ...@@ -54,7 +54,7 @@ exec sql end declare section;
while (1) { while (1) {
strcpy(msg, "fetch"); strcpy(msg, "fetch");
exec sql fetch in cur into :personal:ind_personal, :married:ind_married, :children:ind_children; exec sql fetch cur into :personal:ind_personal, :married:ind_married, :children:ind_children;
printf("%8.8s", personal.name.arr); printf("%8.8s", personal.name.arr);
if (ind_personal.ind_birth.born >= 0) if (ind_personal.ind_birth.born >= 0)
printf(", born %d", personal.birth.born); printf(", born %d", personal.birth.born);
...@@ -73,7 +73,7 @@ exec sql end declare section; ...@@ -73,7 +73,7 @@ exec sql end declare section;
strcpy(msg, "close"); strcpy(msg, "close");
exec sql close cur; exec sql close cur;
/* and now the same query with prepare */ /* and now a query with prepare */
exec sql prepare MM from "select name, born, age, married, children from meskes where name = ?"; exec sql prepare MM from "select name, born, age, married, children from meskes where name = ?";
exec sql declare prep cursor for MM; exec sql declare prep cursor for MM;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment