PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ ShpDumperOpenTable()

int ShpDumperOpenTable ( SHPDUMPERSTATE state)

Definition at line 1350 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().

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, tmpint++);
1569  continue;
1570  }
1571  }
1572 
1573  /* make UPPERCASE if keep_fieldname_case = 0 */
1574  if (!state->config->keep_fieldname_case)
1575  for (j = 0; j < strlen(dbffieldname); j++)
1576  dbffieldname[j] = toupper(dbffieldname[j]);
1577 
1578  /* Issue warning if column has been renamed */
1579  if (strcasecmp(dbffieldname, pgfieldname))
1580  {
1581  if ( snprintf(buf, 256, _("Warning, field %s renamed to %s\n"),
1582  pgfieldname, dbffieldname) >= 256 )
1583  {
1584  buf[255] = '\0';
1585  }
1586  /* Note: we concatenate all warnings from the main loop as this is useful information */
1587  strncat(state->message, buf, SHPDUMPERMSGLEN - strlen(state->message) - 1);
1588 
1589  ret = SHPDUMPERWARN;
1590  }
1591 
1592 
1593  /*
1594  * Find appropriate type of dbf attributes
1595  */
1596 
1597  /* int2 type */
1598  if (pgfieldtype == 21)
1599  {
1600  /*
1601  * Longest text representation for
1602  * an int2 type (16bit) is 6 bytes
1603  * (-32768)
1604  */
1605  dbffieldtype = FTInteger;
1606  dbffieldsize = 6;
1607  dbffielddecs = 0;
1608  }
1609 
1610  /* int4 type */
1611  else if (pgfieldtype == 23)
1612  {
1613  /*
1614  * Longest text representation for
1615  * an int4 type (32bit) is 11 bytes
1616  * (-2147483648)
1617  */
1618  dbffieldtype = FTInteger;
1619  dbffieldsize = 11;
1620  dbffielddecs = 0;
1621  }
1622 
1623  /* int8 type */
1624  else if (pgfieldtype == 20)
1625  {
1626  /*
1627  * Longest text representation for
1628  * an int8 type (64bit) is 20 bytes
1629  * (-9223372036854775808)
1630  */
1631  dbffieldtype = FTInteger;
1632  dbffieldsize = 19;
1633  dbffielddecs = 0;
1634  }
1635 
1636  /*
1637  * double or numeric types:
1638  * 700: float4
1639  * 701: float8
1640  * 1700: numeric
1641  *
1642  *
1643  * TODO: stricter handling of sizes
1644  */
1645  else if (pgfieldtype == 700 || pgfieldtype == 701 || pgfieldtype == 1700)
1646  {
1647  dbffieldtype = FTDouble;
1648  dbffieldsize = 32;
1649  dbffielddecs = 10;
1650  }
1651 
1652  /*
1653  * Boolean field, we use FTLogical
1654  */
1655  else if (pgfieldtype == 16)
1656  {
1657  dbffieldtype = FTLogical;
1658  dbffieldsize = 1;
1659  dbffielddecs = 0;
1660  }
1661 
1662  /*
1663  * Date field
1664  */
1665  else if (pgfieldtype == 1082)
1666  {
1667  dbffieldtype = FTDate;
1668  dbffieldsize = 8;
1669  dbffielddecs = 0;
1670  }
1671 
1672  /*
1673  * time, timetz, timestamp, or timestamptz field.
1674  */
1675  else if (pgfieldtype == 1083 || pgfieldtype == 1266 || pgfieldtype == 1114 || pgfieldtype == 1184)
1676  {
1677  int secondsize;
1678 
1679  switch (pgtypmod)
1680  {
1681  case -1:
1682  secondsize = 6 + 1;
1683  break;
1684  case 0:
1685  secondsize = 0;
1686  break;
1687  default:
1688  secondsize = pgtypmod + 1;
1689  break;
1690  }
1691 
1692  /* We assume the worst case scenario for all of these:
1693  * date = '5874897-12-31' = 13
1694  * date = '294276-11-20' = 12 (with --enable-interger-datetimes)
1695  * time = '00:00:00' = 8
1696  * zone = '+01:39:52' = 9 (see Europe/Helsinki around 1915)
1697  */
1698 
1699  /* time */
1700  if (pgfieldtype == 1083)
1701  {
1702  dbffieldsize = 8 + secondsize;
1703  }
1704  /* timetz */
1705  else if (pgfieldtype == 1266)
1706  {
1707  dbffieldsize = 8 + secondsize + 9;
1708  }
1709  /* timestamp */
1710  else if (pgfieldtype == 1114)
1711  {
1712  dbffieldsize = 13 + 1 + 8 + secondsize;
1713  }
1714  /* timestamptz */
1715  else if (pgfieldtype == 1184)
1716  {
1717  dbffieldsize = 13 + 1 + 8 + secondsize + 9;
1718  }
1719 
1720  dbffieldtype = FTString;
1721  dbffielddecs = 0;
1722  }
1723 
1724  /*
1725  * uuid type 36 bytes (12345678-9012-3456-7890-123456789012)
1726  */
1727  else if (pgfieldtype == 2950)
1728  {
1729  dbffieldtype = FTString;
1730  dbffieldsize = 36;
1731  dbffielddecs = 0;
1732  }
1733 
1734  /*
1735  * For variable-sized fields we know about, we use
1736  * the maximum allowed size.
1737  * 1042 is bpchar, 1043 is varchar
1738  */
1739  else if ((pgfieldtype == 1042 || pgfieldtype == 1043) && pgtypmod != -1)
1740  {
1741  /*
1742  * mod is maximum allowed size, including
1743  * header which contains *real* size.
1744  */
1745  dbffieldtype = FTString;
1746  dbffieldsize = pgtypmod - 4; /* 4 is header size */
1747  dbffielddecs = 0;
1748  }
1749 
1750  /* For all other valid non-geometry/geography fields... */
1751  else if (dbffieldtype == -1)
1752  {
1753  /*
1754  * For types we don't know anything about, all
1755  * we can do is query the table for the maximum field
1756  * size.
1757  */
1758  dbffieldsize = getMaxFieldSize(state->conn, state->schema, state->table, pgfieldname);
1759  if (dbffieldsize == -1)
1760  {
1761  free(dbffieldname);
1762  return 0;
1763  }
1764 
1765  if (!dbffieldsize)
1766  dbffieldsize = 32;
1767 
1768  /* might 0 be a good size ? */
1769 
1770  dbffieldtype = FTString;
1771  dbffielddecs = 0;
1772 
1773  /* Check to make sure the final field size isn't too large */
1774  if (dbffieldsize > MAX_DBF_FIELD_SIZE)
1775  {
1776  /* Note: we concatenate all warnings from the main loop as this is useful information */
1777  snprintf(buf, 256, _("Warning: values of field '%s' exceeding maximum dbf field width (%d) "
1778  "will be truncated.\n"), dbffieldname, MAX_DBF_FIELD_SIZE);
1779  strncat(state->message, buf, SHPDUMPERMSGLEN - strlen(state->message));
1780  dbffieldsize = MAX_DBF_FIELD_SIZE;
1781 
1782  ret = SHPDUMPERWARN;
1783  }
1784  }
1785 
1786  LWDEBUGF(3, "DBF FIELD_NAME: %s, SIZE: %d\n", dbffieldname, dbffieldsize);
1787 
1788  if (dbffieldtype != 9)
1789  {
1790  /* Add the field to the DBF file */
1791  if (DBFAddField(state->dbf, dbffieldname, dbffieldtype, dbffieldsize, dbffielddecs) == -1)
1792  {
1793  snprintf(state->message, SHPDUMPERMSGLEN, _("Error: field %s of type %d could not be created."), dbffieldname, dbffieldtype);
1794 
1795  return SHPDUMPERERR;
1796  }
1797 
1798  /* Add the field information to our field arrays */
1799  state->dbffieldnames[state->fieldcount] = dbffieldname;
1800  state->dbffieldtypes[state->fieldcount] = dbffieldtype;
1801  state->pgfieldnames[state->fieldcount] = pgfieldname;
1802  state->pgfieldlens[state->fieldcount] = pgfieldlen;
1803  state->pgfieldtypmods[state->fieldcount] = pgtypmod;
1804 
1805  state->fieldcount++;
1806  }
1807  }
1808 
1809  /* Now we have generated the field lists, grab some info about the table */
1810  status = getTableInfo(state);
1811  if (status == SHPDUMPERERR)
1812  return SHPDUMPERERR;
1813 
1814  LWDEBUGF(3, "rows: %d\n", state->rowcount);
1815  LWDEBUGF(3, "shptype: %c\n", state->outtype);
1816  LWDEBUGF(3, "shpouttype: %d\n", state->outshptype);
1817 
1818  /* If we didn't find a geometry/geography column... */
1819  if (!state->geo_col_name)
1820  {
1821  if (state->config->geo_col_name)
1822  {
1823  /* A geo* column was specified, but not found */
1824  snprintf(state->message, SHPDUMPERMSGLEN, _("%s: no such attribute in table %s"), state->config->geo_col_name, state->table);
1825 
1826  return SHPDUMPERERR;
1827  }
1828  else
1829  {
1830  /* No geo* column specified so we can only create the DBF section -
1831  but let's issue a warning... */
1832  snprintf(buf, 256, _("No geometry column found.\nThe DBF file will be created but not the shx or shp files.\n"));
1833  strncat(state->message, buf, SHPDUMPERMSGLEN - strlen(state->message));
1834 
1835  state->shp = NULL;
1836 
1837  ret = SHPDUMPERWARN;
1838  }
1839  }
1840  else
1841  {
1842  /* Since we have found a geo* column, open the shapefile */
1843  state->shp = SHPCreate(state->shp_file, state->outshptype);
1844  if (!state->shp)
1845  {
1846  snprintf(state->message, SHPDUMPERMSGLEN, _("Could not open shapefile %s!"), state->shp_file);
1847 
1848  return SHPDUMPERERR;
1849  }
1850  }
1851 
1852 
1853  /* Now we have the complete list of fieldnames, let's generate the SQL query. First let's make sure
1854  we reserve enough space for tables with lots of columns */
1855  j = 0;
1856  /*TODO: this really should be rewritten to use stringbuffer */
1857  for (i = 0; i < state->fieldcount; i++)
1858  j += strlen( state->pgfieldnames[i]) + 10; /*add extra space for the quotes to quote identify and any embedded quotes that may need escaping */
1859 
1860  state->main_scan_query = malloc(1024 + j);
1861 
1862  sprintf(state->main_scan_query, "DECLARE cur ");
1863  if (state->config->binary)
1864  strcat(state->main_scan_query, "BINARY ");
1865 
1866  strcat(state->main_scan_query, "CURSOR FOR SELECT ");
1867 
1868  for (i = 0; i < state->fieldcount; i++)
1869  {
1870  /* Comma-separated column names */
1871  if (i > 0)
1872  strcat(state->main_scan_query, ",");
1873 
1874  if (state->config->binary)
1875  sprintf(buf, "%s::text", quote_identifier(state->pgfieldnames[i]) ) ;
1876  else
1877  sprintf(buf, "%s", quote_identifier(state->pgfieldnames[i]) );
1878 
1879  strcat(state->main_scan_query, buf);
1880  }
1881 
1882  /* If we found a valid geometry/geography column then use it */
1883  if (state->geo_col_name)
1884  {
1885  /* If this is the (only) column, no need for the initial comma */
1886  if (state->fieldcount > 0)
1887  strcat(state->main_scan_query, ",");
1888 
1889  if (state->big_endian)
1890  {
1891  if (state->pgis_major_version > 0)
1892  {
1893  sprintf(buf, "ST_asEWKB(ST_SetSRID(%s::geometry, 0), 'XDR') AS _geoX", quote_identifier(state->geo_col_name) );
1894  }
1895  else
1896  {
1897  sprintf(buf, "asbinary(%s::geometry, 'XDR') AS _geoX",
1898  quote_identifier(state->geo_col_name) );
1899  }
1900  }
1901  else /* little_endian */
1902  {
1903  if (state->pgis_major_version > 0)
1904  {
1905  sprintf(buf, "ST_AsEWKB(ST_SetSRID(%s::geometry, 0), 'NDR') AS _geoX", quote_identifier(state->geo_col_name) ) ;
1906  }
1907  else
1908  {
1909  sprintf(buf, "asbinary(%s::geometry, 'NDR') AS _geoX",
1910  quote_identifier(state->geo_col_name) );
1911  }
1912  }
1913 
1914  strcat(state->main_scan_query, buf);
1915  }
1916 
1917  if (state->schema)
1918  {
1919  sprintf(buf, " FROM \"%s\".\"%s\"", state->schema, state->table);
1920  }
1921  else
1922  {
1923  sprintf(buf, " FROM \"%s\"", state->table);
1924  }
1925 
1926  strcat(state->main_scan_query, buf);
1927 
1928  /* Order by 'gid' (if found) */
1929  if (gidfound)
1930  {
1931  sprintf(buf, " ORDER BY \"gid\"");
1932  strcat(state->main_scan_query, buf);
1933  }
1934 
1935  /* Now we've finished with the result set, we can dispose of it */
1936  PQclear(res);
1937 
1938  LWDEBUGF(3, "FINAL QUERY: %s\n", state->main_scan_query);
1939 
1940  /*
1941  * Begin the transaction
1942  * (a cursor can only be defined inside a transaction block)
1943  */
1944  res = PQexec(state->conn, "BEGIN");
1945  if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
1946  {
1947  snprintf(state->message, SHPDUMPERMSGLEN, _("Error starting transaction: %s"), PQresultErrorMessage(res));
1948  PQclear(res);
1949  return SHPDUMPERERR;
1950  }
1951 
1952  PQclear(res);
1953 
1954  /* Execute the main scan query */
1955  res = PQexec(state->conn, state->main_scan_query);
1956  if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
1957  {
1958  snprintf(state->message, SHPDUMPERMSGLEN, _("Error executing main scan query: %s"), PQresultErrorMessage(res));
1959  PQclear(res);
1960  return SHPDUMPERERR;
1961  }
1962 
1963  PQclear(res);
1964 
1965  /* Setup initial scan state */
1966  state->currow = 0;
1967  state->curresrow = 0;
1968  state->currescount = 0;
1969  state->fetchres = NULL;
1970 
1971  /* Generate the fetch query */
1972  state->fetch_query = malloc(256);
1973  sprintf(state->fetch_query, "FETCH %d FROM cur", state->config->fetchsize);
1974 
1975  return SHPDUMPEROK;
1976 }
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: