Commit 050256c2 authored by unknown's avatar unknown

Remove NOT_YET code

Update comments
Add more tests for "let from query"


client/mysqltest.c:
  Remove NOT_YET code
  Update comments
mysql-test/r/mysqltest.result:
  Add more tests for "let from query"
mysql-test/t/mysqltest.test:
  Add more tests for "let from query"
parent 135b5863
...@@ -1777,40 +1777,22 @@ void var_query_set(VAR *var, const char *query, const char** query_end) ...@@ -1777,40 +1777,22 @@ void var_query_set(VAR *var, const char *query, const char** query_end)
die("Query '%s' didn't return a result set", ds_query.str); die("Query '%s' didn't return a result set", ds_query.str);
dynstr_free(&ds_query); dynstr_free(&ds_query);
if ((row = mysql_fetch_row(res)) && row[0]) if ((row= mysql_fetch_row(res)) && row[0])
{ {
/* /*
Concatenate all row results with tab in between to allow us to work Concatenate all fields in the first row with tab in between
with results from many columns (for example from SHOW VARIABLES) and assign that string to the $variable
*/ */
DYNAMIC_STRING result; DYNAMIC_STRING result;
uint i; uint i;
ulong *lengths; ulong *lengths;
#ifdef NOT_YET
MYSQL_FIELD *fields= mysql_fetch_fields(res);
#endif
init_dynamic_string(&result, "", 2048, 2048); init_dynamic_string(&result, "", 512, 512);
lengths= mysql_fetch_lengths(res); lengths= mysql_fetch_lengths(res);
for (i=0; i < mysql_num_fields(res); i++) for (i= 0; i < mysql_num_fields(res); i++)
{ {
if (row[0]) if (row[i])
{ {
#ifdef NOT_YET
/* Add to <var_name>_<col_name> */
uint j;
char var_col_name[MAX_VAR_NAME_LENGTH];
uint length= snprintf(var_col_name, MAX_VAR_NAME_LENGTH,
"$%s_%s", var->name, fields[i].name);
/* Convert characters not allowed in variable names to '_' */
for (j= 1; j < length; j++)
{
if (!my_isvar(charset_info,var_col_name[j]))
var_col_name[j]= '_';
}
var_set(var_col_name, var_col_name + length,
row[i], row[i] + lengths[i]);
#endif
/* Add column to tab separated string */ /* Add column to tab separated string */
dynstr_append_mem(&result, row[i], lengths[i]); dynstr_append_mem(&result, row[i], lengths[i]);
} }
......
...@@ -280,6 +280,18 @@ let $B = changed value of B; ...@@ -280,6 +280,18 @@ let $B = changed value of B;
var2: content of variable 1 var2: content of variable 1
var3: content of variable 1 content of variable 1 var3: content of variable 1 content of variable 1
length of var3 is longer than 0 length of var3 is longer than 0
var1
hi 1 hi there
var2
2
var2 again
2
var3 two columns with same name
1 2 3
var4 from query that returns NULL
var5 from query that returns no row
failing query in let
mysqltest: At line 1: Error running query 'failing query': 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'failing query' at line 1
mysqltest: At line 1: Missing required argument 'filename' to command 'source' mysqltest: At line 1: Missing required argument 'filename' to command 'source'
mysqltest: At line 1: Could not open file ./non_existingFile mysqltest: At line 1: Could not open file ./non_existingFile
mysqltest: In included file "MYSQLTEST_VARDIR/tmp/recursive.sql": At line 1: Source directives are nesting too deep mysqltest: In included file "MYSQLTEST_VARDIR/tmp/recursive.sql": At line 1: Source directives are nesting too deep
......
...@@ -736,38 +736,40 @@ if (`select length("$var3") > 0`) ...@@ -736,38 +736,40 @@ if (`select length("$var3") > 0`)
# Test to assign let from query # Test to assign let from query
# let $<var_name>=`<query>`; # let $<var_name>=`<query>`;
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
--disable_parsing
echo var1; echo var1;
let $var1= `select "hi" as "Col", 1 as "Column1", "hi there" as Col3`; let $var1= `select "hi" as "Col", 1 as "Column1", "hi there" as Col3`;
echo $var1; echo $var1;
echo $var1_Col;
echo $var1_Column1;
echo $var1_Col3;
echo var2; echo var2;
let $var2= `select 2 as "Column num 2"`; let $var2= `select 2 as "Column num 2"`;
echo $var2; echo $var2;
echo $var2_Column num 2;
echo $var2_Column;
echo var2 again; echo var2 again;
let $var2= `select 2 as "Column num 2"`; let $var2= `select 2 as "Column num 2"`;
echo $var2; echo $var2;
echo $var2_Column num 2;
echo $var2_Column_num_2;
echo $var2_Column;
echo var3 two columns with same name; echo var3 two columns with same name;
let $var3= `select 1 as "Col", 2 as "Col", 3 as "var3"`; let $var3= `select 1 as "Col", 2 as "Col", 3 as "var3"`;
echo $var3; echo $var3;
echo $var3_Col;
echo $var3_Col;
echo $var3_var3;
#echo failing query in let; echo var4 from query that returns NULL;
#--error 1 let $var4= `select NULL`;
#--exec echo "let $var2= `failing query;`" | $MYSQL_TEST 2>&1
--enable_parsing echo var5 from query that returns no row;
let $var5= `SHOW VARIABLES LIKE "nonexisting_variable"`;
echo failing query in let;
--write_file $MYSQLTEST_VARDIR/tmp/let.sql
let $var2= `failing query`;
echo $var2;
EOF
--error 1
--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/let.sql 2>&1
remove_file $MYSQLTEST_VARDIR/tmp/let.sql;
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# Test source command # Test source command
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment