556{
557 int size;
560
561
562
563
565 if ( schema )
566 {
568 &query,
569 "select max(octet_length(\"%s\"::text)) from \"%s\".\"%s\"",
570 fname, schema, table);
571 }
572 else
573 {
575 &query,
576 "select max(octet_length(\"%s\"::text)) from \"%s\"",
577 fname, table);
578 }
579
581
584 if ( ! res || PQresultStatus(res) != PGRES_TUPLES_OK )
585 {
586 printf(
_(
"Querying for maximum field length: %s"),
587 PQerrorMessage(
conn));
588 return -1;
589 }
590
591 if (PQntuples(res) <= 0 )
592 {
593 PQclear(res);
594 return -1;
595 }
596 size = atoi(PQgetvalue(res, 0, 0));
597 PQclear(res);
598 return size;
599}
#define LWDEBUGF(level, msg,...)
static SHPCONNECTIONCONFIG * conn
void stringbuffer_release(stringbuffer_t *s)
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.
const char * stringbuffer_getstring(stringbuffer_t *s)
Returns a reference to the internal string being managed by the stringbuffer.
void stringbuffer_init(stringbuffer_t *s)