Parse the `swapks` header if it is provided

next
Sayan Nandan 3 years ago
parent 288533f16b
commit 49fa843eb2

@ -12,13 +12,15 @@ All changes in this project will be noted in this file.
```sql
CREATE KEYSPACE <name>
```
- The `system` keyspace is reserved for the system
- The `system` keyspace is reserved for the system while the `default` keyspace is
the one available by default. The `system` or `default` keyspace cannot be removed
- Keyspaces can be deleted with:
```sql
DROP KEYSPACE <name>
```
- **Multiple tables**:
- Tables hold the actual data
- Tables hold the actual data. When you connect to the server, you are connected to the `default`
table in the `default` keyspace. This table is non-removable
- Tables can be created with:
```sql
CREATE TABLE <entity> <model>(modelargs) <properties>
@ -102,6 +104,8 @@ All changes in this project will be noted in this file.
- Zero length argument causing runtime panic in `skysh`
- Panic on incorrect data type in `skyd`
- `sky-bench` no longer affects your personal data because it creates a random temporary table
under the `default` keyspace
## Version 0.6.3 [2021-06-27]

@ -82,7 +82,7 @@ Skytable uses a Makefile for builds and running the test suite along with a numb
make release
```
> **TIP**: You can explicitly specificy a target triple by setting a `TARGET` environment variable
> **TIP**: You can explicitly specify a target triple by setting a `TARGET` environment variable
**Testing**
@ -92,4 +92,4 @@ Testing is simple: just run this:
make test
```
> **NOTE**: Make sure port 2003 is not used by any applications
> **NOTE**: Make sure port 2003 is not used by any applications and make sure your own instance isn't running on port 2003! The test suite creates a `testsuite` keyspace and some tables within it to run all the tests.

@ -28,7 +28,9 @@ You can learn more about installation [here](https://docs.skytable.io/getting-st
## Features
- **Insanely fast**: Scale to millions of queries per second per node
- **Key/value store**: `GET` , `SET` , `UPDATE` and [all that stuff](https://docs.skytable.io/actions-overview)
- **Multiple keyspaces/tables**: Seamlessly integrates with actions to provide a SQL-like experience
- **Key/value store**: `GET` , `SET` , `UPDATE` and [all that stuff](https://docs.skytable.io/actions-overview). With the `str` and `binstr` types.
- **Volatile tables**: For all the caching you need
- **Snapshots**: Automated (and tunable) snapshots for stress-free backups
- **Secure**: Secure connections are built into Skytable with SSL/TLS
- **Multithreaded**: Designed to exploit all CPU cores

@ -67,6 +67,29 @@ macro_rules! gen_constants_and_matches {
};
}
macro_rules! swap_entity {
($con:expr, $handle:expr, $entity:expr) => {
match parser::get_query_entity(&$entity) {
Ok(e) => match $handle.swap_entity(e) {
Ok(()) => $con.write_response(responses::groups::OKAY).await?,
Err(DdlError::ObjectNotFound) => {
$con.write_response(responses::groups::CONTAINER_NOT_FOUND)
.await?
}
Err(DdlError::DefaultNotFound) => {
$con.write_response(responses::groups::DEFAULT_UNSET)
.await?
}
Err(_) => unsafe {
// we know Corestore::swap_entity doesn't return anything else
impossible!()
},
},
Err(e) => $con.write_response(e).await?,
}
};
}
/// Execute a simple(*) query
pub async fn execute_simple<T, Strm>(
db: &mut Corestore,
@ -77,10 +100,13 @@ where
T: ProtocolConnectionExt<Strm>,
Strm: AsyncReadExt + AsyncWriteExt + Unpin + Send + Sync,
{
let buf = if let Element::FlatArray(arr) = buf {
arr
} else {
return con.write_response(responses::groups::WRONGTYPE_ERR).await;
let buf = match buf {
Element::FlatArray(a) => a,
Element::SwapKSHeader(swapks) => {
swap_entity!(con, db, swapks);
return Ok(());
}
_ => return con.write_response(responses::groups::WRONGTYPE_ERR).await,
};
let mut buf = buf.into_iter();
gen_constants_and_matches!(
@ -113,20 +139,10 @@ where
}
action! {
/// Handle `use <entity>` like queries
fn entity_swap(handle: &mut Corestore, con: &mut T, mut act: ActionIter) {
match act.next() {
Some(entity) => match parser::get_query_entity(&entity) {
Ok(e) => match handle.swap_entity(e) {
Ok(()) => con.write_response(responses::groups::OKAY).await?,
Err(DdlError::ObjectNotFound) => con.write_response(responses::groups::CONTAINER_NOT_FOUND).await?,
Err(DdlError::DefaultNotFound) => con.write_response(responses::groups::DEFAULT_UNSET).await?,
Err(_) => unsafe {
// we know Corestore::swap_entity doesn't return anything else
impossible!()
}
},
Err(e) => con.write_response(e).await?,
},
Some(entity) => swap_entity!(con, handle, entity),
None => con.write_response(responses::groups::ACTION_ERR).await?,
}
Ok(())

Loading…
Cancel
Save