PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ ShpDumperOpenTable()

int ShpDumperOpenTable ( SHPDUMPERSTATE state)

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

1351 {
1352  PGresult *res;
1353 
1354  char buf[256];
1355  char *query;
1356  int gidfound = 0, i, j, ret, status;
1357 
1358 
1359  /* Open the column map if one was specified */
1360  if (state->config->column_map_filename)
1361  {
1362  ret = colmap_read(state->config->column_map_filename,
1363  &state->column_map, state->message, SHPDUMPERMSGLEN);
1364  if (!ret) return SHPDUMPERERR;
1365  }
1366 
1367  /* If a user-defined query has been specified, create and point the state to our new table */
1368  if (state->config->usrquery)
1369  {
1370  state->table = malloc(20 + 20); /* string + max long precision */
1371  sprintf(state->table, "__pgsql2shp%lu_tmp_table", (long)getpid());
1372 
1373  query = malloc(32 + strlen(state->table) + strlen(state->config->usrquery));
1374 
1375  sprintf(query, "CREATE TEMP TABLE \"%s\" AS %s", state->table, state->config->usrquery);
1376  res = PQexec(state->conn, query);
1377  free(query);
1378 
1379  /* Execute the code to create the table */
1380  if (PQresultStatus(res) != PGRES_COMMAND_OK)
1381  {
1382  snprintf(state->message, SHPDUMPERMSGLEN, _("Error executing user query: %s"), PQresultErrorMessage(res));
1383  PQclear(res);
1384  return SHPDUMPERERR;
1385  }
1386  }
1387  else
1388  {
1389  /* Simply point the state to copies of the supplied schema and table */
1390  state->table = strdup(state->config->table);
1391  if (state->config->schema)
1392  state->schema = strdup(state->config->schema);
1393  }
1394 
1395 
1396  /* Get the list of columns and their types for the selected table */
1397  if (state->schema)
1398  {
1399  query = malloc(250 + strlen(state->schema) + strlen(state->table));
1400 
1401  sprintf(query, "SELECT a.attname, a.atttypid, "
1402  "a.atttypmod, a.attlen FROM "
1403  "pg_attribute a, pg_class c, pg_namespace n WHERE "
1404  "n.nspname = '%s' AND a.attrelid = c.oid AND "
1405  "n.oid = c.relnamespace AND "
1406  "a.atttypid != 0 AND "
1407  "a.attnum > 0 AND c.relname = '%s'", state->schema, state->table);
1408  }
1409  else
1410  {
1411  query = malloc(250 + strlen(state->table));
1412 
1413  sprintf(query, "SELECT a.attname, a.atttypid, "
1414  "a.atttypmod, a.attlen FROM "
1415  "pg_attribute a, pg_class c WHERE "
1416  "a.attrelid = c.oid and a.attnum > 0 AND "
1417  "a.atttypid != 0 AND "
1418  "c.relname = '%s' AND "
1419  "pg_catalog.pg_table_is_visible(c.oid)", state->table);
1420  }
1421 
1422  LWDEBUGF(3, "query is: %s\n", query);
1423 
1424  res = PQexec(state->conn, query);
1425  free(query);
1426 
1427  if (PQresultStatus(res) != PGRES_TUPLES_OK)
1428  {
1429  snprintf(state->message, SHPDUMPERMSGLEN, _("Error querying for attributes: %s"), PQresultErrorMessage(res));
1430  PQclear(res);
1431  return SHPDUMPERERR;
1432  }
1433 
1434  if (!PQntuples(res))
1435  {
1436  snprintf(state->message, SHPDUMPERMSGLEN, _("Table %s does not exist"), state->table);
1437  PQclear(res);
1438  return SHPDUMPERERR;
1439  }
1440 
1441  /* If a shapefile name was specified, use it. Otherwise simply use the table name. */
1442  if (state->config->shp_file != NULL)
1443  state->shp_file = state->config->shp_file;
1444  else
1445  state->shp_file = state->table;
1446 
1447  /* Create the dbf file: */
1448  /* If there's a user-specified encoding hanging around, try and use that. */
1449  /* Otherwise, just use UTF-8 encoding, since that's usually our client encoding. */
1450  if ( getenv("PGCLIENTENCODING") )
1451  {
1452  char *codepage = encoding2codepage(getenv("PGCLIENTENCODING"));
1453  state->dbf = DBFCreateEx(state->shp_file, codepage);
1454  }
1455  else
1456  {
1457  state->dbf = DBFCreateEx(state->shp_file, "UTF-8");
1458  }
1459 
1460  if (!state->dbf)
1461  {
1462  snprintf(state->message, SHPDUMPERMSGLEN, _("Could not create dbf file %s"), state->shp_file);
1463  return SHPDUMPERERR;
1464  }
1465 
1466  /*
1467  * Scan the result setting fields to be returned in mainscan
1468  * query, filling the type_ary, and creating .dbf and .shp files.
1469  */
1470  state->dbffieldnames = malloc(sizeof(char *) * PQntuples(res));
1471  state->dbffieldtypes = malloc(sizeof(int) * PQntuples(res));
1472  state->pgfieldnames = malloc(sizeof(char *) * PQntuples(res));
1473  state->pgfieldlens = malloc(sizeof(int) * PQntuples(res));
1474  state->pgfieldtypmods = malloc(sizeof(int) * PQntuples(res));
1475  state->fieldcount = 0;
1476  int tmpint = 1;
1477 
1478  for (i = 0; i < PQntuples(res); i++)
1479  {
1480  char *ptr;
1481 
1482  int pgfieldtype, pgtypmod, pgfieldlen;
1483  char *pgfieldname;
1484 
1485  int dbffieldtype, dbffieldsize, dbffielddecs;
1486  char *dbffieldname;
1487 
1488  pgfieldname = PQgetvalue(res, i, 0);
1489  pgfieldtype = atoi(PQgetvalue(res, i, 1));
1490  pgtypmod = atoi(PQgetvalue(res, i, 2));
1491  pgfieldlen = atoi(PQgetvalue(res, i, 3));
1492  dbffieldtype = -1;
1493  dbffieldsize = 0;
1494  dbffielddecs = 0;
1495 
1496  /*
1497  * This is a geometry/geography column
1498  */
1499  if (pgfieldtype == state->geom_oid || pgfieldtype == state->geog_oid)
1500  {
1501  /* If no geometry/geography column has been found yet... */
1502  if (!state->geo_col_name)
1503  {
1504  /* If either no geo* column name was provided (in which case this is
1505  the first match) or we match the provided column name, we have
1506  found our geo* column */
1507  if (!state->config->geo_col_name || !strcmp(state->config->geo_col_name, pgfieldname))
1508  {
1509  dbffieldtype = 9;
1510 
1511  state->geo_col_name = strdup(pgfieldname);
1512  }
1513  }
1514  }
1515 
1516  /*
1517  * Everything else (non geometries) will be
1518  * a DBF attribute.
1519  */
1520 
1521  /* Skip gid (if not asked to do otherwise */
1522  if (!strcmp(pgfieldname, "gid") )
1523  {
1524  gidfound = 1;
1525 
1526  if (!state->config->includegid)
1527  continue;
1528  }
1529 
1530  /* Unescape any reserved column names */
1531  ptr = pgfieldname;
1532  if (!state->config->unescapedattrs)
1533  {
1534  if (*ptr == '_')
1535  ptr += 2;
1536  }
1537 
1538  /*
1539  * This needs special handling since both xmin and _xmin
1540  * becomes __xmin when escaped
1541  */
1542 
1543  /* Limit dbf field name to 10-digits */
1544  dbffieldname = malloc(11);
1545  strncpy(dbffieldname, ptr, 10);
1546  dbffieldname[10] = '\0';
1547 
1548  /* If a column map file has been passed in,
1549  * use this to create the dbf field name from
1550  * the PostgreSQL column name */
1551  {
1552  const char *mapped = colmap_dbf_by_pg(&state->column_map, dbffieldname);
1553  if (mapped)
1554  {
1555  strncpy(dbffieldname, mapped, 10);
1556  dbffieldname[10] = '\0';
1557  }
1558  }
1559 
1560  /*
1561  * make sure the fields all have unique names,
1562  */
1563  tmpint = 1;
1564  for (j = 0; j < state->fieldcount; j++)
1565  {
1566  if (!strncasecmp(dbffieldname, state->dbffieldnames[j], 10))
1567  {
1568  sprintf(dbffieldname, "%.7s_%.2d", ptr, abs(tmpint) % 100);
1569  tmpint++;
1570  continue;
1571  }
1572  }
1573 
1574  /* make UPPERCASE if keep_fieldname_case = 0 */
1575  if (!state->config->keep_fieldname_case)
1576  {
1577  size_t nameit;
1578  for (nameit = 0; nameit < strlen(dbffieldname); nameit++)
1579  dbffieldname[nameit] = toupper(dbffieldname[nameit]);
1580  }
1581 
1582  /* Issue warning if column has been renamed */
1583  if (strcasecmp(dbffieldname, pgfieldname))
1584  {
1585  if ( snprintf(buf, 256, _("Warning, field %s renamed to %s\n"),
1586  pgfieldname, dbffieldname) >= 256 )
1587  {
1588  buf[255] = '\0';
1589  }
1590  /* Note: we concatenate all warnings from the main loop as this is useful information */
1591  strncat(state->message, buf, SHPDUMPERMSGLEN - strlen(state->message) - 1);
1592 
1593  ret = SHPDUMPERWARN;
1594  }
1595 
1596 
1597  /*
1598  * Find appropriate type of dbf attributes
1599  */
1600 
1601  /* int2 type */
1602  if (pgfieldtype == 21)
1603  {
1604  /*
1605  * Longest text representation for
1606  * an int2 type (16bit) is 6 bytes
1607  * (-32768)
1608  */
1609  dbffieldtype = FTInteger;
1610  dbffieldsize = 6;
1611  dbffielddecs = 0;
1612  }
1613 
1614  /* int4 type */
1615  else if (pgfieldtype == 23)
1616  {
1617  /*
1618  * Longest text representation for
1619  * an int4 type (32bit) is 11 bytes
1620  * (-2147483648)
1621  */
1622  dbffieldtype = FTInteger;
1623  dbffieldsize = 11;
1624  dbffielddecs = 0;
1625  }
1626 
1627  /* int8 type */
1628  else if (pgfieldtype == 20)
1629  {
1630  /*
1631  * Longest text representation for
1632  * an int8 type (64bit) is 20 bytes
1633  * (-9223372036854775808)
1634  */
1635  dbffieldtype = FTInteger;
1636  dbffieldsize = 19;
1637  dbffielddecs = 0;
1638  }
1639 
1640  /*
1641  * double or numeric types:
1642  * 700: float4
1643  * 701: float8
1644  * 1700: numeric
1645  *
1646  *
1647  * TODO: stricter handling of sizes
1648  */
1649  else if (pgfieldtype == 700 || pgfieldtype == 701 || pgfieldtype == 1700)
1650  {
1651  dbffieldtype = FTDouble;
1652  dbffieldsize = 32;
1653  dbffielddecs = 10;
1654  }
1655 
1656  /*
1657  * Boolean field, we use FTLogical
1658  */
1659  else if (pgfieldtype == 16)
1660  {
1661  dbffieldtype = FTLogical;
1662  dbffieldsize = 1;
1663  dbffielddecs = 0;
1664  }
1665 
1666  /*
1667  * Date field
1668  */
1669  else if (pgfieldtype == 1082)
1670  {
1671  dbffieldtype = FTDate;
1672  dbffieldsize = 8;
1673  dbffielddecs = 0;
1674  }
1675 
1676  /*
1677  * time, timetz, timestamp, or timestamptz field.
1678  */
1679  else if (pgfieldtype == 1083 || pgfieldtype == 1266 || pgfieldtype == 1114 || pgfieldtype == 1184)
1680  {
1681  int secondsize;
1682 
1683  switch (pgtypmod)
1684  {
1685  case -1:
1686  secondsize = 6 + 1;
1687  break;
1688  case 0:
1689  secondsize = 0;
1690  break;
1691  default:
1692  secondsize = pgtypmod + 1;
1693  break;
1694  }
1695 
1696  /* We assume the worst case scenario for all of these:
1697  * date = '5874897-12-31' = 13
1698  * date = '294276-11-20' = 12 (with --enable-interger-datetimes)
1699  * time = '00:00:00' = 8
1700  * zone = '+01:39:52' = 9 (see Europe/Helsinki around 1915)
1701  */
1702 
1703  /* time */
1704  if (pgfieldtype == 1083)
1705  {
1706  dbffieldsize = 8 + secondsize;
1707  }
1708  /* timetz */
1709  else if (pgfieldtype == 1266)
1710  {
1711  dbffieldsize = 8 + secondsize + 9;
1712  }
1713  /* timestamp */
1714  else if (pgfieldtype == 1114)
1715  {
1716  dbffieldsize = 13 + 1 + 8 + secondsize;
1717  }
1718  /* timestamptz */
1719  else if (pgfieldtype == 1184)
1720  {
1721  dbffieldsize = 13 + 1 + 8 + secondsize + 9;
1722  }
1723 
1724  dbffieldtype = FTString;
1725  dbffielddecs = 0;
1726  }
1727 
1728  /*
1729  * uuid type 36 bytes (12345678-9012-3456-7890-123456789012)
1730  */
1731  else if (pgfieldtype == 2950)
1732  {
1733  dbffieldtype = FTString;
1734  dbffieldsize = 36;
1735  dbffielddecs = 0;
1736  }
1737 
1738  /*
1739  * For variable-sized fields we know about, we use
1740  * the maximum allowed size.
1741  * 1042 is bpchar, 1043 is varchar
1742  */
1743  else if ((pgfieldtype == 1042 || pgfieldtype == 1043) && pgtypmod != -1)
1744  {
1745  /*
1746  * mod is maximum allowed size, including
1747  * header which contains *real* size.
1748  */
1749  dbffieldtype = FTString;
1750  dbffieldsize = pgtypmod - 4; /* 4 is header size */
1751  dbffielddecs = 0;
1752  }
1753 
1754  /* For all other valid non-geometry/geography fields... */
1755  else if (dbffieldtype == -1)
1756  {
1757  /*
1758  * For types we don't know anything about, all
1759  * we can do is query the table for the maximum field
1760  * size.
1761  */
1762  dbffieldsize = getMaxFieldSize(state->conn, state->schema, state->table, pgfieldname);
1763  if (dbffieldsize == -1)
1764  {
1765  free(dbffieldname);
1766  return 0;
1767  }
1768 
1769  if (!dbffieldsize)
1770  dbffieldsize = 32;
1771 
1772  /* might 0 be a good size ? */
1773 
1774  dbffieldtype = FTString;
1775  dbffielddecs = 0;
1776 
1777  /* Check to make sure the final field size isn't too large */
1778  if (dbffieldsize > MAX_DBF_FIELD_SIZE)
1779  {
1780  /* Note: we concatenate all warnings from the main loop as this is useful information */
1781  snprintf(buf, 256, _("Warning: values of field '%s' exceeding maximum dbf field width (%d) "
1782  "will be truncated.\n"), dbffieldname, MAX_DBF_FIELD_SIZE);
1783  strncat(state->message, buf, SHPDUMPERMSGLEN - strlen(state->message));
1784  dbffieldsize = MAX_DBF_FIELD_SIZE;
1785 
1786  ret = SHPDUMPERWARN;
1787  }
1788  }
1789 
1790  LWDEBUGF(3, "DBF FIELD_NAME: %s, SIZE: %d\n", dbffieldname, dbffieldsize);
1791 
1792  if (dbffieldtype != 9)
1793  {
1794  /* Add the field to the DBF file */
1795  if (DBFAddField(state->dbf, dbffieldname, dbffieldtype, dbffieldsize, dbffielddecs) == -1)
1796  {
1797  snprintf(state->message, SHPDUMPERMSGLEN, _("Error: field %s of type %d could not be created."), dbffieldname, dbffieldtype);
1798 
1799  return SHPDUMPERERR;
1800  }
1801 
1802  /* Add the field information to our field arrays */
1803  state->dbffieldnames[state->fieldcount] = dbffieldname;
1804  state->dbffieldtypes[state->fieldcount] = dbffieldtype;
1805  state->pgfieldnames[state->fieldcount] = pgfieldname;
1806  state->pgfieldlens[state->fieldcount] = pgfieldlen;
1807  state->pgfieldtypmods[state->fieldcount] = pgtypmod;
1808 
1809  state->fieldcount++;
1810  }
1811  }
1812 
1813  /* Now we have generated the field lists, grab some info about the table */
1814  status = getTableInfo(state);
1815  if (status == SHPDUMPERERR)
1816  return SHPDUMPERERR;
1817 
1818  LWDEBUGF(3, "rows: %d\n", state->rowcount);
1819  LWDEBUGF(3, "shptype: %c\n", state->outtype);
1820  LWDEBUGF(3, "shpouttype: %d\n", state->outshptype);
1821 
1822  /* If we didn't find a geometry/geography column... */
1823  if (!state->geo_col_name)
1824  {
1825  if (state->config->geo_col_name)
1826  {
1827  /* A geo* column was specified, but not found */
1828  snprintf(state->message, SHPDUMPERMSGLEN, _("%s: no such attribute in table %s"), state->config->geo_col_name, state->table);
1829 
1830  return SHPDUMPERERR;
1831  }
1832  else
1833  {
1834  /* No geo* column specified so we can only create the DBF section -
1835  but let's issue a warning... */
1836  snprintf(buf, 256, _("No geometry column found.\nThe DBF file will be created but not the shx or shp files.\n"));
1837  strncat(state->message, buf, SHPDUMPERMSGLEN - strlen(state->message));
1838 
1839  state->shp = NULL;
1840 
1841  ret = SHPDUMPERWARN;
1842  }
1843  }
1844  else
1845  {
1846  /* Since we have found a geo* column, open the shapefile */
1847  state->shp = SHPCreate(state->shp_file, state->outshptype);
1848  if (!state->shp)
1849  {
1850  snprintf(state->message, SHPDUMPERMSGLEN, _("Could not open shapefile %s!"), state->shp_file);
1851 
1852  return SHPDUMPERERR;
1853  }
1854  }
1855 
1856 
1857  /* Now we have the complete list of fieldnames, let's generate the SQL query. First let's make sure
1858  we reserve enough space for tables with lots of columns */
1859  j = 0;
1860  /*TODO: this really should be rewritten to use stringbuffer */
1861  for (i = 0; i < state->fieldcount; i++)
1862  j += strlen( state->pgfieldnames[i]) + 10; /*add extra space for the quotes to quote identify and any embedded quotes that may need escaping */
1863 
1864  state->main_scan_query = malloc(1024 + j);
1865 
1866  sprintf(state->main_scan_query, "DECLARE cur ");
1867  if (state->config->binary)
1868  strcat(state->main_scan_query, "BINARY ");
1869 
1870  strcat(state->main_scan_query, "CURSOR FOR SELECT ");
1871 
1872  for (i = 0; i < state->fieldcount; i++)
1873  {
1874  /* Comma-separated column names */
1875  if (i > 0)
1876  strcat(state->main_scan_query, ",");
1877 
1878  if (state->config->binary)
1879  sprintf(buf, "%s::text", quote_identifier(state->pgfieldnames[i]) ) ;
1880  else
1881  sprintf(buf, "%s", quote_identifier(state->pgfieldnames[i]) );
1882 
1883  strcat(state->main_scan_query, buf);
1884  }
1885 
1886  /* If we found a valid geometry/geography column then use it */
1887  if (state->geo_col_name)
1888  {
1889  /* If this is the (only) column, no need for the initial comma */
1890  if (state->fieldcount > 0)
1891  strcat(state->main_scan_query, ",");
1892 
1893  if (state->big_endian)
1894  {
1895  if (state->pgis_major_version > 0)
1896  {
1897  sprintf(buf, "ST_asEWKB(ST_SetSRID(%s::geometry, 0), 'XDR') AS _geoX", quote_identifier(state->geo_col_name) );
1898  }
1899  else
1900  {
1901  sprintf(buf, "asbinary(%s::geometry, 'XDR') AS _geoX",
1902  quote_identifier(state->geo_col_name) );
1903  }
1904  }
1905  else /* little_endian */
1906  {
1907  if (state->pgis_major_version > 0)
1908  {
1909  sprintf(buf, "ST_AsEWKB(ST_SetSRID(%s::geometry, 0), 'NDR') AS _geoX", quote_identifier(state->geo_col_name) ) ;
1910  }
1911  else
1912  {
1913  sprintf(buf, "asbinary(%s::geometry, 'NDR') AS _geoX",
1914  quote_identifier(state->geo_col_name) );
1915  }
1916  }
1917 
1918  strcat(state->main_scan_query, buf);
1919  }
1920 
1921  if (state->schema)
1922  {
1923  sprintf(buf, " FROM \"%s\".\"%s\"", state->schema, state->table);
1924  }
1925  else
1926  {
1927  sprintf(buf, " FROM \"%s\"", state->table);
1928  }
1929 
1930  strcat(state->main_scan_query, buf);
1931 
1932  /* Order by 'gid' (if found) */
1933  if (gidfound)
1934  {
1935  sprintf(buf, " ORDER BY \"gid\"");
1936  strcat(state->main_scan_query, buf);
1937  }
1938 
1939  /* Now we've finished with the result set, we can dispose of it */
1940  PQclear(res);
1941 
1942  LWDEBUGF(3, "FINAL QUERY: %s\n", state->main_scan_query);
1943 
1944  /*
1945  * Begin the transaction
1946  * (a cursor can only be defined inside a transaction block)
1947  */
1948  res = PQexec(state->conn, "BEGIN");
1949  if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
1950  {
1951  snprintf(state->message, SHPDUMPERMSGLEN, _("Error starting transaction: %s"), PQresultErrorMessage(res));
1952  PQclear(res);
1953  return SHPDUMPERERR;
1954  }
1955 
1956  PQclear(res);
1957 
1958  /* Execute the main scan query */
1959  res = PQexec(state->conn, state->main_scan_query);
1960  if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
1961  {
1962  snprintf(state->message, SHPDUMPERMSGLEN, _("Error executing main scan query: %s"), PQresultErrorMessage(res));
1963  PQclear(res);
1964  return SHPDUMPERERR;
1965  }
1966 
1967  PQclear(res);
1968 
1969  /* Setup initial scan state */
1970  state->currow = 0;
1971  state->curresrow = 0;
1972  state->currescount = 0;
1973  state->fetchres = NULL;
1974 
1975  /* Generate the fetch query */
1976  state->fetch_query = malloc(256);
1977  sprintf(state->fetch_query, "FETCH %d FROM cur", state->config->fetchsize);
1978 
1979  return SHPDUMPEROK;
1980 }
int SHPAPI_CALL DBFAddField(DBFHandle psDBF, const char *pszFieldName, DBFFieldType eType, int nWidth, int nDecimals)
Definition: dbfopen.c:773
DBFHandle SHPAPI_CALL DBFCreateEx(const char *pszFilename, const char *pszCodePage)
Definition: dbfopen.c:641
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
void * malloc(YYSIZE_T)
void free(void *)
tuple res
Definition: window.py:78
static int getMaxFieldSize(PGconn *conn, char *schema, char *table, char *fname)
static int getTableInfo(SHPDUMPERSTATE *state)
char * quote_identifier(const char *s)
#define MAX_DBF_FIELD_SIZE
#define SHPDUMPERMSGLEN
#define SHPDUMPEROK
#define SHPDUMPERERR
#define SHPDUMPERWARN
SHPHandle SHPAPI_CALL SHPCreate(const char *pszShapeFile, int nShapeType)
Definition: shpopen.c:828
char * encoding2codepage(const char *encoding)
Definition: shpcommon.c:343
int colmap_read(const char *filename, colmap *map, char *errbuf, size_t errbuflen)
Read the content of filename into a symbol map.
Definition: shpcommon.c:213
const char * colmap_dbf_by_pg(colmap *map, const char *pgname)
Definition: shpcommon.c:185
#define _(String)
Definition: shpcommon.h:24
char * column_map_filename
SHPDUMPERCONFIG * config
PGresult * fetchres
char message[SHPDUMPERMSGLEN]

References _, shp_dumper_state::big_endian, shp_dumper_config::binary, colmap_dbf_by_pg(), colmap_read(), shp_dumper_state::column_map, shp_dumper_config::column_map_filename, shp_dumper_state::config, shp_dumper_state::conn, shp_dumper_state::currescount, shp_dumper_state::curresrow, shp_dumper_state::currow, shp_dumper_state::dbf, DBFAddField(), DBFCreateEx(), shp_dumper_state::dbffieldnames, shp_dumper_state::dbffieldtypes, encoding2codepage(), shp_dumper_state::fetch_query, shp_dumper_state::fetchres, shp_dumper_config::fetchsize, shp_dumper_state::fieldcount, free(), shp_dumper_config::geo_col_name, shp_dumper_state::geo_col_name, shp_dumper_state::geog_oid, shp_dumper_state::geom_oid, getMaxFieldSize(), getTableInfo(), shp_dumper_config::includegid, shp_dumper_config::keep_fieldname_case, LWDEBUGF, shp_dumper_state::main_scan_query, malloc(), MAX_DBF_FIELD_SIZE, shp_dumper_state::message, shp_dumper_state::outshptype, shp_dumper_state::outtype, shp_dumper_state::pgfieldlens, shp_dumper_state::pgfieldnames, shp_dumper_state::pgfieldtypmods, shp_dumper_state::pgis_major_version, quote_identifier(), window::res, shp_dumper_state::rowcount, shp_dumper_config::schema, shp_dumper_state::schema, shp_dumper_state::shp, shp_dumper_config::shp_file, shp_dumper_state::shp_file, SHPCreate(), SHPDUMPERERR, SHPDUMPERMSGLEN, SHPDUMPEROK, SHPDUMPERWARN, shp_dumper_config::table, shp_dumper_state::table, shp_dumper_config::unescapedattrs, and shp_dumper_config::usrquery.

Referenced by main(), and pgui_action_export().

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