PostGIS  2.5.0beta2dev-r@@SVN_REVISION@@

◆ copy_from()

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 833 of file raster2pgsql.c.

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

Referenced by insert_records().

836 {
837  char *sql = NULL;
838  uint32_t len = 0;
839 
840  assert(table != NULL);
841  assert(column != NULL);
842 
843  len = strlen("COPY () FROM stdin;") + 1;
844  if (schema != NULL)
845  len += strlen(schema);
846  len += strlen(table);
847  len += strlen(column);
848  if (filename != NULL)
849  len += strlen(",") + strlen(file_column_name);
850 
851  sql = rtalloc(sizeof(char) * len);
852  if (sql == NULL) {
853  rterror(_("copy_from: Could not allocate memory for COPY statement"));
854  return 0;
855  }
856  sprintf(sql, "COPY %s%s (%s%s%s) FROM stdin;",
857  (schema != NULL ? schema : ""),
858  table,
859  column,
860  (filename != NULL ? "," : ""),
861  (filename != NULL ? file_column_name : "")
862  );
863 
864  append_sql_to_buffer(buffer, sql);
865  sql = NULL;
866 
867  return 1;
868 }
#define _(String)
Definition: shpcommon.h:24
void rterror(const char *fmt,...)
Wrappers used for reporting errors and info.
Definition: rt_context.c:199
void * rtalloc(size_t size)
Wrappers used for managing memory.
Definition: rt_context.c:171
unsigned int uint32_t
Definition: uthash.h:78
static int append_sql_to_buffer(STRINGBUFFER *buffer, const char *str)
Definition: raster2pgsql.c:825
Here is the call graph for this function:
Here is the caller graph for this function: