Commit 7845954e authored by Michael Meskes's avatar Michael Meskes

Committed again to add the missing files/patches.

parent 949af991
...@@ -71,7 +71,7 @@ extern void add_variable(struct arguments **, struct variable *, struct variable ...@@ -71,7 +71,7 @@ extern void add_variable(struct arguments **, struct variable *, struct variable
extern void append_variable(struct arguments **, struct variable *, struct variable *); extern void append_variable(struct arguments **, struct variable *, struct variable *);
extern void dump_variables(struct arguments *, int); extern void dump_variables(struct arguments *, int);
extern struct typedefs *get_typedef(char *); extern struct typedefs *get_typedef(char *);
extern void adjust_array(enum ECPGttype, int *, int *, int, int, bool); extern void adjust_array(enum ECPGttype, int *, int *, int, int, int);
extern void reset_variables(void); extern void reset_variables(void);
extern void check_indicator(struct ECPGtype *); extern void check_indicator(struct ECPGtype *);
extern void remove_variables(int); extern void remove_variables(int);
......
This diff is collapsed.
...@@ -298,7 +298,7 @@ get_typedef(char *name) ...@@ -298,7 +298,7 @@ get_typedef(char *name)
} }
void void
adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dimension, int type_index, bool pointer) adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dimension, int type_index, int pointer_len)
{ {
if (type_index >= 0) if (type_index >= 0)
{ {
...@@ -318,8 +318,19 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim ...@@ -318,8 +318,19 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim
*dimension = type_dimension; *dimension = type_dimension;
} }
if (pointer_len>2)
{ sprintf(errortext, "No multilevel (more than 2) pointer supported %d",pointer_len);
mmerror(ET_FATAL, errortext);
// mmerror(ET_FATAL, "No multilevel (more than 2) pointer supported %d",pointer_len);
}
if (pointer_len>1 && type_enum!=ECPGt_char && type_enum!=ECPGt_unsigned_char)
mmerror(ET_FATAL, "No pointer to pointer supported for this type");
if (pointer_len>1 && (*length >= 0 || *dimension >= 0))
mmerror(ET_FATAL, "No multi-dimensional array support");
if (*length >= 0 && *dimension >= 0 && pointer) if (*length >= 0 && *dimension >= 0 && pointer_len)
mmerror(ET_FATAL, "No multi-dimensional array support"); mmerror(ET_FATAL, "No multi-dimensional array support");
switch (type_enum) switch (type_enum)
...@@ -327,7 +338,7 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim ...@@ -327,7 +338,7 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim
case ECPGt_struct: case ECPGt_struct:
case ECPGt_union: case ECPGt_union:
/* pointer has to get dimension 0 */ /* pointer has to get dimension 0 */
if (pointer) if (pointer_len)
{ {
*length = *dimension; *length = *dimension;
*dimension = 0; *dimension = 0;
...@@ -339,7 +350,7 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim ...@@ -339,7 +350,7 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim
break; break;
case ECPGt_varchar: case ECPGt_varchar:
/* pointer has to get dimension 0 */ /* pointer has to get dimension 0 */
if (pointer) if (pointer_len)
*dimension = 0; *dimension = 0;
/* one index is the string length */ /* one index is the string length */
...@@ -352,8 +363,15 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim ...@@ -352,8 +363,15 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim
break; break;
case ECPGt_char: case ECPGt_char:
case ECPGt_unsigned_char: case ECPGt_unsigned_char:
/* char ** */
if (pointer_len==2)
{
*length = *dimension = 0;
break;
}
/* pointer has to get length 0 */ /* pointer has to get length 0 */
if (pointer) if (pointer_len==1)
*length = 0; *length = 0;
/* one index is the string length */ /* one index is the string length */
...@@ -362,11 +380,10 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim ...@@ -362,11 +380,10 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim
*length = (*dimension < 0) ? 1 : *dimension; *length = (*dimension < 0) ? 1 : *dimension;
*dimension = -1; *dimension = -1;
} }
break; break;
default: default:
/* a pointer has dimension = 0 */ /* a pointer has dimension = 0 */
if (pointer) if (pointer_len)
{ {
*length = *dimension; *length = *dimension;
*dimension = 0; *dimension = 0;
......
#include <stdio.h>
exec sql include sqlca;
#include <stdlib.h>
int main()
{
exec sql begin declare section;
char **cpp=0;
int *ipointer=0;
exec sql end declare section;
int i;
if (getenv("SQLOPT")) ECPGdebug(1,stderr);
exec sql whenever sqlerror do sqlprint();
exec sql connect to template1;
exec sql allocate descriptor mydesc;
exec sql select tablename into descriptor mydesc from pg_tables;
exec sql get descriptor mydesc value 1 :cpp=DATA, :ipointer=INDICATOR;
printf("Result ");
for (i=0;i<sqlca.sqlerrd[2];++i)
{ if (ipointer[i]) printf("NULL, ");
else printf("'%s', ",cpp[i]);
}
ECPGfree_auto_mem();
printf("\n");
exec sql deallocate descriptor mydesc;
exec sql disconnect;
return 0;
}
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