PostGIS  2.4.9dev-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 830 of file raster2pgsql.c.

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

Referenced by insert_records().

833 {
834  char *sql = NULL;
835  uint32_t len = 0;
836 
837  assert(table != NULL);
838  assert(column != NULL);
839 
840  len = strlen("COPY () FROM stdin;") + 1;
841  if (schema != NULL)
842  len += strlen(schema);
843  len += strlen(table);
844  len += strlen(column);
845  if (filename != NULL)
846  len += strlen(",") + strlen(file_column_name);
847 
848  sql = rtalloc(sizeof(char) * len);
849  if (sql == NULL) {
850  rterror(_("copy_from: Could not allocate memory for COPY statement"));
851  return 0;
852  }
853  sprintf(sql, "COPY %s%s (%s%s%s) FROM stdin;",
854  (schema != NULL ? schema : ""),
855  table,
856  column,
857  (filename != NULL ? "," : ""),
858  (filename != NULL ? file_column_name : "")
859  );
860 
861  append_sql_to_buffer(buffer, sql);
862  sql = NULL;
863 
864  return 1;
865 }
#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:822
Here is the call graph for this function:
Here is the caller graph for this function: