PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ getMaxFieldSize()

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

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

535 {
536  int size;
537  char *query;
538  PGresult *res;
539 
540  /*( this is ugly: don't forget counting the length */
541  /* when changing the fixed query strings ) */
542 
543  if ( schema )
544  {
545  query = (char *)malloc(strlen(fname)+strlen(table)+
546  strlen(schema)+46);
547  sprintf(query,
548  "select max(octet_length(\"%s\"::text)) from \"%s\".\"%s\"",
549  fname, schema, table);
550  }
551  else
552  {
553  query = (char *)malloc(strlen(fname)+strlen(table)+46);
554  sprintf(query,
555  "select max(octet_length(\"%s\"::text)) from \"%s\"",
556  fname, table);
557  }
558 
559  LWDEBUGF(4, "maxFieldLenQuery: %s\n", query);
560 
561  res = PQexec(conn, query);
562  free(query);
563  if ( ! res || PQresultStatus(res) != PGRES_TUPLES_OK )
564  {
565  printf( _("Querying for maximum field length: %s"),
566  PQerrorMessage(conn));
567  return -1;
568  }
569 
570  if (PQntuples(res) <= 0 )
571  {
572  PQclear(res);
573  return -1;
574  }
575  size = atoi(PQgetvalue(res, 0, 0));
576  PQclear(res);
577  return size;
578 }
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
void * malloc(YYSIZE_T)
void free(void *)
tuple res
Definition: window.py:78
static SHPCONNECTIONCONFIG * conn
#define _(String)
Definition: shpcommon.h:24

References _, conn, free(), LWDEBUGF, malloc(), and window::res.

Referenced by ShpDumperOpenTable().

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