PostGIS  3.0.0dev-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 1071 of file raster2pgsql.c.

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

Referenced by process_rasters().

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