mirror of
https://github.com/mdbtools/mdbtools.git
synced 2025-06-28 15:39:02 +08:00
Patch nosanitize.diff form Nirgal
This commit is contained in:
parent
b5cabb1834
commit
8ef50c444e
@ -1,7 +1,7 @@
|
|||||||
NAME
|
NAME
|
||||||
mdb-export - Export data in an MDB database table to CSV format.
|
mdb-export - Export data in an MDB database table to CSV format.
|
||||||
SYNOPSIS
|
SYNOPSIS
|
||||||
mdb-export [-H] [-d <delimiter>] [-R <row delim>] [[-Q] || [-q <quote> [-X <escape>]]] [-I] [-D <format>] [-S] <database> <table>
|
mdb-export [-H] [-d <delimiter>] [-R <row delim>] [[-Q] || [-q <quote> [-X <escape>]]] [-I] [-D <format>] <database> <table>
|
||||||
|
|
||||||
DESCRIPTION
|
DESCRIPTION
|
||||||
mdb-export is a utility program distributed with MDB Tools.
|
mdb-export is a utility program distributed with MDB Tools.
|
||||||
@ -15,7 +15,6 @@ OPTIONS
|
|||||||
-R Specify a row delimiter
|
-R Specify a row delimiter
|
||||||
-I INSERT statements (instead of CSV). You must specify the SQL dialect.
|
-I INSERT statements (instead of CSV). You must specify the SQL dialect.
|
||||||
-D Set the date format (see strftime(3) for details)
|
-D Set the date format (see strftime(3) for details)
|
||||||
-S Sanitize names (replace spaces etc. with underscore)
|
|
||||||
-q Use to wrap text-like fields. Default is ".
|
-q Use to wrap text-like fields. Default is ".
|
||||||
-X Use to escape quoted characters within a field. Default is doubling.
|
-X Use to escape quoted characters within a field. Default is doubling.
|
||||||
|
|
||||||
|
@ -22,8 +22,6 @@ OPTIONS
|
|||||||
--no-indexes Don't export INDEXes.
|
--no-indexes Don't export INDEXes.
|
||||||
--relations Export foreign keys constraints. This is the default.
|
--relations Export foreign keys constraints. This is the default.
|
||||||
--no-relations Don't export foreign keys constraints.
|
--no-relations Don't export foreign keys constraints.
|
||||||
-S, --sanitize Replace non alphanumric characters by underscore.
|
|
||||||
--no-sanitize Don't replace non alphanumric characters by underscore. This is the default.
|
|
||||||
|
|
||||||
backend Specifies target DDL dialect. Supported values are access, sybase, oracle, postgres, and mysql. If not specified the generated DDL will be in access format.
|
backend Specifies target DDL dialect. Supported values are access, sybase, oracle, postgres, and mysql. If not specified the generated DDL will be in access format.
|
||||||
|
|
||||||
|
@ -161,8 +161,7 @@ enum {
|
|||||||
MDB_SHEXP_COMMENTS = 1<<3, /* export comments on columns & tables */
|
MDB_SHEXP_COMMENTS = 1<<3, /* export comments on columns & tables */
|
||||||
MDB_SHEXP_DEFVALUES = 1<<4, /* export default values */
|
MDB_SHEXP_DEFVALUES = 1<<4, /* export default values */
|
||||||
MDB_SHEXP_INDEXES = 1<<5, /* export indices */
|
MDB_SHEXP_INDEXES = 1<<5, /* export indices */
|
||||||
MDB_SHEXP_RELATIONS = 1<<6, /* export relation (foreign keys) */
|
MDB_SHEXP_RELATIONS = 1<<6 /* export relation (foreign keys) */
|
||||||
MDB_SHEXP_SANITIZE = 1<<7 /* clean up names */
|
|
||||||
};
|
};
|
||||||
#define MDB_SHEXP_DEFAULT (MDB_SHEXP_CST_NOTNULL | MDB_SHEXP_COMMENTS | MDB_SHEXP_INDEXES | MDB_SHEXP_RELATIONS)
|
#define MDB_SHEXP_DEFAULT (MDB_SHEXP_CST_NOTNULL | MDB_SHEXP_COMMENTS | MDB_SHEXP_INDEXES | MDB_SHEXP_RELATIONS)
|
||||||
|
|
||||||
@ -483,7 +482,6 @@ extern int mdb_read_row(MdbTableDef *table, unsigned int row);
|
|||||||
extern void buffer_dump(const void *buf, int start, size_t len);
|
extern void buffer_dump(const void *buf, int start, size_t len);
|
||||||
|
|
||||||
/* backend.c */
|
/* backend.c */
|
||||||
extern char* sanitize_name(const char* name);
|
|
||||||
extern char* mdb_get_coltype_string(MdbBackend *backend, int col_type); /* obsolete */
|
extern char* mdb_get_coltype_string(MdbBackend *backend, int col_type); /* obsolete */
|
||||||
extern int mdb_coltype_takes_length(MdbBackend *backend, int col_type); /* obsolete */
|
extern int mdb_coltype_takes_length(MdbBackend *backend, int col_type); /* obsolete */
|
||||||
extern const MdbBackendType* mdb_get_colbacktype(const MdbColumn *col);
|
extern const MdbBackendType* mdb_get_colbacktype(const MdbColumn *col);
|
||||||
|
@ -154,29 +154,6 @@ static MdbBackendType mdb_mysql_shortdate_type =
|
|||||||
#ifndef JAVA
|
#ifndef JAVA
|
||||||
static gboolean mdb_drop_backend(gpointer key, gpointer value, gpointer data);
|
static gboolean mdb_drop_backend(gpointer key, gpointer value, gpointer data);
|
||||||
|
|
||||||
char* sanitize_name(const char* str)
|
|
||||||
{
|
|
||||||
char *result = malloc(256);
|
|
||||||
char *p = result;
|
|
||||||
|
|
||||||
if (*str) {
|
|
||||||
*p = isalpha(*str) ? *str : '_';
|
|
||||||
p++;
|
|
||||||
if (!isdigit(*str)) /* if it was a digit, keep it */
|
|
||||||
str++;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (*str) {
|
|
||||||
*p = isalnum(*str) ? *str : '_';
|
|
||||||
p++;
|
|
||||||
str++;
|
|
||||||
}
|
|
||||||
|
|
||||||
*p = 0;
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gchar*
|
static gchar*
|
||||||
quote_generic(const gchar *value, gchar quote_char, gchar escape_char) {
|
quote_generic(const gchar *value, gchar quote_char, gchar escape_char) {
|
||||||
gchar *result, *pr;
|
gchar *result, *pr;
|
||||||
@ -338,7 +315,7 @@ void mdb_init_backends()
|
|||||||
mdb_backends = g_hash_table_new(g_str_hash, g_str_equal);
|
mdb_backends = g_hash_table_new(g_str_hash, g_str_equal);
|
||||||
|
|
||||||
mdb_register_backend("access",
|
mdb_register_backend("access",
|
||||||
MDB_SHEXP_DROPTABLE|MDB_SHEXP_CST_NOTNULL|MDB_SHEXP_DEFVALUES|MDB_SHEXP_SANITIZE,
|
MDB_SHEXP_DROPTABLE|MDB_SHEXP_CST_NOTNULL|MDB_SHEXP_DEFVALUES,
|
||||||
mdb_access_types, NULL, NULL,
|
mdb_access_types, NULL, NULL,
|
||||||
"Date()", "Date()",
|
"Date()", "Date()",
|
||||||
"-- That file uses encoding %s\n",
|
"-- That file uses encoding %s\n",
|
||||||
@ -348,7 +325,7 @@ void mdb_init_backends()
|
|||||||
NULL,
|
NULL,
|
||||||
quote_schema_name_bracket_merge);
|
quote_schema_name_bracket_merge);
|
||||||
mdb_register_backend("sybase",
|
mdb_register_backend("sybase",
|
||||||
MDB_SHEXP_DROPTABLE|MDB_SHEXP_CST_NOTNULL|MDB_SHEXP_CST_NOTEMPTY|MDB_SHEXP_COMMENTS|MDB_SHEXP_DEFVALUES|MDB_SHEXP_SANITIZE,
|
MDB_SHEXP_DROPTABLE|MDB_SHEXP_CST_NOTNULL|MDB_SHEXP_CST_NOTEMPTY|MDB_SHEXP_COMMENTS|MDB_SHEXP_DEFVALUES,
|
||||||
mdb_sybase_types, &mdb_sybase_shortdate_type, NULL,
|
mdb_sybase_types, &mdb_sybase_shortdate_type, NULL,
|
||||||
"getdate()", "getdate()",
|
"getdate()", "getdate()",
|
||||||
"-- That file uses encoding %s\n",
|
"-- That file uses encoding %s\n",
|
||||||
@ -358,7 +335,7 @@ void mdb_init_backends()
|
|||||||
"COMMENT ON TABLE %s IS %s;\n",
|
"COMMENT ON TABLE %s IS %s;\n",
|
||||||
quote_schema_name_dquote);
|
quote_schema_name_dquote);
|
||||||
mdb_register_backend("oracle",
|
mdb_register_backend("oracle",
|
||||||
MDB_SHEXP_DROPTABLE|MDB_SHEXP_CST_NOTNULL|MDB_SHEXP_COMMENTS|MDB_SHEXP_INDEXES|MDB_SHEXP_RELATIONS|MDB_SHEXP_DEFVALUES|MDB_SHEXP_SANITIZE,
|
MDB_SHEXP_DROPTABLE|MDB_SHEXP_CST_NOTNULL|MDB_SHEXP_COMMENTS|MDB_SHEXP_INDEXES|MDB_SHEXP_RELATIONS|MDB_SHEXP_DEFVALUES,
|
||||||
mdb_oracle_types, &mdb_oracle_shortdate_type, NULL,
|
mdb_oracle_types, &mdb_oracle_shortdate_type, NULL,
|
||||||
"current_date", "sysdate",
|
"current_date", "sysdate",
|
||||||
"-- That file uses encoding %s\n",
|
"-- That file uses encoding %s\n",
|
||||||
@ -368,7 +345,7 @@ void mdb_init_backends()
|
|||||||
"COMMENT ON TABLE %s IS %s;\n",
|
"COMMENT ON TABLE %s IS %s;\n",
|
||||||
quote_schema_name_dquote);
|
quote_schema_name_dquote);
|
||||||
mdb_register_backend("postgres",
|
mdb_register_backend("postgres",
|
||||||
MDB_SHEXP_DROPTABLE|MDB_SHEXP_CST_NOTNULL|MDB_SHEXP_CST_NOTEMPTY|MDB_SHEXP_COMMENTS|MDB_SHEXP_INDEXES|MDB_SHEXP_RELATIONS|MDB_SHEXP_DEFVALUES|MDB_SHEXP_SANITIZE,
|
MDB_SHEXP_DROPTABLE|MDB_SHEXP_CST_NOTNULL|MDB_SHEXP_CST_NOTEMPTY|MDB_SHEXP_COMMENTS|MDB_SHEXP_INDEXES|MDB_SHEXP_RELATIONS|MDB_SHEXP_DEFVALUES,
|
||||||
mdb_postgres_types, &mdb_postgres_shortdate_type, &mdb_postgres_serial_type,
|
mdb_postgres_types, &mdb_postgres_shortdate_type, &mdb_postgres_serial_type,
|
||||||
"current_date", "now()",
|
"current_date", "now()",
|
||||||
"SET client_encoding = '%s';\n",
|
"SET client_encoding = '%s';\n",
|
||||||
@ -378,7 +355,7 @@ void mdb_init_backends()
|
|||||||
"COMMENT ON TABLE %s IS %s;\n",
|
"COMMENT ON TABLE %s IS %s;\n",
|
||||||
quote_schema_name_dquote);
|
quote_schema_name_dquote);
|
||||||
mdb_register_backend("mysql",
|
mdb_register_backend("mysql",
|
||||||
MDB_SHEXP_DROPTABLE|MDB_SHEXP_CST_NOTNULL|MDB_SHEXP_CST_NOTEMPTY|MDB_SHEXP_COMMENTS|MDB_SHEXP_DEFVALUES|MDB_SHEXP_SANITIZE,
|
MDB_SHEXP_DROPTABLE|MDB_SHEXP_CST_NOTNULL|MDB_SHEXP_CST_NOTEMPTY|MDB_SHEXP_COMMENTS|MDB_SHEXP_DEFVALUES,
|
||||||
mdb_mysql_types, &mdb_mysql_shortdate_type, NULL,
|
mdb_mysql_types, &mdb_mysql_shortdate_type, NULL,
|
||||||
"current_date", "now()",
|
"current_date", "now()",
|
||||||
"-- That file uses encoding %s\n",
|
"-- That file uses encoding %s\n",
|
||||||
@ -453,7 +430,7 @@ int mdb_set_default_backend(MdbHandle *mdb, const char *backend_name)
|
|||||||
* @table: Table to process
|
* @table: Table to process
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
mdb_print_indexes(FILE* outfile, MdbTableDef *table, char *namespace, int sanitize)
|
mdb_print_indexes(FILE* outfile, MdbTableDef *table, char *namespace)
|
||||||
{
|
{
|
||||||
unsigned int i, j;
|
unsigned int i, j;
|
||||||
char* quoted_table_name;
|
char* quoted_table_name;
|
||||||
@ -473,10 +450,7 @@ mdb_print_indexes(FILE* outfile, MdbTableDef *table, char *namespace, int saniti
|
|||||||
|
|
||||||
fprintf (outfile, "-- CREATE INDEXES ...\n");
|
fprintf (outfile, "-- CREATE INDEXES ...\n");
|
||||||
|
|
||||||
if (sanitize)
|
quoted_table_name = mdb->default_backend->quote_schema_name(namespace, table->name);
|
||||||
quoted_table_name = sanitize_name(table->name);
|
|
||||||
else
|
|
||||||
quoted_table_name = mdb->default_backend->quote_schema_name(namespace, table->name);
|
|
||||||
|
|
||||||
for (i=0;i<table->num_idxs;i++) {
|
for (i=0;i<table->num_idxs;i++) {
|
||||||
idx = g_ptr_array_index (table->indices, i);
|
idx = g_ptr_array_index (table->indices, i);
|
||||||
@ -492,10 +466,7 @@ mdb_print_indexes(FILE* outfile, MdbTableDef *table, char *namespace, int saniti
|
|||||||
strcat(index_name, idx->name);
|
strcat(index_name, idx->name);
|
||||||
strcat(index_name, "_idx");
|
strcat(index_name, "_idx");
|
||||||
}
|
}
|
||||||
if (sanitize)
|
quoted_name = mdb->default_backend->quote_schema_name(namespace, index_name);
|
||||||
quoted_name = sanitize_name(index_name);
|
|
||||||
else
|
|
||||||
quoted_name = mdb->default_backend->quote_schema_name(namespace, index_name);
|
|
||||||
if (idx->index_type==1) {
|
if (idx->index_type==1) {
|
||||||
fprintf (outfile, "ALTER TABLE %s ADD CONSTRAINT %s PRIMARY KEY (", quoted_table_name, quoted_name);
|
fprintf (outfile, "ALTER TABLE %s ADD CONSTRAINT %s PRIMARY KEY (", quoted_table_name, quoted_name);
|
||||||
} else {
|
} else {
|
||||||
@ -511,10 +482,7 @@ mdb_print_indexes(FILE* outfile, MdbTableDef *table, char *namespace, int saniti
|
|||||||
if (j)
|
if (j)
|
||||||
fprintf(outfile, ", ");
|
fprintf(outfile, ", ");
|
||||||
col=g_ptr_array_index(table->columns,idx->key_col_num[j]-1);
|
col=g_ptr_array_index(table->columns,idx->key_col_num[j]-1);
|
||||||
if (sanitize)
|
quoted_name = mdb->default_backend->quote_schema_name(NULL, col->name);
|
||||||
quoted_name = sanitize_name(col->name);
|
|
||||||
else
|
|
||||||
quoted_name = mdb->default_backend->quote_schema_name(NULL, col->name);
|
|
||||||
fprintf (outfile, "%s", quoted_name);
|
fprintf (outfile, "%s", quoted_name);
|
||||||
if (idx->index_type!=1 && idx->key_col_order[j])
|
if (idx->index_type!=1 && idx->key_col_order[j])
|
||||||
/* no DESC for primary keys */
|
/* no DESC for primary keys */
|
||||||
@ -667,14 +635,10 @@ generate_table_schema(FILE *outfile, MdbCatalogEntry *entry, char *namespace, gu
|
|||||||
unsigned int i;
|
unsigned int i;
|
||||||
char* quoted_table_name;
|
char* quoted_table_name;
|
||||||
char* quoted_name;
|
char* quoted_name;
|
||||||
int sanitize = export_options & MDB_SHEXP_SANITIZE;
|
|
||||||
MdbProperties *props;
|
MdbProperties *props;
|
||||||
const char *prop_value;
|
const char *prop_value;
|
||||||
|
|
||||||
if (sanitize)
|
quoted_table_name = mdb->default_backend->quote_schema_name(namespace, entry->object_name);
|
||||||
quoted_table_name = sanitize_name(entry->object_name);
|
|
||||||
else
|
|
||||||
quoted_table_name = mdb->default_backend->quote_schema_name(namespace, entry->object_name);
|
|
||||||
|
|
||||||
/* drop the table if it exists */
|
/* drop the table if it exists */
|
||||||
if (export_options & MDB_SHEXP_DROPTABLE)
|
if (export_options & MDB_SHEXP_DROPTABLE)
|
||||||
@ -693,10 +657,7 @@ generate_table_schema(FILE *outfile, MdbCatalogEntry *entry, char *namespace, gu
|
|||||||
for (i = 0; i < table->num_cols; i++) {
|
for (i = 0; i < table->num_cols; i++) {
|
||||||
col = g_ptr_array_index (table->columns, i);
|
col = g_ptr_array_index (table->columns, i);
|
||||||
|
|
||||||
if (sanitize)
|
quoted_name = mdb->default_backend->quote_schema_name(NULL, col->name);
|
||||||
quoted_name = sanitize_name(col->name);
|
|
||||||
else
|
|
||||||
quoted_name = mdb->default_backend->quote_schema_name(NULL, col->name);
|
|
||||||
fprintf (outfile, "\t%s\t\t\t%s", quoted_name,
|
fprintf (outfile, "\t%s\t\t\t%s", quoted_name,
|
||||||
mdb_get_colbacktype_string (col));
|
mdb_get_colbacktype_string (col));
|
||||||
free(quoted_name);
|
free(quoted_name);
|
||||||
@ -773,10 +734,7 @@ generate_table_schema(FILE *outfile, MdbCatalogEntry *entry, char *namespace, gu
|
|||||||
if (!props)
|
if (!props)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (sanitize)
|
quoted_name = mdb->default_backend->quote_schema_name(NULL, col->name);
|
||||||
quoted_name = sanitize_name(col->name);
|
|
||||||
else
|
|
||||||
quoted_name = mdb->default_backend->quote_schema_name(NULL, col->name);
|
|
||||||
|
|
||||||
if (export_options & MDB_SHEXP_CST_NOTEMPTY) {
|
if (export_options & MDB_SHEXP_CST_NOTEMPTY) {
|
||||||
prop_value = mdb_col_get_prop(col, "AllowZeroLength");
|
prop_value = mdb_col_get_prop(col, "AllowZeroLength");
|
||||||
@ -816,7 +774,7 @@ generate_table_schema(FILE *outfile, MdbCatalogEntry *entry, char *namespace, gu
|
|||||||
|
|
||||||
if (export_options & MDB_SHEXP_INDEXES)
|
if (export_options & MDB_SHEXP_INDEXES)
|
||||||
// prints all the indexes of that table
|
// prints all the indexes of that table
|
||||||
mdb_print_indexes(outfile, table, namespace, sanitize);
|
mdb_print_indexes(outfile, table, namespace);
|
||||||
|
|
||||||
free(quoted_table_name);
|
free(quoted_table_name);
|
||||||
|
|
||||||
|
@ -5,7 +5,6 @@ LIBMDB_1.0 {
|
|||||||
# LIBMDB_2.0 {
|
# LIBMDB_2.0 {
|
||||||
global:
|
global:
|
||||||
mdb_*;
|
mdb_*;
|
||||||
sanitize_name;
|
|
||||||
kkd_to_props;
|
kkd_to_props;
|
||||||
_mdb_put_int16;
|
_mdb_put_int16;
|
||||||
_mdb_put_int32;
|
_mdb_put_int32;
|
||||||
|
@ -84,13 +84,12 @@ main(int argc, char **argv)
|
|||||||
char header_row = 1;
|
char header_row = 1;
|
||||||
char quote_text = 1;
|
char quote_text = 1;
|
||||||
char *insert_dialect = NULL;
|
char *insert_dialect = NULL;
|
||||||
char sanitize = 0;
|
|
||||||
char *namespace = "";
|
char *namespace = "";
|
||||||
int opt;
|
int opt;
|
||||||
char *value;
|
char *value;
|
||||||
size_t length;
|
size_t length;
|
||||||
|
|
||||||
while ((opt=getopt(argc, argv, "HQq:X:d:D:R:I:N:S"))!=-1) {
|
while ((opt=getopt(argc, argv, "HQq:X:d:D:R:I:N:"))!=-1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'H':
|
case 'H':
|
||||||
header_row = 0;
|
header_row = 0;
|
||||||
@ -111,9 +110,6 @@ main(int argc, char **argv)
|
|||||||
insert_dialect = (char*) g_strdup(optarg);
|
insert_dialect = (char*) g_strdup(optarg);
|
||||||
header_row = 0;
|
header_row = 0;
|
||||||
break;
|
break;
|
||||||
case 'S':
|
|
||||||
sanitize = 1;
|
|
||||||
break;
|
|
||||||
case 'D':
|
case 'D':
|
||||||
mdb_set_date_fmt(optarg);
|
mdb_set_date_fmt(optarg);
|
||||||
break;
|
break;
|
||||||
@ -150,7 +146,6 @@ main(int argc, char **argv)
|
|||||||
fprintf(stderr," -R <delimiter> specify a row delimiter\n");
|
fprintf(stderr," -R <delimiter> specify a row delimiter\n");
|
||||||
fprintf(stderr," -I <backend> INSERT statements (instead of CSV)\n");
|
fprintf(stderr," -I <backend> INSERT statements (instead of CSV)\n");
|
||||||
fprintf(stderr," -D <format> set the date format (see strftime(3) for details)\n");
|
fprintf(stderr," -D <format> set the date format (see strftime(3) for details)\n");
|
||||||
fprintf(stderr," -S Sanitize names (replace spaces etc. with underscore)\n");
|
|
||||||
fprintf(stderr," -q <char> Use <char> to wrap text-like fields. Default is \".\n");
|
fprintf(stderr," -q <char> Use <char> to wrap text-like fields. Default is \".\n");
|
||||||
fprintf(stderr," -X <char> Use <char> to escape quoted characters within a field. Default is doubling.\n");
|
fprintf(stderr," -X <char> Use <char> to escape quoted characters within a field. Default is doubling.\n");
|
||||||
fprintf(stderr," -N <namespace> Prefix identifiers with namespace\n");
|
fprintf(stderr," -N <namespace> Prefix identifiers with namespace\n");
|
||||||
@ -206,7 +201,7 @@ main(int argc, char **argv)
|
|||||||
col=g_ptr_array_index(table->columns,j);
|
col=g_ptr_array_index(table->columns,j);
|
||||||
if (j)
|
if (j)
|
||||||
fputs(delimiter, stdout);
|
fputs(delimiter, stdout);
|
||||||
fputs(sanitize ? sanitize_name(col->name) : col->name, stdout);
|
fputs(col->name, stdout);
|
||||||
}
|
}
|
||||||
fputs("\n", stdout);
|
fputs("\n", stdout);
|
||||||
}
|
}
|
||||||
@ -215,19 +210,13 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
if (insert_dialect) {
|
if (insert_dialect) {
|
||||||
char *quoted_name;
|
char *quoted_name;
|
||||||
if (sanitize)
|
quoted_name = mdb->default_backend->quote_schema_name(NULL, argv[optind + 1]);
|
||||||
quoted_name = sanitize_name(argv[optind + 1]);
|
|
||||||
else
|
|
||||||
quoted_name = mdb->default_backend->quote_schema_name(NULL, argv[optind + 1]);
|
|
||||||
fprintf(stdout, "INSERT INTO %s%s (", namespace, quoted_name);
|
fprintf(stdout, "INSERT INTO %s%s (", namespace, quoted_name);
|
||||||
free(quoted_name);
|
free(quoted_name);
|
||||||
for (j=0;j<table->num_cols;j++) {
|
for (j=0;j<table->num_cols;j++) {
|
||||||
if (j>0) fputs(", ", stdout);
|
if (j>0) fputs(", ", stdout);
|
||||||
col=g_ptr_array_index(table->columns,j);
|
col=g_ptr_array_index(table->columns,j);
|
||||||
if (sanitize)
|
quoted_name = mdb->default_backend->quote_schema_name(NULL, col->name);
|
||||||
quoted_name = sanitize_name(col->name);
|
|
||||||
else
|
|
||||||
quoted_name = mdb->default_backend->quote_schema_name(NULL, col->name);
|
|
||||||
fputs(quoted_name, stdout);
|
fputs(quoted_name, stdout);
|
||||||
free(quoted_name);
|
free(quoted_name);
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,6 @@ main (int argc, char **argv)
|
|||||||
fprintf (stderr, "where options are:\n");
|
fprintf (stderr, "where options are:\n");
|
||||||
fprintf (stderr, " -T <table> Only create schema for named table\n");
|
fprintf (stderr, " -T <table> Only create schema for named table\n");
|
||||||
fprintf (stderr, " -N <namespace> Prefix identifiers with namespace\n");
|
fprintf (stderr, " -N <namespace> Prefix identifiers with namespace\n");
|
||||||
fprintf (stderr, " -S Sanitize names (replace spaces etc. with underscore)\n");
|
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,11 +63,9 @@ main (int argc, char **argv)
|
|||||||
{"no-indexes", 0, NULL, 0},
|
{"no-indexes", 0, NULL, 0},
|
||||||
{"relations", 0, NULL, 0},
|
{"relations", 0, NULL, 0},
|
||||||
{"no-relations", 0, NULL, 0},
|
{"no-relations", 0, NULL, 0},
|
||||||
{"sanitize", 0, NULL, 'S'},
|
|
||||||
{"no-sanitize", 0, NULL, 0},
|
|
||||||
{NULL, 0, NULL, 0},
|
{NULL, 0, NULL, 0},
|
||||||
};
|
};
|
||||||
opt = getopt_long(argc, argv, "T:N:S", long_options, &option_index);
|
opt = getopt_long(argc, argv, "T:N:", long_options, &option_index);
|
||||||
if (opt == -1)
|
if (opt == -1)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -130,10 +127,6 @@ main (int argc, char **argv)
|
|||||||
export_options &= ~MDB_SHEXP_RELATIONS;
|
export_options &= ~MDB_SHEXP_RELATIONS;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!strcmp(long_options[option_index].name, "no-sanitize")) {
|
|
||||||
export_options &= ~MDB_SHEXP_SANITIZE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
fprintf(stderr, "unimplemented option %s", long_options[option_index].name);
|
fprintf(stderr, "unimplemented option %s", long_options[option_index].name);
|
||||||
if (optarg)
|
if (optarg)
|
||||||
fprintf(stderr, " with arg %s", optarg);
|
fprintf(stderr, " with arg %s", optarg);
|
||||||
@ -148,10 +141,6 @@ main (int argc, char **argv)
|
|||||||
case 'N':
|
case 'N':
|
||||||
namespace = (char *) g_strdup(optarg);
|
namespace = (char *) g_strdup(optarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'S':
|
|
||||||
export_options |= MDB_SHEXP_SANITIZE;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user