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

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

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

Referenced by main(), and pgui_action_import().

1462 {
1463  char *copystr;
1464 
1465  /* Allocate the string for the COPY statement */
1466  if (state->config->dump_format)
1467  {
1468  if (state->config->schema)
1469  {
1470  copystr = malloc(strlen(state->config->schema) + strlen(state->config->table) +
1471  strlen(state->col_names) + 40);
1472 
1473  sprintf(copystr, "COPY \"%s\".\"%s\" %s FROM stdin;\n",
1474  state->config->schema, state->config->table, state->col_names);
1475  }
1476  else
1477  {
1478  copystr = malloc(strlen(state->config->table) + strlen(state->col_names) + 40);
1479 
1480  sprintf(copystr, "COPY \"%s\" %s FROM stdin;\n", state->config->table, state->col_names);
1481  }
1482 
1483  *strheader = copystr;
1484  return SHPLOADEROK;
1485  }
1486  else
1487  {
1488  /* Flag an error as something has gone horribly wrong */
1489  snprintf(state->message, SHPLOADERMSGLEN, _("Internal error: attempt to generate a COPY statement for data that hasn't been requested in COPY format"));
1490 
1491  return SHPLOADERERR;
1492  }
1493 }
SHPLOADERCONFIG * config
#define _(String)
Definition: shpcommon.h:24
#define SHPLOADEROK
char message[SHPLOADERMSGLEN]
void * malloc(YYSIZE_T)
#define SHPLOADERERR
#define SHPLOADERMSGLEN

Here is the call graph for this function:

Here is the caller graph for this function: