PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ getMaxFieldSize()

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

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

556{
557 int size;
558 stringbuffer_t query;
559 PGresult *res;
560
561 /*( this is ugly: don't forget counting the length */
562 /* when changing the fixed query strings ) */
563
564 stringbuffer_init(&query);
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
580 LWDEBUGF(4, "maxFieldLenQuery: %s\n", stringbuffer_getstring(&query));
581
582 res = PQexec(conn, stringbuffer_getstring(&query));
583 stringbuffer_release(&query);
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,...)
Definition lwgeom_log.h:106
tuple res
Definition window.py:79
static SHPCONNECTIONCONFIG * conn
#define _(String)
Definition shpcommon.h:24
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)

References _, conn, LWDEBUGF, 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: