PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ create_index()

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

Definition at line 1058 of file raster2pgsql.c.

1062 {
1063 char *sql = NULL;
1064 uint32_t len = 0;
1065 char *_table = NULL;
1066 char *_column = NULL;
1067
1068 assert(table != NULL);
1069 assert(column != NULL);
1070
1071 _table = chartrim(table, "\"");
1072 _column = chartrim(column, "\"");
1073
1074 /* create index */
1075 len = strlen("CREATE INDEX \"__gist\" ON USING gist (st_convexhull());") + 1;
1076 if (schema != NULL)
1077 len += strlen(schema);
1078 len += strlen(_table);
1079 len += strlen(_column);
1080 len += strlen(table);
1081 len += strlen(column);
1082 if (tablespace != NULL)
1083 len += strlen(" TABLESPACE ") + strlen(tablespace);
1084
1085 sql = rtalloc(sizeof(char) * len);
1086 if (sql == NULL) {
1087 rterror(_("create_index: Could not allocate memory for CREATE INDEX statement"));
1088 rtdealloc(_table);
1089 rtdealloc(_column);
1090 return 0;
1091 }
1092 sprintf(sql, "CREATE INDEX ON %s%s USING gist (st_convexhull(%s))%s%s;",
1093 (schema != NULL ? schema : ""),
1094 table,
1095 column,
1096 (tablespace != NULL ? " TABLESPACE " : ""),
1097 (tablespace != NULL ? tablespace : "")
1098 );
1099 rtdealloc(_table);
1100 rtdealloc(_column);
1101
1103
1104 return 1;
1105}
void rterror(const char *fmt,...) __attribute__((format(printf
Wrappers used for reporting errors and info.
void * rtalloc(size_t size)
Wrappers used for managing memory.
Definition rt_context.c:191
void rtdealloc(void *mem)
Definition rt_context.c:206
Datum buffer(PG_FUNCTION_ARGS)
static int append_sql_to_buffer(STRINGBUFFER *buffer, const char *str)
static char * chartrim(const char *input, char *remove)
#define _(String)
Definition shpcommon.h:24

References _, append_sql_to_buffer(), buffer(), chartrim(), rtalloc(), rtdealloc(), and rterror().

Referenced by flatgeobuf_agg_ctx_init(), pgis_asflatgeobuf_transfn(), and process_rasters().

Here is the call graph for this function:
Here is the caller graph for this function: