PostGIS  2.1.10dev-r@@SVN_REVISION@@
static int copy_from ( const char *  schema,
const char *  table,
const char *  column,
const char *  filename,
const char *  file_column_name,
STRINGBUFFER buffer 
)
static

Definition at line 997 of file raster2pgsql.c.

References _, append_sql_to_buffer(), rtalloc(), rtdealloc(), rterror(), and rtgdalraster::sql.

Referenced by process_rasters().

1001  {
1002  char *sql = NULL;
1003  uint32_t len = 0;
1004 
1005  assert(table != NULL);
1006  assert(column != NULL);
1007 
1008  len = strlen("COPY () FROM stdin;") + 1;
1009  if (schema != NULL)
1010  len += strlen(schema);
1011  len += strlen(table);
1012  len += strlen(column);
1013  if (filename != NULL)
1014  len += strlen(",") + strlen(file_column_name);
1015 
1016  sql = rtalloc(sizeof(char) * len);
1017  if (sql == NULL) {
1018  rterror(_("copy_from: Could not allocate memory for COPY statement"));
1019  return 0;
1020  }
1021  sprintf(sql, "COPY %s%s (%s%s%s) FROM stdin;",
1022  (schema != NULL ? schema : ""),
1023  table,
1024  column,
1025  (filename != NULL ? "," : ""),
1026  (filename != NULL ? file_column_name : "")
1027  );
1028 
1029  append_sql_to_buffer(buffer, sql);
1030  rtdealloc(sql);
1031  sql = NULL;
1032 
1033  return 1;
1034 }
void rtdealloc(void *mem)
Definition: rt_api.c:882
#define _(String)
Definition: shpcommon.h:23
static int append_sql_to_buffer(STRINGBUFFER *buffer, const char *str)
Definition: raster2pgsql.c:820
void * rtalloc(size_t size)
Raster core memory management functions.
Definition: rt_api.c:867
void rterror(const char *fmt,...)
Raster core error and info handlers.
Definition: rt_api.c:895

Here is the call graph for this function:

Here is the caller graph for this function: