PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ create_index()

static int create_index ( const char *  schema,
const char *  table,
const char *  column,
const char *  tablespace,
STRINGBUFFER buffer 
)
static

Definition at line 1068 of file raster2pgsql.c.

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

Referenced by process_rasters().

1072  {
1073  char *sql = NULL;
1074  uint32_t len = 0;
1075  char *_table = NULL;
1076  char *_column = NULL;
1077 
1078  assert(table != NULL);
1079  assert(column != NULL);
1080 
1081  _table = chartrim(table, "\"");
1082  _column = chartrim(column, "\"");
1083 
1084  /* create index */
1085  len = strlen("CREATE INDEX \"__gist\" ON USING gist (st_convexhull());") + 1;
1086  if (schema != NULL)
1087  len += strlen(schema);
1088  len += strlen(_table);
1089  len += strlen(_column);
1090  len += strlen(table);
1091  len += strlen(column);
1092  if (tablespace != NULL)
1093  len += strlen(" TABLESPACE ") + strlen(tablespace);
1094 
1095  sql = rtalloc(sizeof(char) * len);
1096  if (sql == NULL) {
1097  rterror(_("create_index: Could not allocate memory for CREATE INDEX statement"));
1098  rtdealloc(_table);
1099  rtdealloc(_column);
1100  return 0;
1101  }
1102  sprintf(sql, "CREATE INDEX ON %s%s USING gist (st_convexhull(%s))%s%s;",
1103  (schema != NULL ? schema : ""),
1104  table,
1105  column,
1106  (tablespace != NULL ? " TABLESPACE " : ""),
1107  (tablespace != NULL ? tablespace : "")
1108  );
1109  rtdealloc(_table);
1110  rtdealloc(_column);
1111 
1112  append_sql_to_buffer(buffer, sql);
1113 
1114  return 1;
1115 }
#define _(String)
Definition: shpcommon.h:24
static char * chartrim(const char *input, char *remove)
Definition: raster2pgsql.c:293
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
void rtdealloc(void *mem)
Definition: rt_context.c:186
Here is the call graph for this function:
Here is the caller graph for this function: