PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ getMaxFieldSize()

static int getMaxFieldSize ( PGconn *  conn,
char *  schema,
char *  table,
char *  fname 
)
static

Definition at line 551 of file pgsql2shp-core.c.

552 {
553  int size;
554  stringbuffer_t query;
555  PGresult *res;
556 
557  /*( this is ugly: don't forget counting the length */
558  /* when changing the fixed query strings ) */
559 
560  stringbuffer_init(&query);
561  if ( schema )
562  {
564  &query,
565  "select max(octet_length(\"%s\"::text)) from \"%s\".\"%s\"",
566  fname, schema, table);
567  }
568  else
569  {
571  &query,
572  "select max(octet_length(\"%s\"::text)) from \"%s\"",
573  fname, table);
574  }
575 
576  LWDEBUGF(4, "maxFieldLenQuery: %s\n", stringbuffer_getstring(&query));
577 
578  res = PQexec(conn, stringbuffer_getstring(&query));
579  stringbuffer_release(&query);
580  if ( ! res || PQresultStatus(res) != PGRES_TUPLES_OK )
581  {
582  printf( _("Querying for maximum field length: %s"),
583  PQerrorMessage(conn));
584  return -1;
585  }
586 
587  if (PQntuples(res) <= 0 )
588  {
589  PQclear(res);
590  return -1;
591  }
592  size = atoi(PQgetvalue(res, 0, 0));
593  PQclear(res);
594  return size;
595 }
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
tuple res
Definition: window.py:79
static SHPCONNECTIONCONFIG * conn
#define _(String)
Definition: shpcommon.h:24
void stringbuffer_release(stringbuffer_t *s)
Definition: stringbuffer.c:48
int stringbuffer_aprintf(stringbuffer_t *s, const char *fmt,...)
Appends a formatted string to the current string buffer, using the format and argument list provided.
Definition: stringbuffer.c:247
void stringbuffer_init(stringbuffer_t *s)
Definition: stringbuffer.c:54
const char * stringbuffer_getstring(stringbuffer_t *s)
Returns a reference to the internal string being managed by the stringbuffer.
Definition: stringbuffer.c:122

References _, conn, LWDEBUGF, window::res, stringbuffer_aprintf(), stringbuffer_getstring(), stringbuffer_init(), and stringbuffer_release().

Referenced by ShpDumperOpenTable().

Here is the call graph for this function:
Here is the caller graph for this function: