PostGIS  2.3.7dev-r@@SVN_REVISION@@
static int create_table ( const char *  schema,
const char *  table,
const char *  column,
const int  file_column,
const char *  file_column_name,
const char *  tablespace,
const char *  idx_tablespace,
STRINGBUFFER buffer 
)
static

Definition at line 1020 of file raster2pgsql.c.

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

Referenced by process_rasters().

1025  {
1026  char *sql = NULL;
1027  uint32_t len = 0;
1028 
1029  assert(table != NULL);
1030  assert(column != NULL);
1031 
1032  len = strlen("CREATE TABLE (\"rid\" serial PRIMARY KEY, raster);") + 1;
1033  if (schema != NULL)
1034  len += strlen(schema);
1035  len += strlen(table);
1036  len += strlen(column);
1037  if (file_column)
1038  len += strlen(", text") + strlen(file_column_name);
1039  if (tablespace != NULL)
1040  len += strlen(" TABLESPACE ") + strlen(tablespace);
1041  if (idx_tablespace != NULL)
1042  len += strlen(" USING INDEX TABLESPACE ") + strlen(idx_tablespace);
1043 
1044  sql = rtalloc(sizeof(char) * len);
1045  if (sql == NULL) {
1046  rterror(_("create_table: Could not allocate memory for CREATE TABLE statement"));
1047  return 0;
1048  }
1049  sprintf(sql, "CREATE TABLE %s%s (\"rid\" serial PRIMARY KEY%s%s,%s raster%s%s%s)%s%s;",
1050  (schema != NULL ? schema : ""),
1051  table,
1052  (idx_tablespace != NULL ? " USING INDEX TABLESPACE " : ""),
1053  (idx_tablespace != NULL ? idx_tablespace : ""),
1054  column,
1055  (file_column ? "," : ""),
1056  (file_column ? file_column_name : ""),
1057  (file_column ? " text" : ""),
1058  (tablespace != NULL ? " TABLESPACE " : ""),
1059  (tablespace != NULL ? tablespace : "")
1060  );
1061 
1062  append_sql_to_buffer(buffer, sql);
1063 
1064  return 1;
1065 }
#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
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: