PostGIS  2.5.0dev-r@@SVN_REVISION@@

◆ ShpDumperOpenTable()

int ShpDumperOpenTable ( SHPDUMPERSTATE state)

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

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().

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