Skip to content

Commit 7f64c62

Browse files
committed
improve error message for illegal characters
1 parent 0210c7d commit 7f64c62

File tree

4 files changed

+14
-15
lines changed

4 files changed

+14
-15
lines changed

src/options.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ options_t::options_t(int argc, char *argv[]) : options_t()
395395
break;
396396
case 'p':
397397
prefix = optarg;
398-
check_identifier(prefix, "prefix");
398+
check_identifier(prefix, "--prefix parameter");
399399
break;
400400
case 'd':
401401
database_options.db = optarg;
@@ -559,11 +559,11 @@ options_t::options_t(int argc, char *argv[]) : options_t()
559559
break;
560560
case 215:
561561
middle_dbschema = optarg;
562-
check_identifier(middle_dbschema, "middle-schema");
562+
check_identifier(middle_dbschema, "--middle-schema parameter");
563563
break;
564564
case 216:
565565
output_dbschema = optarg;
566-
check_identifier(output_dbschema, "output-pgsql-schema");
566+
check_identifier(output_dbschema, "--output-pgsql-schema parameter");
567567
break;
568568
case 217:
569569
if (std::strcmp(optarg, "false") == 0) {

src/output-flex.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,7 @@ flex_table_t &output_flex_t::create_flex_table()
988988
std::string const table_name =
989989
luaX_get_table_string(lua_state(), "name", -1, "The table");
990990

991-
check_identifier(table_name, "table");
991+
check_identifier(table_name, "table names");
992992

993993
auto const it = std::find_if(m_tables->cbegin(), m_tables->cend(),
994994
[&table_name](flex_table_t const &table) {
@@ -1008,7 +1008,7 @@ flex_table_t &output_flex_t::create_flex_table()
10081008
lua_getfield(lua_state(), -1, "schema");
10091009
if (lua_isstring(lua_state(), -1)) {
10101010
std::string const schema = lua_tostring(lua_state(), -1);
1011-
check_identifier(schema, "schema");
1011+
check_identifier(schema, "schema field");
10121012
new_table.set_schema(schema);
10131013
}
10141014
lua_pop(lua_state(), 1);
@@ -1039,7 +1039,7 @@ flex_table_t &output_flex_t::create_flex_table()
10391039
lua_getfield(lua_state(), -1, "data_tablespace");
10401040
if (lua_isstring(lua_state(), -1)) {
10411041
std::string const tablespace = lua_tostring(lua_state(), -1);
1042-
check_identifier(tablespace, "data_tablespace");
1042+
check_identifier(tablespace, "data_tablespace field");
10431043
new_table.set_data_tablespace(tablespace);
10441044
}
10451045
lua_pop(lua_state(), 1);
@@ -1048,7 +1048,7 @@ flex_table_t &output_flex_t::create_flex_table()
10481048
lua_getfield(lua_state(), -1, "index_tablespace");
10491049
if (lua_isstring(lua_state(), -1)) {
10501050
std::string const tablespace = lua_tostring(lua_state(), -1);
1051-
check_identifier(tablespace, "index_tablespace");
1051+
check_identifier(tablespace, "index_tablespace field");
10521052
new_table.set_index_tablespace(tablespace);
10531053
}
10541054
lua_pop(lua_state(), 1);
@@ -1085,7 +1085,7 @@ void output_flex_t::setup_id_columns(flex_table_t *table)
10851085
if (lua_isstring(lua_state(), -1)) {
10861086
std::string const column_name =
10871087
lua_tolstring(lua_state(), -1, nullptr);
1088-
check_identifier(column_name, "column");
1088+
check_identifier(column_name, "column names");
10891089
auto &column = table->add_column(column_name, "id_type", "");
10901090
column.set_not_null();
10911091
} else if (!lua_isnil(lua_state(), -1)) {
@@ -1098,7 +1098,7 @@ void output_flex_t::setup_id_columns(flex_table_t *table)
10981098

10991099
std::string const name =
11001100
luaX_get_table_string(lua_state(), "id_column", -2, "The ids field");
1101-
check_identifier(name, "column");
1101+
check_identifier(name, "column names");
11021102

11031103
auto &column = table->add_column(name, "id_num", "");
11041104
column.set_not_null();
@@ -1130,7 +1130,7 @@ void output_flex_t::setup_flex_table_columns(flex_table_t *table)
11301130
"Column entry", "text");
11311131
char const *const name =
11321132
luaX_get_table_string(lua_state(), "column", -2, "Column entry");
1133-
check_identifier(name, "column");
1133+
check_identifier(name, "column names");
11341134
char const *const sql_type = luaX_get_table_string(
11351135
lua_state(), "sql_type", -3, "Column entry", "");
11361136

src/pgsql.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,7 @@ void check_identifier(std::string const &name, char const *in)
206206
}
207207

208208
throw std::runtime_error{
209-
"Special characters are not allowed in {} names: '{}'."_format(in,
210-
name)};
209+
"Special characters are not allowed in {}: '{}'."_format(in, name)};
211210
}
212211

213212
std::map<std::string, std::string>

src/table.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,14 @@ void table_t::start(std::string const &conninfo, std::string const &table_space)
107107

108108
//first with the regular columns
109109
for (auto const &column : m_columns) {
110-
check_identifier(column.name, "column");
111-
check_identifier(column.type_name, "column type");
110+
check_identifier(column.name, "column names");
111+
check_identifier(column.type_name, "column types");
112112
sql += R"("{}" {},)"_format(column.name, column.type_name);
113113
}
114114

115115
//then with the hstore columns
116116
for (auto const &hcolumn : m_hstore_columns) {
117-
check_identifier(hcolumn, "column");
117+
check_identifier(hcolumn, "column names");
118118
sql += R"("{}" hstore,)"_format(hcolumn);
119119
}
120120

0 commit comments

Comments
 (0)