mirror of
https://github.com/postgres/postgres.git
synced 2025-11-22 12:22:45 +03:00
*** empty log message ***
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
# Copyright (c) 1994, Regents of the University of California
|
||||
#
|
||||
# IDENTIFICATION
|
||||
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/Makefile.in,v 1.58 2000/02/16 16:18:05 meskes Exp $
|
||||
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/Makefile.in,v 1.59 2000/02/22 19:57:05 meskes Exp $
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
@@ -23,7 +23,7 @@ ifdef KRBVERS
|
||||
CFLAGS+= $(KRBFLAGS)
|
||||
endif
|
||||
|
||||
OBJS= ecpglib.o typename.o
|
||||
OBJS= ecpglib.o typename.o descriptor.o
|
||||
|
||||
SHLIB_LINK= -L../../libpq -lpq
|
||||
|
||||
|
||||
@@ -10,6 +10,157 @@ ECPGget_desc_header(int lineno, char * desc_name, int *count)
|
||||
return false;
|
||||
|
||||
*count = PQnfields(ECPGresult);
|
||||
ECPGlog("ECPGget-desc_header: found %d sttributes.\n", *count);
|
||||
ECPGlog("ECPGget_desc_header: found %d attributes.\n", *count);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
get_int_item(int lineno, void *var, enum ECPGdtype vartype, int value)
|
||||
{
|
||||
switch (vartype)
|
||||
{
|
||||
case ECPGt_short:
|
||||
*(short *)var = value;
|
||||
break;
|
||||
case ECPGt_int:
|
||||
*(int *)var = value;
|
||||
break;
|
||||
case ECPGt_long:
|
||||
*(long *)var = value;
|
||||
break;
|
||||
case ECPGt_unsigned_short:
|
||||
*(unsigned short *)var = value;
|
||||
break;
|
||||
case ECPGt_unsigned_int:
|
||||
*(unsigned int *)var = value;
|
||||
break;
|
||||
case ECPGt_unsigned_long:
|
||||
*(unsigned long *)var = value;
|
||||
break;
|
||||
case ECPGt_float:
|
||||
*(float *)var = value;
|
||||
break;
|
||||
case ECPGt_double:
|
||||
*(double *)var = value;
|
||||
break;
|
||||
default:
|
||||
ECPGraise(lineno, ECPG_VAR_NOT_NUMERIC, NULL);
|
||||
return (false);
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool
|
||||
ECPGget_desc(int lineno, char *desc_name, int index, ...)
|
||||
{
|
||||
va_list args;
|
||||
PGresult *ECPGresult = ECPGresultByDescriptor(lineno, desc_name);
|
||||
enum ECPGdtype type;
|
||||
bool DataButNoIndicator = false;
|
||||
|
||||
va_start(args, index);
|
||||
if (!ECPGresult)
|
||||
return (false);
|
||||
|
||||
if (PQntuples(ECPGresult) < 1)
|
||||
{
|
||||
ECPGraise(lineno, ECPG_NOT_FOUND, NULL);
|
||||
return (false);
|
||||
}
|
||||
|
||||
if (index < 1 || index >PQnfields(ECPGresult))
|
||||
{
|
||||
ECPGraise(lineno, ECPG_INVALID_DESCRIPTOR_INDEX, NULL);
|
||||
return (false);
|
||||
}
|
||||
|
||||
ECPGlog("ECPGget_desc: reading items for tuple %d\n", index);
|
||||
--index;
|
||||
|
||||
type = va_arg(args, enum ECPGdtype);
|
||||
|
||||
while (type != ECPGd_EODT)
|
||||
{
|
||||
char type_str[20];
|
||||
long varcharsize;
|
||||
long offset;
|
||||
long arrsize;
|
||||
enum ECPGttype vartype;
|
||||
void *var;
|
||||
|
||||
vartype = va_arg(args, enum ECPGttype);
|
||||
var = va_arg(args, void *);
|
||||
varcharsize = va_arg(args, long);
|
||||
arrsize = va_arg(args, long);
|
||||
offset = va_arg(args, long);
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case (ECPGd_indicator):
|
||||
if (!get_int_item(lineno, var, vartype, -PQgetisnull(ECPGresult, 0, index)))
|
||||
return (false);
|
||||
break;
|
||||
|
||||
case ECPGd_name:
|
||||
strncpy((char *)var, PQfname(ECPGresult, index), varcharsize);
|
||||
break;
|
||||
|
||||
case ECPGd_nullable:
|
||||
if (!get_int_item(lineno, var, vartype, 1))
|
||||
return (false);
|
||||
break;
|
||||
|
||||
case ECPGd_key_member:
|
||||
if (!get_int_item(lineno, var, vartype, 0))
|
||||
return (false);
|
||||
break;
|
||||
|
||||
case ECPGd_scale:
|
||||
if (!get_int_item(lineno, var, vartype, (PQfmod(ECPGresult, index) - VARHDRSZ) & 0xffff))
|
||||
return (false);
|
||||
break;
|
||||
|
||||
case ECPGd_precision:
|
||||
if (!get_int_item(lineno, var, vartype, PQfmod(ECPGresult, index) >> 16))
|
||||
return (false);
|
||||
break;
|
||||
|
||||
case ECPGd_ret_length:
|
||||
case ECPGd_ret_octet:
|
||||
if (!get_int_item(lineno, var, vartype, PQgetlength(ECPGresult, 0, index)))
|
||||
return (false);
|
||||
break;
|
||||
|
||||
case ECPGd_octet:
|
||||
if (!get_int_item(lineno, var, vartype, PQfsize(ECPGresult, index)))
|
||||
return (false);
|
||||
break;
|
||||
|
||||
case ECPGd_length:
|
||||
if (!get_int_item(lineno, var, vartype, PQfmod(ECPGresult, index) - VARHDRSZ))
|
||||
return (false);
|
||||
break;
|
||||
|
||||
case ECPGd_type:
|
||||
if (!get_int_item(lineno, var, vartype, ECPGDynamicType(PQftype(ECPGresult, index))))
|
||||
return (false);
|
||||
break;
|
||||
|
||||
default:
|
||||
snprintf(type_str, sizeof(type_str), "%d", type);
|
||||
ECPGraise(lineno, ECPG_UNKNOWN_DESCRIPTOR_ITEM, type_str);
|
||||
return(false);
|
||||
}
|
||||
|
||||
type = va_arg(args, enum ECPGdtype);
|
||||
}
|
||||
|
||||
if (DataButNoIndicator && PQgetisnull(ECPGresult, 0, index))
|
||||
{
|
||||
ECPGraise(lineno, ECPG_MISSING_INDICATOR, NULL);
|
||||
return (false);
|
||||
}
|
||||
|
||||
return (true);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
*
|
||||
* Copyright (c) 2000, Christof Petig <christof.petig@wtal.de>
|
||||
*
|
||||
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/dynamic.c,v 1.4 2000/02/18 16:02:49 meskes Exp $
|
||||
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/dynamic.c,v 1.5 2000/02/22 19:57:05 meskes Exp $
|
||||
*/
|
||||
|
||||
/* I borrowed the include files from ecpglib.c, maybe we don't need all of them */
|
||||
@@ -198,7 +198,7 @@ bool ECPGdo_descriptor(int line,const char *connection,
|
||||
|
||||
/* free previous result */
|
||||
if (i->result) PQclear(i->result);
|
||||
i->result=NULL;
|
||||
i->result=NULL;
|
||||
|
||||
status=do_descriptor2(line,connection,&i->result,query);
|
||||
|
||||
@@ -206,7 +206,8 @@ bool ECPGdo_descriptor(int line,const char *connection,
|
||||
return (status);
|
||||
}
|
||||
}
|
||||
ECPGraise(line, ECPG_UNKNOWN_DESCRIPTOR, NULL);
|
||||
|
||||
ECPGraise(line, ECPG_UNKNOWN_DESCRIPTOR, descriptor);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -219,7 +220,7 @@ PGresult *ECPGresultByDescriptor(int line,const char *name)
|
||||
if (!strcmp(name, i->name)) return i->result;
|
||||
}
|
||||
|
||||
ECPGraise(line, ECPG_UNKNOWN_DESCRIPTOR, NULL);
|
||||
ECPGraise(line, ECPG_UNKNOWN_DESCRIPTOR, name);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -238,7 +239,7 @@ bool ECPGdeallocate_desc(int line,const char *name)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
ECPGraise(line, ECPG_UNKNOWN_DESCRIPTOR, NULL);
|
||||
ECPGraise(line, ECPG_UNKNOWN_DESCRIPTOR, name);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -259,7 +260,7 @@ ECPGraise(int line, int code, const char *str)
|
||||
{
|
||||
struct auto_mem *am;
|
||||
|
||||
sqlca.sqlcode=code;
|
||||
sqlca.sqlcode = code;
|
||||
switch (code)
|
||||
{
|
||||
case ECPG_NOT_FOUND:
|
||||
@@ -294,15 +295,25 @@ ECPGraise(int line, int code, const char *str)
|
||||
|
||||
case ECPG_UNKNOWN_DESCRIPTOR:
|
||||
snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
|
||||
"descriptor not found, line %d.", line);
|
||||
"descriptor %s not found, line %d.", str, line);
|
||||
break;
|
||||
|
||||
case ECPG_INVALID_DESCRIPTOR_INDEX:
|
||||
snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
|
||||
"descriptor index out of range, line %d.", line);
|
||||
break;
|
||||
|
||||
case ECPG_UNKNOWN_DESCRIPTOR_ITEM:
|
||||
snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
|
||||
"unknown descriptor item %s, line %d.", str, line);
|
||||
break;
|
||||
|
||||
case ECPG_VAR_NOT_NUMERIC:
|
||||
snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
|
||||
"variable is not a numeric type, line %d.", line);
|
||||
break;
|
||||
|
||||
default:
|
||||
default:
|
||||
snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
|
||||
"SQL error #%d, line %d.",code, line);
|
||||
break;
|
||||
|
||||
@@ -190,7 +190,7 @@ ecpg_alloc(long size, int lineno)
|
||||
if (!new)
|
||||
{
|
||||
ECPGlog("out of memory\n");
|
||||
ECPGraise(ECPG_OUT_OF_MEMORY, lineno, NULL);
|
||||
ECPGraise(lineno, ECPG_OUT_OF_MEMORY, NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@ ecpg_strdup(const char *string, int lineno)
|
||||
if (!new)
|
||||
{
|
||||
ECPGlog("out of memory\n");
|
||||
ECPGraise(ECPG_OUT_OF_MEMORY, lineno, NULL);
|
||||
ECPGraise(lineno, ECPG_OUT_OF_MEMORY, NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -634,7 +634,7 @@ ECPGexecute(struct statement * stmt)
|
||||
|
||||
default:
|
||||
/* Not implemented yet */
|
||||
ECPGraise(ECPG_UNSUPPORTED, stmt->lineno, ECPGtype_name(var->type));
|
||||
ECPGraise(stmt->lineno, ECPG_UNSUPPORTED, ECPGtype_name(var->type));
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
@@ -657,7 +657,7 @@ ECPGexecute(struct statement * stmt)
|
||||
* We have an argument but we dont have the matched up string
|
||||
* in the string
|
||||
*/
|
||||
ECPGraise(ECPG_TOO_MANY_ARGUMENTS, stmt->lineno, NULL);
|
||||
ECPGraise(stmt->lineno, ECPG_TOO_MANY_ARGUMENTS, NULL);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
@@ -694,7 +694,7 @@ ECPGexecute(struct statement * stmt)
|
||||
/* Check if there are unmatched things left. */
|
||||
if (next_insert(copiedquery) != NULL)
|
||||
{
|
||||
ECPGraise(ECPG_TOO_FEW_ARGUMENTS, stmt->lineno, NULL);
|
||||
ECPGraise(stmt->lineno, ECPG_TOO_FEW_ARGUMENTS, NULL);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -742,7 +742,7 @@ ECPGexecute(struct statement * stmt)
|
||||
{
|
||||
ECPGlog("ECPGexecute line %d: Incorrect number of matches: %d\n",
|
||||
stmt->lineno, ntuples);
|
||||
ECPGraise(ECPG_NOT_FOUND, stmt->lineno, NULL);
|
||||
ECPGraise(stmt->lineno, ECPG_NOT_FOUND, NULL);
|
||||
status = false;
|
||||
break;
|
||||
}
|
||||
@@ -756,7 +756,7 @@ ECPGexecute(struct statement * stmt)
|
||||
if (var == NULL)
|
||||
{
|
||||
ECPGlog("ECPGexecute line %d: Too few arguments.\n", stmt->lineno);
|
||||
ECPGraise(ECPG_TOO_FEW_ARGUMENTS, stmt->lineno, NULL);
|
||||
ECPGraise(stmt->lineno, ECPG_TOO_FEW_ARGUMENTS, NULL);
|
||||
return (false);
|
||||
}
|
||||
|
||||
@@ -778,7 +778,7 @@ ECPGexecute(struct statement * stmt)
|
||||
{
|
||||
ECPGlog("ECPGexecute line %d: Incorrect number of matches: %d don't fit into array of %d\n",
|
||||
stmt->lineno, ntuples, var->arrsize);
|
||||
ECPGraise(ECPG_TOO_MANY_MATCHES, stmt->lineno, NULL);
|
||||
ECPGraise(stmt->lineno, ECPG_TOO_MANY_MATCHES, NULL);
|
||||
status = false;
|
||||
break;
|
||||
}
|
||||
@@ -853,7 +853,7 @@ ECPGexecute(struct statement * stmt)
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ECPGraise(ECPG_UNSUPPORTED, stmt->lineno, ECPGtype_name(var->ind_type));
|
||||
ECPGraise(stmt->lineno, ECPG_UNSUPPORTED, ECPGtype_name(var->ind_type));
|
||||
status = false;
|
||||
break;
|
||||
}
|
||||
@@ -1057,7 +1057,7 @@ ECPGexecute(struct statement * stmt)
|
||||
break;
|
||||
|
||||
default:
|
||||
ECPGraise(ECPG_UNSUPPORTED, stmt->lineno, ECPGtype_name(var->type));
|
||||
ECPGraise(stmt->lineno, ECPG_UNSUPPORTED, ECPGtype_name(var->type));
|
||||
status = false;
|
||||
break;
|
||||
}
|
||||
@@ -1067,7 +1067,7 @@ ECPGexecute(struct statement * stmt)
|
||||
|
||||
if (status && var != NULL)
|
||||
{
|
||||
ECPGraise(ECPG_TOO_MANY_ARGUMENTS, stmt->lineno, NULL);
|
||||
ECPGraise(stmt->lineno, ECPG_TOO_MANY_ARGUMENTS, NULL);
|
||||
status = false;
|
||||
}
|
||||
|
||||
@@ -1123,7 +1123,7 @@ ECPGexecute(struct statement * stmt)
|
||||
}
|
||||
|
||||
bool
|
||||
ECPGdo(int lineno, const char *connection_name, char *query,...)
|
||||
ECPGdo(int lineno, const char *connection_name, char *query, ...)
|
||||
{
|
||||
va_list args;
|
||||
struct statement *stmt;
|
||||
|
||||
Reference in New Issue
Block a user