- Made sure pointers are correctly inserted by libecpg. My thanks go
to Jan Urbanek for findin many bugs before the
release.
+
+Wed Apr 5 07:54:56 CEST 2000
+
+ - Added patch by Peter Eisentraut to fix some
+ duplicate definittions in preproc.y.
+ - Removed duplicate ',' in execute.c.
+ - Changed error message for backend errors so it fits into sqlca.
+ - Fixed array handling.
- Set library version to 3.1.0.
- Set ecpg version to 2.7.0.
const char *descriptor,const char *query);
bool ECPGdeallocate_desc(int line,const char *name);
bool ECPGallocate_desc(int line,const char *name);
- void ECPGraise(int line, int code, const char *str);
+ void ECPGraise(int line, int code, char *str);
bool ECPGget_desc_header(int, char *, int *);
bool ECPGget_desc(int, char *, int, ...);
#include
void
-ECPGraise(int line, int code, const char *str)
+ECPGraise(int line, int code, char *str)
{
sqlca.sqlcode = code;
+
switch (code)
{
case ECPG_NOT_FOUND:
"Variable is not a character type in line %d.", line);
break;
- case ECPG_PGSQL:
+ case ECPG_PGSQL:
+ /* strip trailing newline */
+ if (str[strlen(str)-1] == '\n')
+ str[strlen(str)-1] = '\0';
+
snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
- "Postgres error '%s' in line %d.", str, line);
+ "'%s' in line %d.", str, line);
break;
case ECPG_TRANS:
default:
snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
- "SQL error #%d in line %d.",code, line);
+ "SQL error #%d in line %d.", code, line);
break;
}
sqlca.sqlerrm.sqlerrml = strlen(sqlca.sqlerrm.sqlerrmc);
-
+
/* free all memory we have allocated for the user */
free_auto_mem();
}
strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'"));
}
else
- sprintf(mallocedval, "%c,", (*((char *) var->value)) ? 't' : 'f');
+ sprintf(mallocedval, "%c", (*((char *) var->value)) ? 't' : 'f');
tobeinserted = mallocedval;
break;
default:
/* Not implemented yet */
- ECPGraise(stmt->lineno, ECPG_UNSUPPORTED, ECPGtype_name(var->type));
+ ECPGraise(stmt->lineno, ECPG_UNSUPPORTED, (char *)ECPGtype_name(var->type));
return false;
break;
}
*
* Copyright (c) 2000, Christof Petig
*
- * $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/execute.c,v 1.3 2000/04/03 19:34:25 meskes Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/execute.c,v 1.4 2000/04/05 09:05:28 meskes Exp $
*/
PGconn *ECPG_internal_get_connection(char *name);
}
}
- ECPGraise(line, ECPG_UNKNOWN_DESCRIPTOR, descriptor);
+ ECPGraise(line, ECPG_UNKNOWN_DESCRIPTOR, (char *) descriptor);
return false;
}
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.57 2000/03/30 11:41:40 meskes Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.58 2000/04/05 09:05:34 meskes Exp $
*
*-------------------------------------------------------------------------
*/
braces_open = 0;
preproc_tos = 0;
+ yylineno = 0;
ifcond = TRUE;
stacked_if_value[preproc_tos].condition = ifcond;
stacked_if_value[preproc_tos].else_branch = FALSE;
%type TriggerActionTime CreateTrigStmt DropPLangStmt PLangTrusted
%type CreatePLangStmt IntegerOnly TriggerFuncArgs TriggerFuncArg
%type ViewStmt LoadStmt CreatedbStmt createdb_opt_encoding
-%type createdb_opt_location opt_encoding AlterTableStmt
+%type createdb_opt_location opt_encoding
%type DropdbStmt ClusterStmt grantee RevokeStmt table_expr Bit bit
%type GrantStmt privileges operation_commalist operation
%type opt_cursor opt_lmode ConstraintsSetStmt comment_tg
%type select_clause opt_select_limit select_limit_value ConstraintTimeSpec
%type select_offset_value using_expr join_expr ReindexStmt
%type using_list from_expr join_clause join_type
-%type join_qual update_list join_clause join_clause_with_union
+%type join_qual update_list join_clause_with_union
%type opt_level opt_lock lock_type users_in_new_group_clause
%type OptConstrFromTable comment_op OptTempTableName
%type constraints_set_list constraints_set_namelist comment_fn
%type enum_type civariableonly ECPGCursorStmt ECPGDeallocate
%type ECPGFree ECPGDeclare ECPGVar opt_at enum_definition
%type struct_type s_struct declaration declarations variable_declarations
-%type s_struct s_union union_type ECPGSetAutocommit on_off
+%type s_union union_type ECPGSetAutocommit on_off
%type ECPGAllocateDescr ECPGDeallocateDescr symbol opt_symbol
%type ECPGGetDescriptorHeader ECPGColId ECPGColLabel ECPGTypeName
%type ECPGLabelTypeName
$$ = cat_str(4, $1, mm_strdup($2), $3.str, $4);
break;
case ECPGt_varchar:
- if (dimension == -1)
+ if (dimension < 0)
type = ECPGmake_simple_type(actual_type[struct_level].type_enum, length);
else
type = ECPGmake_array_type(ECPGmake_simple_type(actual_type[struct_level].type_enum, length), dimension);
void
ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * typ, const char *ind_name, struct ECPGtype * ind_typ, const char *prefix, const char *ind_prefix)
{
-#if 0
- if (ind_typ == NULL)
- {
- ind_typ = &ecpg_no_indicator;
- ind_name = "no_indicator";
- }
-#endif
switch (typ->typ)
{
case ECPGt_array:
char *variable = (char *) mm_alloc(strlen(name) + ((prefix == NULL) ? 0 : strlen(prefix)) + 4);
char *offset = (char *) mm_alloc(strlen(name) + strlen("sizeof(struct varchar_)") + 1);
- /* we have to use the pointer except for arrays with given bounds */
- if (arrsize > 0)
- sprintf(variable, "(%s%s)", prefix ? prefix : "", name);
- else
- sprintf(variable, "&(%s%s)", prefix ? prefix : "", name);
-
switch (typ)
{
case ECPGt_varchar:
+ /* we have to use the pointer except for arrays with given bounds */
+ if (arrsize > 0)
+ sprintf(variable, "(%s%s)", prefix ? prefix : "", name);
+ else
+ sprintf(variable, "&(%s%s)", prefix ? prefix : "", name);
+
sprintf(offset, "sizeof(struct varchar_%s)", name);
break;
case ECPGt_char:
case ECPGt_unsigned_char:
case ECPGt_char_variable:
+ /* we have to use the pointer except for arrays with given bounds */
+ if (varcharsize > 1 || arrsize > 0)
+ sprintf(variable, "(%s%s)", prefix ? prefix : "", name);
+ else
+ sprintf(variable, "&(%s%s)", prefix ? prefix : "", name);
+
sprintf(offset, "%ld*sizeof(char)", varcharsize == 0 ? 1 : varcharsize);
break;
default:
+ /* we have to use the pointer except for arrays with given bounds */
+ if (arrsize > 0)
+ sprintf(variable, "(%s%s)", prefix ? prefix : "", name);
+ else
+ sprintf(variable, "&(%s%s)", prefix ? prefix : "", name);
+
sprintf(offset, "sizeof(%s)", ECPGtype_name(typ));
break;
}
all: test1 test2 test3 test4 perftest dyntest dyntest2
-#LDFLAGS=-g -I /usr/local/pgsql/include -L/usr/local/pgsql/lib -lecpg -lpq -lcrypt
-LDFLAGS=-g -I../include -I/usr/include/postgresql -L../lib -L/usr/lib/postgresql -lecpg -lpq -lcrypt
+LDFLAGS=-g -I /usr/local/pgsql/include -L/usr/local/pgsql/lib -lecpg -lpq -lcrypt
+#LDFLAGS=-g -I../include -I/usr/include/postgresql -L../lib -L/usr/lib/postgresql -lecpg -lpq -lcrypt
#LDFLAGS=-g -I/usr/include/postgresql -lecpg -lpq -lcrypt
#ECPG=/usr/local/pgsql/bin/ecpg
int i = 3;
int *did = &i;
int a[10] = {9,8,7,6,5,4,3,2,1,0};
+ char text[10] = "klmnopqrst";
+ char *t = "uvwxyz1234";
double f;
EXEC SQL END DECLARE SECTION;
FILE *dbgs;
EXEC SQL BEGIN WORK;
-/* EXEC SQL CREATE TABLE test (f decimal(8,2), i int, a int[10]);*/
- EXEC SQL CREATE TABLE test (f float, i int, a int[10]);
+ EXEC SQL CREATE TABLE test (f float, i int, a int[10], text char(10));
- EXEC SQL INSERT INTO test(f,i,a) VALUES(404.90,1,'{0,1,2,3,4,5,6,7,8,9}');
+ EXEC SQL INSERT INTO test(f,i,a,text) VALUES(404.90,1,'{0,1,2,3,4,5,6,7,8,9}','abcdefghij');
- EXEC SQL INSERT INTO test(f,i,a) VALUES(140787.0,2,:a);
+ EXEC SQL INSERT INTO test(f,i,a,text) VALUES(140787.0,2,:a,:text);
- EXEC SQL INSERT INTO test(f,i,a) VALUES(14.07,:did,:a);
+ EXEC SQL INSERT INTO test(f,i,a,text) VALUES(14.07,:did,:a,:t);
EXEC SQL COMMIT;
EXEC SQL BEGIN WORK;
- EXEC SQL SELECT f
- INTO :f
+ EXEC SQL SELECT f,text
+ INTO :f,:text
FROM test
- WHERE i = :i;
+ WHERE i = 1;
- printf("Found f=%f\n", f);
+ printf("Found f=%f text=%10.10s\n", f, text);
- EXEC SQL SELECT a
- INTO :a
+ f=14.07;
+ EXEC SQL SELECT a,text
+ INTO :a,:t
FROM test
WHERE f = :f;
for (i = 0; i < 10; i++)
printf("Found a[%d] = %d\n", i, a[i]);
+ printf("Found text=%10.10s\n", t);
+
EXEC SQL DROP TABLE test;
EXEC SQL COMMIT;