-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
43 changed files
with
12,344 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
# Global excludes across all subdirectories | ||
*.o | ||
*.wasm | ||
*.obj | ||
*.bc | ||
*.so | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
# postgres@wasm | ||
|
||
|
||
## Compilation | ||
|
||
export EMMAKEN_CFLAGS="-Wl,--allow-undefined" | ||
emconfigure ./configure CFLAGS='-Oz' --without-readline --without-zlib --disable-thread-safety --disable-spinlocks | ||
export EMMAKEN_CFLAGS="-s ERROR_ON_UNDEFINED_SYMBOLS=0 -s TOTAL_MEMORY=65536000 -s EMULATE_FUNCTION_POINTER_CASTS=1" | ||
emmake make -j4 | ||
|
||
## Setup the data directory | ||
|
||
emcc src/bin/initdb/initdb.o -L src/port/ -L src/common -L src/fe_utils -L src/interfaces/libpq -lpq -lpgfeutils -lpgcommon -lpgport -o initdb.js | ||
|
||
# create empty datadir | ||
rm -rf datadir | ||
mkdir datadir | ||
chmod 0750 datadir | ||
touch datadir/postgresql.conf | ||
touch datadir/postgresql.auto.conf | ||
touch datadir/pg_ident.conf | ||
touch datadir/pg_hba.conf | ||
echo '15devel' > datadir/PG_VERSION | ||
mkdir -p datadir/global | ||
mkdir -p datadir/pg_wal/archive_status | ||
mkdir -p datadir/pg_commit_ts | ||
mkdir -p datadir/pg_dynshmem | ||
mkdir -p datadir/pg_notify | ||
mkdir -p datadir/pg_serial | ||
mkdir -p datadir/pg_snapshots | ||
mkdir -p datadir/pg_subtrans | ||
mkdir -p datadir/pg_twophase | ||
mkdir -p datadir/pg_multixact | ||
mkdir -p datadir/pg_multixact/members | ||
mkdir -p datadir/pg_multixact/offsets | ||
mkdir -p datadir/base | ||
mkdir -p datadir/base/1 | ||
echo '15devel' > datadir/base/1/PG_VERSION | ||
mkdir -p datadir/pg_replslot | ||
mkdir -p datadir/pg_tblspc | ||
mkdir -p datadir/pg_stat | ||
mkdir -p datadir/pg_stat_tmp | ||
mkdir -p datadir/pg_xact | ||
mkdir -p datadir/pg_logical | ||
mkdir -p datadir/pg_logical/snapshots | ||
mkdir -p datadir/pg_logical/mapping | ||
|
||
|
||
# add that keys to postgres.o compilation: | ||
--preload-file /Users/stas/datadir --preload-file /usr/local/pgsql/share/ | ||
|
||
cd src/backend | ||
|
||
node postgres --boot -x1 -X 16777216 -d 5 -c dynamic_shared_memory_type=mmap -D /data | ||
|
||
|
||
|
||
node postgres --single -F -O -j -c search_path=pg_catalog -c dynamic_shared_memory_type=mmap -d 5 -D /data template1 | ||
|
||
|
||
|
||
|
||
------ | ||
|
||
|
||
var Module = { | ||
preRun: [function() { | ||
function stdin() { | ||
// Return ASCII code of character, or null if no input | ||
} | ||
|
||
function stdout(asciiCode) { | ||
// Do something with the asciiCode | ||
} | ||
|
||
function stderr(asciiCode) { | ||
// Do something with the asciiCode | ||
} | ||
|
||
FS.init(stdin, stdout, stderr); | ||
}] | ||
}; | ||
|
||
|
||
# todo | ||
|
||
+ separate fs packaging from compiling | ||
+ read from events | ||
+ somehow report back | ||
+ identify and fix FUNCTION_POINTER_CASTS | ||
+ fix report back corrupt memory | ||
|
||
* automate datadir process | ||
* split to commits, ensure usual postgres is properly built | ||
* provide js wrapper | ||
* nice UI | ||
* catch errors | ||
|
||
* less data in share | ||
* exclude wal from the datadir (kk hack) or smaller WAL? | ||
|
||
* create postgres db -- more init | ||
|
||
* regress test? =) | ||
|
||
* work with the remote data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<!doctype html> | ||
<html lang=en> | ||
<head> | ||
<meta charset=utf-8> | ||
<title>zenith</title> | ||
<link rel="preconnect" href="https://fonts.gstatic.com"> | ||
<link href="https://fonts.googleapis.com/css2?family=Fira+Code&display=swap" rel="stylesheet"> | ||
<link href="styles.css" rel="stylesheet"> | ||
</head> | ||
<body> | ||
<div id="console"> | ||
<div class="console-line"> | ||
<!-- <p> | ||
Zenith is building open-source cloud-native PostgreSQL.<br /><br /> | ||
Our architecture separates storage from compute,<br /> | ||
allowing for stateless and serverless Postgres.<br /><br /> | ||
We’re a well funded startup with deep knowledge of<br /> | ||
Postgres internals and decades of experience building<br /> | ||
distributed systems.<br /><br /> | ||
To learn more, please take a look at our <a href="https://github.com/zenithdb" target="_blank">GitHub</a>.<br/><br /> | ||
For information on oppurtunities at Zenith, read jobs.txt. | ||
</p> --> | ||
</div> | ||
<div class="console-line active"> | ||
<div class="prompt">zenith ›</div> | ||
<div class="body"></div> | ||
</div> | ||
</div> | ||
|
||
<!-- <input id="query_field" type="text"></input> | ||
<button id="run_btn">run</button> --> | ||
|
||
<script type='text/javascript'> | ||
// var run_btn = document.getElementById('run_btn'); | ||
// var query_field = document.getElementById('query_field'); | ||
|
||
// window.addEventListener('pg_wasm_result', (e) => { | ||
// alert(e.detail.result); | ||
// }); | ||
|
||
// run_btn.onclick = (e) => { | ||
// var event = new CustomEvent("pg_wasm_query", { | ||
// detail: { | ||
// query: query_field.value | ||
// } | ||
// }); | ||
// window.dispatchEvent(event); | ||
// }; | ||
|
||
var Module = { | ||
preRun: [], | ||
postRun: [], | ||
arguments: ['--single','-F','-O','-j','-c','search_path=pg_catalog','-c','dynamic_shared_memory_type=mmap','-d','0','-D','/Users/stas/datadir','template1'], | ||
print: (function() { | ||
return function(text) { | ||
if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' '); | ||
console.error(text); | ||
}; | ||
})(), | ||
printErr: function(text) { | ||
if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' '); | ||
console.error(text); | ||
}, | ||
setStatus: function(text) { | ||
if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' '); | ||
console.error("Set status:" + text); | ||
}, | ||
totalDependencies: 0, | ||
monitorRunDependencies: function(left) { | ||
this.totalDependencies = Math.max(this.totalDependencies, left); | ||
Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')' : 'All downloads complete.'); | ||
} | ||
}; | ||
|
||
|
||
Module.setStatus('Downloading...'); | ||
window.onerror = function(event) { | ||
Module.setStatus('Exception thrown, see JavaScript console'); | ||
Module.setStatus = function(text) { | ||
if (text) Module.printErr('[post-exception status] ' + text); | ||
}; | ||
}; | ||
</script> | ||
<script async type="text/javascript" src="share.js"></script> | ||
<script async type="text/javascript" src="datadir.js"></script> | ||
<script async type="text/javascript" src="postgres.js"></script> | ||
|
||
</body> | ||
<script src="script.js"></script> | ||
</html> |
Oops, something went wrong.