Re: PGparam proposal - Mailing list pgsql-hackers

From Andrew Chernow
Subject Re: PGparam proposal
Date
Msg-id 475EDDB4.4070301@esilo.com
Whole thread Raw
In response to Re: PGparam proposal  (Andrew Chernow <ac@esilo.com>)
Responses PGparam proposal v2  (Andrew Chernow <ac@esilo.com>)
List pgsql-hackers
> your proposal completely glossed over the> issue of exactly what data structure would be exposed to clients for>
anythingmore complex than an integer
 

Yeah.  Forgot to include the below in the proposal and the last email. 
Here is the lastest list for complex types.  Most have been around since 
the last 0.5 patch.  Still need numeric, date, time and a couple others.

typedef struct
{  double x;  double y;
} PGpoint;

typedef struct
{  PGpoint pts[2];
} PGlseg;

typedef struct
{  PGpoint high;  PGpoint low;
} PGbox;

typedef struct
{  PGpoint center;  double radius;
} PGcircle;

/* When used with PQgetf, 'pts' must be freed with PQfreemem(). */
typedef struct
{  int npts;  int closed;  PGpoint *pts;
} PGpath;

/* When used with PQgetf, 'pts' must be freed with PQfreemem(). */
typedef struct
{  int npts;  PGpoint *pts;
} PGpolygon;

/* This struct works with CIDR as well. */
typedef struct
{  /* here for convenience, value the same as first 2 bytes of sa_buf */  unsigned short sa_family;
  /* mask, ie. /24 */  int mask;  int is_cidr;
  /* Cast to: sockaddr, sockaddr_in, sockaddr_in6, sockaddr_stroage */  int sa_len;  char sa_buf[128];
} PGinet;

typedef struct
{  int a;  int b;  int c;  int d;  int e;  int f;
} PGmacaddr;

/* main problem with this type is that it can be a double * or int64 and that is a compile-time decision.  This means *
theclient has a 50% chance of getting it wrong.  It would * be nice if the server included an indicater or converted *
theexternal format to one or the other.  OR, make client * aware of server's timestamp encoding when it connects. */
 
typedef struct
{  /* When non-zero, this is a TIMESTAMP WITH TIME ZONE.  When zero,   * this is a TIMESTAMP WITHOUT TIME ZONE.  When
WITHOUT,gmtoff   * will always be 0 and tzn will be "GMT".   */  int withtz;
 
  /* binary timestamp from server (in host order).  If haveint64 is   * non-zero, use the 'ts.asint64' value otherwise
use'ts.asdouble'.   */  int haveint64;  union  {    struct {      unsigned int a;      signed int b;    } asint64;
 
    double asdouble;  } ts;
  /* microseconds */  int usec;  /* GMT offset, some systems don't have this in struct tm */  int gmtoff;  /* time zone
name,some systems don't have this in struct tm */  char *tzn;  /* broken-down time */  struct tm tm;
 
} PGtimestamp;


/* still working on this, may need access macros */

typedef struct
{  int dim;  int lbound;
} PGarraydim;

typedef struct
{  int len;
  /* already in PGtype format.  For instance:   *   (PGpolygon *)arr->items[i].data   * or   *   printf("text=%s\n",
arr->items[i].data);  *   * Could have a union of all types here but that   * doesn't help much for 3rd party types.
*/ char *data;
 
} PGarrayitem;

typedef struct
{  Oid oid; /* type of items[].data */  int ndim;  PGarraydim dims[MAXDIM];  int nitems;  PGarrayitem *items;
} PGarray;

andrew & merlin


pgsql-hackers by date:

Previous
From: Josh Berkus
Date:
Subject: Re: VLDB Features
Next
From: Andrew Sullivan
Date:
Subject: Re: WORM and Read Only Tables (v0.1)