duckdb 0.3.2-dev1028.0 → 0.3.2-dev1053.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/duckdb.cpp +236 -168
- package/src/duckdb.hpp +222 -188
- package/src/parquet-amalgamation.cpp +20442 -20442
package/src/duckdb.cpp
CHANGED
|
@@ -57349,7 +57349,7 @@ void BufferedCSVReader::DetectHeader(const vector<vector<LogicalType>> &best_sql
|
|
|
57349
57349
|
// update parser info, and read, generate & set col_names based on previous findings
|
|
57350
57350
|
if (((!first_row_consistent || first_row_nulls) && !options.has_header) || (options.has_header && options.header)) {
|
|
57351
57351
|
options.header = true;
|
|
57352
|
-
|
|
57352
|
+
case_insensitive_map_t<idx_t> name_collision_count;
|
|
57353
57353
|
// get header names from CSV
|
|
57354
57354
|
for (idx_t col = 0; col < options.num_cols; col++) {
|
|
57355
57355
|
const auto &val = best_header_row.GetValue(col, 0);
|
|
@@ -74221,7 +74221,7 @@ string Function::CallToString(const string &name, const vector<LogicalType> &arg
|
|
|
74221
74221
|
}
|
|
74222
74222
|
|
|
74223
74223
|
string Function::CallToString(const string &name, const vector<LogicalType> &arguments,
|
|
74224
|
-
const
|
|
74224
|
+
const named_parameter_type_map_t &named_parameters) {
|
|
74225
74225
|
vector<string> input_arguments;
|
|
74226
74226
|
input_arguments.reserve(arguments.size() + named_parameters.size());
|
|
74227
74227
|
for (auto &arg : arguments) {
|
|
@@ -79987,7 +79987,7 @@ bool ClampIndex(INDEX_TYPE &index, const INPUT_TYPE &value) {
|
|
|
79987
79987
|
}
|
|
79988
79988
|
index = length + index;
|
|
79989
79989
|
} else if (index > length) {
|
|
79990
|
-
|
|
79990
|
+
index = length;
|
|
79991
79991
|
}
|
|
79992
79992
|
return true;
|
|
79993
79993
|
}
|
|
@@ -89604,7 +89604,7 @@ public:
|
|
|
89604
89604
|
private:
|
|
89605
89605
|
//! Binds an arrow table
|
|
89606
89606
|
static unique_ptr<FunctionData> ArrowScanBind(ClientContext &context, vector<Value> &inputs,
|
|
89607
|
-
|
|
89607
|
+
named_parameter_map_t &named_parameters,
|
|
89608
89608
|
vector<LogicalType> &input_table_types,
|
|
89609
89609
|
vector<string> &input_table_names, vector<LogicalType> &return_types,
|
|
89610
89610
|
vector<string> &names);
|
|
@@ -89804,7 +89804,7 @@ LogicalType GetArrowLogicalType(ArrowSchema &schema,
|
|
|
89804
89804
|
}
|
|
89805
89805
|
|
|
89806
89806
|
unique_ptr<FunctionData> ArrowTableFunction::ArrowScanBind(ClientContext &context, vector<Value> &inputs,
|
|
89807
|
-
|
|
89807
|
+
named_parameter_map_t &named_parameters,
|
|
89808
89808
|
vector<LogicalType> &input_table_types,
|
|
89809
89809
|
vector<string> &input_table_names,
|
|
89810
89810
|
vector<LogicalType> &return_types, vector<string> &names) {
|
|
@@ -90808,7 +90808,7 @@ struct UnnestTableFunction {
|
|
|
90808
90808
|
namespace duckdb {
|
|
90809
90809
|
|
|
90810
90810
|
static unique_ptr<FunctionData> CheckpointBind(ClientContext &context, vector<Value> &inputs,
|
|
90811
|
-
|
|
90811
|
+
named_parameter_map_t &named_parameters,
|
|
90812
90812
|
vector<LogicalType> &input_table_types,
|
|
90813
90813
|
vector<string> &input_table_names, vector<LogicalType> &return_types,
|
|
90814
90814
|
vector<string> &names) {
|
|
@@ -91460,7 +91460,7 @@ struct GlobFunctionBindData : public TableFunctionData {
|
|
|
91460
91460
|
};
|
|
91461
91461
|
|
|
91462
91462
|
static unique_ptr<FunctionData> GlobFunctionBind(ClientContext &context, vector<Value> &inputs,
|
|
91463
|
-
|
|
91463
|
+
named_parameter_map_t &named_parameters,
|
|
91464
91464
|
vector<LogicalType> &input_table_types,
|
|
91465
91465
|
vector<string> &input_table_names, vector<LogicalType> &return_types,
|
|
91466
91466
|
vector<string> &names) {
|
|
@@ -91637,7 +91637,7 @@ struct PragmaDetailedProfilingOutputData : public TableFunctionData {
|
|
|
91637
91637
|
};
|
|
91638
91638
|
|
|
91639
91639
|
static unique_ptr<FunctionData> PragmaDetailedProfilingOutputBind(ClientContext &context, vector<Value> &inputs,
|
|
91640
|
-
|
|
91640
|
+
named_parameter_map_t &named_parameters,
|
|
91641
91641
|
vector<LogicalType> &input_table_types,
|
|
91642
91642
|
vector<string> &input_table_names,
|
|
91643
91643
|
vector<LogicalType> &return_types,
|
|
@@ -91813,12 +91813,10 @@ struct PragmaLastProfilingOutputData : public TableFunctionData {
|
|
|
91813
91813
|
vector<LogicalType> types;
|
|
91814
91814
|
};
|
|
91815
91815
|
|
|
91816
|
-
static unique_ptr<FunctionData>
|
|
91817
|
-
|
|
91818
|
-
|
|
91819
|
-
|
|
91820
|
-
vector<LogicalType> &return_types,
|
|
91821
|
-
vector<string> &names) {
|
|
91816
|
+
static unique_ptr<FunctionData>
|
|
91817
|
+
PragmaLastProfilingOutputBind(ClientContext &context, vector<Value> &inputs, named_parameter_map_t &named_parameters,
|
|
91818
|
+
vector<LogicalType> &input_table_types, vector<string> &input_table_names,
|
|
91819
|
+
vector<LogicalType> &return_types, vector<string> &names) {
|
|
91822
91820
|
names.emplace_back("OPERATOR_ID");
|
|
91823
91821
|
return_types.emplace_back(LogicalType::INTEGER);
|
|
91824
91822
|
|
|
@@ -91932,7 +91930,7 @@ struct RangeFunctionBindData : public TableFunctionData {
|
|
|
91932
91930
|
|
|
91933
91931
|
template <bool GENERATE_SERIES>
|
|
91934
91932
|
static unique_ptr<FunctionData>
|
|
91935
|
-
RangeFunctionBind(ClientContext &context, vector<Value> &inputs,
|
|
91933
|
+
RangeFunctionBind(ClientContext &context, vector<Value> &inputs, named_parameter_map_t &named_parameters,
|
|
91936
91934
|
vector<LogicalType> &input_table_types, vector<string> &input_table_names,
|
|
91937
91935
|
vector<LogicalType> &return_types, vector<string> &names) {
|
|
91938
91936
|
auto result = make_unique<RangeFunctionBindData>();
|
|
@@ -92043,7 +92041,7 @@ struct RangeDateTimeBindData : public TableFunctionData {
|
|
|
92043
92041
|
|
|
92044
92042
|
template <bool GENERATE_SERIES>
|
|
92045
92043
|
static unique_ptr<FunctionData>
|
|
92046
|
-
RangeDateTimeBind(ClientContext &context, vector<Value> &inputs,
|
|
92044
|
+
RangeDateTimeBind(ClientContext &context, vector<Value> &inputs, named_parameter_map_t &named_parameters,
|
|
92047
92045
|
vector<LogicalType> &input_table_types, vector<string> &input_table_names,
|
|
92048
92046
|
vector<LogicalType> &return_types, vector<string> &names) {
|
|
92049
92047
|
auto result = make_unique<RangeDateTimeBindData>();
|
|
@@ -92182,7 +92180,7 @@ void BuiltinFunctions::RegisterTableFunctions() {
|
|
|
92182
92180
|
namespace duckdb {
|
|
92183
92181
|
|
|
92184
92182
|
static unique_ptr<FunctionData> ReadCSVBind(ClientContext &context, vector<Value> &inputs,
|
|
92185
|
-
|
|
92183
|
+
named_parameter_map_t &named_parameters,
|
|
92186
92184
|
vector<LogicalType> &input_table_types, vector<string> &input_table_names,
|
|
92187
92185
|
vector<LogicalType> &return_types, vector<string> &names) {
|
|
92188
92186
|
auto &config = DBConfig::GetConfig(context);
|
|
@@ -92201,22 +92199,23 @@ static unique_ptr<FunctionData> ReadCSVBind(ClientContext &context, vector<Value
|
|
|
92201
92199
|
}
|
|
92202
92200
|
|
|
92203
92201
|
for (auto &kv : named_parameters) {
|
|
92204
|
-
|
|
92202
|
+
auto loption = StringUtil::Lower(kv.first);
|
|
92203
|
+
if (loption == "auto_detect") {
|
|
92205
92204
|
options.auto_detect = BooleanValue::Get(kv.second);
|
|
92206
|
-
} else if (
|
|
92205
|
+
} else if (loption == "sep" || loption == "delim") {
|
|
92207
92206
|
options.SetDelimiter(StringValue::Get(kv.second));
|
|
92208
|
-
} else if (
|
|
92207
|
+
} else if (loption == "header") {
|
|
92209
92208
|
options.header = BooleanValue::Get(kv.second);
|
|
92210
92209
|
options.has_header = true;
|
|
92211
|
-
} else if (
|
|
92210
|
+
} else if (loption == "quote") {
|
|
92212
92211
|
options.quote = StringValue::Get(kv.second);
|
|
92213
92212
|
options.has_quote = true;
|
|
92214
|
-
} else if (
|
|
92213
|
+
} else if (loption == "escape") {
|
|
92215
92214
|
options.escape = StringValue::Get(kv.second);
|
|
92216
92215
|
options.has_escape = true;
|
|
92217
|
-
} else if (
|
|
92216
|
+
} else if (loption == "nullstr") {
|
|
92218
92217
|
options.null_str = StringValue::Get(kv.second);
|
|
92219
|
-
} else if (
|
|
92218
|
+
} else if (loption == "sample_size") {
|
|
92220
92219
|
int64_t sample_size = kv.second.GetValue<int64_t>();
|
|
92221
92220
|
if (sample_size < 1 && sample_size != -1) {
|
|
92222
92221
|
throw BinderException("Unsupported parameter for SAMPLE_SIZE: cannot be smaller than 1");
|
|
@@ -92231,7 +92230,7 @@ static unique_ptr<FunctionData> ReadCSVBind(ClientContext &context, vector<Value
|
|
|
92231
92230
|
options.sample_chunk_size = STANDARD_VECTOR_SIZE;
|
|
92232
92231
|
options.sample_chunks = sample_size / STANDARD_VECTOR_SIZE;
|
|
92233
92232
|
}
|
|
92234
|
-
} else if (
|
|
92233
|
+
} else if (loption == "sample_chunk_size") {
|
|
92235
92234
|
options.sample_chunk_size = kv.second.GetValue<int64_t>();
|
|
92236
92235
|
if (options.sample_chunk_size > STANDARD_VECTOR_SIZE) {
|
|
92237
92236
|
throw BinderException(
|
|
@@ -92240,14 +92239,14 @@ static unique_ptr<FunctionData> ReadCSVBind(ClientContext &context, vector<Value
|
|
|
92240
92239
|
} else if (options.sample_chunk_size < 1) {
|
|
92241
92240
|
throw BinderException("Unsupported parameter for SAMPLE_CHUNK_SIZE: cannot be smaller than 1");
|
|
92242
92241
|
}
|
|
92243
|
-
} else if (
|
|
92242
|
+
} else if (loption == "sample_chunks") {
|
|
92244
92243
|
options.sample_chunks = kv.second.GetValue<int64_t>();
|
|
92245
92244
|
if (options.sample_chunks < 1) {
|
|
92246
92245
|
throw BinderException("Unsupported parameter for SAMPLE_CHUNKS: cannot be smaller than 1");
|
|
92247
92246
|
}
|
|
92248
|
-
} else if (
|
|
92247
|
+
} else if (loption == "all_varchar") {
|
|
92249
92248
|
options.all_varchar = BooleanValue::Get(kv.second);
|
|
92250
|
-
} else if (
|
|
92249
|
+
} else if (loption == "dateformat") {
|
|
92251
92250
|
options.has_format[LogicalTypeId::DATE] = true;
|
|
92252
92251
|
auto &date_format = options.date_format[LogicalTypeId::DATE];
|
|
92253
92252
|
date_format.format_specifier = StringValue::Get(kv.second);
|
|
@@ -92255,7 +92254,7 @@ static unique_ptr<FunctionData> ReadCSVBind(ClientContext &context, vector<Value
|
|
|
92255
92254
|
if (!error.empty()) {
|
|
92256
92255
|
throw InvalidInputException("Could not parse DATEFORMAT: %s", error.c_str());
|
|
92257
92256
|
}
|
|
92258
|
-
} else if (
|
|
92257
|
+
} else if (loption == "timestampformat") {
|
|
92259
92258
|
options.has_format[LogicalTypeId::TIMESTAMP] = true;
|
|
92260
92259
|
auto ×tamp_format = options.date_format[LogicalTypeId::TIMESTAMP];
|
|
92261
92260
|
timestamp_format.format_specifier = StringValue::Get(kv.second);
|
|
@@ -92263,9 +92262,9 @@ static unique_ptr<FunctionData> ReadCSVBind(ClientContext &context, vector<Value
|
|
|
92263
92262
|
if (!error.empty()) {
|
|
92264
92263
|
throw InvalidInputException("Could not parse TIMESTAMPFORMAT: %s", error.c_str());
|
|
92265
92264
|
}
|
|
92266
|
-
} else if (
|
|
92265
|
+
} else if (loption == "normalize_names") {
|
|
92267
92266
|
options.normalize_names = BooleanValue::Get(kv.second);
|
|
92268
|
-
} else if (
|
|
92267
|
+
} else if (loption == "columns") {
|
|
92269
92268
|
auto &child_type = kv.second.type();
|
|
92270
92269
|
if (child_type.id() != LogicalTypeId::STRUCT) {
|
|
92271
92270
|
throw BinderException("read_csv columns requires a a struct as input");
|
|
@@ -92284,12 +92283,14 @@ static unique_ptr<FunctionData> ReadCSVBind(ClientContext &context, vector<Value
|
|
|
92284
92283
|
if (names.empty()) {
|
|
92285
92284
|
throw BinderException("read_csv requires at least a single column as input!");
|
|
92286
92285
|
}
|
|
92287
|
-
} else if (
|
|
92286
|
+
} else if (loption == "compression") {
|
|
92288
92287
|
options.compression = FileCompressionTypeFromString(StringValue::Get(kv.second));
|
|
92289
|
-
} else if (
|
|
92288
|
+
} else if (loption == "filename") {
|
|
92290
92289
|
result->include_file_name = BooleanValue::Get(kv.second);
|
|
92291
|
-
} else if (
|
|
92290
|
+
} else if (loption == "skip") {
|
|
92292
92291
|
options.skip_rows = kv.second.GetValue<int64_t>();
|
|
92292
|
+
} else {
|
|
92293
|
+
throw InternalException("Unrecognized parameter %s", kv.first);
|
|
92293
92294
|
}
|
|
92294
92295
|
}
|
|
92295
92296
|
if (!options.auto_detect && return_types.empty()) {
|
|
@@ -92343,7 +92344,7 @@ static unique_ptr<FunctionOperatorData> ReadCSVInit(ClientContext &context, cons
|
|
|
92343
92344
|
}
|
|
92344
92345
|
|
|
92345
92346
|
static unique_ptr<FunctionData> ReadCSVAutoBind(ClientContext &context, vector<Value> &inputs,
|
|
92346
|
-
|
|
92347
|
+
named_parameter_map_t &named_parameters,
|
|
92347
92348
|
vector<LogicalType> &input_table_types,
|
|
92348
92349
|
vector<string> &input_table_names, vector<LogicalType> &return_types,
|
|
92349
92350
|
vector<string> &names) {
|
|
@@ -92468,7 +92469,7 @@ struct RepeatOperatorData : public FunctionOperatorData {
|
|
|
92468
92469
|
};
|
|
92469
92470
|
|
|
92470
92471
|
static unique_ptr<FunctionData> RepeatBind(ClientContext &context, vector<Value> &inputs,
|
|
92471
|
-
|
|
92472
|
+
named_parameter_map_t &named_parameters,
|
|
92472
92473
|
vector<LogicalType> &input_table_types, vector<string> &input_table_names,
|
|
92473
92474
|
vector<LogicalType> &return_types, vector<string> &names) {
|
|
92474
92475
|
// the repeat function returns the type of the first argument
|
|
@@ -92515,7 +92516,7 @@ void RepeatTableFunction::RegisterFunction(BuiltinFunctions &set) {
|
|
|
92515
92516
|
namespace duckdb {
|
|
92516
92517
|
|
|
92517
92518
|
static unique_ptr<FunctionData> SummaryFunctionBind(ClientContext &context, vector<Value> &inputs,
|
|
92518
|
-
|
|
92519
|
+
named_parameter_map_t &named_parameters,
|
|
92519
92520
|
vector<LogicalType> &input_table_types,
|
|
92520
92521
|
vector<string> &input_table_names,
|
|
92521
92522
|
vector<LogicalType> &return_types, vector<string> &names) {
|
|
@@ -92583,7 +92584,7 @@ struct DuckDBColumnsData : public FunctionOperatorData {
|
|
|
92583
92584
|
};
|
|
92584
92585
|
|
|
92585
92586
|
static unique_ptr<FunctionData> DuckDBColumnsBind(ClientContext &context, vector<Value> &inputs,
|
|
92586
|
-
|
|
92587
|
+
named_parameter_map_t &named_parameters,
|
|
92587
92588
|
vector<LogicalType> &input_table_types,
|
|
92588
92589
|
vector<string> &input_table_names, vector<LogicalType> &return_types,
|
|
92589
92590
|
vector<string> &names) {
|
|
@@ -92918,7 +92919,7 @@ struct DuckDBConstraintsData : public FunctionOperatorData {
|
|
|
92918
92919
|
};
|
|
92919
92920
|
|
|
92920
92921
|
static unique_ptr<FunctionData> DuckDBConstraintsBind(ClientContext &context, vector<Value> &inputs,
|
|
92921
|
-
|
|
92922
|
+
named_parameter_map_t &named_parameters,
|
|
92922
92923
|
vector<LogicalType> &input_table_types,
|
|
92923
92924
|
vector<string> &input_table_names,
|
|
92924
92925
|
vector<LogicalType> &return_types, vector<string> &names) {
|
|
@@ -93122,7 +93123,7 @@ struct DuckDBDependenciesData : public FunctionOperatorData {
|
|
|
93122
93123
|
};
|
|
93123
93124
|
|
|
93124
93125
|
static unique_ptr<FunctionData> DuckDBDependenciesBind(ClientContext &context, vector<Value> &inputs,
|
|
93125
|
-
|
|
93126
|
+
named_parameter_map_t &named_parameters,
|
|
93126
93127
|
vector<LogicalType> &input_table_types,
|
|
93127
93128
|
vector<string> &input_table_names,
|
|
93128
93129
|
vector<LogicalType> &return_types, vector<string> &names) {
|
|
@@ -93245,7 +93246,7 @@ struct DuckDBFunctionsData : public FunctionOperatorData {
|
|
|
93245
93246
|
};
|
|
93246
93247
|
|
|
93247
93248
|
static unique_ptr<FunctionData> DuckDBFunctionsBind(ClientContext &context, vector<Value> &inputs,
|
|
93248
|
-
|
|
93249
|
+
named_parameter_map_t &named_parameters,
|
|
93249
93250
|
vector<LogicalType> &input_table_types,
|
|
93250
93251
|
vector<string> &input_table_names,
|
|
93251
93252
|
vector<LogicalType> &return_types, vector<string> &names) {
|
|
@@ -93656,7 +93657,7 @@ struct DuckDBIndexesData : public FunctionOperatorData {
|
|
|
93656
93657
|
};
|
|
93657
93658
|
|
|
93658
93659
|
static unique_ptr<FunctionData> DuckDBIndexesBind(ClientContext &context, vector<Value> &inputs,
|
|
93659
|
-
|
|
93660
|
+
named_parameter_map_t &named_parameters,
|
|
93660
93661
|
vector<LogicalType> &input_table_types,
|
|
93661
93662
|
vector<string> &input_table_names, vector<LogicalType> &return_types,
|
|
93662
93663
|
vector<string> &names) {
|
|
@@ -93776,7 +93777,7 @@ struct DuckDBKeywordsData : public FunctionOperatorData {
|
|
|
93776
93777
|
};
|
|
93777
93778
|
|
|
93778
93779
|
static unique_ptr<FunctionData> DuckDBKeywordsBind(ClientContext &context, vector<Value> &inputs,
|
|
93779
|
-
|
|
93780
|
+
named_parameter_map_t &named_parameters,
|
|
93780
93781
|
vector<LogicalType> &input_table_types,
|
|
93781
93782
|
vector<string> &input_table_names, vector<LogicalType> &return_types,
|
|
93782
93783
|
vector<string> &names) {
|
|
@@ -93861,7 +93862,7 @@ struct DuckDBSchemasData : public FunctionOperatorData {
|
|
|
93861
93862
|
};
|
|
93862
93863
|
|
|
93863
93864
|
static unique_ptr<FunctionData> DuckDBSchemasBind(ClientContext &context, vector<Value> &inputs,
|
|
93864
|
-
|
|
93865
|
+
named_parameter_map_t &named_parameters,
|
|
93865
93866
|
vector<LogicalType> &input_table_types,
|
|
93866
93867
|
vector<string> &input_table_names, vector<LogicalType> &return_types,
|
|
93867
93868
|
vector<string> &names) {
|
|
@@ -93946,7 +93947,7 @@ struct DuckDBSequencesData : public FunctionOperatorData {
|
|
|
93946
93947
|
};
|
|
93947
93948
|
|
|
93948
93949
|
static unique_ptr<FunctionData> DuckDBSequencesBind(ClientContext &context, vector<Value> &inputs,
|
|
93949
|
-
|
|
93950
|
+
named_parameter_map_t &named_parameters,
|
|
93950
93951
|
vector<LogicalType> &input_table_types,
|
|
93951
93952
|
vector<string> &input_table_names,
|
|
93952
93953
|
vector<LogicalType> &return_types, vector<string> &names) {
|
|
@@ -94081,7 +94082,7 @@ struct DuckDBSettingsData : public FunctionOperatorData {
|
|
|
94081
94082
|
};
|
|
94082
94083
|
|
|
94083
94084
|
static unique_ptr<FunctionData> DuckDBSettingsBind(ClientContext &context, vector<Value> &inputs,
|
|
94084
|
-
|
|
94085
|
+
named_parameter_map_t &named_parameters,
|
|
94085
94086
|
vector<LogicalType> &input_table_types,
|
|
94086
94087
|
vector<string> &input_table_names, vector<LogicalType> &return_types,
|
|
94087
94088
|
vector<string> &names) {
|
|
@@ -94190,7 +94191,7 @@ struct DuckDBTablesData : public FunctionOperatorData {
|
|
|
94190
94191
|
};
|
|
94191
94192
|
|
|
94192
94193
|
static unique_ptr<FunctionData> DuckDBTablesBind(ClientContext &context, vector<Value> &inputs,
|
|
94193
|
-
|
|
94194
|
+
named_parameter_map_t &named_parameters,
|
|
94194
94195
|
vector<LogicalType> &input_table_types,
|
|
94195
94196
|
vector<string> &input_table_names, vector<LogicalType> &return_types,
|
|
94196
94197
|
vector<string> &names) {
|
|
@@ -94343,7 +94344,7 @@ struct DuckDBTypesData : public FunctionOperatorData {
|
|
|
94343
94344
|
};
|
|
94344
94345
|
|
|
94345
94346
|
static unique_ptr<FunctionData> DuckDBTypesBind(ClientContext &context, vector<Value> &inputs,
|
|
94346
|
-
|
|
94347
|
+
named_parameter_map_t &named_parameters,
|
|
94347
94348
|
vector<LogicalType> &input_table_types,
|
|
94348
94349
|
vector<string> &input_table_names, vector<LogicalType> &return_types,
|
|
94349
94350
|
vector<string> &names) {
|
|
@@ -94482,7 +94483,7 @@ struct DuckDBViewsData : public FunctionOperatorData {
|
|
|
94482
94483
|
};
|
|
94483
94484
|
|
|
94484
94485
|
static unique_ptr<FunctionData> DuckDBViewsBind(ClientContext &context, vector<Value> &inputs,
|
|
94485
|
-
|
|
94486
|
+
named_parameter_map_t &named_parameters,
|
|
94486
94487
|
vector<LogicalType> &input_table_types,
|
|
94487
94488
|
vector<string> &input_table_names, vector<LogicalType> &return_types,
|
|
94488
94489
|
vector<string> &names) {
|
|
@@ -94593,7 +94594,7 @@ struct PragmaCollateData : public FunctionOperatorData {
|
|
|
94593
94594
|
};
|
|
94594
94595
|
|
|
94595
94596
|
static unique_ptr<FunctionData> PragmaCollateBind(ClientContext &context, vector<Value> &inputs,
|
|
94596
|
-
|
|
94597
|
+
named_parameter_map_t &named_parameters,
|
|
94597
94598
|
vector<LogicalType> &input_table_types,
|
|
94598
94599
|
vector<string> &input_table_names, vector<LogicalType> &return_types,
|
|
94599
94600
|
vector<string> &names) {
|
|
@@ -94653,7 +94654,7 @@ struct PragmaDatabaseListData : public FunctionOperatorData {
|
|
|
94653
94654
|
};
|
|
94654
94655
|
|
|
94655
94656
|
static unique_ptr<FunctionData> PragmaDatabaseListBind(ClientContext &context, vector<Value> &inputs,
|
|
94656
|
-
|
|
94657
|
+
named_parameter_map_t &named_parameters,
|
|
94657
94658
|
vector<LogicalType> &input_table_types,
|
|
94658
94659
|
vector<string> &input_table_names,
|
|
94659
94660
|
vector<LogicalType> &return_types, vector<string> &names) {
|
|
@@ -94714,7 +94715,7 @@ struct PragmaDatabaseSizeData : public FunctionOperatorData {
|
|
|
94714
94715
|
};
|
|
94715
94716
|
|
|
94716
94717
|
static unique_ptr<FunctionData> PragmaDatabaseSizeBind(ClientContext &context, vector<Value> &inputs,
|
|
94717
|
-
|
|
94718
|
+
named_parameter_map_t &named_parameters,
|
|
94718
94719
|
vector<LogicalType> &input_table_types,
|
|
94719
94720
|
vector<string> &input_table_names,
|
|
94720
94721
|
vector<LogicalType> &return_types, vector<string> &names) {
|
|
@@ -94818,7 +94819,7 @@ struct PragmaFunctionsData : public FunctionOperatorData {
|
|
|
94818
94819
|
};
|
|
94819
94820
|
|
|
94820
94821
|
static unique_ptr<FunctionData> PragmaFunctionsBind(ClientContext &context, vector<Value> &inputs,
|
|
94821
|
-
|
|
94822
|
+
named_parameter_map_t &named_parameters,
|
|
94822
94823
|
vector<LogicalType> &input_table_types,
|
|
94823
94824
|
vector<string> &input_table_names,
|
|
94824
94825
|
vector<LogicalType> &return_types, vector<string> &names) {
|
|
@@ -94954,7 +94955,7 @@ struct PragmaStorageOperatorData : public FunctionOperatorData {
|
|
|
94954
94955
|
};
|
|
94955
94956
|
|
|
94956
94957
|
static unique_ptr<FunctionData> PragmaStorageInfoBind(ClientContext &context, vector<Value> &inputs,
|
|
94957
|
-
|
|
94958
|
+
named_parameter_map_t &named_parameters,
|
|
94958
94959
|
vector<LogicalType> &input_table_types,
|
|
94959
94960
|
vector<string> &input_table_names,
|
|
94960
94961
|
vector<LogicalType> &return_types, vector<string> &names) {
|
|
@@ -95081,7 +95082,7 @@ struct PragmaTableOperatorData : public FunctionOperatorData {
|
|
|
95081
95082
|
};
|
|
95082
95083
|
|
|
95083
95084
|
static unique_ptr<FunctionData> PragmaTableInfoBind(ClientContext &context, vector<Value> &inputs,
|
|
95084
|
-
|
|
95085
|
+
named_parameter_map_t &named_parameters,
|
|
95085
95086
|
vector<LogicalType> &input_table_types,
|
|
95086
95087
|
vector<string> &input_table_names,
|
|
95087
95088
|
vector<LogicalType> &return_types, vector<string> &names) {
|
|
@@ -95401,7 +95402,7 @@ static vector<TestType> GetTestTypes() {
|
|
|
95401
95402
|
}
|
|
95402
95403
|
|
|
95403
95404
|
static unique_ptr<FunctionData> TestAllTypesBind(ClientContext &context, vector<Value> &inputs,
|
|
95404
|
-
|
|
95405
|
+
named_parameter_map_t &named_parameters,
|
|
95405
95406
|
vector<LogicalType> &input_table_types,
|
|
95406
95407
|
vector<string> &input_table_names, vector<LogicalType> &return_types,
|
|
95407
95408
|
vector<string> &names) {
|
|
@@ -95961,7 +95962,7 @@ struct UnnestOperatorData : public FunctionOperatorData {
|
|
|
95961
95962
|
};
|
|
95962
95963
|
|
|
95963
95964
|
static unique_ptr<FunctionData> UnnestBind(ClientContext &context, vector<Value> &inputs,
|
|
95964
|
-
|
|
95965
|
+
named_parameter_map_t &named_parameters,
|
|
95965
95966
|
vector<LogicalType> &input_table_types, vector<string> &input_table_names,
|
|
95966
95967
|
vector<LogicalType> &return_types, vector<string> &names) {
|
|
95967
95968
|
return_types.push_back(ListType::GetChildType(inputs[0].type()));
|
|
@@ -96006,7 +96007,7 @@ struct PragmaVersionData : public FunctionOperatorData {
|
|
|
96006
96007
|
};
|
|
96007
96008
|
|
|
96008
96009
|
static unique_ptr<FunctionData> PragmaVersionBind(ClientContext &context, vector<Value> &inputs,
|
|
96009
|
-
|
|
96010
|
+
named_parameter_map_t &named_parameters,
|
|
96010
96011
|
vector<LogicalType> &input_table_types,
|
|
96011
96012
|
vector<string> &input_table_names, vector<LogicalType> &return_types,
|
|
96012
96013
|
vector<string> &names) {
|
|
@@ -98748,7 +98749,7 @@ vector<unique_ptr<SQLStatement>> ClientContext::ParseStatements(const string &qu
|
|
|
98748
98749
|
}
|
|
98749
98750
|
|
|
98750
98751
|
vector<unique_ptr<SQLStatement>> ClientContext::ParseStatementsInternal(ClientContextLock &lock, const string &query) {
|
|
98751
|
-
Parser parser;
|
|
98752
|
+
Parser parser(GetParserOptions());
|
|
98752
98753
|
parser.ParseQuery(query);
|
|
98753
98754
|
|
|
98754
98755
|
PragmaHandler handler(*this);
|
|
@@ -99485,6 +99486,12 @@ bool ClientContext::TryGetCurrentSetting(const std::string &key, Value &result)
|
|
|
99485
99486
|
return true;
|
|
99486
99487
|
}
|
|
99487
99488
|
|
|
99489
|
+
ParserOptions ClientContext::GetParserOptions() {
|
|
99490
|
+
ParserOptions options;
|
|
99491
|
+
options.preserve_identifier_case = ClientConfig::GetConfig(*this).preserve_identifier_case;
|
|
99492
|
+
return options;
|
|
99493
|
+
}
|
|
99494
|
+
|
|
99488
99495
|
} // namespace duckdb
|
|
99489
99496
|
|
|
99490
99497
|
|
|
@@ -99678,6 +99685,15 @@ struct PerfectHashThresholdSetting {
|
|
|
99678
99685
|
static Value GetSetting(ClientContext &context);
|
|
99679
99686
|
};
|
|
99680
99687
|
|
|
99688
|
+
struct PreserveIdentifierCase {
|
|
99689
|
+
static constexpr const char *Name = "preserve_identifier_case";
|
|
99690
|
+
static constexpr const char *Description =
|
|
99691
|
+
"Whether or not to preserve the identifier case, instead of always lowercasing all non-quoted identifiers";
|
|
99692
|
+
static constexpr const LogicalTypeId InputType = LogicalTypeId::BOOLEAN;
|
|
99693
|
+
static void SetLocal(ClientContext &context, const Value ¶meter);
|
|
99694
|
+
static Value GetSetting(ClientContext &context);
|
|
99695
|
+
};
|
|
99696
|
+
|
|
99681
99697
|
struct ProfilerHistorySize {
|
|
99682
99698
|
static constexpr const char *Name = "profiler_history_size";
|
|
99683
99699
|
static constexpr const char *Description = "Sets the profiler history size";
|
|
@@ -99789,6 +99805,7 @@ static ConfigurationOption internal_options[] = {DUCKDB_GLOBAL(AccessModeSetting
|
|
|
99789
99805
|
DUCKDB_GLOBAL_ALIAS("memory_limit", MaximumMemorySetting),
|
|
99790
99806
|
DUCKDB_GLOBAL_ALIAS("null_order", DefaultNullOrderSetting),
|
|
99791
99807
|
DUCKDB_LOCAL(PerfectHashThresholdSetting),
|
|
99808
|
+
DUCKDB_LOCAL(PreserveIdentifierCase),
|
|
99792
99809
|
DUCKDB_LOCAL(ProfilerHistorySize),
|
|
99793
99810
|
DUCKDB_LOCAL(ProfileOutputSetting),
|
|
99794
99811
|
DUCKDB_LOCAL(ProfilingModeSetting),
|
|
@@ -99828,8 +99845,10 @@ ConfigurationOption *DBConfig::GetOptionByIndex(idx_t target_index) {
|
|
|
99828
99845
|
}
|
|
99829
99846
|
|
|
99830
99847
|
ConfigurationOption *DBConfig::GetOptionByName(const string &name) {
|
|
99848
|
+
auto lname = StringUtil::Lower(name);
|
|
99831
99849
|
for (idx_t index = 0; internal_options[index].name; index++) {
|
|
99832
|
-
|
|
99850
|
+
D_ASSERT(StringUtil::Lower(internal_options[index].name) == string(internal_options[index].name));
|
|
99851
|
+
if (internal_options[index].name == lname) {
|
|
99833
99852
|
return internal_options + index;
|
|
99834
99853
|
}
|
|
99835
99854
|
}
|
|
@@ -100032,15 +100051,14 @@ namespace duckdb {
|
|
|
100032
100051
|
class TableFunctionRelation : public Relation {
|
|
100033
100052
|
public:
|
|
100034
100053
|
TableFunctionRelation(ClientContext &context, string name, vector<Value> parameters,
|
|
100035
|
-
|
|
100036
|
-
shared_ptr<Relation> input_relation_p = nullptr);
|
|
100054
|
+
named_parameter_map_t named_parameters, shared_ptr<Relation> input_relation_p = nullptr);
|
|
100037
100055
|
|
|
100038
100056
|
TableFunctionRelation(ClientContext &context, string name, vector<Value> parameters,
|
|
100039
100057
|
shared_ptr<Relation> input_relation_p = nullptr);
|
|
100040
100058
|
|
|
100041
100059
|
string name;
|
|
100042
100060
|
vector<Value> parameters;
|
|
100043
|
-
|
|
100061
|
+
named_parameter_map_t named_parameters;
|
|
100044
100062
|
vector<ColumnDefinition> columns;
|
|
100045
100063
|
shared_ptr<Relation> input_relation;
|
|
100046
100064
|
|
|
@@ -100317,12 +100335,12 @@ shared_ptr<Relation> Connection::View(const string &schema_name, const string &t
|
|
|
100317
100335
|
|
|
100318
100336
|
shared_ptr<Relation> Connection::TableFunction(const string &fname) {
|
|
100319
100337
|
vector<Value> values;
|
|
100320
|
-
|
|
100338
|
+
named_parameter_map_t named_parameters;
|
|
100321
100339
|
return TableFunction(fname, values, named_parameters);
|
|
100322
100340
|
}
|
|
100323
100341
|
|
|
100324
100342
|
shared_ptr<Relation> Connection::TableFunction(const string &fname, const vector<Value> &values,
|
|
100325
|
-
const
|
|
100343
|
+
const named_parameter_map_t &named_parameters) {
|
|
100326
100344
|
return make_shared<TableFunctionRelation>(*context, fname, values, named_parameters);
|
|
100327
100345
|
}
|
|
100328
100346
|
|
|
@@ -100365,7 +100383,7 @@ shared_ptr<Relation> Connection::ReadCSV(const string &csv_file, const vector<st
|
|
|
100365
100383
|
// parse columns
|
|
100366
100384
|
vector<ColumnDefinition> column_list;
|
|
100367
100385
|
for (auto &column : columns) {
|
|
100368
|
-
auto col_list = Parser::ParseColumnList(column);
|
|
100386
|
+
auto col_list = Parser::ParseColumnList(column, context->GetParserOptions());
|
|
100369
100387
|
if (col_list.size() != 1) {
|
|
100370
100388
|
throw ParserException("Expected a single column definition");
|
|
100371
100389
|
}
|
|
@@ -110909,7 +110927,7 @@ QueryRelation::QueryRelation(ClientContext &context, string query, string alias)
|
|
|
110909
110927
|
}
|
|
110910
110928
|
|
|
110911
110929
|
unique_ptr<SelectStatement> QueryRelation::GetSelectStatement() {
|
|
110912
|
-
Parser parser;
|
|
110930
|
+
Parser parser(context.GetParserOptions());
|
|
110913
110931
|
parser.ParseQuery(query);
|
|
110914
110932
|
if (parser.statements.size() != 1) {
|
|
110915
110933
|
throw ParserException("Expected a single SELECT statement");
|
|
@@ -111174,7 +111192,7 @@ string SubqueryRelation::ToString(idx_t depth) {
|
|
|
111174
111192
|
namespace duckdb {
|
|
111175
111193
|
|
|
111176
111194
|
TableFunctionRelation::TableFunctionRelation(ClientContext &context, string name_p, vector<Value> parameters_p,
|
|
111177
|
-
|
|
111195
|
+
named_parameter_map_t named_parameters,
|
|
111178
111196
|
shared_ptr<Relation> input_relation_p)
|
|
111179
111197
|
: Relation(context, RelationType::TABLE_FUNCTION_RELATION), name(move(name_p)), parameters(move(parameters_p)),
|
|
111180
111198
|
named_parameters(move(named_parameters)), input_relation(move(input_relation_p)) {
|
|
@@ -111291,6 +111309,7 @@ public:
|
|
|
111291
111309
|
|
|
111292
111310
|
|
|
111293
111311
|
|
|
111312
|
+
|
|
111294
111313
|
namespace duckdb {
|
|
111295
111314
|
|
|
111296
111315
|
TableRelation::TableRelation(ClientContext &context, unique_ptr<TableDescription> description)
|
|
@@ -111323,9 +111342,9 @@ string TableRelation::ToString(idx_t depth) {
|
|
|
111323
111342
|
return RenderWhitespace(depth) + "Scan Table [" + description->table + "]";
|
|
111324
111343
|
}
|
|
111325
111344
|
|
|
111326
|
-
static unique_ptr<ParsedExpression> ParseCondition(const string &condition) {
|
|
111345
|
+
static unique_ptr<ParsedExpression> ParseCondition(ClientContext &context, const string &condition) {
|
|
111327
111346
|
if (!condition.empty()) {
|
|
111328
|
-
auto expression_list = Parser::ParseExpressionList(condition);
|
|
111347
|
+
auto expression_list = Parser::ParseExpressionList(condition, context.GetParserOptions());
|
|
111329
111348
|
if (expression_list.size() != 1) {
|
|
111330
111349
|
throw ParserException("Expected a single expression as filter condition");
|
|
111331
111350
|
}
|
|
@@ -111338,15 +111357,15 @@ static unique_ptr<ParsedExpression> ParseCondition(const string &condition) {
|
|
|
111338
111357
|
void TableRelation::Update(const string &update_list, const string &condition) {
|
|
111339
111358
|
vector<string> update_columns;
|
|
111340
111359
|
vector<unique_ptr<ParsedExpression>> expressions;
|
|
111341
|
-
auto cond = ParseCondition(condition);
|
|
111342
|
-
Parser::ParseUpdateList(update_list, update_columns, expressions);
|
|
111360
|
+
auto cond = ParseCondition(context, condition);
|
|
111361
|
+
Parser::ParseUpdateList(update_list, update_columns, expressions, context.GetParserOptions());
|
|
111343
111362
|
auto update = make_shared<UpdateRelation>(context, move(cond), description->schema, description->table,
|
|
111344
111363
|
move(update_columns), move(expressions));
|
|
111345
111364
|
update->Execute();
|
|
111346
111365
|
}
|
|
111347
111366
|
|
|
111348
111367
|
void TableRelation::Delete(const string &condition) {
|
|
111349
|
-
auto cond = ParseCondition(condition);
|
|
111368
|
+
auto cond = ParseCondition(context, condition);
|
|
111350
111369
|
auto del = make_shared<DeleteRelation>(context, move(cond), description->schema, description->table);
|
|
111351
111370
|
del->Execute();
|
|
111352
111371
|
}
|
|
@@ -111459,7 +111478,7 @@ ValueRelation::ValueRelation(ClientContext &context, const vector<vector<Value>>
|
|
|
111459
111478
|
|
|
111460
111479
|
ValueRelation::ValueRelation(ClientContext &context, const string &values_list, vector<string> names_p, string alias_p)
|
|
111461
111480
|
: Relation(context, RelationType::VALUE_LIST_RELATION), names(move(names_p)), alias(move(alias_p)) {
|
|
111462
|
-
this->expressions = Parser::ParseValuesList(values_list);
|
|
111481
|
+
this->expressions = Parser::ParseValuesList(values_list, context.GetParserOptions());
|
|
111463
111482
|
context.TryBindRelation(*this, this->columns);
|
|
111464
111483
|
}
|
|
111465
111484
|
|
|
@@ -111694,7 +111713,7 @@ shared_ptr<Relation> Relation::Project(const string &expression, const string &a
|
|
|
111694
111713
|
}
|
|
111695
111714
|
|
|
111696
111715
|
shared_ptr<Relation> Relation::Project(const string &select_list, const vector<string> &aliases) {
|
|
111697
|
-
auto expressions = Parser::ParseExpressionList(select_list);
|
|
111716
|
+
auto expressions = Parser::ParseExpressionList(select_list, context.GetParserOptions());
|
|
111698
111717
|
return make_shared<ProjectionRelation>(shared_from_this(), move(expressions), aliases);
|
|
111699
111718
|
}
|
|
111700
111719
|
|
|
@@ -111703,13 +111722,14 @@ shared_ptr<Relation> Relation::Project(const vector<string> &expressions) {
|
|
|
111703
111722
|
return Project(expressions, aliases);
|
|
111704
111723
|
}
|
|
111705
111724
|
|
|
111706
|
-
static vector<unique_ptr<ParsedExpression>> StringListToExpressionList(
|
|
111725
|
+
static vector<unique_ptr<ParsedExpression>> StringListToExpressionList(ClientContext &context,
|
|
111726
|
+
const vector<string> &expressions) {
|
|
111707
111727
|
if (expressions.empty()) {
|
|
111708
111728
|
throw ParserException("Zero expressions provided");
|
|
111709
111729
|
}
|
|
111710
111730
|
vector<unique_ptr<ParsedExpression>> result_list;
|
|
111711
111731
|
for (auto &expr : expressions) {
|
|
111712
|
-
auto expression_list = Parser::ParseExpressionList(expr);
|
|
111732
|
+
auto expression_list = Parser::ParseExpressionList(expr, context.GetParserOptions());
|
|
111713
111733
|
if (expression_list.size() != 1) {
|
|
111714
111734
|
throw ParserException("Expected a single expression in the expression list");
|
|
111715
111735
|
}
|
|
@@ -111719,12 +111739,12 @@ static vector<unique_ptr<ParsedExpression>> StringListToExpressionList(const vec
|
|
|
111719
111739
|
}
|
|
111720
111740
|
|
|
111721
111741
|
shared_ptr<Relation> Relation::Project(const vector<string> &expressions, const vector<string> &aliases) {
|
|
111722
|
-
auto result_list = StringListToExpressionList(expressions);
|
|
111742
|
+
auto result_list = StringListToExpressionList(context, expressions);
|
|
111723
111743
|
return make_shared<ProjectionRelation>(shared_from_this(), move(result_list), aliases);
|
|
111724
111744
|
}
|
|
111725
111745
|
|
|
111726
111746
|
shared_ptr<Relation> Relation::Filter(const string &expression) {
|
|
111727
|
-
auto expression_list = Parser::ParseExpressionList(expression);
|
|
111747
|
+
auto expression_list = Parser::ParseExpressionList(expression, context.GetParserOptions());
|
|
111728
111748
|
if (expression_list.size() != 1) {
|
|
111729
111749
|
throw ParserException("Expected a single expression as filter condition");
|
|
111730
111750
|
}
|
|
@@ -111733,7 +111753,7 @@ shared_ptr<Relation> Relation::Filter(const string &expression) {
|
|
|
111733
111753
|
|
|
111734
111754
|
shared_ptr<Relation> Relation::Filter(const vector<string> &expressions) {
|
|
111735
111755
|
// if there are multiple expressions, we AND them together
|
|
111736
|
-
auto expression_list = StringListToExpressionList(expressions);
|
|
111756
|
+
auto expression_list = StringListToExpressionList(context, expressions);
|
|
111737
111757
|
D_ASSERT(!expression_list.empty());
|
|
111738
111758
|
|
|
111739
111759
|
auto expr = move(expression_list[0]);
|
|
@@ -111749,7 +111769,7 @@ shared_ptr<Relation> Relation::Limit(int64_t limit, int64_t offset) {
|
|
|
111749
111769
|
}
|
|
111750
111770
|
|
|
111751
111771
|
shared_ptr<Relation> Relation::Order(const string &expression) {
|
|
111752
|
-
auto order_list = Parser::ParseOrderList(expression);
|
|
111772
|
+
auto order_list = Parser::ParseOrderList(expression, context.GetParserOptions());
|
|
111753
111773
|
return make_shared<OrderRelation>(shared_from_this(), move(order_list));
|
|
111754
111774
|
}
|
|
111755
111775
|
|
|
@@ -111759,7 +111779,7 @@ shared_ptr<Relation> Relation::Order(const vector<string> &expressions) {
|
|
|
111759
111779
|
}
|
|
111760
111780
|
vector<OrderByNode> order_list;
|
|
111761
111781
|
for (auto &expression : expressions) {
|
|
111762
|
-
auto inner_list = Parser::ParseOrderList(expression);
|
|
111782
|
+
auto inner_list = Parser::ParseOrderList(expression, context.GetParserOptions());
|
|
111763
111783
|
if (inner_list.size() != 1) {
|
|
111764
111784
|
throw ParserException("Expected a single ORDER BY expression in the expression list");
|
|
111765
111785
|
}
|
|
@@ -111769,7 +111789,7 @@ shared_ptr<Relation> Relation::Order(const vector<string> &expressions) {
|
|
|
111769
111789
|
}
|
|
111770
111790
|
|
|
111771
111791
|
shared_ptr<Relation> Relation::Join(const shared_ptr<Relation> &other, const string &condition, JoinType type) {
|
|
111772
|
-
auto expression_list = Parser::ParseExpressionList(condition);
|
|
111792
|
+
auto expression_list = Parser::ParseExpressionList(condition, context.GetParserOptions());
|
|
111773
111793
|
D_ASSERT(!expression_list.empty());
|
|
111774
111794
|
|
|
111775
111795
|
if (expression_list.size() > 1 || expression_list[0]->type == ExpressionType::COLUMN_REF) {
|
|
@@ -111813,24 +111833,24 @@ shared_ptr<Relation> Relation::Alias(const string &alias) {
|
|
|
111813
111833
|
}
|
|
111814
111834
|
|
|
111815
111835
|
shared_ptr<Relation> Relation::Aggregate(const string &aggregate_list) {
|
|
111816
|
-
auto expression_list = Parser::ParseExpressionList(aggregate_list);
|
|
111836
|
+
auto expression_list = Parser::ParseExpressionList(aggregate_list, context.GetParserOptions());
|
|
111817
111837
|
return make_shared<AggregateRelation>(shared_from_this(), move(expression_list));
|
|
111818
111838
|
}
|
|
111819
111839
|
|
|
111820
111840
|
shared_ptr<Relation> Relation::Aggregate(const string &aggregate_list, const string &group_list) {
|
|
111821
|
-
auto expression_list = Parser::ParseExpressionList(aggregate_list);
|
|
111822
|
-
auto groups = Parser::ParseExpressionList(group_list);
|
|
111841
|
+
auto expression_list = Parser::ParseExpressionList(aggregate_list, context.GetParserOptions());
|
|
111842
|
+
auto groups = Parser::ParseExpressionList(group_list, context.GetParserOptions());
|
|
111823
111843
|
return make_shared<AggregateRelation>(shared_from_this(), move(expression_list), move(groups));
|
|
111824
111844
|
}
|
|
111825
111845
|
|
|
111826
111846
|
shared_ptr<Relation> Relation::Aggregate(const vector<string> &aggregates) {
|
|
111827
|
-
auto aggregate_list = StringListToExpressionList(aggregates);
|
|
111847
|
+
auto aggregate_list = StringListToExpressionList(context, aggregates);
|
|
111828
111848
|
return make_shared<AggregateRelation>(shared_from_this(), move(aggregate_list));
|
|
111829
111849
|
}
|
|
111830
111850
|
|
|
111831
111851
|
shared_ptr<Relation> Relation::Aggregate(const vector<string> &aggregates, const vector<string> &groups) {
|
|
111832
|
-
auto aggregate_list = StringListToExpressionList(aggregates);
|
|
111833
|
-
auto group_list = StringListToExpressionList(groups);
|
|
111852
|
+
auto aggregate_list = StringListToExpressionList(context, aggregates);
|
|
111853
|
+
auto group_list = StringListToExpressionList(context, groups);
|
|
111834
111854
|
return make_shared<AggregateRelation>(shared_from_this(), move(aggregate_list), move(group_list));
|
|
111835
111855
|
}
|
|
111836
111856
|
|
|
@@ -111924,7 +111944,7 @@ void Relation::Delete(const string &condition) {
|
|
|
111924
111944
|
}
|
|
111925
111945
|
|
|
111926
111946
|
shared_ptr<Relation> Relation::TableFunction(const std::string &fname, const vector<Value> &values,
|
|
111927
|
-
const
|
|
111947
|
+
const named_parameter_map_t &named_parameters) {
|
|
111928
111948
|
return make_shared<TableFunctionRelation>(context, fname, values, named_parameters, shared_from_this());
|
|
111929
111949
|
}
|
|
111930
111950
|
|
|
@@ -111980,6 +112000,7 @@ string Relation::RenderWhitespace(idx_t depth) {
|
|
|
111980
112000
|
|
|
111981
112001
|
|
|
111982
112002
|
|
|
112003
|
+
|
|
111983
112004
|
namespace duckdb {
|
|
111984
112005
|
|
|
111985
112006
|
//===--------------------------------------------------------------------===//
|
|
@@ -112377,6 +112398,17 @@ Value PerfectHashThresholdSetting::GetSetting(ClientContext &context) {
|
|
|
112377
112398
|
return Value::BIGINT(ClientConfig::GetConfig(context).perfect_ht_threshold);
|
|
112378
112399
|
}
|
|
112379
112400
|
|
|
112401
|
+
//===--------------------------------------------------------------------===//
|
|
112402
|
+
// PreserveIdentifierCase
|
|
112403
|
+
//===--------------------------------------------------------------------===//
|
|
112404
|
+
void PreserveIdentifierCase::SetLocal(ClientContext &context, const Value &input) {
|
|
112405
|
+
ClientConfig::GetConfig(context).preserve_identifier_case = input.GetValue<bool>();
|
|
112406
|
+
}
|
|
112407
|
+
|
|
112408
|
+
Value PreserveIdentifierCase::GetSetting(ClientContext &context) {
|
|
112409
|
+
return Value::BOOLEAN(ClientConfig::GetConfig(context).preserve_identifier_case);
|
|
112410
|
+
}
|
|
112411
|
+
|
|
112380
112412
|
//===--------------------------------------------------------------------===//
|
|
112381
112413
|
// Profiler History Size
|
|
112382
112414
|
//===--------------------------------------------------------------------===//
|
|
@@ -127776,6 +127808,7 @@ unique_ptr<ParsedExpression> CollateExpression::Deserialize(ExpressionType type,
|
|
|
127776
127808
|
|
|
127777
127809
|
|
|
127778
127810
|
|
|
127811
|
+
|
|
127779
127812
|
namespace duckdb {
|
|
127780
127813
|
|
|
127781
127814
|
ColumnRefExpression::ColumnRefExpression(string column_name, string table_name)
|
|
@@ -127825,13 +127858,24 @@ string ColumnRefExpression::ToString() const {
|
|
|
127825
127858
|
}
|
|
127826
127859
|
|
|
127827
127860
|
bool ColumnRefExpression::Equals(const ColumnRefExpression *a, const ColumnRefExpression *b) {
|
|
127828
|
-
|
|
127861
|
+
if (a->column_names.size() != b->column_names.size()) {
|
|
127862
|
+
return false;
|
|
127863
|
+
}
|
|
127864
|
+
for (idx_t i = 0; i < a->column_names.size(); i++) {
|
|
127865
|
+
auto lcase_a = StringUtil::Lower(a->column_names[i]);
|
|
127866
|
+
auto lcase_b = StringUtil::Lower(b->column_names[i]);
|
|
127867
|
+
if (lcase_a != lcase_b) {
|
|
127868
|
+
return false;
|
|
127869
|
+
}
|
|
127870
|
+
}
|
|
127871
|
+
return true;
|
|
127829
127872
|
}
|
|
127830
127873
|
|
|
127831
127874
|
hash_t ColumnRefExpression::Hash() const {
|
|
127832
127875
|
hash_t result = ParsedExpression::Hash();
|
|
127833
127876
|
for (auto &column_name : column_names) {
|
|
127834
|
-
|
|
127877
|
+
auto lcase = StringUtil::Lower(column_name);
|
|
127878
|
+
result = CombineHash(result, duckdb::Hash<const char *>(lcase.c_str()));
|
|
127835
127879
|
}
|
|
127836
127880
|
return result;
|
|
127837
127881
|
}
|
|
@@ -135054,7 +135098,10 @@ public:
|
|
|
135054
135098
|
|
|
135055
135099
|
static bool IsKeyword(const std::string &text);
|
|
135056
135100
|
static std::vector<duckdb_libpgquery::PGKeyword> KeywordList();
|
|
135101
|
+
|
|
135102
|
+
static void SetPreserveIdentifierCase(bool downcase);
|
|
135057
135103
|
};
|
|
135104
|
+
|
|
135058
135105
|
}
|
|
135059
135106
|
|
|
135060
135107
|
|
|
@@ -135115,12 +135162,13 @@ PGTypeName *SystemTypeName(const char *name);
|
|
|
135115
135162
|
|
|
135116
135163
|
namespace duckdb {
|
|
135117
135164
|
|
|
135118
|
-
Parser::Parser() {
|
|
135165
|
+
Parser::Parser(ParserOptions options_p) : options(options_p) {
|
|
135119
135166
|
}
|
|
135120
135167
|
|
|
135121
135168
|
void Parser::ParseQuery(const string &query) {
|
|
135122
135169
|
Transformer transformer;
|
|
135123
135170
|
{
|
|
135171
|
+
PostgresParser::SetPreserveIdentifierCase(options.preserve_identifier_case);
|
|
135124
135172
|
PostgresParser parser;
|
|
135125
135173
|
parser.Parse(query);
|
|
135126
135174
|
|
|
@@ -135216,11 +135264,11 @@ vector<ParserKeyword> Parser::KeywordList() {
|
|
|
135216
135264
|
return result;
|
|
135217
135265
|
}
|
|
135218
135266
|
|
|
135219
|
-
vector<unique_ptr<ParsedExpression>> Parser::ParseExpressionList(const string &select_list) {
|
|
135267
|
+
vector<unique_ptr<ParsedExpression>> Parser::ParseExpressionList(const string &select_list, ParserOptions options) {
|
|
135220
135268
|
// construct a mock query prefixed with SELECT
|
|
135221
135269
|
string mock_query = "SELECT " + select_list;
|
|
135222
135270
|
// parse the query
|
|
135223
|
-
Parser parser;
|
|
135271
|
+
Parser parser(options);
|
|
135224
135272
|
parser.ParseQuery(mock_query);
|
|
135225
135273
|
// check the statements
|
|
135226
135274
|
if (parser.statements.size() != 1 || parser.statements[0]->type != StatementType::SELECT_STATEMENT) {
|
|
@@ -135234,11 +135282,11 @@ vector<unique_ptr<ParsedExpression>> Parser::ParseExpressionList(const string &s
|
|
|
135234
135282
|
return move(select_node.select_list);
|
|
135235
135283
|
}
|
|
135236
135284
|
|
|
135237
|
-
vector<OrderByNode> Parser::ParseOrderList(const string &select_list) {
|
|
135285
|
+
vector<OrderByNode> Parser::ParseOrderList(const string &select_list, ParserOptions options) {
|
|
135238
135286
|
// construct a mock query
|
|
135239
135287
|
string mock_query = "SELECT * FROM tbl ORDER BY " + select_list;
|
|
135240
135288
|
// parse the query
|
|
135241
|
-
Parser parser;
|
|
135289
|
+
Parser parser(options);
|
|
135242
135290
|
parser.ParseQuery(mock_query);
|
|
135243
135291
|
// check the statements
|
|
135244
135292
|
if (parser.statements.size() != 1 || parser.statements[0]->type != StatementType::SELECT_STATEMENT) {
|
|
@@ -135258,11 +135306,11 @@ vector<OrderByNode> Parser::ParseOrderList(const string &select_list) {
|
|
|
135258
135306
|
}
|
|
135259
135307
|
|
|
135260
135308
|
void Parser::ParseUpdateList(const string &update_list, vector<string> &update_columns,
|
|
135261
|
-
vector<unique_ptr<ParsedExpression>> &expressions) {
|
|
135309
|
+
vector<unique_ptr<ParsedExpression>> &expressions, ParserOptions options) {
|
|
135262
135310
|
// construct a mock query
|
|
135263
135311
|
string mock_query = "UPDATE tbl SET " + update_list;
|
|
135264
135312
|
// parse the query
|
|
135265
|
-
Parser parser;
|
|
135313
|
+
Parser parser(options);
|
|
135266
135314
|
parser.ParseQuery(mock_query);
|
|
135267
135315
|
// check the statements
|
|
135268
135316
|
if (parser.statements.size() != 1 || parser.statements[0]->type != StatementType::UPDATE_STATEMENT) {
|
|
@@ -135273,11 +135321,11 @@ void Parser::ParseUpdateList(const string &update_list, vector<string> &update_c
|
|
|
135273
135321
|
expressions = move(update.expressions);
|
|
135274
135322
|
}
|
|
135275
135323
|
|
|
135276
|
-
vector<vector<unique_ptr<ParsedExpression>>> Parser::ParseValuesList(const string &value_list) {
|
|
135324
|
+
vector<vector<unique_ptr<ParsedExpression>>> Parser::ParseValuesList(const string &value_list, ParserOptions options) {
|
|
135277
135325
|
// construct a mock query
|
|
135278
135326
|
string mock_query = "VALUES " + value_list;
|
|
135279
135327
|
// parse the query
|
|
135280
|
-
Parser parser;
|
|
135328
|
+
Parser parser(options);
|
|
135281
135329
|
parser.ParseQuery(mock_query);
|
|
135282
135330
|
// check the statements
|
|
135283
135331
|
if (parser.statements.size() != 1 || parser.statements[0]->type != StatementType::SELECT_STATEMENT) {
|
|
@@ -135295,9 +135343,9 @@ vector<vector<unique_ptr<ParsedExpression>>> Parser::ParseValuesList(const strin
|
|
|
135295
135343
|
return move(values_list.values);
|
|
135296
135344
|
}
|
|
135297
135345
|
|
|
135298
|
-
vector<ColumnDefinition> Parser::ParseColumnList(const string &column_list) {
|
|
135346
|
+
vector<ColumnDefinition> Parser::ParseColumnList(const string &column_list, ParserOptions options) {
|
|
135299
135347
|
string mock_query = "CREATE TABLE blabla (" + column_list + ")";
|
|
135300
|
-
Parser parser;
|
|
135348
|
+
Parser parser(options);
|
|
135301
135349
|
parser.ParseQuery(mock_query);
|
|
135302
135350
|
if (parser.statements.size() != 1 || parser.statements[0]->type != StatementType::CREATE_STATEMENT) {
|
|
135303
135351
|
throw ParserException("Expected a single CREATE statement");
|
|
@@ -142133,7 +142181,7 @@ class BoundSelectNode;
|
|
|
142133
142181
|
|
|
142134
142182
|
struct BoundGroupInformation {
|
|
142135
142183
|
expression_map_t<idx_t> map;
|
|
142136
|
-
|
|
142184
|
+
case_insensitive_map_t<idx_t> alias_map;
|
|
142137
142185
|
};
|
|
142138
142186
|
|
|
142139
142187
|
//! The SELECT binder is responsible for binding an expression within the SELECT clause of a SQL statement
|
|
@@ -142919,6 +142967,7 @@ unique_ptr<Expression> ExpressionBinder::PushCollation(ClientContext &context, u
|
|
|
142919
142967
|
} else {
|
|
142920
142968
|
collation = collation_p;
|
|
142921
142969
|
}
|
|
142970
|
+
collation = StringUtil::Lower(collation);
|
|
142922
142971
|
// bind the collation
|
|
142923
142972
|
if (collation.empty() || collation == "binary" || collation == "c" || collation == "posix") {
|
|
142924
142973
|
// binary collation: just skip
|
|
@@ -143997,14 +144046,14 @@ class ColumnRefExpression;
|
|
|
143997
144046
|
//! A helper binder for WhereBinder and HavingBinder which support alias as a columnref.
|
|
143998
144047
|
class ColumnAliasBinder {
|
|
143999
144048
|
public:
|
|
144000
|
-
ColumnAliasBinder(BoundSelectNode &node, const
|
|
144049
|
+
ColumnAliasBinder(BoundSelectNode &node, const case_insensitive_map_t<idx_t> &alias_map);
|
|
144001
144050
|
|
|
144002
144051
|
BindResult BindAlias(ExpressionBinder &enclosing_binder, ColumnRefExpression &expr, idx_t depth,
|
|
144003
144052
|
bool root_expression);
|
|
144004
144053
|
|
|
144005
144054
|
private:
|
|
144006
144055
|
BoundSelectNode &node;
|
|
144007
|
-
const
|
|
144056
|
+
const case_insensitive_map_t<idx_t> &alias_map;
|
|
144008
144057
|
bool in_alias;
|
|
144009
144058
|
};
|
|
144010
144059
|
|
|
@@ -144053,7 +144102,6 @@ protected:
|
|
|
144053
144102
|
|
|
144054
144103
|
|
|
144055
144104
|
|
|
144056
|
-
|
|
144057
144105
|
namespace duckdb {
|
|
144058
144106
|
class ConstantExpression;
|
|
144059
144107
|
class ColumnRefExpression;
|
|
@@ -144062,7 +144110,7 @@ class ColumnRefExpression;
|
|
|
144062
144110
|
class GroupBinder : public ExpressionBinder {
|
|
144063
144111
|
public:
|
|
144064
144112
|
GroupBinder(Binder &binder, ClientContext &context, SelectNode &node, idx_t group_index,
|
|
144065
|
-
|
|
144113
|
+
case_insensitive_map_t<idx_t> &alias_map, case_insensitive_map_t<idx_t> &group_alias_map);
|
|
144066
144114
|
|
|
144067
144115
|
//! The unbound root expression
|
|
144068
144116
|
unique_ptr<ParsedExpression> unbound_expression;
|
|
@@ -144079,8 +144127,8 @@ protected:
|
|
|
144079
144127
|
BindResult BindConstant(ConstantExpression &expr);
|
|
144080
144128
|
|
|
144081
144129
|
SelectNode &node;
|
|
144082
|
-
|
|
144083
|
-
|
|
144130
|
+
case_insensitive_map_t<idx_t> &alias_map;
|
|
144131
|
+
case_insensitive_map_t<idx_t> &group_alias_map;
|
|
144084
144132
|
unordered_set<idx_t> used_aliases;
|
|
144085
144133
|
|
|
144086
144134
|
idx_t group_index;
|
|
@@ -144107,7 +144155,7 @@ namespace duckdb {
|
|
|
144107
144155
|
class HavingBinder : public SelectBinder {
|
|
144108
144156
|
public:
|
|
144109
144157
|
HavingBinder(Binder &binder, ClientContext &context, BoundSelectNode &node, BoundGroupInformation &info,
|
|
144110
|
-
|
|
144158
|
+
case_insensitive_map_t<idx_t> &alias_map);
|
|
144111
144159
|
|
|
144112
144160
|
protected:
|
|
144113
144161
|
BindResult BindExpression(unique_ptr<ParsedExpression> *expr_ptr, idx_t depth,
|
|
@@ -144140,7 +144188,7 @@ namespace duckdb {
|
|
|
144140
144188
|
class QualifyBinder : public SelectBinder {
|
|
144141
144189
|
public:
|
|
144142
144190
|
QualifyBinder(Binder &binder, ClientContext &context, BoundSelectNode &node, BoundGroupInformation &info,
|
|
144143
|
-
|
|
144191
|
+
case_insensitive_map_t<idx_t> &alias_map);
|
|
144144
144192
|
|
|
144145
144193
|
protected:
|
|
144146
144194
|
BindResult BindExpression(unique_ptr<ParsedExpression> *expr_ptr, idx_t depth,
|
|
@@ -144177,10 +144225,10 @@ class SelectNode;
|
|
|
144177
144225
|
//! The ORDER binder is responsible for binding an expression within the ORDER BY clause of a SQL statement
|
|
144178
144226
|
class OrderBinder {
|
|
144179
144227
|
public:
|
|
144180
|
-
OrderBinder(vector<Binder *> binders, idx_t projection_index,
|
|
144228
|
+
OrderBinder(vector<Binder *> binders, idx_t projection_index, case_insensitive_map_t<idx_t> &alias_map,
|
|
144181
144229
|
expression_map_t<idx_t> &projection_map, idx_t max_count);
|
|
144182
144230
|
OrderBinder(vector<Binder *> binders, idx_t projection_index, SelectNode &node,
|
|
144183
|
-
|
|
144231
|
+
case_insensitive_map_t<idx_t> &alias_map, expression_map_t<idx_t> &projection_map);
|
|
144184
144232
|
|
|
144185
144233
|
public:
|
|
144186
144234
|
unique_ptr<Expression> Bind(unique_ptr<ParsedExpression> expr);
|
|
@@ -144197,7 +144245,7 @@ private:
|
|
|
144197
144245
|
idx_t projection_index;
|
|
144198
144246
|
idx_t max_count;
|
|
144199
144247
|
vector<unique_ptr<ParsedExpression>> *extra_list;
|
|
144200
|
-
|
|
144248
|
+
case_insensitive_map_t<idx_t> &alias_map;
|
|
144201
144249
|
expression_map_t<idx_t> &projection_map;
|
|
144202
144250
|
};
|
|
144203
144251
|
|
|
@@ -144441,7 +144489,7 @@ unique_ptr<BoundQueryNode> Binder::BindNode(SelectNode &statement) {
|
|
|
144441
144489
|
statement.select_list = move(new_select_list);
|
|
144442
144490
|
|
|
144443
144491
|
// create a mapping of (alias -> index) and a mapping of (Expression -> index) for the SELECT list
|
|
144444
|
-
|
|
144492
|
+
case_insensitive_map_t<idx_t> alias_map;
|
|
144445
144493
|
expression_map_t<idx_t> projection_map;
|
|
144446
144494
|
for (idx_t i = 0; i < statement.select_list.size(); i++) {
|
|
144447
144495
|
auto &expr = statement.select_list[i];
|
|
@@ -144635,7 +144683,7 @@ public:
|
|
|
144635
144683
|
|
|
144636
144684
|
namespace duckdb {
|
|
144637
144685
|
|
|
144638
|
-
static void GatherAliases(BoundQueryNode &node,
|
|
144686
|
+
static void GatherAliases(BoundQueryNode &node, case_insensitive_map_t<idx_t> &aliases,
|
|
144639
144687
|
expression_map_t<idx_t> &expressions) {
|
|
144640
144688
|
if (node.type == QueryNodeType::SET_OPERATION_NODE) {
|
|
144641
144689
|
// setop, recurse
|
|
@@ -144705,7 +144753,7 @@ unique_ptr<BoundQueryNode> Binder::BindNode(SetOperationNode &statement) {
|
|
|
144705
144753
|
|
|
144706
144754
|
// we recursively visit the children of this node to extract aliases and expressions that can be referenced in
|
|
144707
144755
|
// the ORDER BY
|
|
144708
|
-
|
|
144756
|
+
case_insensitive_map_t<idx_t> alias_map;
|
|
144709
144757
|
expression_map_t<idx_t> expression_map;
|
|
144710
144758
|
GatherAliases(*result, alias_map, expression_map);
|
|
144711
144759
|
|
|
@@ -146585,7 +146633,7 @@ BoundStatement Binder::Bind(InsertStatement &stmt) {
|
|
|
146585
146633
|
// insertion statement specifies column list
|
|
146586
146634
|
|
|
146587
146635
|
// create a mapping of (list index) -> (column index)
|
|
146588
|
-
|
|
146636
|
+
case_insensitive_map_t<idx_t> column_name_map;
|
|
146589
146637
|
for (idx_t i = 0; i < stmt.columns.size(); i++) {
|
|
146590
146638
|
column_name_map[stmt.columns[i]] = i;
|
|
146591
146639
|
auto entry = table->name_map.find(stmt.columns[i]);
|
|
@@ -147896,7 +147944,7 @@ unique_ptr<BoundTableRef> Binder::Bind(JoinRef &ref) {
|
|
|
147896
147944
|
|
|
147897
147945
|
namespace duckdb {
|
|
147898
147946
|
|
|
147899
|
-
void Binder::BindNamedParameters(
|
|
147947
|
+
void Binder::BindNamedParameters(named_parameter_type_map_t &types, named_parameter_map_t &values,
|
|
147900
147948
|
QueryErrorContext &error_context, string &func_name) {
|
|
147901
147949
|
for (auto &kv : values) {
|
|
147902
147950
|
auto entry = types.find(kv.first);
|
|
@@ -147973,7 +148021,7 @@ unique_ptr<BoundTableRef> Binder::Bind(SubqueryRef &ref, CommonTableExpressionIn
|
|
|
147973
148021
|
namespace duckdb {
|
|
147974
148022
|
|
|
147975
148023
|
bool Binder::BindFunctionParameters(vector<unique_ptr<ParsedExpression>> &expressions, vector<LogicalType> &arguments,
|
|
147976
|
-
vector<Value> ¶meters,
|
|
148024
|
+
vector<Value> ¶meters, named_parameter_map_t &named_parameters,
|
|
147977
148025
|
unique_ptr<BoundSubqueryRef> &subquery, string &error) {
|
|
147978
148026
|
bool seen_subquery = false;
|
|
147979
148027
|
for (auto &child : expressions) {
|
|
@@ -148037,7 +148085,7 @@ unique_ptr<BoundTableRef> Binder::Bind(TableFunctionRef &ref) {
|
|
|
148037
148085
|
// evaluate the input parameters to the function
|
|
148038
148086
|
vector<LogicalType> arguments;
|
|
148039
148087
|
vector<Value> parameters;
|
|
148040
|
-
|
|
148088
|
+
named_parameter_map_t named_parameters;
|
|
148041
148089
|
unique_ptr<BoundSubqueryRef> subquery;
|
|
148042
148090
|
string error;
|
|
148043
148091
|
if (!BindFunctionParameters(fexpr->children, arguments, parameters, named_parameters, subquery, error)) {
|
|
@@ -150004,7 +150052,7 @@ BindResult CheckBinder::BindCheckColumn(ColumnRefExpression &colref) {
|
|
|
150004
150052
|
|
|
150005
150053
|
namespace duckdb {
|
|
150006
150054
|
|
|
150007
|
-
ColumnAliasBinder::ColumnAliasBinder(BoundSelectNode &node, const
|
|
150055
|
+
ColumnAliasBinder::ColumnAliasBinder(BoundSelectNode &node, const case_insensitive_map_t<idx_t> &alias_map)
|
|
150008
150056
|
: node(node), alias_map(alias_map), in_alias(false) {
|
|
150009
150057
|
}
|
|
150010
150058
|
|
|
@@ -150068,7 +150116,7 @@ string ConstantBinder::UnsupportedAggregateMessage() {
|
|
|
150068
150116
|
namespace duckdb {
|
|
150069
150117
|
|
|
150070
150118
|
GroupBinder::GroupBinder(Binder &binder, ClientContext &context, SelectNode &node, idx_t group_index,
|
|
150071
|
-
|
|
150119
|
+
case_insensitive_map_t<idx_t> &alias_map, case_insensitive_map_t<idx_t> &group_alias_map)
|
|
150072
150120
|
: ExpressionBinder(binder, context), node(node), alias_map(alias_map), group_alias_map(group_alias_map),
|
|
150073
150121
|
group_index(group_index) {
|
|
150074
150122
|
}
|
|
@@ -150176,7 +150224,7 @@ BindResult GroupBinder::BindColumnRef(ColumnRefExpression &colref) {
|
|
|
150176
150224
|
namespace duckdb {
|
|
150177
150225
|
|
|
150178
150226
|
HavingBinder::HavingBinder(Binder &binder, ClientContext &context, BoundSelectNode &node, BoundGroupInformation &info,
|
|
150179
|
-
|
|
150227
|
+
case_insensitive_map_t<idx_t> &alias_map)
|
|
150180
150228
|
: SelectBinder(binder, context, node, info), column_alias_binder(node, alias_map) {
|
|
150181
150229
|
target_type = LogicalType(LogicalTypeId::BOOLEAN);
|
|
150182
150230
|
}
|
|
@@ -150271,13 +150319,13 @@ string InsertBinder::UnsupportedAggregateMessage() {
|
|
|
150271
150319
|
|
|
150272
150320
|
namespace duckdb {
|
|
150273
150321
|
|
|
150274
|
-
OrderBinder::OrderBinder(vector<Binder *> binders, idx_t projection_index,
|
|
150322
|
+
OrderBinder::OrderBinder(vector<Binder *> binders, idx_t projection_index, case_insensitive_map_t<idx_t> &alias_map,
|
|
150275
150323
|
expression_map_t<idx_t> &projection_map, idx_t max_count)
|
|
150276
150324
|
: binders(move(binders)), projection_index(projection_index), max_count(max_count), extra_list(nullptr),
|
|
150277
150325
|
alias_map(alias_map), projection_map(projection_map) {
|
|
150278
150326
|
}
|
|
150279
150327
|
OrderBinder::OrderBinder(vector<Binder *> binders, idx_t projection_index, SelectNode &node,
|
|
150280
|
-
|
|
150328
|
+
case_insensitive_map_t<idx_t> &alias_map, expression_map_t<idx_t> &projection_map)
|
|
150281
150329
|
: binders(move(binders)), projection_index(projection_index), alias_map(alias_map), projection_map(projection_map) {
|
|
150282
150330
|
this->max_count = node.select_list.size();
|
|
150283
150331
|
this->extra_list = &node.select_list;
|
|
@@ -150375,7 +150423,7 @@ unique_ptr<Expression> OrderBinder::Bind(unique_ptr<ParsedExpression> expr) {
|
|
|
150375
150423
|
namespace duckdb {
|
|
150376
150424
|
|
|
150377
150425
|
QualifyBinder::QualifyBinder(Binder &binder, ClientContext &context, BoundSelectNode &node, BoundGroupInformation &info,
|
|
150378
|
-
|
|
150426
|
+
case_insensitive_map_t<idx_t> &alias_map)
|
|
150379
150427
|
: SelectBinder(binder, context, node, info), column_alias_binder(node, alias_map) {
|
|
150380
150428
|
target_type = LogicalType(LogicalTypeId::BOOLEAN);
|
|
150381
150429
|
}
|
|
@@ -152412,7 +152460,7 @@ void PragmaHandler::HandlePragmaStatementsInternal(vector<unique_ptr<SQLStatemen
|
|
|
152412
152460
|
if (!new_query.empty()) {
|
|
152413
152461
|
// this PRAGMA statement gets replaced by a new query string
|
|
152414
152462
|
// push the new query string through the parser again and add it to the transformer
|
|
152415
|
-
Parser parser;
|
|
152463
|
+
Parser parser(context.GetParserOptions());
|
|
152416
152464
|
parser.ParseQuery(new_query);
|
|
152417
152465
|
// insert the new statements and remove the old statement
|
|
152418
152466
|
// FIXME: off by one here maybe?
|
|
@@ -222201,6 +222249,45 @@ PGNode *newNode(size_t size, PGNodeTag type) {
|
|
|
222201
222249
|
|
|
222202
222250
|
|
|
222203
222251
|
|
|
222252
|
+
// LICENSE_CHANGE_BEGIN
|
|
222253
|
+
// The following code up to LICENSE_CHANGE_END is subject to THIRD PARTY LICENSE #9
|
|
222254
|
+
// See the end of this file for a list
|
|
222255
|
+
|
|
222256
|
+
/*-------------------------------------------------------------------------
|
|
222257
|
+
*
|
|
222258
|
+
* scansup.h
|
|
222259
|
+
* scanner support routines. used by both the bootstrap lexer
|
|
222260
|
+
* as well as the normal lexer
|
|
222261
|
+
*
|
|
222262
|
+
* Portions Copyright (c) 1996-2017, PostgreSQL Global Development PGGroup
|
|
222263
|
+
* Portions Copyright (c) 1994, Regents of the University of California
|
|
222264
|
+
*
|
|
222265
|
+
* src/include/parser/scansup.h
|
|
222266
|
+
*
|
|
222267
|
+
*-------------------------------------------------------------------------
|
|
222268
|
+
*/
|
|
222269
|
+
|
|
222270
|
+
|
|
222271
|
+
|
|
222272
|
+
namespace duckdb_libpgquery {
|
|
222273
|
+
|
|
222274
|
+
char *scanstr(const char *s);
|
|
222275
|
+
|
|
222276
|
+
char *downcase_truncate_identifier(const char *ident, int len, bool warn);
|
|
222277
|
+
|
|
222278
|
+
char *downcase_identifier(const char *ident, int len, bool warn, bool truncate);
|
|
222279
|
+
|
|
222280
|
+
bool scanner_isspace(char ch);
|
|
222281
|
+
|
|
222282
|
+
void set_preserve_identifier_case(bool downcase);
|
|
222283
|
+
bool get_preserve_identifier_case();
|
|
222284
|
+
|
|
222285
|
+
}
|
|
222286
|
+
|
|
222287
|
+
// LICENSE_CHANGE_END
|
|
222288
|
+
|
|
222289
|
+
|
|
222290
|
+
|
|
222204
222291
|
// LICENSE_CHANGE_BEGIN
|
|
222205
222292
|
// The following code up to LICENSE_CHANGE_END is subject to THIRD PARTY LICENSE #9
|
|
222206
222293
|
// See the end of this file for a list
|
|
@@ -222281,6 +222368,10 @@ vector<duckdb_libpgquery::PGKeyword> PostgresParser::KeywordList() {
|
|
|
222281
222368
|
return duckdb_libpgquery::keyword_list();
|
|
222282
222369
|
}
|
|
222283
222370
|
|
|
222371
|
+
void PostgresParser::SetPreserveIdentifierCase(bool preserve) {
|
|
222372
|
+
duckdb_libpgquery::set_preserve_identifier_case(preserve);
|
|
222373
|
+
}
|
|
222374
|
+
|
|
222284
222375
|
}
|
|
222285
222376
|
|
|
222286
222377
|
|
|
@@ -251625,41 +251716,6 @@ int base_yylex(YYSTYPE *lvalp, YYLTYPE *llocp, core_yyscan_t yyscanner) {
|
|
|
251625
251716
|
/* only needed for GUC variables */
|
|
251626
251717
|
|
|
251627
251718
|
|
|
251628
|
-
// LICENSE_CHANGE_BEGIN
|
|
251629
|
-
// The following code up to LICENSE_CHANGE_END is subject to THIRD PARTY LICENSE #9
|
|
251630
|
-
// See the end of this file for a list
|
|
251631
|
-
|
|
251632
|
-
/*-------------------------------------------------------------------------
|
|
251633
|
-
*
|
|
251634
|
-
* scansup.h
|
|
251635
|
-
* scanner support routines. used by both the bootstrap lexer
|
|
251636
|
-
* as well as the normal lexer
|
|
251637
|
-
*
|
|
251638
|
-
* Portions Copyright (c) 1996-2017, PostgreSQL Global Development PGGroup
|
|
251639
|
-
* Portions Copyright (c) 1994, Regents of the University of California
|
|
251640
|
-
*
|
|
251641
|
-
* src/include/parser/scansup.h
|
|
251642
|
-
*
|
|
251643
|
-
*-------------------------------------------------------------------------
|
|
251644
|
-
*/
|
|
251645
|
-
|
|
251646
|
-
|
|
251647
|
-
|
|
251648
|
-
namespace duckdb_libpgquery {
|
|
251649
|
-
|
|
251650
|
-
char *scanstr(const char *s);
|
|
251651
|
-
|
|
251652
|
-
char *downcase_truncate_identifier(const char *ident, int len, bool warn);
|
|
251653
|
-
|
|
251654
|
-
char *downcase_identifier(const char *ident, int len, bool warn, bool truncate);
|
|
251655
|
-
|
|
251656
|
-
bool scanner_isspace(char ch);
|
|
251657
|
-
|
|
251658
|
-
}
|
|
251659
|
-
|
|
251660
|
-
// LICENSE_CHANGE_END
|
|
251661
|
-
|
|
251662
|
-
|
|
251663
251719
|
|
|
251664
251720
|
// LICENSE_CHANGE_BEGIN
|
|
251665
251721
|
// The following code up to LICENSE_CHANGE_END is subject to THIRD PARTY LICENSE #9
|
|
@@ -255819,6 +255875,16 @@ char *downcase_truncate_identifier(const char *ident, int len, bool warn) {
|
|
|
255819
255875
|
return downcase_identifier(ident, len, warn, true);
|
|
255820
255876
|
}
|
|
255821
255877
|
|
|
255878
|
+
static __thread bool pg_preserve_identifier_case = false;
|
|
255879
|
+
|
|
255880
|
+
void set_preserve_identifier_case(bool preserve) {
|
|
255881
|
+
pg_preserve_identifier_case = preserve;
|
|
255882
|
+
}
|
|
255883
|
+
|
|
255884
|
+
bool get_preserve_identifier_case() {
|
|
255885
|
+
return pg_preserve_identifier_case;
|
|
255886
|
+
}
|
|
255887
|
+
|
|
255822
255888
|
/*
|
|
255823
255889
|
* a workhorse for downcase_truncate_identifier
|
|
255824
255890
|
*/
|
|
@@ -255842,10 +255908,12 @@ char *downcase_identifier(const char *ident, int len, bool warn, bool truncate)
|
|
|
255842
255908
|
for (i = 0; i < len; i++) {
|
|
255843
255909
|
unsigned char ch = (unsigned char)ident[i];
|
|
255844
255910
|
|
|
255845
|
-
if (
|
|
255846
|
-
ch
|
|
255847
|
-
|
|
255848
|
-
ch
|
|
255911
|
+
if (!get_preserve_identifier_case()) {
|
|
255912
|
+
if (ch >= 'A' && ch <= 'Z')
|
|
255913
|
+
ch += 'a' - 'A';
|
|
255914
|
+
else if (enc_is_single_byte && IS_HIGHBIT_SET(ch) && isupper(ch))
|
|
255915
|
+
ch = tolower(ch);
|
|
255916
|
+
}
|
|
255849
255917
|
result[i] = (char)ch;
|
|
255850
255918
|
}
|
|
255851
255919
|
result[i] = '\0';
|