mirror of
https://github.com/postgres/postgres.git
synced 2025-06-02 00:01:40 -04:00
*** empty log message ***
This commit is contained in:
parent
ab0c8c691e
commit
bc8a39beef
@ -59,7 +59,7 @@ extern "C"
|
|||||||
const char *descriptor,const char *query);
|
const char *descriptor,const char *query);
|
||||||
bool ECPGdeallocate_desc(int line,const char *name);
|
bool ECPGdeallocate_desc(int line,const char *name);
|
||||||
bool ECPGallocate_desc(int line,const char *name);
|
bool ECPGallocate_desc(int line,const char *name);
|
||||||
void ECPGraise(int line,int code);
|
void ECPGraise(int line, int code, const char *str);
|
||||||
bool ECPGget_desc_header(int, char *, int *);
|
bool ECPGget_desc_header(int, char *, int *);
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 2000, Christof Petig <christof.petig@wtal.de>
|
* Copyright (c) 2000, Christof Petig <christof.petig@wtal.de>
|
||||||
*
|
*
|
||||||
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/dynamic.c,v 1.3 2000/02/18 14:34:05 meskes Exp $
|
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/dynamic.c,v 1.4 2000/02/18 16:02:49 meskes Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* I borrowed the include files from ecpglib.c, maybe we don't need all of them */
|
/* I borrowed the include files from ecpglib.c, maybe we don't need all of them */
|
||||||
@ -10,7 +10,8 @@
|
|||||||
#include <sql3types.h>
|
#include <sql3types.h>
|
||||||
|
|
||||||
static struct descriptor
|
static struct descriptor
|
||||||
{ char *name;
|
{
|
||||||
|
char *name;
|
||||||
PGresult *result;
|
PGresult *result;
|
||||||
struct descriptor *next;
|
struct descriptor *next;
|
||||||
} *all_descriptors=NULL;
|
} *all_descriptors=NULL;
|
||||||
@ -18,7 +19,8 @@ static struct descriptor
|
|||||||
PGconn *ECPG_internal_get_connection(char *name);
|
PGconn *ECPG_internal_get_connection(char *name);
|
||||||
|
|
||||||
unsigned int ECPGDynamicType(Oid type)
|
unsigned int ECPGDynamicType(Oid type)
|
||||||
{ switch(type)
|
{
|
||||||
|
switch(type)
|
||||||
{ case 16: return SQL3_BOOLEAN; /* bool */
|
{ case 16: return SQL3_BOOLEAN; /* bool */
|
||||||
case 21: return SQL3_SMALLINT; /* int2 */
|
case 21: return SQL3_SMALLINT; /* int2 */
|
||||||
case 23: return SQL3_INTEGER; /* int4 */
|
case 23: return SQL3_INTEGER; /* int4 */
|
||||||
@ -204,7 +206,7 @@ bool ECPGdo_descriptor(int line,const char *connection,
|
|||||||
return (status);
|
return (status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ECPGraise(line,ECPG_UNKNOWN_DESCRIPTOR);
|
ECPGraise(line, ECPG_UNKNOWN_DESCRIPTOR, NULL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -217,7 +219,7 @@ PGresult *ECPGresultByDescriptor(int line,const char *name)
|
|||||||
if (!strcmp(name, i->name)) return i->result;
|
if (!strcmp(name, i->name)) return i->result;
|
||||||
}
|
}
|
||||||
|
|
||||||
ECPGraise(line,ECPG_UNKNOWN_DESCRIPTOR);
|
ECPGraise(line, ECPG_UNKNOWN_DESCRIPTOR, NULL);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -236,7 +238,7 @@ bool ECPGdeallocate_desc(int line,const char *name)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ECPGraise(line,ECPG_UNKNOWN_DESCRIPTOR);
|
ECPGraise(line, ECPG_UNKNOWN_DESCRIPTOR, NULL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,8 +254,11 @@ bool ECPGallocate_desc(int line,const char *name)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ECPGraise(int line, int code)
|
void
|
||||||
|
ECPGraise(int line, int code, const char *str)
|
||||||
{
|
{
|
||||||
|
struct auto_mem *am;
|
||||||
|
|
||||||
sqlca.sqlcode=code;
|
sqlca.sqlcode=code;
|
||||||
switch (code)
|
switch (code)
|
||||||
{
|
{
|
||||||
@ -261,21 +266,57 @@ void ECPGraise(int line, int code)
|
|||||||
snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
|
snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
|
||||||
"No data found line %d.", line);
|
"No data found line %d.", line);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case ECPG_OUT_OF_MEMORY:
|
||||||
|
snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
|
||||||
|
"Out of memory in line %d.", line);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ECPG_UNSUPPORTED:
|
||||||
|
snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
|
||||||
|
"Unsupported type %s in line %d.", str, line);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ECPG_TOO_MANY_ARGUMENTS:
|
||||||
|
snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
|
||||||
|
"Too many arguments in line %d.", line);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ECPG_TOO_FEW_ARGUMENTS:
|
||||||
|
snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
|
||||||
|
"Too few arguments in line %d.", line);
|
||||||
|
break;
|
||||||
|
|
||||||
case ECPG_MISSING_INDICATOR:
|
case ECPG_MISSING_INDICATOR:
|
||||||
snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
|
snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
|
||||||
"NULL value without indicator, line %d.", line);
|
"NULL value without indicator, line %d.", line);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ECPG_UNKNOWN_DESCRIPTOR:
|
case ECPG_UNKNOWN_DESCRIPTOR:
|
||||||
snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
|
snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
|
||||||
"descriptor not found, line %d.", line);
|
"descriptor not found, line %d.", line);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ECPG_INVALID_DESCRIPTOR_INDEX:
|
case ECPG_INVALID_DESCRIPTOR_INDEX:
|
||||||
snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
|
snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
|
||||||
"descriptor index out of range, line %d.", line);
|
"descriptor index out of range, line %d.", line);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
|
snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
|
||||||
"SQL error #%d, line %d.",code, line);
|
"SQL error #%d, line %d.",code, line);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* free all memory we have allocated for the user */
|
||||||
|
for (am = auto_allocs; am;)
|
||||||
|
{
|
||||||
|
struct auto_mem *act = am;
|
||||||
|
|
||||||
|
am = am->next;
|
||||||
|
free(act->pointer);
|
||||||
|
free(act);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto_allocs = NULL;
|
||||||
}
|
}
|
||||||
|
@ -190,7 +190,7 @@ ecpg_alloc(long size, int lineno)
|
|||||||
if (!new)
|
if (!new)
|
||||||
{
|
{
|
||||||
ECPGlog("out of memory\n");
|
ECPGlog("out of memory\n");
|
||||||
register_error(ECPG_OUT_OF_MEMORY, "Out of memory in line %d", lineno);
|
ECPGraise(ECPG_OUT_OF_MEMORY, lineno, NULL);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,7 +206,7 @@ ecpg_strdup(const char *string, int lineno)
|
|||||||
if (!new)
|
if (!new)
|
||||||
{
|
{
|
||||||
ECPGlog("out of memory\n");
|
ECPGlog("out of memory\n");
|
||||||
register_error(ECPG_OUT_OF_MEMORY, "Out of memory in line %d", lineno);
|
ECPGraise(ECPG_OUT_OF_MEMORY, lineno, NULL);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -634,8 +634,7 @@ ECPGexecute(struct statement * stmt)
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
/* Not implemented yet */
|
/* Not implemented yet */
|
||||||
register_error(ECPG_UNSUPPORTED, "Unsupported type %s on line %d.",
|
ECPGraise(ECPG_UNSUPPORTED, stmt->lineno, ECPGtype_name(var->type));
|
||||||
ECPGtype_name(var->type), stmt->lineno);
|
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -658,7 +657,7 @@ ECPGexecute(struct statement * stmt)
|
|||||||
* We have an argument but we dont have the matched up string
|
* We have an argument but we dont have the matched up string
|
||||||
* in the string
|
* in the string
|
||||||
*/
|
*/
|
||||||
register_error(ECPG_TOO_MANY_ARGUMENTS, "Too many arguments line %d.", stmt->lineno);
|
ECPGraise(ECPG_TOO_MANY_ARGUMENTS, stmt->lineno, NULL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -695,7 +694,7 @@ ECPGexecute(struct statement * stmt)
|
|||||||
/* Check if there are unmatched things left. */
|
/* Check if there are unmatched things left. */
|
||||||
if (next_insert(copiedquery) != NULL)
|
if (next_insert(copiedquery) != NULL)
|
||||||
{
|
{
|
||||||
register_error(ECPG_TOO_FEW_ARGUMENTS, "Too few arguments line %d.", stmt->lineno);
|
ECPGraise(ECPG_TOO_FEW_ARGUMENTS, stmt->lineno, NULL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -743,7 +742,7 @@ ECPGexecute(struct statement * stmt)
|
|||||||
{
|
{
|
||||||
ECPGlog("ECPGexecute line %d: Incorrect number of matches: %d\n",
|
ECPGlog("ECPGexecute line %d: Incorrect number of matches: %d\n",
|
||||||
stmt->lineno, ntuples);
|
stmt->lineno, ntuples);
|
||||||
register_error(ECPG_NOT_FOUND, "No data found line %d.", stmt->lineno);
|
ECPGraise(ECPG_NOT_FOUND, stmt->lineno, NULL);
|
||||||
status = false;
|
status = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -757,7 +756,7 @@ ECPGexecute(struct statement * stmt)
|
|||||||
if (var == NULL)
|
if (var == NULL)
|
||||||
{
|
{
|
||||||
ECPGlog("ECPGexecute line %d: Too few arguments.\n", stmt->lineno);
|
ECPGlog("ECPGexecute line %d: Too few arguments.\n", stmt->lineno);
|
||||||
register_error(ECPG_TOO_FEW_ARGUMENTS, "Too few arguments line %d.", stmt->lineno);
|
ECPGraise(ECPG_TOO_FEW_ARGUMENTS, stmt->lineno, NULL);
|
||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -779,7 +778,7 @@ ECPGexecute(struct statement * stmt)
|
|||||||
{
|
{
|
||||||
ECPGlog("ECPGexecute line %d: Incorrect number of matches: %d don't fit into array of %d\n",
|
ECPGlog("ECPGexecute line %d: Incorrect number of matches: %d don't fit into array of %d\n",
|
||||||
stmt->lineno, ntuples, var->arrsize);
|
stmt->lineno, ntuples, var->arrsize);
|
||||||
register_error(ECPG_TOO_MANY_MATCHES, "Too many matches line %d.", stmt->lineno);
|
ECPGraise(ECPG_TOO_MANY_MATCHES, stmt->lineno, NULL);
|
||||||
status = false;
|
status = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -854,7 +853,7 @@ ECPGexecute(struct statement * stmt)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
register_error(ECPG_UNSUPPORTED, "Unsupported indicator type %s on line %d.", ECPGtype_name(var->ind_type), stmt->lineno);
|
ECPGraise(ECPG_UNSUPPORTED, stmt->lineno, ECPGtype_name(var->ind_type));
|
||||||
status = false;
|
status = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1058,7 +1057,7 @@ ECPGexecute(struct statement * stmt)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
register_error(ECPG_UNSUPPORTED, "Unsupported type %s on line %d.", ECPGtype_name(var->type), stmt->lineno);
|
ECPGraise(ECPG_UNSUPPORTED, stmt->lineno, ECPGtype_name(var->type));
|
||||||
status = false;
|
status = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1068,7 +1067,7 @@ ECPGexecute(struct statement * stmt)
|
|||||||
|
|
||||||
if (status && var != NULL)
|
if (status && var != NULL)
|
||||||
{
|
{
|
||||||
register_error(ECPG_TOO_MANY_ARGUMENTS, "Too many arguments line %d.", stmt->lineno);
|
ECPGraise(ECPG_TOO_MANY_ARGUMENTS, stmt->lineno, NULL);
|
||||||
status = false;
|
status = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user