duckdb 0.3.2-dev876.0 → 0.3.2-dev901.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 +378 -102
- package/src/duckdb.hpp +42 -2
- package/src/parquet-amalgamation.cpp +30894 -30894
package/src/duckdb.cpp
CHANGED
|
@@ -32120,7 +32120,9 @@ enum class DatePartSpecifier : uint8_t {
|
|
|
32120
32120
|
DOY,
|
|
32121
32121
|
YEARWEEK,
|
|
32122
32122
|
ERA,
|
|
32123
|
-
|
|
32123
|
+
TIMEZONE,
|
|
32124
|
+
TIMEZONE_HOUR,
|
|
32125
|
+
TIMEZONE_MINUTE
|
|
32124
32126
|
};
|
|
32125
32127
|
|
|
32126
32128
|
DUCKDB_API bool TryGetDatePartSpecifier(const string &specifier, DatePartSpecifier &result);
|
|
@@ -75008,6 +75010,10 @@ struct EpochFun {
|
|
|
75008
75010
|
static void RegisterFunction(BuiltinFunctions &set);
|
|
75009
75011
|
};
|
|
75010
75012
|
|
|
75013
|
+
struct MakeDateFun {
|
|
75014
|
+
static void RegisterFunction(BuiltinFunctions &set);
|
|
75015
|
+
};
|
|
75016
|
+
|
|
75011
75017
|
struct StrfTimeFun {
|
|
75012
75018
|
static void RegisterFunction(BuiltinFunctions &set);
|
|
75013
75019
|
};
|
|
@@ -75549,7 +75555,7 @@ bool TryGetDatePartSpecifier(const string &specifier_p, DatePartSpecifier &resul
|
|
|
75549
75555
|
result = DatePartSpecifier::DECADE;
|
|
75550
75556
|
} else if (specifier == "century" || specifier == "centuries") {
|
|
75551
75557
|
result = DatePartSpecifier::CENTURY;
|
|
75552
|
-
} else if (specifier == "millennium" || specifier == "millennia") {
|
|
75558
|
+
} else if (specifier == "millennium" || specifier == "millennia" || specifier == "millenium") {
|
|
75553
75559
|
result = DatePartSpecifier::MILLENNIUM;
|
|
75554
75560
|
} else if (specifier == "microseconds" || specifier == "microsecond") {
|
|
75555
75561
|
result = DatePartSpecifier::MICROSECONDS;
|
|
@@ -75585,8 +75591,12 @@ bool TryGetDatePartSpecifier(const string &specifier_p, DatePartSpecifier &resul
|
|
|
75585
75591
|
result = DatePartSpecifier::YEARWEEK;
|
|
75586
75592
|
} else if (specifier == "era") {
|
|
75587
75593
|
result = DatePartSpecifier::ERA;
|
|
75588
|
-
} else if (specifier == "
|
|
75589
|
-
result = DatePartSpecifier::
|
|
75594
|
+
} else if (specifier == "timezone") {
|
|
75595
|
+
result = DatePartSpecifier::TIMEZONE;
|
|
75596
|
+
} else if (specifier == "timezone_hour") {
|
|
75597
|
+
result = DatePartSpecifier::TIMEZONE_HOUR;
|
|
75598
|
+
} else if (specifier == "timezone_minute") {
|
|
75599
|
+
result = DatePartSpecifier::TIMEZONE_MINUTE;
|
|
75590
75600
|
} else {
|
|
75591
75601
|
return false;
|
|
75592
75602
|
}
|
|
@@ -75635,7 +75645,9 @@ DatePartSpecifier GetDateTypePartSpecifier(const string &specifier, LogicalType
|
|
|
75635
75645
|
case DatePartSpecifier::MINUTE:
|
|
75636
75646
|
case DatePartSpecifier::HOUR:
|
|
75637
75647
|
case DatePartSpecifier::EPOCH:
|
|
75638
|
-
case DatePartSpecifier::
|
|
75648
|
+
case DatePartSpecifier::TIMEZONE:
|
|
75649
|
+
case DatePartSpecifier::TIMEZONE_HOUR:
|
|
75650
|
+
case DatePartSpecifier::TIMEZONE_MINUTE:
|
|
75639
75651
|
return part;
|
|
75640
75652
|
default:
|
|
75641
75653
|
break;
|
|
@@ -75760,9 +75772,15 @@ struct DatePart {
|
|
|
75760
75772
|
};
|
|
75761
75773
|
|
|
75762
75774
|
struct DecadeOperator {
|
|
75775
|
+
// From the PG docs: "The year field divided by 10"
|
|
75776
|
+
template <typename TR>
|
|
75777
|
+
static inline TR DecadeFromYear(TR yyyy) {
|
|
75778
|
+
return yyyy / 10;
|
|
75779
|
+
}
|
|
75780
|
+
|
|
75763
75781
|
template <class TA, class TR>
|
|
75764
75782
|
static inline TR Operation(TA input) {
|
|
75765
|
-
return YearOperator::Operation<TA, TR>(input)
|
|
75783
|
+
return DecadeFromYear(YearOperator::Operation<TA, TR>(input));
|
|
75766
75784
|
}
|
|
75767
75785
|
|
|
75768
75786
|
template <class T>
|
|
@@ -75774,9 +75792,25 @@ struct DatePart {
|
|
|
75774
75792
|
};
|
|
75775
75793
|
|
|
75776
75794
|
struct CenturyOperator {
|
|
75795
|
+
// From the PG docs:
|
|
75796
|
+
// "The first century starts at 0001-01-01 00:00:00 AD, although they did not know it at the time.
|
|
75797
|
+
// This definition applies to all Gregorian calendar countries.
|
|
75798
|
+
// There is no century number 0, you go from -1 century to 1 century.
|
|
75799
|
+
// If you disagree with this, please write your complaint to: Pope, Cathedral Saint-Peter of Roma, Vatican."
|
|
75800
|
+
// (To be fair, His Holiness had nothing to do with this -
|
|
75801
|
+
// it was the lack of zero in the counting systems of the time...)
|
|
75802
|
+
template <typename TR>
|
|
75803
|
+
static inline TR CenturyFromYear(TR yyyy) {
|
|
75804
|
+
if (yyyy > 0) {
|
|
75805
|
+
return ((yyyy - 1) / 100) + 1;
|
|
75806
|
+
} else {
|
|
75807
|
+
return (yyyy / 100) - 1;
|
|
75808
|
+
}
|
|
75809
|
+
}
|
|
75810
|
+
|
|
75777
75811
|
template <class TA, class TR>
|
|
75778
75812
|
static inline TR Operation(TA input) {
|
|
75779
|
-
return (
|
|
75813
|
+
return CenturyFromYear(YearOperator::Operation<TA, TR>(input));
|
|
75780
75814
|
}
|
|
75781
75815
|
|
|
75782
75816
|
template <class T>
|
|
@@ -75787,24 +75821,39 @@ struct DatePart {
|
|
|
75787
75821
|
}
|
|
75788
75822
|
};
|
|
75789
75823
|
|
|
75790
|
-
struct
|
|
75824
|
+
struct MillenniumOperator {
|
|
75825
|
+
// See the century comment
|
|
75826
|
+
template <typename TR>
|
|
75827
|
+
static inline TR MillenniumFromYear(TR yyyy) {
|
|
75828
|
+
if (yyyy > 0) {
|
|
75829
|
+
return ((yyyy - 1) / 1000) + 1;
|
|
75830
|
+
} else {
|
|
75831
|
+
return (yyyy / 1000) - 1;
|
|
75832
|
+
}
|
|
75833
|
+
}
|
|
75834
|
+
|
|
75791
75835
|
template <class TA, class TR>
|
|
75792
75836
|
static inline TR Operation(TA input) {
|
|
75793
|
-
return (
|
|
75837
|
+
return MillenniumFromYear<TR>(YearOperator::Operation<TA, TR>(input));
|
|
75794
75838
|
}
|
|
75795
75839
|
|
|
75796
75840
|
template <class T>
|
|
75797
75841
|
static unique_ptr<BaseStatistics> PropagateStatistics(ClientContext &context, BoundFunctionExpression &expr,
|
|
75798
75842
|
FunctionData *bind_data,
|
|
75799
75843
|
vector<unique_ptr<BaseStatistics>> &child_stats) {
|
|
75800
|
-
return PropagateDatePartStatistics<T,
|
|
75844
|
+
return PropagateDatePartStatistics<T, MillenniumOperator>(child_stats);
|
|
75801
75845
|
}
|
|
75802
75846
|
};
|
|
75803
75847
|
|
|
75804
75848
|
struct QuarterOperator {
|
|
75849
|
+
template <class TR>
|
|
75850
|
+
static inline TR QuarterFromMonth(TR mm) {
|
|
75851
|
+
return (mm - 1) / Interval::MONTHS_PER_QUARTER + 1;
|
|
75852
|
+
}
|
|
75853
|
+
|
|
75805
75854
|
template <class TA, class TR>
|
|
75806
75855
|
static inline TR Operation(TA input) {
|
|
75807
|
-
return (Date::ExtractMonth(input)
|
|
75856
|
+
return QuarterFromMonth(Date::ExtractMonth(input));
|
|
75808
75857
|
}
|
|
75809
75858
|
|
|
75810
75859
|
template <class T>
|
|
@@ -75817,11 +75866,16 @@ struct DatePart {
|
|
|
75817
75866
|
};
|
|
75818
75867
|
|
|
75819
75868
|
struct DayOfWeekOperator {
|
|
75820
|
-
template <class
|
|
75821
|
-
static inline TR
|
|
75869
|
+
template <class TR>
|
|
75870
|
+
static inline TR DayOfWeekFromISO(TR isodow) {
|
|
75822
75871
|
// day of the week (Sunday = 0, Saturday = 6)
|
|
75823
75872
|
// turn sunday into 0 by doing mod 7
|
|
75824
|
-
return
|
|
75873
|
+
return isodow % 7;
|
|
75874
|
+
}
|
|
75875
|
+
|
|
75876
|
+
template <class TA, class TR>
|
|
75877
|
+
static inline TR Operation(TA input) {
|
|
75878
|
+
return DayOfWeekFromISO(Date::ExtractISODayOfTheWeek(input));
|
|
75825
75879
|
}
|
|
75826
75880
|
|
|
75827
75881
|
template <class T>
|
|
@@ -75876,9 +75930,14 @@ struct DatePart {
|
|
|
75876
75930
|
};
|
|
75877
75931
|
|
|
75878
75932
|
struct YearWeekOperator {
|
|
75933
|
+
template <class TR>
|
|
75934
|
+
static inline TR YearWeekFromParts(TR yyyy, TR ww) {
|
|
75935
|
+
return yyyy * 100 + ((yyyy > 0) ? ww : -ww);
|
|
75936
|
+
}
|
|
75937
|
+
|
|
75879
75938
|
template <class TA, class TR>
|
|
75880
75939
|
static inline TR Operation(TA input) {
|
|
75881
|
-
return YearOperator::Operation<TA, TR>(input)
|
|
75940
|
+
return YearWeekFromParts(YearOperator::Operation<TA, TR>(input), WeekOperator::Operation<TA, TR>(input));
|
|
75882
75941
|
}
|
|
75883
75942
|
|
|
75884
75943
|
template <class T>
|
|
@@ -75974,9 +76033,14 @@ struct DatePart {
|
|
|
75974
76033
|
};
|
|
75975
76034
|
|
|
75976
76035
|
struct EraOperator {
|
|
76036
|
+
template <class TR>
|
|
76037
|
+
static inline TR EraFromYear(TR yyyy) {
|
|
76038
|
+
return yyyy > 0 ? 1 : 0;
|
|
76039
|
+
}
|
|
76040
|
+
|
|
75977
76041
|
template <class TA, class TR>
|
|
75978
76042
|
static inline TR Operation(TA input) {
|
|
75979
|
-
return Date::ExtractYear(input)
|
|
76043
|
+
return EraFromYear(Date::ExtractYear(input));
|
|
75980
76044
|
}
|
|
75981
76045
|
|
|
75982
76046
|
template <class T>
|
|
@@ -75987,7 +76051,7 @@ struct DatePart {
|
|
|
75987
76051
|
}
|
|
75988
76052
|
};
|
|
75989
76053
|
|
|
75990
|
-
struct
|
|
76054
|
+
struct TimezoneOperator {
|
|
75991
76055
|
template <class TA, class TR>
|
|
75992
76056
|
static inline TR Operation(TA input) {
|
|
75993
76057
|
// Regular timestamps are UTC.
|
|
@@ -76002,6 +76066,10 @@ struct DatePart {
|
|
|
76002
76066
|
}
|
|
76003
76067
|
};
|
|
76004
76068
|
|
|
76069
|
+
// These are all zero and have the same restrictions
|
|
76070
|
+
using TimezoneHourOperator = TimezoneOperator;
|
|
76071
|
+
using TimezoneMinuteOperator = TimezoneOperator;
|
|
76072
|
+
|
|
76005
76073
|
struct StructOperator {
|
|
76006
76074
|
using part_codes_t = vector<DatePartSpecifier>;
|
|
76007
76075
|
using part_mask_t = uint64_t;
|
|
@@ -76051,7 +76119,9 @@ struct DatePart {
|
|
|
76051
76119
|
case DatePartSpecifier::HOUR:
|
|
76052
76120
|
mask |= TIME;
|
|
76053
76121
|
break;
|
|
76054
|
-
case DatePartSpecifier::
|
|
76122
|
+
case DatePartSpecifier::TIMEZONE:
|
|
76123
|
+
case DatePartSpecifier::TIMEZONE_HOUR:
|
|
76124
|
+
case DatePartSpecifier::TIMEZONE_MINUTE:
|
|
76055
76125
|
mask |= ZONE;
|
|
76056
76126
|
break;
|
|
76057
76127
|
}
|
|
@@ -76083,19 +76153,19 @@ struct DatePart {
|
|
|
76083
76153
|
part_data[idx] = dd;
|
|
76084
76154
|
}
|
|
76085
76155
|
if ((part_data = HasPartValue(part_values, DatePartSpecifier::DECADE))) {
|
|
76086
|
-
part_data[idx] = yyyy
|
|
76156
|
+
part_data[idx] = DecadeOperator::DecadeFromYear(yyyy);
|
|
76087
76157
|
}
|
|
76088
76158
|
if ((part_data = HasPartValue(part_values, DatePartSpecifier::CENTURY))) {
|
|
76089
|
-
part_data[idx] = (yyyy
|
|
76159
|
+
part_data[idx] = CenturyOperator::CenturyFromYear(yyyy);
|
|
76090
76160
|
}
|
|
76091
76161
|
if ((part_data = HasPartValue(part_values, DatePartSpecifier::MILLENNIUM))) {
|
|
76092
|
-
part_data[idx] = (yyyy
|
|
76162
|
+
part_data[idx] = MillenniumOperator::MillenniumFromYear(yyyy);
|
|
76093
76163
|
}
|
|
76094
76164
|
if ((part_data = HasPartValue(part_values, DatePartSpecifier::QUARTER))) {
|
|
76095
|
-
part_data[idx] = (mm
|
|
76165
|
+
part_data[idx] = QuarterOperator::QuarterFromMonth(mm);
|
|
76096
76166
|
}
|
|
76097
76167
|
if ((part_data = HasPartValue(part_values, DatePartSpecifier::ERA))) {
|
|
76098
|
-
part_data[idx] = yyyy
|
|
76168
|
+
part_data[idx] = EraOperator::EraFromYear(yyyy);
|
|
76099
76169
|
}
|
|
76100
76170
|
}
|
|
76101
76171
|
|
|
@@ -76105,9 +76175,8 @@ struct DatePart {
|
|
|
76105
76175
|
if (mask & DOW) {
|
|
76106
76176
|
isodow = Date::ExtractISODayOfTheWeek(input);
|
|
76107
76177
|
ww = Date::ExtractISOWeekNumber(input);
|
|
76108
|
-
int32_t dow = isodow % 7;
|
|
76109
76178
|
if ((part_data = HasPartValue(part_values, DatePartSpecifier::DOW))) {
|
|
76110
|
-
part_data[idx] =
|
|
76179
|
+
part_data[idx] = DayOfWeekOperator::DayOfWeekFromISO(isodow);
|
|
76111
76180
|
}
|
|
76112
76181
|
if ((part_data = HasPartValue(part_values, DatePartSpecifier::ISODOW))) {
|
|
76113
76182
|
part_data[idx] = isodow;
|
|
@@ -76116,7 +76185,7 @@ struct DatePart {
|
|
|
76116
76185
|
part_data[idx] = ww;
|
|
76117
76186
|
}
|
|
76118
76187
|
if ((part_data = HasPartValue(part_values, DatePartSpecifier::YEARWEEK))) {
|
|
76119
|
-
part_data[idx] = yyyy
|
|
76188
|
+
part_data[idx] = YearWeekOperator::YearWeekFromParts(yyyy, ww);
|
|
76120
76189
|
}
|
|
76121
76190
|
}
|
|
76122
76191
|
|
|
@@ -76200,12 +76269,12 @@ int64_t DatePart::CenturyOperator::Operation(dtime_t input) {
|
|
|
76200
76269
|
}
|
|
76201
76270
|
|
|
76202
76271
|
template <>
|
|
76203
|
-
int64_t DatePart::
|
|
76272
|
+
int64_t DatePart::MillenniumOperator::Operation(interval_t input) {
|
|
76204
76273
|
return input.months / Interval::MONTHS_PER_MILLENIUM;
|
|
76205
76274
|
}
|
|
76206
76275
|
|
|
76207
76276
|
template <>
|
|
76208
|
-
int64_t DatePart::
|
|
76277
|
+
int64_t DatePart::MillenniumOperator::Operation(dtime_t input) {
|
|
76209
76278
|
throw NotImplementedException("\"time\" units \"millennium\" not recognized");
|
|
76210
76279
|
}
|
|
76211
76280
|
|
|
@@ -76422,17 +76491,17 @@ int64_t DatePart::EraOperator::Operation(dtime_t input) {
|
|
|
76422
76491
|
}
|
|
76423
76492
|
|
|
76424
76493
|
template <>
|
|
76425
|
-
int64_t DatePart::
|
|
76426
|
-
|
|
76494
|
+
int64_t DatePart::TimezoneOperator::Operation(date_t input) {
|
|
76495
|
+
throw NotImplementedException("\"date\" units \"timezone\" not recognized");
|
|
76427
76496
|
}
|
|
76428
76497
|
|
|
76429
76498
|
template <>
|
|
76430
|
-
int64_t DatePart::
|
|
76431
|
-
throw NotImplementedException("\"interval\" units \"
|
|
76499
|
+
int64_t DatePart::TimezoneOperator::Operation(interval_t input) {
|
|
76500
|
+
throw NotImplementedException("\"interval\" units \"timezone\" not recognized");
|
|
76432
76501
|
}
|
|
76433
76502
|
|
|
76434
76503
|
template <>
|
|
76435
|
-
int64_t DatePart::
|
|
76504
|
+
int64_t DatePart::TimezoneOperator::Operation(dtime_t input) {
|
|
76436
76505
|
return 0;
|
|
76437
76506
|
}
|
|
76438
76507
|
|
|
@@ -76467,7 +76536,13 @@ void DatePart::StructOperator::Operation(int64_t **part_values, const dtime_t &i
|
|
|
76467
76536
|
}
|
|
76468
76537
|
|
|
76469
76538
|
if (mask & ZONE) {
|
|
76470
|
-
if ((part_data = HasPartValue(part_values, DatePartSpecifier::
|
|
76539
|
+
if ((part_data = HasPartValue(part_values, DatePartSpecifier::TIMEZONE))) {
|
|
76540
|
+
part_data[idx] = 0;
|
|
76541
|
+
}
|
|
76542
|
+
if ((part_data = HasPartValue(part_values, DatePartSpecifier::TIMEZONE_HOUR))) {
|
|
76543
|
+
part_data[idx] = 0;
|
|
76544
|
+
}
|
|
76545
|
+
if ((part_data = HasPartValue(part_values, DatePartSpecifier::TIMEZONE_MINUTE))) {
|
|
76471
76546
|
part_data[idx] = 0;
|
|
76472
76547
|
}
|
|
76473
76548
|
}
|
|
@@ -76479,9 +76554,18 @@ void DatePart::StructOperator::Operation(int64_t **part_values, const timestamp_
|
|
|
76479
76554
|
date_t d;
|
|
76480
76555
|
dtime_t t;
|
|
76481
76556
|
Timestamp::Convert(input, d, t);
|
|
76482
|
-
|
|
76483
|
-
|
|
76484
|
-
|
|
76557
|
+
|
|
76558
|
+
// Both define epoch, and the correct value is the sum.
|
|
76559
|
+
// So mask it out and compute it separately.
|
|
76560
|
+
Operation(part_values, d, idx, mask & ~EPOCH);
|
|
76561
|
+
Operation(part_values, t, idx, mask & ~EPOCH);
|
|
76562
|
+
|
|
76563
|
+
if (mask & EPOCH) {
|
|
76564
|
+
auto part_data = HasPartValue(part_values, DatePartSpecifier::EPOCH);
|
|
76565
|
+
if (part_data) {
|
|
76566
|
+
part_data[idx] = EpochOperator::Operation<timestamp_t, int64_t>(input);
|
|
76567
|
+
}
|
|
76568
|
+
}
|
|
76485
76569
|
}
|
|
76486
76570
|
|
|
76487
76571
|
template <>
|
|
@@ -76553,7 +76637,7 @@ static int64_t ExtractElement(DatePartSpecifier type, T element) {
|
|
|
76553
76637
|
case DatePartSpecifier::CENTURY:
|
|
76554
76638
|
return DatePart::CenturyOperator::template Operation<T, int64_t>(element);
|
|
76555
76639
|
case DatePartSpecifier::MILLENNIUM:
|
|
76556
|
-
return DatePart::
|
|
76640
|
+
return DatePart::MillenniumOperator::template Operation<T, int64_t>(element);
|
|
76557
76641
|
case DatePartSpecifier::QUARTER:
|
|
76558
76642
|
return DatePart::QuarterOperator::template Operation<T, int64_t>(element);
|
|
76559
76643
|
case DatePartSpecifier::DOW:
|
|
@@ -76580,8 +76664,10 @@ static int64_t ExtractElement(DatePartSpecifier type, T element) {
|
|
|
76580
76664
|
return DatePart::HoursOperator::template Operation<T, int64_t>(element);
|
|
76581
76665
|
case DatePartSpecifier::ERA:
|
|
76582
76666
|
return DatePart::EraOperator::template Operation<T, int64_t>(element);
|
|
76583
|
-
case DatePartSpecifier::
|
|
76584
|
-
|
|
76667
|
+
case DatePartSpecifier::TIMEZONE:
|
|
76668
|
+
case DatePartSpecifier::TIMEZONE_HOUR:
|
|
76669
|
+
case DatePartSpecifier::TIMEZONE_MINUTE:
|
|
76670
|
+
return DatePart::TimezoneOperator::template Operation<T, int64_t>(element);
|
|
76585
76671
|
default:
|
|
76586
76672
|
throw NotImplementedException("Specifier type not implemented for DATEPART");
|
|
76587
76673
|
}
|
|
@@ -76741,14 +76827,14 @@ struct StructDatePart {
|
|
|
76741
76827
|
|
|
76742
76828
|
const auto count = args.size();
|
|
76743
76829
|
Vector &input = args.data[0];
|
|
76744
|
-
vector<int64_t *> part_values(int(DatePartSpecifier::
|
|
76830
|
+
vector<int64_t *> part_values(int(DatePartSpecifier::TIMEZONE_MINUTE) + 1, nullptr);
|
|
76745
76831
|
const auto part_mask = DatePart::StructOperator::GetMask(info.part_codes);
|
|
76746
76832
|
|
|
76747
76833
|
auto &child_entries = StructVector::GetEntries(result);
|
|
76748
76834
|
|
|
76749
76835
|
// The first computer of a part "owns" it
|
|
76750
76836
|
// and other requestors just reference the owner
|
|
76751
|
-
vector<size_t> owners(int(DatePartSpecifier::
|
|
76837
|
+
vector<size_t> owners(int(DatePartSpecifier::TIMEZONE_MINUTE) + 1, child_entries.size());
|
|
76752
76838
|
for (size_t col = 0; col < child_entries.size(); ++col) {
|
|
76753
76839
|
const auto part_index = size_t(info.part_codes[col]);
|
|
76754
76840
|
if (owners[part_index] == child_entries.size()) {
|
|
@@ -76847,13 +76933,16 @@ void DatePartFun::RegisterFunction(BuiltinFunctions &set) {
|
|
|
76847
76933
|
AddDatePartOperator<DatePart::DayOperator>(set, "day");
|
|
76848
76934
|
AddDatePartOperator<DatePart::DecadeOperator>(set, "decade");
|
|
76849
76935
|
AddDatePartOperator<DatePart::CenturyOperator>(set, "century");
|
|
76850
|
-
AddDatePartOperator<DatePart::
|
|
76936
|
+
AddDatePartOperator<DatePart::MillenniumOperator>(set, "millennium");
|
|
76851
76937
|
AddDatePartOperator<DatePart::QuarterOperator>(set, "quarter");
|
|
76852
76938
|
AddDatePartOperator<DatePart::DayOfWeekOperator>(set, "dayofweek");
|
|
76853
76939
|
AddDatePartOperator<DatePart::ISODayOfWeekOperator>(set, "isodow");
|
|
76854
76940
|
AddDatePartOperator<DatePart::DayOfYearOperator>(set, "dayofyear");
|
|
76855
76941
|
AddDatePartOperator<DatePart::WeekOperator>(set, "week");
|
|
76856
76942
|
AddDatePartOperator<DatePart::EraOperator>(set, "era");
|
|
76943
|
+
AddDatePartOperator<DatePart::TimezoneOperator>(set, "timezone");
|
|
76944
|
+
AddDatePartOperator<DatePart::TimezoneHourOperator>(set, "timezone_hour");
|
|
76945
|
+
AddDatePartOperator<DatePart::TimezoneMinuteOperator>(set, "timezone_minute");
|
|
76857
76946
|
AddTimePartOperator<DatePart::EpochOperator>(set, "epoch");
|
|
76858
76947
|
AddTimePartOperator<DatePart::MicrosecondsOperator>(set, "microsecond");
|
|
76859
76948
|
AddTimePartOperator<DatePart::MillisecondsOperator>(set, "millisecond");
|
|
@@ -77737,6 +77826,189 @@ void EpochFun::RegisterFunction(BuiltinFunctions &set) {
|
|
|
77737
77826
|
|
|
77738
77827
|
|
|
77739
77828
|
|
|
77829
|
+
//===----------------------------------------------------------------------===//
|
|
77830
|
+
// DuckDB
|
|
77831
|
+
//
|
|
77832
|
+
// duckdb/common/vector_operations/senary_executor.hpp
|
|
77833
|
+
//
|
|
77834
|
+
//
|
|
77835
|
+
//===----------------------------------------------------------------------===//
|
|
77836
|
+
|
|
77837
|
+
|
|
77838
|
+
|
|
77839
|
+
|
|
77840
|
+
|
|
77841
|
+
namespace duckdb {
|
|
77842
|
+
|
|
77843
|
+
struct SenaryExecutor {
|
|
77844
|
+
static const size_t NCOLS = 6;
|
|
77845
|
+
|
|
77846
|
+
template <class TA, class TB, class TC, class TD, class TE, class TF, class TR,
|
|
77847
|
+
class FUN = std::function<TR(TA, TB, TC, TD, TE, TF)>>
|
|
77848
|
+
static void Execute(DataChunk &input, Vector &result, FUN fun) {
|
|
77849
|
+
D_ASSERT(input.ColumnCount() >= NCOLS);
|
|
77850
|
+
const auto count = input.size();
|
|
77851
|
+
|
|
77852
|
+
bool all_constant = true;
|
|
77853
|
+
bool any_null = false;
|
|
77854
|
+
for (const auto &v : input.data) {
|
|
77855
|
+
if (v.GetVectorType() == VectorType::CONSTANT_VECTOR) {
|
|
77856
|
+
if (ConstantVector::IsNull(v)) {
|
|
77857
|
+
any_null = true;
|
|
77858
|
+
}
|
|
77859
|
+
} else {
|
|
77860
|
+
all_constant = false;
|
|
77861
|
+
break;
|
|
77862
|
+
}
|
|
77863
|
+
}
|
|
77864
|
+
|
|
77865
|
+
if (all_constant) {
|
|
77866
|
+
result.SetVectorType(VectorType::CONSTANT_VECTOR);
|
|
77867
|
+
if (any_null) {
|
|
77868
|
+
ConstantVector::SetNull(result, true);
|
|
77869
|
+
} else {
|
|
77870
|
+
auto adata = ConstantVector::GetData<TA>(input.data[0]);
|
|
77871
|
+
auto bdata = ConstantVector::GetData<TB>(input.data[1]);
|
|
77872
|
+
auto cdata = ConstantVector::GetData<TC>(input.data[2]);
|
|
77873
|
+
auto ddata = ConstantVector::GetData<TD>(input.data[3]);
|
|
77874
|
+
auto edata = ConstantVector::GetData<TE>(input.data[4]);
|
|
77875
|
+
auto fdata = ConstantVector::GetData<TF>(input.data[5]);
|
|
77876
|
+
auto result_data = ConstantVector::GetData<TR>(result);
|
|
77877
|
+
result_data[0] = fun(*adata, *bdata, *cdata, *ddata, *edata, *fdata);
|
|
77878
|
+
}
|
|
77879
|
+
} else {
|
|
77880
|
+
result.SetVectorType(VectorType::FLAT_VECTOR);
|
|
77881
|
+
auto result_data = FlatVector::GetData<TR>(result);
|
|
77882
|
+
auto &result_validity = FlatVector::Validity(result);
|
|
77883
|
+
|
|
77884
|
+
bool all_valid = true;
|
|
77885
|
+
vector<VectorData> vdata(NCOLS);
|
|
77886
|
+
for (size_t c = 0; c < NCOLS; ++c) {
|
|
77887
|
+
input.data[c].Orrify(count, vdata[c]);
|
|
77888
|
+
all_valid = all_valid && vdata[c].validity.AllValid();
|
|
77889
|
+
}
|
|
77890
|
+
|
|
77891
|
+
auto adata = (const TA *)(vdata[0].data);
|
|
77892
|
+
auto bdata = (const TB *)(vdata[1].data);
|
|
77893
|
+
auto cdata = (const TC *)(vdata[2].data);
|
|
77894
|
+
auto ddata = (const TD *)(vdata[3].data);
|
|
77895
|
+
auto edata = (const TE *)(vdata[4].data);
|
|
77896
|
+
auto fdata = (const TF *)(vdata[5].data);
|
|
77897
|
+
|
|
77898
|
+
vector<idx_t> idx(NCOLS);
|
|
77899
|
+
if (all_valid) {
|
|
77900
|
+
for (idx_t r = 0; r < count; ++r) {
|
|
77901
|
+
for (size_t c = 0; c < NCOLS; ++c) {
|
|
77902
|
+
idx[c] = vdata[c].sel->get_index(r);
|
|
77903
|
+
}
|
|
77904
|
+
result_data[r] =
|
|
77905
|
+
fun(adata[idx[0]], bdata[idx[1]], cdata[idx[2]], ddata[idx[3]], edata[idx[4]], fdata[idx[5]]);
|
|
77906
|
+
}
|
|
77907
|
+
} else {
|
|
77908
|
+
for (idx_t r = 0; r < count; ++r) {
|
|
77909
|
+
all_valid = true;
|
|
77910
|
+
for (size_t c = 0; c < NCOLS; ++c) {
|
|
77911
|
+
idx[c] = vdata[c].sel->get_index(r);
|
|
77912
|
+
if (!vdata[c].validity.RowIsValid(idx[c])) {
|
|
77913
|
+
result_validity.SetInvalid(r);
|
|
77914
|
+
all_valid = false;
|
|
77915
|
+
break;
|
|
77916
|
+
}
|
|
77917
|
+
}
|
|
77918
|
+
if (all_valid) {
|
|
77919
|
+
result_data[r] = fun(adata[idx[0]], bdata[idx[1]], cdata[idx[2]], ddata[idx[3]], edata[idx[4]],
|
|
77920
|
+
fdata[idx[5]]);
|
|
77921
|
+
}
|
|
77922
|
+
}
|
|
77923
|
+
}
|
|
77924
|
+
}
|
|
77925
|
+
}
|
|
77926
|
+
};
|
|
77927
|
+
|
|
77928
|
+
} // namespace duckdb
|
|
77929
|
+
|
|
77930
|
+
|
|
77931
|
+
namespace duckdb {
|
|
77932
|
+
|
|
77933
|
+
struct MakeDateOperator {
|
|
77934
|
+
template <typename YYYY, typename MM, typename DD, typename RESULT_TYPE>
|
|
77935
|
+
static RESULT_TYPE Operation(YYYY yyyy, MM mm, DD dd) {
|
|
77936
|
+
return Date::FromDate(yyyy, mm, dd);
|
|
77937
|
+
}
|
|
77938
|
+
};
|
|
77939
|
+
|
|
77940
|
+
template <typename T>
|
|
77941
|
+
static void ExecuteMakeDate(DataChunk &input, ExpressionState &state, Vector &result) {
|
|
77942
|
+
D_ASSERT(input.ColumnCount() == 3);
|
|
77943
|
+
auto &yyyy = input.data[0];
|
|
77944
|
+
auto &mm = input.data[1];
|
|
77945
|
+
auto &dd = input.data[2];
|
|
77946
|
+
|
|
77947
|
+
TernaryExecutor::Execute<T, T, T, date_t>(yyyy, mm, dd, result, input.size(),
|
|
77948
|
+
MakeDateOperator::Operation<T, T, T, date_t>);
|
|
77949
|
+
}
|
|
77950
|
+
|
|
77951
|
+
struct MakeTimeOperator {
|
|
77952
|
+
template <typename HH, typename MM, typename SS, typename RESULT_TYPE>
|
|
77953
|
+
static RESULT_TYPE Operation(HH hh, MM mm, SS ss) {
|
|
77954
|
+
int64_t secs = ss;
|
|
77955
|
+
int64_t micros = std::round((ss - secs) * Interval::MICROS_PER_SEC);
|
|
77956
|
+
return Time::FromTime(hh, mm, secs, micros);
|
|
77957
|
+
}
|
|
77958
|
+
};
|
|
77959
|
+
|
|
77960
|
+
template <typename T>
|
|
77961
|
+
static void ExecuteMakeTime(DataChunk &input, ExpressionState &state, Vector &result) {
|
|
77962
|
+
D_ASSERT(input.ColumnCount() == 3);
|
|
77963
|
+
auto &yyyy = input.data[0];
|
|
77964
|
+
auto &mm = input.data[1];
|
|
77965
|
+
auto &dd = input.data[2];
|
|
77966
|
+
|
|
77967
|
+
TernaryExecutor::Execute<T, T, double, dtime_t>(yyyy, mm, dd, result, input.size(),
|
|
77968
|
+
MakeTimeOperator::Operation<T, T, double, dtime_t>);
|
|
77969
|
+
}
|
|
77970
|
+
|
|
77971
|
+
struct MakeTimestampOperator {
|
|
77972
|
+
template <typename YYYY, typename MM, typename DD, typename HR, typename MN, typename SS, typename RESULT_TYPE>
|
|
77973
|
+
static RESULT_TYPE Operation(YYYY yyyy, MM mm, DD dd, HR hr, MN mn, SS ss) {
|
|
77974
|
+
const auto d = MakeDateOperator::Operation<YYYY, MM, DD, date_t>(yyyy, mm, dd);
|
|
77975
|
+
const auto t = MakeTimeOperator::Operation<HR, MN, SS, dtime_t>(hr, mn, ss);
|
|
77976
|
+
return Timestamp::FromDatetime(d, t);
|
|
77977
|
+
}
|
|
77978
|
+
};
|
|
77979
|
+
|
|
77980
|
+
template <typename T>
|
|
77981
|
+
static void ExecuteMakeTimestamp(DataChunk &input, ExpressionState &state, Vector &result) {
|
|
77982
|
+
D_ASSERT(input.ColumnCount() == 6);
|
|
77983
|
+
|
|
77984
|
+
auto func = MakeTimestampOperator::Operation<T, T, T, T, T, double, timestamp_t>;
|
|
77985
|
+
SenaryExecutor::Execute<T, T, T, T, T, double, timestamp_t>(input, result, func);
|
|
77986
|
+
}
|
|
77987
|
+
|
|
77988
|
+
void MakeDateFun::RegisterFunction(BuiltinFunctions &set) {
|
|
77989
|
+
ScalarFunctionSet make_date("make_date");
|
|
77990
|
+
make_date.AddFunction(ScalarFunction({LogicalType::BIGINT, LogicalType::BIGINT, LogicalType::BIGINT},
|
|
77991
|
+
LogicalType::DATE, ExecuteMakeDate<int64_t>));
|
|
77992
|
+
set.AddFunction(make_date);
|
|
77993
|
+
|
|
77994
|
+
ScalarFunctionSet make_time("make_time");
|
|
77995
|
+
make_time.AddFunction(ScalarFunction({LogicalType::BIGINT, LogicalType::BIGINT, LogicalType::DOUBLE},
|
|
77996
|
+
LogicalType::TIME, ExecuteMakeTime<int64_t>));
|
|
77997
|
+
set.AddFunction(make_time);
|
|
77998
|
+
|
|
77999
|
+
ScalarFunctionSet make_timestamp("make_timestamp");
|
|
78000
|
+
make_timestamp.AddFunction(ScalarFunction({LogicalType::BIGINT, LogicalType::BIGINT, LogicalType::BIGINT,
|
|
78001
|
+
LogicalType::BIGINT, LogicalType::BIGINT, LogicalType::DOUBLE},
|
|
78002
|
+
LogicalType::TIMESTAMP, ExecuteMakeTimestamp<int64_t>));
|
|
78003
|
+
set.AddFunction(make_timestamp);
|
|
78004
|
+
}
|
|
78005
|
+
|
|
78006
|
+
} // namespace duckdb
|
|
78007
|
+
|
|
78008
|
+
|
|
78009
|
+
|
|
78010
|
+
|
|
78011
|
+
|
|
77740
78012
|
|
|
77741
78013
|
|
|
77742
78014
|
|
|
@@ -79067,6 +79339,7 @@ void BuiltinFunctions::RegisterDateFunctions() {
|
|
|
79067
79339
|
Register<CurrentDateFun>();
|
|
79068
79340
|
Register<CurrentTimestampFun>();
|
|
79069
79341
|
Register<EpochFun>();
|
|
79342
|
+
Register<MakeDateFun>();
|
|
79070
79343
|
Register<StrfTimeFun>();
|
|
79071
79344
|
Register<StrpTimeFun>();
|
|
79072
79345
|
Register<ToIntervalFun>();
|
|
@@ -96895,7 +97168,7 @@ namespace duckdb {
|
|
|
96895
97168
|
template <class T>
|
|
96896
97169
|
void WriteData(duckdb_result *out, ChunkCollection &source, idx_t col) {
|
|
96897
97170
|
idx_t row = 0;
|
|
96898
|
-
auto target = (T *)out->
|
|
97171
|
+
auto target = (T *)out->__deprecated_columns[col].__deprecated_data;
|
|
96899
97172
|
for (auto &chunk : source.Chunks()) {
|
|
96900
97173
|
auto source = FlatVector::GetData<T>(chunk->data[col]);
|
|
96901
97174
|
auto &mask = FlatVector::Validity(chunk->data[col]);
|
|
@@ -96918,46 +97191,49 @@ duckdb_state duckdb_translate_result(MaterializedQueryResult *result, duckdb_res
|
|
|
96918
97191
|
memset(out, 0, sizeof(duckdb_result));
|
|
96919
97192
|
if (!result->success) {
|
|
96920
97193
|
// write the error message
|
|
96921
|
-
out->
|
|
97194
|
+
out->__deprecated_error_message = strdup(result->error.c_str());
|
|
96922
97195
|
return DuckDBError;
|
|
96923
97196
|
}
|
|
96924
97197
|
// copy the data
|
|
96925
97198
|
// first write the meta data
|
|
96926
|
-
out->
|
|
96927
|
-
out->
|
|
96928
|
-
out->
|
|
96929
|
-
if (out->
|
|
97199
|
+
out->__deprecated_column_count = result->types.size();
|
|
97200
|
+
out->__deprecated_row_count = result->collection.Count();
|
|
97201
|
+
out->__deprecated_rows_changed = 0;
|
|
97202
|
+
if (out->__deprecated_row_count > 0 && StatementTypeReturnChanges(result->statement_type)) {
|
|
96930
97203
|
// update total changes
|
|
96931
97204
|
auto row_changes = result->GetValue(0, 0);
|
|
96932
97205
|
if (!row_changes.is_null && row_changes.TryCastAs(LogicalType::BIGINT)) {
|
|
96933
|
-
out->
|
|
97206
|
+
out->__deprecated_rows_changed = row_changes.GetValue<int64_t>();
|
|
96934
97207
|
}
|
|
96935
97208
|
}
|
|
96936
|
-
out->
|
|
96937
|
-
if (!out->
|
|
97209
|
+
out->__deprecated_columns = (duckdb_column *)duckdb_malloc(sizeof(duckdb_column) * out->__deprecated_column_count);
|
|
97210
|
+
if (!out->__deprecated_columns) { // LCOV_EXCL_START
|
|
96938
97211
|
// malloc failure
|
|
96939
97212
|
return DuckDBError;
|
|
96940
97213
|
} // LCOV_EXCL_STOP
|
|
96941
97214
|
|
|
96942
97215
|
// zero initialize the columns (so we can cleanly delete it in case a malloc fails)
|
|
96943
|
-
memset(out->
|
|
96944
|
-
for (idx_t i = 0; i < out->
|
|
96945
|
-
out->
|
|
96946
|
-
out->
|
|
96947
|
-
out->
|
|
96948
|
-
|
|
96949
|
-
|
|
97216
|
+
memset(out->__deprecated_columns, 0, sizeof(duckdb_column) * out->__deprecated_column_count);
|
|
97217
|
+
for (idx_t i = 0; i < out->__deprecated_column_count; i++) {
|
|
97218
|
+
out->__deprecated_columns[i].__deprecated_type = ConvertCPPTypeToC(result->types[i]);
|
|
97219
|
+
out->__deprecated_columns[i].__deprecated_name = strdup(result->names[i].c_str());
|
|
97220
|
+
out->__deprecated_columns[i].__deprecated_nullmask =
|
|
97221
|
+
(bool *)duckdb_malloc(sizeof(bool) * out->__deprecated_row_count);
|
|
97222
|
+
out->__deprecated_columns[i].__deprecated_data =
|
|
97223
|
+
duckdb_malloc(GetCTypeSize(out->__deprecated_columns[i].__deprecated_type) * out->__deprecated_row_count);
|
|
97224
|
+
if (!out->__deprecated_columns[i].__deprecated_nullmask || !out->__deprecated_columns[i].__deprecated_name ||
|
|
97225
|
+
!out->__deprecated_columns[i].__deprecated_data) { // LCOV_EXCL_START
|
|
96950
97226
|
// malloc failure
|
|
96951
97227
|
return DuckDBError;
|
|
96952
97228
|
} // LCOV_EXCL_STOP
|
|
96953
97229
|
}
|
|
96954
97230
|
// now write the data
|
|
96955
|
-
for (idx_t col = 0; col < out->
|
|
97231
|
+
for (idx_t col = 0; col < out->__deprecated_column_count; col++) {
|
|
96956
97232
|
// first set the nullmask
|
|
96957
97233
|
idx_t row = 0;
|
|
96958
97234
|
for (auto &chunk : result->collection.Chunks()) {
|
|
96959
97235
|
for (idx_t k = 0; k < chunk->size(); k++) {
|
|
96960
|
-
out->
|
|
97236
|
+
out->__deprecated_columns[col].__deprecated_nullmask[row++] = FlatVector::IsNull(chunk->data[col], k);
|
|
96961
97237
|
}
|
|
96962
97238
|
}
|
|
96963
97239
|
// then write the data
|
|
@@ -97008,7 +97284,7 @@ duckdb_state duckdb_translate_result(MaterializedQueryResult *result, duckdb_res
|
|
|
97008
97284
|
break;
|
|
97009
97285
|
case LogicalTypeId::VARCHAR: {
|
|
97010
97286
|
idx_t row = 0;
|
|
97011
|
-
auto target = (const char **)out->
|
|
97287
|
+
auto target = (const char **)out->__deprecated_columns[col].__deprecated_data;
|
|
97012
97288
|
for (auto &chunk : result->collection.Chunks()) {
|
|
97013
97289
|
auto source = FlatVector::GetData<string_t>(chunk->data[col]);
|
|
97014
97290
|
for (idx_t k = 0; k < chunk->size(); k++) {
|
|
@@ -97028,7 +97304,7 @@ duckdb_state duckdb_translate_result(MaterializedQueryResult *result, duckdb_res
|
|
|
97028
97304
|
}
|
|
97029
97305
|
case LogicalTypeId::BLOB: {
|
|
97030
97306
|
idx_t row = 0;
|
|
97031
|
-
auto target = (duckdb_blob *)out->
|
|
97307
|
+
auto target = (duckdb_blob *)out->__deprecated_columns[col].__deprecated_data;
|
|
97032
97308
|
for (auto &chunk : result->collection.Chunks()) {
|
|
97033
97309
|
auto source = FlatVector::GetData<string_t>(chunk->data[col]);
|
|
97034
97310
|
for (idx_t k = 0; k < chunk->size(); k++) {
|
|
@@ -97050,7 +97326,7 @@ duckdb_state duckdb_translate_result(MaterializedQueryResult *result, duckdb_res
|
|
|
97050
97326
|
case LogicalTypeId::TIMESTAMP_MS:
|
|
97051
97327
|
case LogicalTypeId::TIMESTAMP_SEC: {
|
|
97052
97328
|
idx_t row = 0;
|
|
97053
|
-
auto target = (timestamp_t *)out->
|
|
97329
|
+
auto target = (timestamp_t *)out->__deprecated_columns[col].__deprecated_data;
|
|
97054
97330
|
for (auto &chunk : result->collection.Chunks()) {
|
|
97055
97331
|
auto source = FlatVector::GetData<timestamp_t>(chunk->data[col]);
|
|
97056
97332
|
|
|
@@ -97072,7 +97348,7 @@ duckdb_state duckdb_translate_result(MaterializedQueryResult *result, duckdb_res
|
|
|
97072
97348
|
}
|
|
97073
97349
|
case LogicalTypeId::HUGEINT: {
|
|
97074
97350
|
idx_t row = 0;
|
|
97075
|
-
auto target = (duckdb_hugeint *)out->
|
|
97351
|
+
auto target = (duckdb_hugeint *)out->__deprecated_columns[col].__deprecated_data;
|
|
97076
97352
|
for (auto &chunk : result->collection.Chunks()) {
|
|
97077
97353
|
auto source = FlatVector::GetData<hugeint_t>(chunk->data[col]);
|
|
97078
97354
|
for (idx_t k = 0; k < chunk->size(); k++) {
|
|
@@ -97087,7 +97363,7 @@ duckdb_state duckdb_translate_result(MaterializedQueryResult *result, duckdb_res
|
|
|
97087
97363
|
}
|
|
97088
97364
|
case LogicalTypeId::INTERVAL: {
|
|
97089
97365
|
idx_t row = 0;
|
|
97090
|
-
auto target = (duckdb_interval *)out->
|
|
97366
|
+
auto target = (duckdb_interval *)out->__deprecated_columns[col].__deprecated_data;
|
|
97091
97367
|
for (auto &chunk : result->collection.Chunks()) {
|
|
97092
97368
|
auto source = FlatVector::GetData<interval_t>(chunk->data[col]);
|
|
97093
97369
|
for (idx_t k = 0; k < chunk->size(); k++) {
|
|
@@ -97113,101 +97389,101 @@ duckdb_state duckdb_translate_result(MaterializedQueryResult *result, duckdb_res
|
|
|
97113
97389
|
} // namespace duckdb
|
|
97114
97390
|
|
|
97115
97391
|
static void DuckdbDestroyColumn(duckdb_column column, idx_t count) {
|
|
97116
|
-
if (column.
|
|
97117
|
-
if (column.
|
|
97392
|
+
if (column.__deprecated_data) {
|
|
97393
|
+
if (column.__deprecated_type == DUCKDB_TYPE_VARCHAR) {
|
|
97118
97394
|
// varchar, delete individual strings
|
|
97119
|
-
auto data = (char **)column.
|
|
97395
|
+
auto data = (char **)column.__deprecated_data;
|
|
97120
97396
|
for (idx_t i = 0; i < count; i++) {
|
|
97121
97397
|
if (data[i]) {
|
|
97122
97398
|
duckdb_free(data[i]);
|
|
97123
97399
|
}
|
|
97124
97400
|
}
|
|
97125
|
-
} else if (column.
|
|
97401
|
+
} else if (column.__deprecated_type == DUCKDB_TYPE_BLOB) {
|
|
97126
97402
|
// blob, delete individual blobs
|
|
97127
|
-
auto data = (duckdb_blob *)column.
|
|
97403
|
+
auto data = (duckdb_blob *)column.__deprecated_data;
|
|
97128
97404
|
for (idx_t i = 0; i < count; i++) {
|
|
97129
97405
|
if (data[i].data) {
|
|
97130
97406
|
duckdb_free((void *)data[i].data);
|
|
97131
97407
|
}
|
|
97132
97408
|
}
|
|
97133
97409
|
}
|
|
97134
|
-
duckdb_free(column.
|
|
97410
|
+
duckdb_free(column.__deprecated_data);
|
|
97135
97411
|
}
|
|
97136
|
-
if (column.
|
|
97137
|
-
duckdb_free(column.
|
|
97412
|
+
if (column.__deprecated_nullmask) {
|
|
97413
|
+
duckdb_free(column.__deprecated_nullmask);
|
|
97138
97414
|
}
|
|
97139
|
-
if (column.
|
|
97140
|
-
duckdb_free(column.
|
|
97415
|
+
if (column.__deprecated_name) {
|
|
97416
|
+
duckdb_free(column.__deprecated_name);
|
|
97141
97417
|
}
|
|
97142
97418
|
}
|
|
97143
97419
|
|
|
97144
97420
|
void duckdb_destroy_result(duckdb_result *result) {
|
|
97145
|
-
if (result->
|
|
97146
|
-
duckdb_free(result->
|
|
97421
|
+
if (result->__deprecated_error_message) {
|
|
97422
|
+
duckdb_free(result->__deprecated_error_message);
|
|
97147
97423
|
}
|
|
97148
|
-
if (result->
|
|
97149
|
-
for (idx_t i = 0; i < result->
|
|
97150
|
-
DuckdbDestroyColumn(result->
|
|
97424
|
+
if (result->__deprecated_columns) {
|
|
97425
|
+
for (idx_t i = 0; i < result->__deprecated_column_count; i++) {
|
|
97426
|
+
DuckdbDestroyColumn(result->__deprecated_columns[i], result->__deprecated_row_count);
|
|
97151
97427
|
}
|
|
97152
|
-
duckdb_free(result->
|
|
97428
|
+
duckdb_free(result->__deprecated_columns);
|
|
97153
97429
|
}
|
|
97154
97430
|
memset(result, 0, sizeof(duckdb_result));
|
|
97155
97431
|
}
|
|
97156
97432
|
|
|
97157
97433
|
const char *duckdb_column_name(duckdb_result *result, idx_t col) {
|
|
97158
|
-
if (!result || col >= result->
|
|
97434
|
+
if (!result || col >= result->__deprecated_column_count) {
|
|
97159
97435
|
return nullptr;
|
|
97160
97436
|
}
|
|
97161
|
-
return result->
|
|
97437
|
+
return result->__deprecated_columns[col].__deprecated_name;
|
|
97162
97438
|
}
|
|
97163
97439
|
|
|
97164
97440
|
duckdb_type duckdb_column_type(duckdb_result *result, idx_t col) {
|
|
97165
|
-
if (!result || col >= result->
|
|
97441
|
+
if (!result || col >= result->__deprecated_column_count) {
|
|
97166
97442
|
return DUCKDB_TYPE_INVALID;
|
|
97167
97443
|
}
|
|
97168
|
-
return result->
|
|
97444
|
+
return result->__deprecated_columns[col].__deprecated_type;
|
|
97169
97445
|
}
|
|
97170
97446
|
|
|
97171
97447
|
idx_t duckdb_column_count(duckdb_result *result) {
|
|
97172
97448
|
if (!result) {
|
|
97173
97449
|
return 0;
|
|
97174
97450
|
}
|
|
97175
|
-
return result->
|
|
97451
|
+
return result->__deprecated_column_count;
|
|
97176
97452
|
}
|
|
97177
97453
|
|
|
97178
97454
|
idx_t duckdb_row_count(duckdb_result *result) {
|
|
97179
97455
|
if (!result) {
|
|
97180
97456
|
return 0;
|
|
97181
97457
|
}
|
|
97182
|
-
return result->
|
|
97458
|
+
return result->__deprecated_row_count;
|
|
97183
97459
|
}
|
|
97184
97460
|
|
|
97185
97461
|
idx_t duckdb_rows_changed(duckdb_result *result) {
|
|
97186
97462
|
if (!result) {
|
|
97187
97463
|
return 0;
|
|
97188
97464
|
}
|
|
97189
|
-
return result->
|
|
97465
|
+
return result->__deprecated_rows_changed;
|
|
97190
97466
|
}
|
|
97191
97467
|
|
|
97192
97468
|
void *duckdb_column_data(duckdb_result *result, idx_t col) {
|
|
97193
|
-
if (!result || col >= result->
|
|
97469
|
+
if (!result || col >= result->__deprecated_column_count) {
|
|
97194
97470
|
return nullptr;
|
|
97195
97471
|
}
|
|
97196
|
-
return result->
|
|
97472
|
+
return result->__deprecated_columns[col].__deprecated_data;
|
|
97197
97473
|
}
|
|
97198
97474
|
|
|
97199
97475
|
bool *duckdb_nullmask_data(duckdb_result *result, idx_t col) {
|
|
97200
|
-
if (!result || col >= result->
|
|
97476
|
+
if (!result || col >= result->__deprecated_column_count) {
|
|
97201
97477
|
return nullptr;
|
|
97202
97478
|
}
|
|
97203
|
-
return result->
|
|
97479
|
+
return result->__deprecated_columns[col].__deprecated_nullmask;
|
|
97204
97480
|
}
|
|
97205
97481
|
|
|
97206
97482
|
char *duckdb_result_error(duckdb_result *result) {
|
|
97207
97483
|
if (!result) {
|
|
97208
97484
|
return nullptr;
|
|
97209
97485
|
}
|
|
97210
|
-
return result->
|
|
97486
|
+
return result->__deprecated_error_message;
|
|
97211
97487
|
}
|
|
97212
97488
|
|
|
97213
97489
|
|
|
@@ -97238,8 +97514,8 @@ namespace duckdb {
|
|
|
97238
97514
|
//===--------------------------------------------------------------------===//
|
|
97239
97515
|
template <class T>
|
|
97240
97516
|
T UnsafeFetch(duckdb_result *result, idx_t col, idx_t row) {
|
|
97241
|
-
D_ASSERT(row < result->
|
|
97242
|
-
return ((T *)result->
|
|
97517
|
+
D_ASSERT(row < result->__deprecated_row_count);
|
|
97518
|
+
return ((T *)result->__deprecated_columns[col].__deprecated_data)[row];
|
|
97243
97519
|
}
|
|
97244
97520
|
|
|
97245
97521
|
//===--------------------------------------------------------------------===//
|
|
@@ -97360,10 +97636,10 @@ RESULT_TYPE TryCastCInternal(duckdb_result *result, idx_t col, idx_t row) {
|
|
|
97360
97636
|
}
|
|
97361
97637
|
|
|
97362
97638
|
static bool CanFetchValue(duckdb_result *result, idx_t col, idx_t row) {
|
|
97363
|
-
if (!result || col >= result->
|
|
97639
|
+
if (!result || col >= result->__deprecated_column_count || row >= result->__deprecated_row_count) {
|
|
97364
97640
|
return false;
|
|
97365
97641
|
}
|
|
97366
|
-
if (result->
|
|
97642
|
+
if (result->__deprecated_columns[col].__deprecated_nullmask[row]) {
|
|
97367
97643
|
return false;
|
|
97368
97644
|
}
|
|
97369
97645
|
return true;
|
|
@@ -97374,7 +97650,7 @@ static RESULT_TYPE GetInternalCValue(duckdb_result *result, idx_t col, idx_t row
|
|
|
97374
97650
|
if (!CanFetchValue(result, col, row)) {
|
|
97375
97651
|
return FetchDefaultValue::Operation<RESULT_TYPE>();
|
|
97376
97652
|
}
|
|
97377
|
-
switch (result->
|
|
97653
|
+
switch (result->__deprecated_columns[col].__deprecated_type) {
|
|
97378
97654
|
case DUCKDB_TYPE_BOOLEAN:
|
|
97379
97655
|
return TryCastCInternal<bool, RESULT_TYPE, OP>(result, col, row);
|
|
97380
97656
|
case DUCKDB_TYPE_TINYINT:
|
|
@@ -97515,7 +97791,7 @@ char *duckdb_value_varchar_internal(duckdb_result *result, idx_t col, idx_t row)
|
|
|
97515
97791
|
}
|
|
97516
97792
|
|
|
97517
97793
|
duckdb_blob duckdb_value_blob(duckdb_result *result, idx_t col, idx_t row) {
|
|
97518
|
-
if (CanFetchValue(result, col, row) && result->
|
|
97794
|
+
if (CanFetchValue(result, col, row) && result->__deprecated_columns[col].__deprecated_type == DUCKDB_TYPE_BLOB) {
|
|
97519
97795
|
auto internal_result = UnsafeFetch<duckdb_blob>(result, col, row);
|
|
97520
97796
|
|
|
97521
97797
|
duckdb_blob result_blob;
|
|
@@ -97528,10 +97804,10 @@ duckdb_blob duckdb_value_blob(duckdb_result *result, idx_t col, idx_t row) {
|
|
|
97528
97804
|
}
|
|
97529
97805
|
|
|
97530
97806
|
bool duckdb_value_is_null(duckdb_result *result, idx_t col, idx_t row) {
|
|
97531
|
-
if (!result || col >= result->
|
|
97807
|
+
if (!result || col >= result->__deprecated_column_count || row >= result->__deprecated_row_count) {
|
|
97532
97808
|
return false;
|
|
97533
97809
|
}
|
|
97534
|
-
return result->
|
|
97810
|
+
return result->__deprecated_columns[col].__deprecated_nullmask[row];
|
|
97535
97811
|
}
|
|
97536
97812
|
|
|
97537
97813
|
//===----------------------------------------------------------------------===//
|