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

◆ add_raster_constraints()

static int add_raster_constraints ( const char *  schema,
const char *  table,
const char *  column,
int  regular_blocking,
int  max_extent,
STRINGBUFFER buffer 
)
static

Definition at line 1156 of file raster2pgsql.c.

1160 {
1161 char *sql = NULL;
1162 uint32_t len = 0;
1163
1164 char *_tmp = NULL;
1165 char *_schema = NULL;
1166 char *_table = NULL;
1167 char *_column = NULL;
1168
1169 assert(table != NULL);
1170 assert(column != NULL);
1171
1172 /* schema */
1173 if (schema != NULL) {
1174 _tmp = chartrim(schema, ".");
1175 _schema = chartrim(_tmp, "\"");
1176 rtdealloc(_tmp);
1177 _tmp = strreplace(_schema, "'", "''", NULL);
1178 rtdealloc(_schema);
1179 _schema = _tmp;
1180 }
1181
1182 /* table */
1183 _tmp = chartrim(table, "\"");
1184 _table = strreplace(_tmp, "'", "''", NULL);
1185 rtdealloc(_tmp);
1186
1187 /* column */
1188 _tmp = chartrim(column, "\"");
1189 _column = strreplace(_tmp, "'", "''", NULL);
1190 rtdealloc(_tmp);
1191
1192 len = strlen("SELECT AddRasterConstraints('','','',TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,FALSE,TRUE,TRUE,TRUE,TRUE,FALSE);") + 1;
1193 if (_schema != NULL)
1194 len += strlen(_schema);
1195 len += strlen(_table);
1196 len += strlen(_column);
1197
1198 sql = rtalloc(sizeof(char) * len);
1199 if (sql == NULL) {
1200 rterror(_("add_raster_constraints: Could not allocate memory for AddRasterConstraints statement"));
1201 return 0;
1202 }
1203 sprintf(sql, "SELECT AddRasterConstraints('%s','%s','%s',TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,%s,TRUE,TRUE,TRUE,TRUE,%s);",
1204 (_schema != NULL ? _schema : ""),
1205 _table,
1206 _column,
1207 (regular_blocking ? "TRUE" : "FALSE"),
1208 (max_extent ? "TRUE" : "FALSE")
1209 );
1210
1211 if (_schema != NULL)
1212 rtdealloc(_schema);
1213 rtdealloc(_table);
1214 rtdealloc(_column);
1215
1217
1218 return 1;
1219}
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
void rtdealloc(void *mem)
Definition rt_context.c:186
Datum buffer(PG_FUNCTION_ARGS)
static int append_sql_to_buffer(STRINGBUFFER *buffer, const char *str)
static char * strreplace(const char *str, const char *oldstr, const char *newstr, int *count)
static char * chartrim(const char *input, char *remove)
#define _(String)
Definition shpcommon.h:24

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

Referenced by process_rasters().

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