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

◆ create_table()

static int create_table ( const char *  schema,
const char *  table,
const char *  column,
const int  file_column,
const char *  file_column_name,
const char *  tablespace,
const char *  idx_tablespace,
STRINGBUFFER buffer 
)
static

Definition at line 1010 of file raster2pgsql.c.

1015 {
1016 char *sql = NULL;
1017 uint32_t len = 0;
1018
1019 assert(table != NULL);
1020 assert(column != NULL);
1021
1022 len = strlen("CREATE TABLE (\"rid\" serial PRIMARY KEY, raster);") + 1;
1023 if (schema != NULL)
1024 len += strlen(schema);
1025 len += strlen(table);
1026 len += strlen(column);
1027 if (file_column)
1028 len += strlen(", text") + strlen(file_column_name);
1029 if (tablespace != NULL)
1030 len += strlen(" TABLESPACE ") + strlen(tablespace);
1031 if (idx_tablespace != NULL)
1032 len += strlen(" USING INDEX TABLESPACE ") + strlen(idx_tablespace);
1033
1034 sql = rtalloc(sizeof(char) * len);
1035 if (sql == NULL) {
1036 rterror(_("create_table: Could not allocate memory for CREATE TABLE statement"));
1037 return 0;
1038 }
1039 sprintf(sql, "CREATE TABLE %s%s (\"rid\" serial PRIMARY KEY%s%s,%s raster%s%s%s)%s%s;",
1040 (schema != NULL ? schema : ""),
1041 table,
1042 (idx_tablespace != NULL ? " USING INDEX TABLESPACE " : ""),
1043 (idx_tablespace != NULL ? idx_tablespace : ""),
1044 column,
1045 (file_column ? "," : ""),
1046 (file_column ? file_column_name : ""),
1047 (file_column ? " text" : ""),
1048 (tablespace != NULL ? " TABLESPACE " : ""),
1049 (tablespace != NULL ? tablespace : "")
1050 );
1051
1053
1054 return 1;
1055}
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
Datum buffer(PG_FUNCTION_ARGS)
static int append_sql_to_buffer(STRINGBUFFER *buffer, const char *str)
#define _(String)
Definition shpcommon.h:24

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

Referenced by process_rasters().

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