PostGIS  2.5.0beta2dev-r@@SVN_REVISION@@

◆ create_table()

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

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

Referenced by process_rasters().

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