PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ ShpLoaderGetSQLCopyStatement()

int ShpLoaderGetSQLCopyStatement ( SHPLOADERSTATE state,
char **  strheader 
)

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

1482 {
1483  char *copystr;
1484 
1485  /* Allocate the string for the COPY statement */
1486  if (state->config->dump_format)
1487  {
1488  if (state->config->schema)
1489  {
1490  copystr = malloc(strlen(state->config->schema) + strlen(state->config->table) +
1491  strlen(state->col_names) + 40);
1492 
1493  sprintf(copystr, "COPY \"%s\".\"%s\" %s FROM stdin;\n",
1494  state->config->schema, state->config->table, state->col_names);
1495  }
1496  else
1497  {
1498  copystr = malloc(strlen(state->config->table) + strlen(state->col_names) + 40);
1499 
1500  sprintf(copystr, "COPY \"%s\" %s FROM stdin;\n", state->config->table, state->col_names);
1501  }
1502 
1503  *strheader = copystr;
1504  return SHPLOADEROK;
1505  }
1506  else
1507  {
1508  /* Flag an error as something has gone horribly wrong */
1509  snprintf(state->message, SHPLOADERMSGLEN, _("Internal error: attempt to generate a COPY statement for data that hasn't been requested in COPY format"));
1510 
1511  return SHPLOADERERR;
1512  }
1513 }
void * malloc(YYSIZE_T)
#define SHPLOADERMSGLEN
#define SHPLOADERERR
#define SHPLOADEROK
#define _(String)
Definition: shpcommon.h:24
char message[SHPLOADERMSGLEN]
SHPLOADERCONFIG * config

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

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