PostGIS  2.1.10dev-r@@SVN_REVISION@@
int ShpLoaderGetSQLCopyStatement ( SHPLOADERSTATE state,
char **  strheader 
)

Definition at line 1442 of file shp2pgsql-core.c.

References _, shp_loader_state::col_names, shp_loader_state::config, shp_loader_config::dump_format, shp_loader_state::message, shp_loader_config::schema, SHPLOADERERR, SHPLOADERMSGLEN, SHPLOADEROK, and shp_loader_config::table.

Referenced by main(), and pgui_action_import().

1443 {
1444  char *copystr;
1445 
1446  /* Allocate the string for the COPY statement */
1447  if (state->config->dump_format)
1448  {
1449  if (state->config->schema)
1450  {
1451  copystr = malloc(strlen(state->config->schema) + strlen(state->config->table) +
1452  strlen(state->col_names) + 40);
1453 
1454  sprintf(copystr, "COPY \"%s\".\"%s\" %s FROM stdin;\n",
1455  state->config->schema, state->config->table, state->col_names);
1456  }
1457  else
1458  {
1459  copystr = malloc(strlen(state->config->table) + strlen(state->col_names) + 40);
1460 
1461  sprintf(copystr, "COPY \"%s\" %s FROM stdin;\n", state->config->table, state->col_names);
1462  }
1463 
1464  *strheader = copystr;
1465  return SHPLOADEROK;
1466  }
1467  else
1468  {
1469  /* Flag an error as something has gone horribly wrong */
1470  snprintf(state->message, SHPLOADERMSGLEN, _("Internal error: attempt to generate a COPY statement for data that hasn't been requested in COPY format"));
1471 
1472  return SHPLOADERERR;
1473  }
1474 }
SHPLOADERCONFIG * config
#define _(String)
Definition: shpcommon.h:23
#define SHPLOADEROK
char message[SHPLOADERMSGLEN]
#define SHPLOADERERR
#define SHPLOADERMSGLEN

Here is the caller graph for this function: