mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
bug#8281
NdbScanFilter, not a bug. But update example program ndb/ndbapi-examples/ndbapi_scan_example/ndbapi_scan.cpp: memset char[20] as all bytes are significant when comparing
This commit is contained in:
@ -102,6 +102,12 @@ milliSleep(int milliseconds){
|
|||||||
|
|
||||||
struct Car
|
struct Car
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Note memset, so that entire char-fields are cleared
|
||||||
|
* as all 20 bytes are significant (as type is char)
|
||||||
|
*/
|
||||||
|
Car() { memset(this, 0, sizeof(* this)); }
|
||||||
|
|
||||||
unsigned int reg_no;
|
unsigned int reg_no;
|
||||||
char brand[20];
|
char brand[20];
|
||||||
char color[20];
|
char color[20];
|
||||||
@ -791,8 +797,9 @@ int main()
|
|||||||
/**
|
/**
|
||||||
* Note! color needs to be of exact the same size as column defined
|
* Note! color needs to be of exact the same size as column defined
|
||||||
*/
|
*/
|
||||||
char color[20] = "Pink";
|
Car tmp;
|
||||||
if(scan_delete(&myNdb, column_color, color) > 0)
|
sprintf(tmp.color, "Pink");
|
||||||
|
if(scan_delete(&myNdb, column_color, tmp.color) > 0)
|
||||||
std::cout << "scan_delete: Success!" << std::endl << std::endl;
|
std::cout << "scan_delete: Success!" << std::endl << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -803,11 +810,12 @@ int main()
|
|||||||
/**
|
/**
|
||||||
* Note! color1 & 2 need to be of exact the same size as column defined
|
* Note! color1 & 2 need to be of exact the same size as column defined
|
||||||
*/
|
*/
|
||||||
char color1[20] = "Blue";
|
Car tmp1, tmp2;
|
||||||
char color2[20] = "Black";
|
sprintf(tmp1.color, "Blue");
|
||||||
std::cout << "Going to update all " << color1
|
sprintf(tmp2.color, "Black");
|
||||||
<< " cars to " << color2 << " cars!" << std::endl;
|
std::cout << "Going to update all " << tmp1.color
|
||||||
if(scan_update(&myNdb, column_color, color1, color2) > 0)
|
<< " cars to " << tmp2.color << " cars!" << std::endl;
|
||||||
|
if(scan_update(&myNdb, column_color, tmp1.color, tmp2.color) > 0)
|
||||||
std::cout << "scan_update: Success!" << std::endl << std::endl;
|
std::cout << "scan_update: Success!" << std::endl << std::endl;
|
||||||
}
|
}
|
||||||
if(scan_print(&myNdb) > 0)
|
if(scan_print(&myNdb) > 0)
|
||||||
|
Reference in New Issue
Block a user