PostGIS  2.1.10dev-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 948 of file raster2pgsql.c.

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

Referenced by process_rasters().

953  {
954  char *sql = NULL;
955  uint32_t len = 0;
956 
957  assert(table != NULL);
958  assert(column != NULL);
959 
960  len = strlen("CREATE TABLE (\"rid\" serial PRIMARY KEY, raster);") + 1;
961  if (schema != NULL)
962  len += strlen(schema);
963  len += strlen(table);
964  len += strlen(column);
965  if (file_column)
966  len += strlen(", text") + strlen(file_column_name);
967  if (tablespace != NULL)
968  len += strlen(" TABLESPACE ") + strlen(tablespace);
969  if (idx_tablespace != NULL)
970  len += strlen(" USING INDEX TABLESPACE ") + strlen(idx_tablespace);
971 
972  sql = rtalloc(sizeof(char) * len);
973  if (sql == NULL) {
974  rterror(_("create_table: Could not allocate memory for CREATE TABLE statement"));
975  return 0;
976  }
977  sprintf(sql, "CREATE TABLE %s%s (\"rid\" serial PRIMARY KEY%s%s,%s raster%s%s%s)%s%s;",
978  (schema != NULL ? schema : ""),
979  table,
980  (idx_tablespace != NULL ? " USING INDEX TABLESPACE " : ""),
981  (idx_tablespace != NULL ? idx_tablespace : ""),
982  column,
983  (file_column ? "," : ""),
984  (file_column ? file_column_name : ""),
985  (file_column ? " text" : ""),
986  (tablespace != NULL ? " TABLESPACE " : ""),
987  (tablespace != NULL ? tablespace : "")
988  );
989 
990  append_sql_to_buffer(buffer, sql);
991  rtdealloc(sql);
992 
993  return 1;
994 }
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: