Changeset: 7928b0675417 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/7928b0675417
Modified Files:
monetdb5/modules/atoms/json.c
sql/backends/monet5/rel_bin.c
sql/server/rel_exp.c
sql/server/rel_select.c
sql/server/rel_unnest.c
sql/server/sql_parser.y
sql/storage/store.c
Branch: nested
Log Message:
Merges with default
diffs (truncated from 2825 to 300 lines):
diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml
b/.github/ISSUE_TEMPLATE/bug_report.yml
--- a/.github/ISSUE_TEMPLATE/bug_report.yml
+++ b/.github/ISSUE_TEMPLATE/bug_report.yml
@@ -59,3 +59,24 @@ body:
Add any other context or screenshots about the problem here.
validations:
required: false
+ - type: markdown
+ attributes:
+ value: "Identity Disclosure:"
+ - type: input
+ attributes:
+ label: "Full Name:"
+ placeholder: e.g., Jane Doe
+ validations:
+ required: true
+ - type: input
+ attributes:
+ label: "Affiliation:"
+ placeholder: e.g., FooBar Corp
+ validations:
+ required: true
+ - type: markdown
+ attributes:
+ value: |
+ If the above is not given and is not obvious from your GitHub profile
page,
+ we might close your issue without further review. Please refer to the
+ [reasoning behind this
rule](https://berthub.eu/articles/posts/anonymous-help/) if you have questions.
diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml
b/.github/ISSUE_TEMPLATE/feature_request.yml
--- a/.github/ISSUE_TEMPLATE/feature_request.yml
+++ b/.github/ISSUE_TEMPLATE/feature_request.yml
@@ -34,3 +34,24 @@ body:
Add any other context or screenshots about the feature request here.
validations:
required: false
+ - type: markdown
+ attributes:
+ value: "Identity Disclosure:"
+ - type: input
+ attributes:
+ label: "Full Name:"
+ placeholder: e.g., Jane Doe
+ validations:
+ required: true
+ - type: input
+ attributes:
+ label: "Affiliation:"
+ placeholder: e.g., FooBar Corp
+ validations:
+ required: true
+ - type: markdown
+ attributes:
+ value: |
+ If the above is not provided and cannot be inferred from your GitHub
profile page,
+ we might close your issue without further review. Refer to the
+ [reasoning behind this
rule](https://berthub.eu/articles/posts/anonymous-help/) if you have questions.
diff --git a/.github/ISSUE_TEMPLATE/other_issue.yml
b/.github/ISSUE_TEMPLATE/other_issue.yml
--- a/.github/ISSUE_TEMPLATE/other_issue.yml
+++ b/.github/ISSUE_TEMPLATE/other_issue.yml
@@ -26,3 +26,24 @@ body:
Add any other context or screenshots about the problem here.
validations:
required: false
+ - type: markdown
+ attributes:
+ value: "Identity Disclosure:"
+ - type: input
+ attributes:
+ label: "Full Name:"
+ placeholder: e.g., Jane Doe
+ validations:
+ required: true
+ - type: input
+ attributes:
+ label: "Affiliation:"
+ placeholder: e.g., FooBar Corp
+ validations:
+ required: true
+ - type: markdown
+ attributes:
+ value: |
+ If the above is not provided and cannot be inferred from your GitHub
profile page,
+ we might close your issue without further review. Refer to the
+ [reasoning behind this
rule](https://berthub.eu/articles/posts/anonymous-help/) if you have questions.
diff --git a/clients/odbc/driver/ODBCConvert.c
b/clients/odbc/driver/ODBCConvert.c
--- a/clients/odbc/driver/ODBCConvert.c
+++ b/clients/odbc/driver/ODBCConvert.c
@@ -49,7 +49,7 @@ typedef struct {
* 0 is returned if the string is not a number, or if scale doesn't fit.
*/
static int
-parseint(const char *data, bignum_t *nval)
+parsebignum(const char *data, bignum_t *nval)
{
int fraction = 0; /* inside the fractional part */
int scale = 0;
@@ -57,7 +57,7 @@ parseint(const char *data, bignum_t *nva
nval->val = 0;
nval->precision = 0;
- scale = 0;
+
while (space(*data))
data++;
if (*data == '-') {
@@ -1103,7 +1103,7 @@ ODBCFetch(ODBCStmt *stmt,
case SQL_INTERVAL_MINUTE:
case SQL_INTERVAL_MINUTE_TO_SECOND:
case SQL_INTERVAL_SECOND:
- switch (parseint(data, &nval)) {
+ switch (parsebignum(data, &nval)) {
case 0:
/* shouldn't happen: getting here means SQL
* server told us a value was of a certain
@@ -1308,6 +1308,8 @@ ODBCFetch(ODBCStmt *stmt,
case SQL_INTEGER:
case SQL_BIGINT:
case SQL_HUGEINT:
+ case SQL_DECIMAL:
+ case SQL_NUMERIC:
sz = snprintf((char *) ptr, buflen, "%s", data);
if (sz < 0 || sz >= buflen) {
/* Numeric value out of range */
@@ -1320,8 +1322,6 @@ ODBCFetch(ODBCStmt *stmt,
if (lenp)
*lenp = sz;
break;
- case SQL_DECIMAL:
- case SQL_NUMERIC:
case SQL_BIT: {
uint64_t f;
int n;
@@ -2098,7 +2098,7 @@ ODBCFetch(ODBCStmt *stmt,
case SQL_FLOAT:
case SQL_REAL:
/* reparse double and float, parse char */
- if (!parseint(data, &nval)) {
+ if (!parsebignum(data, &nval)) {
/* Invalid character value for cast
* specification */
addStmtError(stmt, "22018", NULL, 0);
@@ -2301,7 +2301,7 @@ ODBCFetch(ODBCStmt *stmt,
case SQL_FLOAT:
case SQL_REAL:
/* reparse double and float, parse char */
- if (!parseint(data, &nval)) {
+ if (!parsebignum(data, &nval)) {
/* Invalid character value for cast
* specification */
addStmtError(stmt, "22018", NULL, 0);
@@ -2370,7 +2370,7 @@ ODBCFetch(ODBCStmt *stmt,
case SQL_FLOAT:
case SQL_REAL:
/* reparse double and float, parse char */
- if (!(i = parseint(data, &nval))) {
+ if (!(i = parsebignum(data, &nval))) {
/* Invalid character value for cast
* specification */
addStmtError(stmt, "22018", NULL, 0);
@@ -3779,7 +3779,7 @@ ODBCStore(ODBCStmt *stmt,
case SQL_C_BINARY:
/* parse character data, reparse floating
* point number */
- if (!parseint(sval, &nval)) {
+ if (!parsebignum(sval, &nval)) {
/* Invalid character value for cast
* specification */
addStmtError(stmt, "22018", NULL, 0);
diff --git a/clients/odbc/tests/ODBCtester.c b/clients/odbc/tests/ODBCtester.c
--- a/clients/odbc/tests/ODBCtester.c
+++ b/clients/odbc/tests/ODBCtester.c
@@ -393,12 +393,12 @@ testGetDataIntervalDay(SQLHANDLE stmt, i
"SQLColAttribute(2, SQL_DESC_DISPLAY_SIZE) returns 0,
NumAttr 21\n"
"SQLGetData(2, SQL_C_CHAR, 41) returns 0, vallen 18,
str_val: 'INTERVAL '101' DAY'\n"
"SQLGetData(2, SQL_C_SLONG) returns 0, vallen 4,
int_val: 101\n" /* SQLstate 07006 Restricted data type attribute
violation */
- "SQLGetData(2, SQL_C_INTERVAL_DAY) returns 0, vallen
28, itv_day_val: 101 (type 3, sign 0)\n" /* SQLstate 22015 Interval field
overflow */
+ "SQLGetData(2, SQL_C_INTERVAL_DAY) returns 0, vallen
28, itv_day_val: 101 (type 3, sign 0)\n"
"SQLColAttribute(3, SQL_DESC_CONCISE_TYPE) returns 0,
NumAttr 103\n"
"SQLColAttribute(3, SQL_DESC_DISPLAY_SIZE) returns 0,
NumAttr 21\n"
"SQLGetData(3, SQL_C_CHAR, 41) returns 0, vallen 19,
str_val: 'INTERVAL -'102' DAY'\n"
"SQLGetData(3, SQL_C_SLONG) returns 0, vallen 4,
int_val: -102\n" /* SQLstate 07006 Restricted data type attribute
violation */
- "SQLGetData(3, SQL_C_INTERVAL_DAY) returns 0, vallen
28, itv_day_val: 102 (type 3, sign 1)\n" /* SQLstate 22015 Interval field
overflow */
+ "SQLGetData(3, SQL_C_INTERVAL_DAY) returns 0, vallen
28, itv_day_val: 102 (type 3, sign 1)\n"
);
ret = SQLCloseCursor(stmt);
@@ -409,6 +409,143 @@ testGetDataIntervalDay(SQLHANDLE stmt, i
return ret;
}
+#ifdef HAVE_HGE
+static SQLRETURN
+testGetDataDecimal(SQLHANDLE stmt, int sqlquery)
+{
+ SQLRETURN ret;
+ SQLLEN RowCount = 0;
+ SWORD NumResultCols = 0;
+
+ size_t outp_len = 1800;
+ char * outp = malloc(outp_len);
+ size_t pos = 0;
+
+ char * sql1 = "select cast(99999999909999999990999999999012345678. as
decimal(38,0)) as val1, cast(-99999999909999999990999999999012345678. as
decimal(38,0)) as val2;";
+ char * sql2 = "select cast(92345678901234567890.123456789 as
decimal(29,9)) as val1, cast(-92345678901234567890.123456789 as decimal(29,9))
as val2;";
+ char * sql3 = "select cast(92345678901234567890.123456789012345678 as
decimal(38,18)) as val1, cast(-9234567890123456789.1234567890123456789 as
decimal(38,19)) as val2;";
+ char * sql4 = "select cast(987654321.12345678901234567890123456789 as
decimal(38,29)) as val1, cast(-987654321.12345678901234567890123456789 as
decimal(38,29)) as val2;";
+ char * sql5 = "select cast(.99999999909999999990999999999012345678 as
decimal(38,38)) as val1, cast(-.99999999909999999990999999999012345678 as
decimal(38,38)) as val2;";
+ char * sql = (sqlquery == 1) ? sql1 : (sqlquery == 2) ? sql2 :
(sqlquery == 3) ? sql3 : (sqlquery == 4) ? sql4 : sql5;
+
+ ret = SQLExecDirect(stmt, (SQLCHAR *) sql, SQL_NTS);
+ pos += snprintf(outp + pos, outp_len - pos, "SQLExecDirect query %d:
%s\n", sqlquery, sql);
+ check(ret, SQL_HANDLE_STMT, stmt, "SQLExecDirect");
+
+ ret = SQLRowCount(stmt, &RowCount);
+ pos += snprintf(outp + pos, outp_len - pos, "SQLRowCount is " LLFMT
"\n", (int64_t) RowCount);
+ check(ret, SQL_HANDLE_STMT, stmt, "SQLRowCount");
+
+ ret = SQLNumResultCols(stmt, &NumResultCols);
+ pos += snprintf(outp + pos, outp_len - pos, "SQLNumResultCols is %d\n",
NumResultCols);
+ check(ret, SQL_HANDLE_STMT, stmt, "SQLNumResultCols");
+
+ ret = SQLFetch(stmt);
+ pos += snprintf(outp + pos, outp_len - pos, "SQLFetch\n");
+ check(ret, SQL_HANDLE_STMT, stmt, "SQLFetch");
+
+ for (SWORD col = 1; col <= NumResultCols; col++) {
+ char buf[99];
+ char dec_str_val[42];
+ SQL_NUMERIC_STRUCT dec_num_val;
+ SQLLEN vallen = 0;
+ SQLLEN NumAttr = 0;
+
+ /* retrieve query result column metadata */
+ ret = SQLColAttribute(stmt, (UWORD)col, SQL_DESC_CONCISE_TYPE,
(PTR)&buf, (SQLLEN)20, NULL, &NumAttr);
+ pos += snprintf(outp + pos, outp_len - pos,
"SQLColAttribute(%d, SQL_DESC_CONCISE_TYPE) returns %d, NumAttr " LLFMT "\n",
col, ret, (int64_t) NumAttr);
+ ret = SQLColAttribute(stmt, (UWORD)col, SQL_DESC_DISPLAY_SIZE,
(PTR)&buf, (SQLLEN)20, NULL, &NumAttr);
+ pos += snprintf(outp + pos, outp_len - pos,
"SQLColAttribute(%d, SQL_DESC_DISPLAY_SIZE) returns %d, NumAttr " LLFMT "\n",
col, ret, (int64_t) NumAttr);
+
+ /* test SQLGetData(SQL_C_CHAR) */
+ ret = SQLGetData(stmt, (UWORD)col, (SWORD)SQL_C_CHAR,
(PTR)&dec_str_val, (SQLLEN)42, &vallen);
+ pos += snprintf(outp + pos, outp_len - pos, "SQLGetData(%d,
SQL_C_CHAR, 42) returns %d, vallen " LLFMT ", str_val: '%s'\n",
+ col, ret, (int64_t) vallen, (vallen == SQL_NULL_DATA) ?
"NULL" : dec_str_val);
+ check(ret, SQL_HANDLE_STMT, stmt, "SQLGetData(col)");
+
+ /* test SQLGetData(SQL_C_NUMERIC) */
+ ret = SQLGetData(stmt, (UWORD)col, (SWORD)SQL_C_NUMERIC,
(PTR)&dec_num_val, (SQLLEN)sizeof(SQL_NUMERIC_STRUCT), &vallen);
+ pos += snprintf(outp + pos, outp_len - pos, "SQLGetData(%d,
SQL_C_NUMERIC, 19) returns %d, vallen " LLFMT ", data_val: ", col, ret,
(int64_t) vallen);
+ if (ret == SQL_SUCCESS) {
+ if (vallen == SQL_NULL_DATA)
+ pos += snprintf(outp + pos, outp_len - pos,
"NULL\n");
+ else {
+ pos += snprintf(outp + pos, outp_len - pos, "%u
%u %u %u %u %u %u %u %u %u %u %u %u %u %u %u\n",
+ (uint8_t)dec_num_val.val[0],
(uint8_t)dec_num_val.val[1], (uint8_t)dec_num_val.val[2],
(uint8_t)dec_num_val.val[3],
+ (uint8_t)dec_num_val.val[4],
(uint8_t)dec_num_val.val[5], (uint8_t)dec_num_val.val[6],
(uint8_t)dec_num_val.val[7],
+ (uint8_t)dec_num_val.val[8],
(uint8_t)dec_num_val.val[9], (uint8_t)dec_num_val.val[10],
(uint8_t)dec_num_val.val[11],
+ (uint8_t)dec_num_val.val[12],
(uint8_t)dec_num_val.val[13], (uint8_t)dec_num_val.val[14],
(uint8_t)dec_num_val.val[15]);
+ }
+ }
+ check(ret, SQL_HANDLE_STMT, stmt, "SQLGetData(col)");
+ }
+
+ compareResult("testGetDataDecimal()", outp,
+ (sqlquery == 1)
+ ? "SQLExecDirect query 1: select
cast(99999999909999999990999999999012345678. as decimal(38,0)) as val1,
cast(-99999999909999999990999999999012345678. as decimal(38,0)) as val2;\n"
+ "SQLRowCount is 1\nSQLNumResultCols is 2\nSQLFetch\n"
+ "SQLColAttribute(1, SQL_DESC_CONCISE_TYPE) returns 0,
NumAttr 3\n"
+ "SQLColAttribute(1, SQL_DESC_DISPLAY_SIZE) returns 0,
NumAttr 40\n"
+ "SQLGetData(1, SQL_C_CHAR, 42) returns 0, vallen 38,
str_val: '99999999909999999990999999999012345678'\n"
+ "SQLGetData(1, SQL_C_NUMERIC, 19) returns 0, vallen 19,
data_val: 0 0 0 96 117 10 24 156 203 180 104 23 167 76 59 75\n"
+ "SQLColAttribute(2, SQL_DESC_CONCISE_TYPE) returns 0,
NumAttr 3\n"
+ "SQLColAttribute(2, SQL_DESC_DISPLAY_SIZE) returns 0,
NumAttr 40\n"
+ "SQLGetData(2, SQL_C_CHAR, 42) returns 0, vallen 39,
str_val: '-99999999909999999990999999999012345678'\n"
+ "SQLGetData(2, SQL_C_NUMERIC, 19) returns 0, vallen 19,
data_val: 0 0 0 96 117 10 24 156 203 180 104 23 167 76 59 75\n"
+ : (sqlquery == 2)
+ ? "SQLExecDirect query 2: select
cast(92345678901234567890.123456789 as decimal(29,9)) as val1,
cast(-92345678901234567890.123456789 as decimal(29,9)) as val2;\n"
+ "SQLRowCount is 1\nSQLNumResultCols is 2\nSQLFetch\n"
+ "SQLColAttribute(1, SQL_DESC_CONCISE_TYPE) returns 0,
NumAttr 3\n"
+ "SQLColAttribute(1, SQL_DESC_DISPLAY_SIZE) returns 0,
NumAttr 31\n"
+ "SQLGetData(1, SQL_C_CHAR, 42) returns 0, vallen 30,
str_val: '92345678901234567890.123456789'\n"
+ "SQLGetData(1, SQL_C_NUMERIC, 19) returns 0, vallen 19,
data_val: 0 8 201 240 176 193 141 1 5 0 0 0 0 0 0 0\n"
+ "SQLColAttribute(2, SQL_DESC_CONCISE_TYPE) returns 0,
NumAttr 3\n"
+ "SQLColAttribute(2, SQL_DESC_DISPLAY_SIZE) returns 0,
NumAttr 31\n"
+ "SQLGetData(2, SQL_C_CHAR, 42) returns 0, vallen 31,
str_val: '-92345678901234567890.123456789'\n"
+ "SQLGetData(2, SQL_C_NUMERIC, 19) returns 0, vallen 19,
data_val: 0 8 201 240 176 193 141 1 5 0 0 0 0 0 0 0\n"
+ : (sqlquery == 3)
+ ? "SQLExecDirect query 3: select
cast(92345678901234567890.123456789012345678 as decimal(38,18)) as val1,
cast(-9234567890123456789.1234567890123456789 as decimal(38,19)) as val2;\n"
+ "SQLRowCount is 1\nSQLNumResultCols is 2\nSQLFetch\n"
+ "SQLColAttribute(1, SQL_DESC_CONCISE_TYPE) returns 0,
NumAttr 3\n"
+ "SQLColAttribute(1, SQL_DESC_DISPLAY_SIZE) returns 0,
NumAttr 40\n"
+ "SQLGetData(1, SQL_C_CHAR, 42) returns 0, vallen 39,
str_val: '92345678901234567890.123456789012345678'\n"
+ "SQLGetData(1, SQL_C_NUMERIC, 19) returns 0, vallen 19,
data_val: 0 8 201 240 176 193 141 1 5 0 0 0 0 0 0 0\n"
+ "SQLColAttribute(2, SQL_DESC_CONCISE_TYPE) returns 0,
NumAttr 3\n"
+ "SQLColAttribute(2, SQL_DESC_DISPLAY_SIZE) returns 0,
NumAttr 40\n"
+ "SQLGetData(2, SQL_C_CHAR, 42) returns 0, vallen 40,
str_val: '-9234567890123456789.1234567890123456789'\n"
+ "SQLGetData(2, SQL_C_NUMERIC, 19) returns 0, vallen 19,
data_val: 0 180 173 177 145 198 39 128 0 0 0 0 0 0 0 0\n"
+ : (sqlquery == 4)
+ ? "SQLExecDirect query 4: select
cast(987654321.12345678901234567890123456789 as decimal(38,29)) as val1,
cast(-987654321.12345678901234567890123456789 as decimal(38,29)) as val2;\n"
+ "SQLRowCount is 1\nSQLNumResultCols is 2\nSQLFetch\n"
+ "SQLColAttribute(1, SQL_DESC_CONCISE_TYPE) returns 0,
NumAttr 3\n"
+ "SQLColAttribute(1, SQL_DESC_DISPLAY_SIZE) returns 0,
NumAttr 40\n"
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]