PostGIS  2.1.10dev-r@@SVN_REVISION@@
static int create_index ( const char *  schema,
const char *  table,
const char *  column,
const char *  tablespace,
STRINGBUFFER buffer 
)
static

Definition at line 1045 of file raster2pgsql.c.

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

Referenced by process_rasters().

1049  {
1050  char *sql = NULL;
1051  uint32_t len = 0;
1052  char *_table = NULL;
1053  char *_column = NULL;
1054 
1055  assert(table != NULL);
1056  assert(column != NULL);
1057 
1058  _table = chartrim(table, "\"");
1059  _column = chartrim(column, "\"");
1060 
1061  /* create index */
1062  len = strlen("CREATE INDEX \"__gist\" ON USING gist (st_convexhull());") + 1;
1063  if (schema != NULL)
1064  len += strlen(schema);
1065  len += strlen(_table);
1066  len += strlen(_column);
1067  len += strlen(table);
1068  len += strlen(column);
1069  if (tablespace != NULL)
1070  len += strlen(" TABLESPACE ") + strlen(tablespace);
1071 
1072  sql = rtalloc(sizeof(char) * len);
1073  if (sql == NULL) {
1074  rterror(_("create_index: Could not allocate memory for CREATE INDEX statement"));
1075  rtdealloc(_table);
1076  rtdealloc(_column);
1077  return 0;
1078  }
1079  sprintf(sql, "CREATE INDEX ON %s%s USING gist (st_convexhull(%s))%s%s;",
1080  (schema != NULL ? schema : ""),
1081  table,
1082  column,
1083  (tablespace != NULL ? " TABLESPACE " : ""),
1084  (tablespace != NULL ? tablespace : "")
1085  );
1086  rtdealloc(_table);
1087  rtdealloc(_column);
1088 
1089  append_sql_to_buffer(buffer, sql);
1090  rtdealloc(sql);
1091 
1092  return 1;
1093 }
void rtdealloc(void *mem)
Definition: rt_api.c:882
#define _(String)
Definition: shpcommon.h:23
static char * chartrim(const char *input, char *remove)
Definition: raster2pgsql.c:294
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: