PostgreSQL, Rust, and Range Types
52 views
Formal Metadata
Title 
PostgreSQL, Rust, and Range Types

Title of Series  
Number of Parts 
31

Author 

Contributors 

License 
CC Attribution 3.0 Unported:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal purpose as long as the work is attributed to the author in the manner specified by the author or licensor. 
DOI  
Publisher 
PGCon  PostgreSQL Conference for Users and Developers, Andrea Ross

Release Date 
2014

Language 
English

Production Place 
Ottawa, Canada

Content Metadata
Subject Area  
Abstract 
Combining database features with language features Range Types, introduced in PostgreSQL 9.2, are an important feature for scheduling and other applications. Range Types allow much more efficient queries on ranges (e.g. ranges of time) such as "overlaps" and "contains", are less errorprone, and offer the critical "nonoverlapping" constraint (useful for preventing schedule conflicts). But to make use of any advanced database features, good support in the client language is crucial. Many people use libraries to translate between database types and types in the client language  not only is that convenient, but it contributes to safety and reduces the chance for simple errors. Rust is a powerful new language with a lot to offer, including a postgres driver that supports Range Types as firstclass types. I'll be discussing how rust libraries help bridge the gap between advanced database features and practical application development. The speed of development in PostgreSQL can often outpace the ecosystem surrounding it. Performanceboosting features are used as quickly as administrators upgrade, but extensions to the SQL language take more time. Without support in the client language, SQL language features are only used by earlyadopters who are willing to put up with the rough edges. As the primary developer for Range Types, I feel that their utility would be greatly increased with greater accessibility for simple applications. The problem they solve  largely the problem of scheduling  is prevalent in such applications. Rust makes a great example of how to better integrate data types into the client language. It's got Option types, which are great for handling edge cases and special values (like an empty or unbounded range); it's fast enough that the driver can be written in rust, which avoids the need for a dependency on libpqdev and enables a little more creativity; and it's got a great community. In particular, I'd like to credit Steven Fackler who wrote the native rustpostgres driver, as well as the Range Types support! This presentation does not assume any prior knowledge of the rust language

Related Material
00:00
Area
Type theory
Goodness of fit
Type theory
Computer animation
Range (statistics)
Range (statistics)
Data analysis
00:49
Complex (psychology)
Spacetime
Interior (topology)
Multiplication sign
Demo (music)
Range (statistics)
Shape (magazine)
Mereology
Variance
Formal language
Timestamp
Word
Etext
Sign (mathematics)
Type theory
Species
Data conversion
Extension (kinesiology)
Position operator
Spacetime
Mapping
View (database)
Geometry
Point (geometry)
Range (statistics)
Bit
Wellenwiderstand <Strömungsmechanik>
Term (mathematics)
Entire function
Type theory
Database
Search algorithm
Right angle
Representation (politics)
Data type
Implementation
Mapping
Sequel
Wellenwiderstand <Strömungsmechanik>
Online help
Field (computer science)
Power (physics)
Scheduling (computing)
Revision control
Term (mathematics)
Database
Integer
Mobile app
Information
Demo (music)
Online help
Mathematical analysis
Line (geometry)
Set (mathematics)
Cartesian coordinate system
Timestamp
Video game
Word
Computer animation
Personal digital assistant
Query language
Device driver
Kolmogorov complexity
Object (grammar)
Integer
07:29
Point (geometry)
Installation art
Range (statistics)
Letterpress printing
Device driver
Electronic mailing list
Semantics (computer science)
Variance
Number
Revision control
Summation
Mathematics
Sign (mathematics)
Bit rate
Operator (mathematics)
Row (database)
Integer
Information security
Software bug
Mapping
PoissonKlammer
Interior (topology)
Token ring
Infinity
Range (statistics)
Total S.A.
Instance (computer science)
Set (mathematics)
Density of states
Variable (mathematics)
Local Group
Type theory
Malware
Computer animation
Estimation
Query language
Personal digital assistant
Right angle
Sinc function
Laptop
11:46
Context awareness
Installation art
Mountain pass
Multiplication sign
WebDAV
Range (statistics)
Function (mathematics)
Parameter (computer programming)
Summation
Exclusive or
Roundness (object)
Type theory
Positional notation
Square number
Cuboid
Row (database)
Error message
Physical system
Metropolitan area network
Product (category theory)
Touchscreen
File format
Interior (topology)
Range (statistics)
Bit
Formal language
Type theory
Numeral (linguistics)
Personal area network
Right angle
Glass float
Laptop
Point (geometry)
Dataflow
Ewe language
Presentation of a group
Line (geometry)
Open set
Theory
Natural number
Operator (mathematics)
Database
Representation (politics)
Glass float
Series (mathematics)
Slide rule
PoissonKlammer
Bound state
Set (mathematics)
Density of states
Timestamp
Local Group
Error message
Estimation
Personal digital assistant
Query language
Universe (mathematics)
Finite set
Units of measurement
19:11
Operations research
Query language
Line (geometry)
Range (statistics)
Range (statistics)
Bound state
Focus (optics)
Sign (mathematics)
Subject indexing
Type theory
Error message
Computer animation
Database
Query language
Subject indexing
Integer
Glass float
Error message
Task (computing)
20:20
Point (geometry)
Query language
Scheduling (computing)
Constraint (mathematics)
Multiplication sign
Characteristic polynomial
Range (statistics)
Letterpress printing
Similarity (geometry)
Control flow
Bound state
Scheduling (computing)
Revision control
Exclusive or
Type theory
Positional notation
Strategy game
Database
Subject indexing
Data conversion
Physical system
Condition number
Scale (map)
Operations research
Series (mathematics)
Constraint (mathematics)
Broadcast programming
Range (statistics)
Table (information)
Sign (mathematics)
Type theory
Subject indexing
Computer animation
Database
Right angle
Pattern language
Procedural programming
23:15
Database transaction
Installation art
Code
Mountain pass
Multiplication sign
Range (statistics)
Insertion loss
Bound state
Disk readandwrite head
Table (information)
Permutation
Exclusive or
Type theory
Row (database)
Extension (kinesiology)
Area
Constraint (mathematics)
Interior (topology)
Range (statistics)
Ext functor
Bit
Type theory
Root
Network topology
Uniform resource name
Order (biology)
Software testing
Convex hull
Quicksort
Laptop
Row (database)
Point (geometry)
Line (geometry)
Constraint (mathematics)
Real number
Electronic mailing list
Revision control
Steady state (chemistry)
Term (mathematics)
Subject indexing
Maize
Traffic reporting
Condition number
Time zone
Cellular automaton
Coma Berenices
Line (geometry)
Density of states
Cartesian coordinate system
Timestamp
Vector potential
Table (information)
Subject indexing
Word
Error message
Computer animation
Estimation
Blog
Speech synthesis
Key (cryptography)
Units of measurement
Integer
Vacuum
Extension (kinesiology)
31:54
Pressure
Readonly memory
Game controller
Line (geometry)
Mountain pass
Range (statistics)
Home page
1 (number)
Mereology
Hand fan
Variance
Formal language
Pointer (computer programming)
Device driver
Goodness of fit
Julia set
Type theory
Blog
Readonly memory
Speicherbereinigung
Error message
Physical system
Area
Metropolitan area network
Programming language
Slide rule
View (database)
Software developer
Web page
Sound effect
Range (statistics)
Bit
Control flow
Cartesian coordinate system
Computer programming
Formal language
Type theory
Root
Exterior algebra
Error message
Computer animation
Personal digital assistant
Revision control
Vertex (graph theory)
Key (cryptography)
Game theory
Task (computing)
Sinc function
34:33
Implementation
Server (computing)
Length
Demo (music)
Range (statistics)
1 (number)
Web browser
Functional (mathematics)
Discrete element method
Theory
Power (physics)
Formal language
Typsystem
Summation
Device driver
Goodness of fit
Julia set
Type theory
Blog
Readonly memory
Database
Operating system
Subtraction
Physical system
Mobile app
Programming language
Series (mathematics)
Slide rule
Demo (music)
Concurrency (computer science)
Real number
Projective plane
Open source
Fitness function
Generic programming
Range (statistics)
Set (mathematics)
Control flow
Cartesian coordinate system
Computer programming
Formal language
Type theory
Computer animation
Blog
Block (periodic table)
Data type
37:11
Group action
Demo (music)
WebDAV
Range (statistics)
File format
Firstorder logic
Function (mathematics)
Bound state
Mereology
Formal language
Medical imaging
Type theory
Flipflop (electronics)
Stress (mechanics)
Buffer solution
Query language
Square number
Row (database)
Uniform boundedness principle
Physical system
Area
Metropolitan area network
Computer font
Link (knot theory)
File format
Real number
Computer file
Open source
Sound effect
Range (statistics)
Bit
Functional (mathematics)
Type theory
Root
Content (media)
Graph coloring
Order (biology)
Resultant
Laptop
Row (database)
Web page
Server (computing)
Open source
Constraint (mathematics)
Line (geometry)
Letterpress printing
Revision control
Inclusion map
Steady state (chemistry)
String (computer science)
Database
Green's function
Ideal (ethics)
Integer
Maize
Macro (computer science)
Mobile app
Chatterbot
PoissonKlammer
Projective plane
Boilerplate (text)
Interactive television
Density of states
Cartesian coordinate system
System call
Vector potential
Table (information)
Loop (music)
Computer animation
Query language
Dependent and independent variables
Data Encryption Standard
Iteration
Key (cryptography)
Library (computing)
41:22
Mobile app
Software engineering
State diagram
Building
Real number
Demo (music)
Open source
Web browser
Discrete element method
Formal language
CAN bus
Error message
Computer animation
Pauli exclusion principle
IRIST
Laptop
Default (computer science)
42:13
Mobile app
Metropolitan area network
Link (knot theory)
Installation art
State diagram
Building
Constraint (mathematics)
Range (statistics)
Interior (topology)
Division (mathematics)
Code
Table (information)
Twitter
Inclusion map
Exclusive or
Root
Error message
Computer animation
Graph coloring
Key (cryptography)
Linear map
Laptop
World Wide Web Consortium
Default (computer science)
43:38
Metropolitan area network
Link (knot theory)
Computer file
File format
Range (statistics)
Instance (computer science)
Total S.A.
Web browser
Computer configuration
Computer animation
Bit rate
Buffer solution
Row (database)
Laptop
World Wide Web Consortium
44:22
Multiplication sign
Scientific modelling
WebDAV
Range (statistics)
File format
Insertion loss
Function (mathematics)
Mereology
Weight
Variance
Formal language
Buffer solution
Network topology
Row (database)
Data conversion
Extension (kinesiology)
Error message
Information security
Physical system
Social class
Area
Metropolitan area network
Computer font
Process (computing)
Theory of relativity
Computer file
Interior (topology)
Range (statistics)
Functional (mathematics)
Flow separation
Type theory
Infinite set
Content (media)
Order (biology)
IRIST
Pattern language
Procedural programming
Data type
Reading (process)
Laptop
Row (database)
Slide rule
Observational study
Sequel
Constraint (mathematics)
Electronic mailing list
Mass
Power (physics)
Finite element method
Database
Operator (mathematics)
Scripting language
Normal (geometry)
Surjective function
Raw image format
Expression
Interactive television
Set (mathematics)
Density of states
Fermat's Last Theorem
Computer animation
Intrusion detection system
Personal digital assistant
Statement (computer science)
Key (cryptography)
Online game
Units of measurement
Vacuum
53:04
Point (geometry)
Feedback
Interactive television
Density of states
Cartesian coordinate system
Mereology
Trigonometric functions
Semantics (computer science)
Web browser
Error message
Computer animation
Repository (publishing)
Device driver
Right angle
Key (cryptography)
Object (grammar)
Resultant
World Wide Web Consortium
00:00
what would you do the for good afternoon everyone my name is Jeff Davis and I will be talking about was pressed range types and thrust for I work for a company called master data of big data analytics company based in the Bay area so that the new the other interested in employment opportunities definitely conducting so 1st
00:51
of all kind of how we going through this is I wanna make a case that powerful data types are important at the database and application should have some agreement about what those besides actually are and I think range types is 1 of those important data types so I'll show you about that 1 thing that's important and then I all be talking about the a language called rust and its implementation of range types in that application space and how it works with PostgreSQL or fact and all of all throw 1st of all like a big thanks to Stephen back where he actually is I think you were from the works for us language and he did a lot of work that he wrote essentially the entire post driver as well as a range check support for that himself so big things that so you know the way I like to put it is you know which describe your business in terms of ints floats timestamps that kind of thing and you know when you put a like that it's kind of you know those those time stamps for those of data types actually can go quite far and in explaining what business is about you build a sophisticated schema describing the relationship between them but when things start to get interesting then that starts to break down and you actually want you know something a little bit more interesting so all give you know just a couple of examples of other successful datatypes that I think help make this case this these are what the talk is about but the full text search is kind obvious case everyone who's done fulltext search and start out with the text field and use like queries how many people have tried that before 1 time or another yes you do the like with the percentage signs and you try to implement the full texts in a solution that way you quickly run and all kinds of problems you know 1 is performance obviously but then beyond that it's it's really not the right data types you know when you're talking about a kind of arbitrary keyword search you really thinking about a set of words maybe positions maybe word stands that make up a document that you're not really concerned with you know some parts of it at all like stop words that and so forth so you know that that's really know 1 example the data type a lot of work is done and that and Chris and again that's not what the talk is about and understand making case that you know this is an interesting data types you can try to build out of the simple tools but it is ultimately doesn't work out pretty well geospatial as another example of that GIS is an amazing that extension of PostgreSQL and it implements a full geospatial data types are useful for all kinds of mapping and other capabilities can be doing geospatial analysis and geospatial queries and shapes and and everything else so that's and that's the a very important extension in the post press ecosystem and sure you can try to do that with a bunch of integer columns and try to make up shapes that way and that and trying to query on top of that and you run into you know so much complexity it's it's really and manage and not to mention the performance problems but so on you know these these are a few examples and I think no also little later why range texts should be included as a part of that and I also think the database in the application should agree about what the data types are generally you know if your you know that very quickly clears up in impedance mismatch between the database and the application if you're getting conversions between a real text you actually care about in the database and the application in a in a consistent way and so if you're constantly have an interesting objects in the application of but then you try to serialize them down to incent and text and so forth then but you know it's it's understandable that that you know would be called impedance mismatch and and that you know you you don't run into some complexity and problems converting and our problems querying that data consistently and treating it consistently in the database without the the database the database without application might be manipulating that same data and so range types phobia jumping into a couple of examples here and but the basic idea of a given talks on this by itself but just that the quick version of this is that it defines a range of values with a definite beginning indefinite and and it could be the end to be inclusive or exclusive and there are very few other details but the bottom line is rather than it being say you know a sequel interval type which might be 2 hours right and that that defines kind of duration of time but it's still essentially you know this scalar value this range that actually has a definite beginning indefinite and so you really need to bits of information or a few pieces of information to really understand the range of values and this is particularly useful for time ranges I believe because of scheduling purposes so let me try to make a quick demo of this it's history sense and then you have to go to that of state with
07:54
simply that sending have to be readable manner so that you integrated it'll print since and I want to start up you get instead select the simple arranged by doing something like this and for range from 1 to 10 the so the 1st thing I'd like to point out is the 1 again that the 1st if you can't see it is the square brackets and did the ending bracket that's a print the Sierra around rates so this represents the range of beginning at 1 and ending at 10 including the value 1 but excluding the value 10 so because these are integers that's a total of 9 and you can do a simple query honest such as this this is the containment operator at sign greater than and physical the value to and we see that that's true also do that overlaps operator which is double ampersand and this is also true because these 2 ranges overlap so we can see there were no longer treating the endpoints especially were actually treating them like I'm more like sets or mathematical intervals to be more precise and this simplifies number of queries you know to to give an example of you know a query that you might try writing to implement this would just integers security drivers you overlaps you'd end up with something like that you know select you know some kind of 3 of the variables in the star in as less than an MeV that you you imagine writing groups like this I to you know and then a bunch of you know and or and then you know you'd have in there may be an extended through using all for that these unbounded range is if using molding you'd end up with a bunch of you know is not an old kind of actually end up being quite long query and mapping already this because it's it's a in complex enough that all Germans that anyway but with the Rangers these are quite simple right and let's say for instance I have an unbounded range here so that's essentially for t infinity is the semantics of that and that current strips so you don't have to think necessarily about all these edge cases you know should I use greater than or equal to worse it was greater than here you know how many different versions of comparing the 1st and the and the last bound Aidid actually specify overlaps it gets all become so range types just simplify things greatly and and that's that's the idea behind and this is going to have our questions at this point on the other it there is a way of controlling that you can so let's say
11:49
it's it can be and although upward but let's say that you specify them using the same notation of this square race and open race so let's everyone and converted we can add a 3rd optional parameter the specified open open said and then and then it's the same so what happened here is remember revealing with values in itself and this is logically the range from 1 to 10 excluding both 1 and 10 but that is equivalent value to the 1 displayed on the screen and that's because we know kind of normalized for the output representation we don't want to distinguish between 2 equivalent values which is you know confusing thing to do you can distinguish between the output representations but you don't want to distinguish between 2 equal values and 1 to 10 exclusive exclusive is equal to 2 to 10 inclusive exclusive and so you can specify things that I'm kind of in that way and it works very seamlessly with the rest so when you use overlaps contains those kinds of range operators then everything just works and you don't have to worry about lots of special cases to deal with and that's that's really you know 1 of the main things that I'm going to do here is you know eliminate as special cases of trying to simplify the queries and simplify the thinking behind using ranges rather than trying to use a complex series of you start and end bounds for the engines are individually I'm so any more questions in the world on right now right now there's not much there are some there you know probably the different ways that I mean you could certainly do that IID constructing arranged sort of light and controlling the output format as you'd like to see but right now as it in using products tools but there there are so i ranges can be censored there's injuryinduced timestamp ranges timestamp times and ranges 8 ranges and numeric ranges and in that kind of the box but let's say in 1 thing we can do is we can define new range types I and II 3 range errors then in the so range that you will this of independently so now we have flow into this so we have float range 1 . 4 2 points and then we can verify that it's a float didn't never numerical from which all of the precision and 0 yes so there there's some of the so also you that's a that's a good point found so let's say we do that with the open open syntax where it's exclusive exclusive groups so here it stays open OK and the reason for that is because there is not a very useful definition of you know kind of 1 tiny and a bit in a range you know 1 tiny increment of arranged to normalise it so although the flow type technically is you know a discrete I should start up in a finite number of bits in the representation of and so therefore there will always be that 1 next value in theory that's that's not very useful for many reasoning standpoint in most situations and so you could but and if the you very nitpicky about it you could try to create you know arranged to ranges that were actually equal in the sense that they represent the same set of values but might not be seen that way by the system and because we don't use that kind of flow increment notion so but you know we treat floats essentially like numerics where there is no 1 single next value of I didn't to work browsing of started singing does the convention that I had to that of the inclusive and exclusive use you what conventionary accustomed to all is the is OK so that you mean I even if I did that the range for specified as say square bracket to comment and round brackets OK yeah OK I mean the the reason behind that is that the values are equal and should be treated that way and in all contexts by the this database system and so that was that was my reason for that I mean that that there is of all I can move on a little bit of the university to you the details about ranges and that's that's laughter entirely with the presentation about like nature of I introduce some of the concepts and like to talk about but
18:55
I think that and we all have a feel for what the inspector trying to accomplish and what they're trying to simplify the and they they they published several things including their performance and just the understandability of the queries
19:19
that so this is on and you know kind of what what range that's a really bad and so you know use beginning and columns and then you can end up with these long messy query is trying to specify simple things like overlaps and that that turns into a problem and it's inconvenient it's error prone it's awkward and and you know there's all kinds of mistakes you can make no indexing support and for but if you're specifying is individual integers like that the best you have our ordinary Btree indexes on integer columns and you're not going to get the performance you expect from that kind of from you know the kind of queries you actually want to run which are know the overlaps intersection that and then I just sit here handle some of the details like in the and so forth this
20:20
is the worst thing that is not all that
20:28
has history to used where the the right yes so if you use the beginning and column I think and the point was that you have to pay very close attention a convention that you developed as so print since it becomes harder you sometimes they're openclose notation or sometimes the closedopen notation and something like that yeah right exactly right yeah yeah I think that's a good point and then I wonder killer feature for range types is exclusion constraints so that the idea here is a schedule conflict is a very simple notion just in everyday conversation everyone knows what a schedule conflict is but to actually enforce that nonoverlapping schedules in a database system in databases smothered than post press as major problems with this and so you know for example you could try you know if you actually try to avoid the race conditions and then you could end up blocking the entire table or resorting some other very strange but in a series of procedural code or a locking pattern or something like that but ultimately you know it's not going to perform very well it's going to be very complicated and or you can try simple strategy may be walking the whole table or you could have you know that essentially know break it into these larger values and you'd really like to deal with that to make it can the chunk it into time slots which is where a lot of people and doing it but it's really awkward and it causes a lot of problems but I'll show how we can overcome every easily using post press with the declarative constraints that performs well using an index lookups with similar performance characteristics to it's a unique constraints and we kind of the best of all worlds so let me give an example of that so what and this is
23:34
this using its timestamp with time zone range sensor ranges from several times that we can we ordinarily I'd like it here and that it could brutality that they have this other cell what we could do is we carried the 1st of all let's add the exclusion constraint of 0 1 9 minor detail we actually need to make use of the of the tree just extension for this example work so and because the create extension syntax that makes it easy steal up to you but I think I raise that a 1 point but it's it's a possibility so that all the time they were all yeah
24:54
exactly that's that's yeah that's that's a problem you know essentially everyone runs in the so make full use of this yearly in the Btree just extension it's been there for a while it works pretty well but not not too much to be concerned about their so hopefully that can end up in court eventually or there could be an easier way to dead included so are there any notes alter table exclude for exclusion constraints using just is the index access method that's going to help us enforce this constraint in a in a performant way so the room with the quality and duration whereas over so 0 0 if you the table rows of there yet so that we so we have this exclude using just room with equals means you know if the room has the same duration with overlaps means of the durations overlap then we have a conflict sort describing the conflict condition here and using this index is a little bit funny about words describing the conditions under which 2 couples conflict they conflictive the room is the same and the duration overlaps and that's how that's how to read that so you know let's go ahead and you know inserts reservations into this the room so when the 3 reservists along with bring 45 day for the other end which is called we even have decent areas for the 1st areas in the 1st half of the values so they so inserted 1 5 4 essentially right now SYRIZA preserving my own speaking time and then let's say that you know 23 times and report reserves 45 a of for 13 20 let's say 2 j a 40 45 billion there and so we can go through a bunch of permutations here is that if we had more time and but you know the bottom line is that it prevents these overlapping reservations but it doesn't declaratively meaning that if you have articles and they're ready you had the exclusion constraint later it's going to fail and adding constraints just like the unique check would fail if you added after you have duplicate values in table but it works concurrently you know unless there's a real conflict 1 transaction what actually sit there are something a real potential conflict of things that actually overlapper actually meet this conflict conditions then on the the transactions will weight on each other they'll perceive so far we have had the best of all worlds here and in in terms of enforcing this kind of constraint so that's really the value of combining range facts of exclusion constraints to to enforce these kinds of things and there is actually some some pretty interesting other things that you can be related to this and so I I encourage you to experimental but I think I a couple blog posts while ago when when these features were introduced so you know I I encourage people check that out there's other people wrote what as well questions at this point and the and it was also 0 you mean so I I think so we're using just which I think you're saying doesn't support index only scans this is that correct and I actually don't know off the top my head whether it does or not but if if you say doesn't I don't think there is a fundamental reason why just wouldn't work with index only stands so I think that that's just a matter of making sure we get that support you know and I think the intention is an excellent scan should work at all and expect what what all of His father was a very so a great so that was just a matter of code then or something something that this is not going to fall for use in those of the region values right yeah that and the index of of course all look in order to do an index only need to be able to reconstruct the entire value properly and so on the methods for range types make that possible and to to construct all values so that shouldn't be too much of a problem assuming we know after we add all this support for these other axis methods that
31:55
so let's back to the 1
32:10
of of the effect on the so
32:24
rest or 1st of all I here 5 hopefully knew that rest was a programming language written by Mozilla and so this is an interesting our language so it's it's got and it's got a native was pressed the case so basically range types of arrest offers you know a few advantages systems oriented programming language so it's you know a little bit more verbose a but it's very safe it prevents any kind of you know that ordinary kinds of memory areas like NullPointerException so and you know any kind of you know that's a faults those types of things heart eliminated by arrests type system yet it offers very good control over memory and does not require the use of a garbage collector so it's a suitable systems programming language but it's still in the development of by Mozilla but but the idea is that you know bring safety to the kinds of applications people writing that I have you know high performance requirements especially you know requirements about controlling the memory and many cases right now that C and C + + and only games in town and you know if you want to have control over memory aside from a few other languages that are used in in certain verticals maybe but for the most part since C possible so the ones out there so rust offers alternative to those that are safe from the kinds of memory errors that are so common it's like this and and it's you know because a systems programming language it's also fairly fast and the the rest post restaurant birds again written by Stephen back is it's a native driver and so it doesn't require the use of would be you and that's that's nice because it's all the more flexible and it doesn't have as
34:35
many dependencies but so are the reason I'm talking about rest but it's a very new language it's not even solidified yet theories I'm talking about is it because they're doing a lot of interesting things and they're the 1st ones to support range types I think that the way it was done was very nice get illustration of both the length you know of all you know the things I document your that the our language making good use of the database as well as having coherent notions of of the same data types and so that that way you know and the application is not using a totally different set of datatypes from the database and and I think some of language features that that a lot of it is simply just because it's this is the 1st implementation of range types in applications face that they can talk about with and and there's other cool things going on I think you know they're developing it's written that Mozilla's of costs they're developing a browser engine in this language called server and then other people are doing some kind of cool things there's like tiny operating system projects are going on that are mostly just for learning now but there's a pool a blog post series by something truly Evans and so anyway this this isn't about a out of the features but just this is why I chose that 1 and it's it's largely because you know it it seems to be a good fit for range types and it has the and that the generic type system is from probably the big 1 because that's what allows just like we defined in the range 5 over floats in 5 seconds in during the demo you know that also you know that generics power also needs to be present in the programming language to really get the full benefit of range facts from the database because in poststressed it's you know a generic type of generic container and and so that the fact that the programming language can support that too is important to get over and so on and then
37:09
can that throws encoded by no since most of you you know almost
37:14
everyone is not really heard rusting in a very few people are really writing in it but I also kind of what I was was hacking on this is not
37:23
a does not a real project and not watching this is a of open source project but there's something I was working so that is so that
37:39
reasonable as another area all of a data from the beginning of the respondents so all all old kind of ignore some of the boilerplate but this basically uses an HTTP library to act as a server farm and then we will have a kind of simple webpage interaction here a very rough of course but you know basically that this get content method and it's just you know generating some content dynamically and then outputting so so you can see it's a little bit more verbose to satisfy the type system then you might be accustomed to and something like Python on but hopefully they they worked out some of you know the conventions to make that you know not so bad so anyway were just you know connecting post stress and then you know a pending some simple HTML string and then so here's a research the database action so what we're gonna do here's going to select some integer ranges from a table X and then the standard iterate through the the interesting part those were going to I have another query in the application language here which is itself a image and were going to up printed in print that range from the database in green if it does not overlap with this strange printed in red if it does overlap indicating potential conflict and of course the real application beating something more interesting but and you can extrapolate from here so 1 of the other nice things about rosters jazz gonna macro system and there's another reason and a fit in with the whole ideal that that I'm describing here so it actually love this that's and that's what this this is really just a function call we've got actually matching with the pose threats the of the bound inclusiveness of the square brackets around brackets here indicating inclusive and exclusive respectively and and then you know inside we've got all these these values here then uses that to construct the range so this is up from 50 to 60 of these systems programming language it's got you know these kind of literals our are our for friends and for integer and there and you say i 32 or some kind of you know native integer sides are everyone but here and it's trying to keep it simple for range we want to be an important in the applications that means using I 32 What's so 10 years and so we have that kind of query there and years in a kind of the loop so for every row in the result so we start off with it as a green color and we actually replace the color with red if the intersection is empty which is another way of saying that there is an overlap and then we just output this format string of including both the color and the value and have in order so that there's actually something else very interesting thing going on here but all get back to that effect
41:25
of their let's say that's filled it
41:34
but few imports than that using the warned about that it's all a compiled dealt with
41:43
that when the language or finished and a of 90
41:48
to actually go rectangular browsers them and recesses the bunch of 4
42:19
engines that so we you can see I'm reloading it and so tender 28 does not interest does not overlap with that 60 then the 200 dollars 32 51 does but 30 49 does not we go back to the poster
42:41
session I will confine table and we can insert into X values it just about out of here so trend make this quick of summary other range that like data insert 50 day so 1st let's decide whether this should not overlap were not and then we'll see based on red green color rather does so what should be inclusivity and exclusivity of this 1050 range be or what we expect that to be yeah exactly so it will exclude they will include 10 but exclude 50 and then we can look back at thrust codes and we
43:42
see that this includes about 50 exclude 60 so since this 1 x glued 60 birds are instances where that includes 50 and the other 1 excludes 50 that we just inserted we would expect this to appear in the rate as the question that that that's that's great
44:16
and so I let me on disruptive and asked Oscar for any questions here in a 2nd
44:23
but 1 other thing I'd like to point out that that I think is is quite interesting about this is the way rests type system works is that we just declared this value to be a range of in 32 in rats equals the 1st value in that row coming from the database and now what's interesting is this is able to choose what conversion function to applied in order to get the into for range out of the database and interest based on this slide so that actually based on the type of the value you're reading it into and that in other words that of the return value the the expression but it's able to infer the uh you know of course the type that this should be but beyond that it's able to actually use that to choose the conversion function and so I think that's a pretty cool approach I think a lot of other languages do a lot of time and mess around with their ideas in enforcing the output type and you know trying to include the fixed by constant or ideas of the types they know about and this makes it more sensible because as you are saying you range types in new conversion functions then it works more seamlessly you don't need defined that OID and hardcoded someplace necessarily for good error checking you might want to know but that becomes optional so this I think has a better chance of working well with userdefined datatypes and userdefined ranges on top of those userdefined datatypes and releasing full extensibility that was processed offers so I just see a lot of great interaction between what Ruskin do with types what what it can do on the database side helpless pressed works and strengths and how they all fit together very well but so you know I think there's gonna be a great example I think other languages can do a lot of these things to but you know like a set of course stresses the first one to support range that's natively and so from here the study questions arranged back into 1 0 0 ICT but no we don't have a way to do that this also supports the standard continuous ranges of numeric where would be no kind of essentially I wouldn't be essentially infinite sets something so it might be an interesting area to explore about you know you right down range that and the primary area of what was the thing that went out of the way in which you have a generous generates is really serious and these patterns in the 1st part so the operator of that was the 1st of its kind in the world that you all so that people are about to get yeah a city you don't have to write yeah there there's I quite a few interesting ways of manipulating and the operators laid out in in a book that I believe that he read as well hopes that and it's called temporal data in the relational model and by at C. J. Date and add Nick Nicolosi warrantless where at Dayton Lorenzo and and I think you Darwin as well that area so that of course over here and that this is the 1st time and the reason that we all about it yeah so customer interaction and how right now I think that and that's been are brought up so post press I net data type is already has supports the that mass so it's not totally ordered type itself and so it hurt it's like and just awkwardness I believe you're right and I agree but it's not bring because we need to define a new totally ordered type that doesn't support in Scarborough have as all you OK OK yeah I mean I I I I agree with that of the 0 yeah if you create a range here you can just do an insert statement then it it supports never to sequel trait that allows it to convert back in your writing script so you don't need to do any special conversion if range back in the process of the manipulated the rest you mean if the lower bound is higher than the upper bound of that will generate an error and I forgot that request from several times and he was trying to describe a use case to me I don't think I fully understood that the use case for that but for 4 1 0 OK I you could work you you just wanted the flip it that would be fairly easy to do programmatically but it's it's not supported now and we mean we decided that so that the idea was and that it's only 1 do something like that it was most likely in error and it's better to throw an error when it's it's it's likely case and support the other case you know if you need to with with procedural code and I think that was the thinking at the time and but if if I understand better some use cases out there for 3 cancer of the city sensations itinerant yeah you could have if both of them are exclusively just end up with a singleton arranged in 1987 and it's a range consisting of exactly 1 value and in this in this class is in no way combined with a that we OK that's a that's a pretty powerful use case loss of those who gets about it's gotten during does as well so yeah just by the security
52:56
that reflect has this 1 this in the spirit of the moles that happens in an imperium doesn't
53:07
interact with anything so this would be the expected results localized they look PostScript I mean I was politicking that that they get out of repository for the rest of us crisper object that uh Stephen backwater interest and looked in the post press he was already you know a fairly comfortable I think at this point with the post press documentation because it actually implemented a new driver so I I I imagine you know he you know you just look at a lot of applications I I did some feedback that but he for the most part has got this stuff but you know very close to the poster Semantics right way and so I mean that's that's the point that I'm trying to make is that the semantic should match rather than having having inconsistent here will think everyone