PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ getMaxFieldSize()

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

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

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