tuples

Поиск
Список
Период
Сортировка
От Collin F. Lynch
Тема tuples
Дата
Msg-id 199906151916.PAA26364@water2.cs.umass.edu
обсуждение исходный текст
Список pgsql-hackers
    I'm attempting to create a custom image object for my database.  At this point the
object contains only two variable length text fields and two size specifiers.  Attatched below
is my code for the object and the image_in function.  Whenever I attempt to insert something
using the image_in function I get one of two errors.

    test2=> insert into images2 values ('ad, fg, 32, 64');
NOTICE:  a
NOTICE:  ad, fg, 32, 64
NOTICE:  ad
NOTICE:  fg
NOTICE:  32
NOTICE:  64
NOTICE:  f
NOTICE:  g
NOTICE:  r
NOTICE:  c
NOTICE:  d
NOTICE:  ad
NOTICE:  fg
ERROR:  Tuple is too big: size 52240

or

test2=> insert into images2 values ('ad, fg, 32, 64');
NOTICE:  a
NOTICE:  ad, fg, 32, 64
NOTICE:  ad
NOTICE:  fg
NOTICE:  32
NOTICE:  64
NOTICE:  f
PQexec() -- Request was sent to backend, but backend closed the channel before responding.
        This probably means the backend terminated abnormally before or while processing the
request.

        I am at a loss to explain either of these errors can anyone give me a hand?


    /*////////////////////////////////////////////////////////////////
// ImageObject.c
//  Image Object and input/output definitions for the image type
// in the PostgresSQl database.  Defined for use by the Computer
// Vision Laboratory at Umass Amherst.
//
// Collin Lynch
// 6/13/1999
////////////////////////////////////////////////////////////////*/

/* Includes*/
#include <stdio.h>
#include <string.h>
#include "postgres.h"
#include "libpq-fe.h"
#include "utils/elog.h"
#include "utils/palloc.h"


/*Struct definition.*/
typedef struct variable_text {

  int4 length;
  char data[1];
} variable_text;

typedef struct image {

  int4 size;    /* The memory size of the image object.*/
  variable_text* name;   /* The Image Name.*/
  variable_text* type;   /* The Image Encoding Type.*/
  int4 width;   /* Thw width of the image.*/
  int4 height;  /* The height of the image.*/
} image;


/*Definition of the input function.*/
image* image_in(char* imagestring) {

  image* result;
  char* name;
  char* encoding;
  int height, width, size;
  char* temp;

  name = (char *) palloc(sizeof(char) * 40);
  encoding = (char *)palloc(sizeof(char) * 30);
  temp = (char *)palloc(sizeof(char) * 2);

  elog(0, "a");

  elog(0, imagestring);

  if(sscanf(imagestring, "%[^,]%*[, ]%[^,]%*[, ]%i%*[, ]%i)", name, encoding, &width, &height) != 4) {

    elog(0, temp);
    elog(1, "image_in: Parse Error.");
    return NULL;
  }

  elog(0, name);
  elog(0, encoding);
  itoa(width, temp);
  elog(0, temp);
  itoa(height, temp);
  elog(0, temp);

  result = (image *)palloc(sizeof(image));

  elog(0, "f");

  result->name = (variable_text *)palloc(VARHDRSZ + VARSIZE(name));
  memmove(result->name->data, name, VARSIZE(name));
  result->name->length = VARHDRSZ + VARSIZE(name);

  elog(0, "g");

  result->type = (variable_text *)palloc(VARHDRSZ + VARSIZE(name));
  memmove(result->type->data, encoding, VARSIZE(encoding));
  result->type->length = VARHDRSZ + VARSIZE(encoding);

  elog(0, "r");

  result->width = width;
  result->height = height;

  elog(0, "c");

  /*Set the size of the image object.*/
  result->size = (VARHDRSZ * 3) + (sizeof(int4) * 2) + VARSIZE(result->name) + VARSIZE(result->type);

  elog(0, "d");

  elog(0, result->name->data);
  elog(0, result->type->data);

  pfree(name);
  pfree(encoding);


  return(result);
}



/*Definition of the output function.*/
char* image_out(image* object) {

  char* result;
  if (object == NULL) {
    return NULL;
  }
  result = (char *)palloc(sizeof(char) * 60);
  sprintf(result, "(%c.%c %f, %f)", object->name, object->type, object->width, object->height);
  return(result);
}

В списке pgsql-hackers по дате отправления:

Предыдущее
От: The Hermit Hacker
Дата:
Сообщение: Linux Weekly News ...
Следующее
От: "Cyril VELTER"
Дата:
Сообщение: BeOS port