-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: import real data from Postgres system tables. (#299)
- Loading branch information
1 parent
1aeb456
commit 1749dfe
Showing
13 changed files
with
4,873 additions
and
21 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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package catalog | ||
|
||
var InitialDataTables = struct { | ||
PGNamespace [][]any | ||
PGRange [][]any | ||
}{ | ||
PGNamespace: [][]any{ | ||
{"99", "pg_toast", "10", ""}, | ||
{"11", "pg_catalog", "10", "{postgres=UC/postgres,=U/postgres}"}, | ||
{"2200", "public", "6171", "{pg_database_owner,=UC/pg_database_owner,=U/pg_database_owner}"}, | ||
{"13219", "information_schema", "10", "{postgres=UC/postgres,=U/postgres}"}, | ||
{"16395", "test_schema", "10", ""}, | ||
}, | ||
PGRange: [][]any{ | ||
{"3904", "23", "4451", "0", "1978", "int4range_canonical", "int4range_subdiff"}, | ||
{"3906", "1700", "4532", "0", "3125", "-", "numrange_subdiff"}, | ||
{"3908", "1114", "4533", "0", "3128", "-", "tsrange_subdiff"}, | ||
{"3910", "1184", "4534", "0", "3127", "-", "tstzrange_subdiff"}, | ||
{"3912", "1082", "4535", "0", "3122", "daterange_canonical", "daterange_subdiff"}, | ||
{"3926", "20", "4536", "0", "3124", "int8range_canonical", "int8range_subdiff"}, | ||
}, | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,18 @@ | ||
package initialdata | ||
|
||
import _ "embed" | ||
|
||
//go:embed pg_class.csv | ||
var pgClassContent string | ||
|
||
//go:embed pg_proc.csv | ||
var pgProcContent string | ||
|
||
//go:embed pg_type.csv | ||
var pgTypeContent string | ||
|
||
var InitialTableDataMap = map[string]string{ | ||
"pg_class": pgClassContent, | ||
"pg_proc": pgProcContent, | ||
"pg_type": pgTypeContent, | ||
} |
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,23 @@ | ||
#!/bin/bash | ||
|
||
# Start a PostgreSQL container and mount the current directory | ||
CONTAINER_ID=$(docker run --rm -d -e POSTGRES_PASSWORD=postgres -v "$(pwd):/data" postgres) | ||
sleep 5 | ||
|
||
# Set file paths within the container | ||
PG_CLASS_FILE="/data/pg_class.csv" | ||
PG_PROC_FILE="/data/pg_proc.csv" | ||
PG_TYPE_FILE="/data/pg_type.csv" | ||
|
||
# Define SQL queries | ||
PG_CLASS_QUERY="SELECT oid, relname, relnamespace, reltype, reloftype, relowner, relam, relfilenode, reltablespace, relpages, reltuples, relallvisible, reltoastrelid, relhasindex, relisshared, relpersistence, relkind, relnatts, relchecks, relhasrules, relhastriggers, relhassubclass, relrowsecurity, relforcerowsecurity, relispopulated, relreplident, relispartition, relrewrite, relfrozenxid, relminmxid, relacl, reloptions, relpartbound FROM pg_class" | ||
PG_PROC_QUERY="SELECT oid, proname, pronamespace, proowner, prolang, procost, prorows, provariadic, prosupport::regproc::oid, prokind, prosecdef, proleakproof, proisstrict, proretset, provolatile, proparallel, pronargs, pronargdefaults, prorettype, proargtypes, proallargtypes, proargmodes, proargnames, proargdefaults, protrftypes, prosrc, probin, prosqlbody, proconfig, proacl FROM pg_proc" | ||
PG_TYPE_QUERY="SELECT oid, typname, typnamespace, typowner, typlen, typbyval, typtype, typcategory, typispreferred, typisdefined, typdelim, typrelid, typsubscript::regproc::oid, typelem, typarray, typinput::regproc::oid, typoutput::regproc::oid, typreceive::regproc::oid, typsend::regproc::oid, typmodin::regproc::oid, typmodout::regproc::oid, typanalyze::regproc::oid, typalign, typstorage, typnotnull, typbasetype, typtypmod, typndims, typcollation, typdefaultbin, typdefault, typacl FROM pg_type" | ||
|
||
# Execute queries and export data to mounted files | ||
docker exec -i $CONTAINER_ID psql -U postgres -c "\COPY ($PG_CLASS_QUERY) TO '$PG_CLASS_FILE' WITH CSV HEADER" | ||
docker exec -i $CONTAINER_ID psql -U postgres -c "\COPY ($PG_PROC_QUERY) TO '$PG_PROC_FILE' WITH CSV HEADER" | ||
docker exec -i $CONTAINER_ID psql -U postgres -c "\COPY ($PG_TYPE_QUERY) TO '$PG_TYPE_FILE' WITH CSV HEADER" | ||
|
||
# Stop the container | ||
docker kill $CONTAINER_ID |
Oops, something went wrong.