4 ms·
> Make has deeply woven into it the assumption that the product of workflows are files, and that the way you can tell the state of a file is by its last modific
by derefr 9y ago
> Make has deeply woven into it the assumption that the product of workflows are files, and that the way you can tell the state of a file is by its last modification date.
I've always wondered whether Make would be seen as less of a grudging necessity, and more of an elegant panacea, if operating systems had gone the route of Plan 9, where everything is—symbolically—a file, even if it's not a file in the sense of "a byte-stream persisted on disk."
Or, to put that another way: have you ever considered writing a FUSE filesystem to expose workflow inputs as readable files, and expect outputs as file creation/write calls—and then just throw Make at that?
- lisper 9y ago> everything is—symbolically—a file How are you going to make the result of a join in a relational database into a file, symbolically or otherwise?
- fiatjaf 9y agoYou would probably need another query language, but that would come with time, after people had gotten used to the idea. With that said, there are NoSQL databases these days whose query language is easily expressed as file paths. CouchDB, for example.
- com2kid 9y ago> How are you going to make the result of a join in a relational database into a file, symbolically or otherwise? A file that represents the temporary table that has been created. Naming it is harder, unless the SQL query writer was feeling nice and verbose.
- ori_b 9y agoOn plan 9, you'd do something like: ctlfd = open("/mnt/sql/ctl", OREAD|OWRITE); write(fd, "your query"); read(fd, resultpath); resultfd = open(resultpath, OREAD); read(fd, result); close(resultfd); This is similar to the patterns used to open network connections or create new windows.
- lisper 9y agoAnd how would you use that in a makefile?
- Spivak 9y agoSomething like this would be ideal. /mnt/sql/myjoin: echo "<sql query>" > /mnt/sql/myjoin It's just representing writing and reading a database as file operations, they map pretty cleanly. Keep in mind that Plan 9 has per process views of the namespace so you don't have to worry about other processes messing up your /mnt/sql.
- lisper 9y agoI think you're missing the point. I have a workflow where I have to perform some action if the result of a join on a DB meets some criterion. How does "make" help in that case?
- ori_b 9y agoIn that case, it doesn't help much. For Plan 9 mk, there's a way to use a custom condition to decide if the action should be executed: rule:P check_query.rc: prereq rules doaction Where check_query may be a small shell script: #!/bin/rc # redirect stdin/stdout to /mnt/sql/ctl <> /mnt/sql/ctl { # send the query to the DB echo query # print the response, check it for # your condition. cat `{sed 1q} | awk '$2 != "condition"{exit(1)}' } But I'm not familiar with an alternative using Make. You'd have to do something like: .PHONY: rule rule: prereq rules check_query.sh && doaction
- lisper 9y ago> You'd have to do something like: That's exactly right, but notice that you are not actually using make at all any more at this point, except as a vehicle to run check_query.sh && doaction which is doing all work.
- enriquto 9y agoyou could mount the database as a filesystem
- Jtsummers 9y agoWith respect to Make, does the database (mounted as a filesystem) retain accurate information that Make needs to operate as designed (primarily the timestamps). To what level of granularity is this data present within the database, and what is the performance of the database accessed in this way? Will it tell you that the table was updated at 08:40:33.7777, or will it tell you only that the whole database was altered at a specific time?
- Spivak 9y agoYou're talking about a theoretical implementation of a filesystem with a back-end in a relational database. The question is only whether the information is available. Say directories map to databases and files map to tables and views. You can create new tables and views by either writing data or an appropriate query. Views and result files would be read-only while data files would be writable. Writing to a data file would be done with a query which modifies the table and the result could be retrieved by then reading the file -- the modification time would be the time of the last update which is known. Views and queries could be cached results from the last time they were ran which could be updated/rerun by touching them or they could be dynamic and update whenever a table they reference is updated.
- boomlinde 9y agoA very simple approach is to use empty marker files to make such changes visible in the filesystem. Say, dbjoin.done: database.db sqlite3 $< <<< "your query" touch $@