Skip to content

Commit e5cd357

Browse files
committed
Merge remote-tracking branch 'origin/2.0-wl10037' into 2.0
2 parents fc1ca55 + 618fb33 commit e5cd357

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+3732
-521
lines changed

cdk/core/tests/session_crud-t.cc

Lines changed: 210 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,7 @@ CRUD_TEST_BEGIN(find)
846846

847847
Expr criteria(criteria_str);
848848

849-
Reply find(sess.coll_find(coll, &criteria, NULL));
849+
Reply find(sess.coll_find(coll, NULL, &criteria, NULL));
850850
Cursor c(find);
851851

852852
set_meta_data(c);
@@ -869,7 +869,7 @@ CRUD_TEST_BEGIN(find)
869869

870870
Expr criteria(criteria_str);
871871

872-
Reply find(sess.coll_find(coll, &criteria, NULL));
872+
Reply find(sess.coll_find(coll, NULL, &criteria, NULL));
873873
Cursor c(find);
874874

875875
set_meta_data(c);
@@ -1054,7 +1054,7 @@ CRUD_TEST_BEGIN(update)
10541054

10551055
// Show data after update.
10561056

1057-
Reply find(sess.coll_find(coll, &which));
1057+
Reply find(sess.coll_find(coll, NULL, &which));
10581058
Cursor c(find);
10591059
set_meta_data(c);
10601060
c.get_rows(*this);
@@ -1088,7 +1088,7 @@ CRUD_TEST_BEGIN(update)
10881088

10891089
// Show data after update.
10901090

1091-
Reply find(sess.coll_find(coll, &which));
1091+
Reply find(sess.coll_find(coll, NULL, &which));
10921092
Cursor c(find);
10931093
set_meta_data(c);
10941094
c.get_rows(*this);
@@ -1173,7 +1173,7 @@ CRUD_TEST_BEGIN(parameters)
11731173
param_values;
11741174

11751175
{
1176-
Reply find(sess.coll_find(coll, &expr, NULL, NULL, NULL, NULL, NULL, &param_values));
1176+
Reply find(sess.coll_find(coll, NULL, &expr, NULL, NULL, NULL, NULL, NULL, &param_values));
11771177
Cursor c(find);
11781178

11791179
set_meta_data(c);
@@ -1205,7 +1205,7 @@ CRUD_TEST_BEGIN(parameters)
12051205
}
12061206

12071207
{
1208-
Reply find(sess.coll_find(coll, &expr, NULL, NULL, NULL, NULL, NULL, &param_values));
1208+
Reply find(sess.coll_find(coll, NULL, &expr, NULL, NULL, NULL, NULL, NULL, &param_values));
12091209
Cursor c(find);
12101210

12111211
set_meta_data(c);
@@ -1226,7 +1226,7 @@ CRUD_TEST_BEGIN(parameters)
12261226
}
12271227

12281228
{
1229-
Reply find(sess.coll_find(coll, &expr, NULL, NULL, NULL, NULL, NULL, &param_values));
1229+
Reply find(sess.coll_find(coll, NULL, &expr, NULL, NULL, NULL, NULL, NULL, &param_values));
12301230
Cursor c(find);
12311231

12321232
set_meta_data(c);
@@ -1287,6 +1287,7 @@ CRUD_TEST_BEGIN(projections)
12871287

12881288
Reply find(
12891289
sess.coll_find(coll,
1290+
NULL, // view spec
12901291
NULL, // where
12911292
&projection,
12921293
NULL, // sort
@@ -1360,7 +1361,7 @@ CRUD_TEST_BEGIN(projections)
13601361
}
13611362
projection;
13621363

1363-
Reply find(sess.table_select(coll, &criteria, &projection));
1364+
Reply find(sess.table_select(coll, NULL, &criteria, &projection));
13641365
Cursor c(find);
13651366

13661367
set_meta_data(c);
@@ -1447,7 +1448,7 @@ CRUD_TEST_BEGIN(insert)
14471448

14481449
{
14491450
TExpr cond("id IS NULL AND extra IS NULL");
1450-
Reply check(sess.table_select(tbl, &cond));
1451+
Reply check(sess.table_select(tbl, NULL, &cond));
14511452
Cursor c(check);
14521453
set_meta_data(c);
14531454
c.get_rows(*this);
@@ -1540,6 +1541,7 @@ CRUD_TEST_BEGIN(group_by)
15401541

15411542
Reply find(
15421543
sess.coll_find(coll,
1544+
NULL, // view spec
15431545
NULL, // where
15441546
&projection,
15451547
NULL, // sort
@@ -1604,6 +1606,7 @@ CRUD_TEST_BEGIN(group_by)
16041606

16051607
Reply find(
16061608
sess.table_select(tbl,
1609+
NULL, // view spec
16071610
NULL, // where
16081611
&projection,
16091612
NULL, // sort
@@ -1626,3 +1629,201 @@ CRUD_TEST_BEGIN(group_by)
16261629
cout <<"Done!" <<endl;
16271630
}
16281631
CRUD_TEST_END
1632+
1633+
1634+
CRUD_TEST_BEGIN(views)
1635+
{
1636+
Session sess(this);
1637+
1638+
if (!sess.is_valid())
1639+
FAIL() << "Invalid Session created";
1640+
1641+
cout << "Session established" << endl;
1642+
1643+
struct View_spec : cdk::View_spec
1644+
{
1645+
Table_ref v;
1646+
String_list *columns;
1647+
cdk::View_spec::Options *opts;
1648+
1649+
View_spec()
1650+
: v("view", "test")
1651+
, columns(NULL)
1652+
, opts(NULL)
1653+
{}
1654+
1655+
void process(Processor &prc) const
1656+
{
1657+
prc.name(v);
1658+
if (columns)
1659+
columns->process_if(prc.columns());
1660+
if (opts)
1661+
opts->process_if(prc.options());
1662+
}
1663+
}
1664+
view;
1665+
1666+
cout << "Creating collection view..." << endl;
1667+
1668+
// Drop the view first, if it already exists.
1669+
1670+
{
1671+
Reply drop(sess.view_drop(view.v));
1672+
drop.wait();
1673+
if (0 < drop.entry_count())
1674+
drop.get_error().rethrow();
1675+
}
1676+
1677+
{
1678+
struct : public View_spec::Options
1679+
{
1680+
void process(Processor &prc) const
1681+
{
1682+
prc.security(View_security::DEFINER);
1683+
prc.check(View_check::LOCAL);
1684+
}
1685+
}
1686+
view_opts;
1687+
1688+
view.opts = &view_opts;
1689+
1690+
struct : public Expression::Document
1691+
{
1692+
void process(Processor &prc) const
1693+
{
1694+
Path name_path("name");
1695+
Path age_path("age");
1696+
Expr double_age("2*age");
1697+
Safe_prc<Processor> sprc(prc);
1698+
1699+
prc.doc_begin();
1700+
1701+
sprc->key_val("name_proj")->scalar()->ref(name_path);
1702+
double_age.process_if(sprc->key_val("age_proj"));
1703+
sprc->key_val("extra.orig_age")->scalar()->ref(age_path);
1704+
sprc->key_val("extra.val")->scalar()->val()->str("bar");
1705+
1706+
prc.doc_end();
1707+
}
1708+
}
1709+
projection;
1710+
1711+
Expr cond("name LIKE 'ba%'");
1712+
1713+
Reply create(sess.coll_find(coll, &view, &cond, &projection));
1714+
create.wait();
1715+
if (0 < create.entry_count())
1716+
create.get_error().rethrow();
1717+
}
1718+
1719+
cout << "View created, querying it..." << endl;
1720+
1721+
{
1722+
Reply select(sess.coll_find(view.v));
1723+
select.wait();
1724+
1725+
cout << "Got reply..." << endl;
1726+
1727+
Cursor c(select);
1728+
1729+
set_meta_data(c);
1730+
c.get_rows(*this);
1731+
c.wait();
1732+
}
1733+
1734+
1735+
cout << "Creating table view..." << endl;
1736+
1737+
// Drop the view first.
1738+
1739+
{
1740+
Reply drop(sess.view_drop(view.v, false));
1741+
drop.wait();
1742+
if (0 < drop.entry_count())
1743+
drop.get_error().rethrow();
1744+
}
1745+
1746+
{
1747+
struct : public View_spec::Options
1748+
{
1749+
void process(Processor &prc) const
1750+
{
1751+
prc.security(View_security::INVOKER);
1752+
prc.algorithm(View_algorithm::UNDEFINED);
1753+
}
1754+
}
1755+
view_opts;
1756+
1757+
view.opts = &view_opts;
1758+
1759+
struct : public Projection
1760+
{
1761+
void process(Processor &prc) const
1762+
{
1763+
Processor::Element_prc *ep;
1764+
1765+
prc.list_begin();
1766+
1767+
if ((ep = prc.list_el()))
1768+
{
1769+
TExpr proj(L"name");
1770+
proj.process_if(ep->expr());
1771+
// no alias
1772+
}
1773+
1774+
if ((ep = prc.list_el()))
1775+
{
1776+
TExpr proj(L"2 * age");
1777+
proj.process_if(ep->expr());
1778+
ep->alias(L"double age");
1779+
}
1780+
1781+
prc.list_end();
1782+
}
1783+
}
1784+
projection;
1785+
1786+
struct : public cdk::String_list
1787+
{
1788+
void process(Processor &prc) const
1789+
{
1790+
prc.list_begin();
1791+
safe_prc(prc)->list_el()->val("view_name");
1792+
safe_prc(prc)->list_el()->val("view_age");
1793+
prc.list_end();
1794+
}
1795+
}
1796+
columns;
1797+
1798+
view.columns = &columns;
1799+
1800+
TExpr cond("name LIKE 'ba%'");
1801+
1802+
Reply create(sess.table_select(tbl, &view, &cond, &projection));
1803+
create.wait();
1804+
if (0 < create.entry_count())
1805+
create.get_error().rethrow();
1806+
}
1807+
1808+
cout << "View created, querying it..." << endl;
1809+
1810+
{
1811+
Reply select(sess.table_select(view.v));
1812+
select.wait();
1813+
1814+
cout << "Got reply..." << endl;
1815+
1816+
Cursor c(select);
1817+
1818+
EXPECT_EQ(L"view_name", c.col_info(0).name());
1819+
EXPECT_EQ(L"view_age", c.col_info(1).name());
1820+
1821+
set_meta_data(c);
1822+
c.get_rows(*this);
1823+
c.wait();
1824+
}
1825+
1826+
1827+
cout <<"Done!" <<endl;
1828+
}
1829+
CRUD_TEST_END

cdk/foundation/connection_yassl.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
PUSH_SYS_WARNINGS
2727
#include "../extra/yassl/include/openssl/ssl.h"
2828
POP_SYS_WARNINGS
29-
#include <mysql/cdk/protocol/mysqlx.h>
3029
#include <mysql/cdk/foundation/error.h>
3130
#include <mysql/cdk/foundation/connection_yassl.h>
3231
#include <mysql/cdk/foundation/opaque_impl.i>

cdk/include/mysql/cdk/api/document.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#ifndef CDK_API_DOCUMENT_H
2626
#define CDK_API_DOCUMENT_H
2727

28-
#include "../foundation.h"
2928
#include "expression.h"
3029

3130
namespace cdk {

cdk/include/mysql/cdk/api/expression.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#ifndef CDK_API_EXPRESSION_H
2626
#define CDK_API_EXPRESSION_H
2727

28+
#include "../foundation.h"
2829
#include <stddef.h> // for NULL
2930
#include <stdint.h>
3031

0 commit comments

Comments
 (0)