-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A catalog is the SQL standard term for a database. A catalog contains schemas, but cannot be directly created with SQL. Instead, a catalog in vsql means a database file which includes a ":memory:" database. Loading multiple catalogs allows vsql to work seamlessly across multiple database files, although there is some limitations with transaction guarantees when working with multiple catalogs. See documentation for more details. Catalogs are virtual, meaning that the catalog name is not encoded into the database file but created when attaching it to the engine. By default the catalog name is derived from the file by using the first part of the file name. For example "/foo/bar.baz.vsql" will be "bar". SQL Standard F651 SQL Standard F762
- Loading branch information
1 parent
8879d67
commit bd6d3b1
Showing
74 changed files
with
1,138 additions
and
509 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,19 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
VSQL1_FILE="$(mktemp -d)/file1.abc.vsql" || exit 1 | ||
VSQL2_FILE="$(mktemp -d)/file2.def.vsql" || exit 1 | ||
TXT_FILE="$(mktemp).sql" || exit 1 | ||
|
||
echo 'CREATE TABLE foo (bar INT);' | $VSQL cli $VSQL1_FILE | ||
echo 'INSERT INTO foo (bar) VALUES (123);' | $VSQL cli $VSQL1_FILE | ||
|
||
echo 'CREATE TABLE foo (baz INT);' | $VSQL cli $VSQL2_FILE | ||
echo 'INSERT INTO foo (baz) VALUES (456);' | $VSQL cli $VSQL2_FILE | ||
|
||
echo 'SELECT * FROM "file1".public.foo;' | $VSQL cli $VSQL1_FILE $VSQL2_FILE > $TXT_FILE | ||
echo 'SELECT * FROM "file2".public.foo;' | $VSQL cli $VSQL1_FILE $VSQL2_FILE >> $TXT_FILE | ||
|
||
grep -R "BAR: 123" $TXT_FILE | ||
grep -R "BAZ: 456" $TXT_FILE |
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
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
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
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,75 @@ | ||
CREATE TABLE ":memory:".PUBLIC.foo (baz INTEGER); | ||
INSERT INTO ":memory:".PUBLIC.foo (baz) VALUES (123); | ||
INSERT INTO ":memory:".PUBLIC.foo (baz) VALUES (456); | ||
SELECT * FROM ":memory:".PUBLIC.foo; | ||
UPDATE ":memory:".PUBLIC.foo SET baz = 789 WHERE baz = 123; | ||
SELECT * FROM ":memory:".PUBLIC.foo; | ||
DELETE FROM ":memory:".PUBLIC.foo WHERE baz > 700; | ||
SELECT * FROM ":memory:".PUBLIC.foo; | ||
-- msg: CREATE TABLE 1 | ||
-- msg: INSERT 1 | ||
-- msg: INSERT 1 | ||
-- BAZ: 123 | ||
-- BAZ: 456 | ||
-- msg: UPDATE 1 | ||
-- BAZ: 789 | ||
-- BAZ: 456 | ||
-- msg: DELETE 1 | ||
-- BAZ: 456 | ||
|
||
/* create_catalog FOO */ | ||
CREATE TABLE foo.public.bar (baz INTEGER); | ||
EXPLAIN SELECT * FROM foo.public.bar; | ||
-- msg: CREATE TABLE 1 | ||
-- EXPLAIN: TABLE FOO.PUBLIC.BAR (BAZ INTEGER) | ||
-- EXPLAIN: EXPR (FOO.PUBLIC.BAR.BAZ INTEGER) | ||
|
||
/* create_catalog FOO */ | ||
CREATE TABLE foo.public.bar (baz INTEGER); | ||
INSERT INTO foo.public.bar (baz) VALUES (123); | ||
EXPLAIN SELECT * FROM foo.public.bar; | ||
SET CATALOG ':memory:'; | ||
-- msg: CREATE TABLE 1 | ||
-- msg: INSERT 1 | ||
-- EXPLAIN: TABLE FOO.PUBLIC.BAR (BAZ INTEGER) | ||
-- EXPLAIN: EXPR (FOO.PUBLIC.BAR.BAZ INTEGER) | ||
-- msg: SET CATALOG 1 | ||
|
||
VALUES CURRENT_CATALOG; | ||
/* create_catalog FOO */ | ||
/* create_catalog BAR */ | ||
VALUES CURRENT_CATALOG; | ||
SET CATALOG 'FOO'; | ||
VALUES CURRENT_CATALOG; | ||
SET CATALOG 'BAR'; | ||
VALUES CURRENT_CATALOG; | ||
CREATE TABLE baz (num1 INTEGER); | ||
INSERT INTO baz (num1) VALUES (123); | ||
SELECT * FROM baz; | ||
SET CATALOG 'FOO'; | ||
SELECT * FROM baz; | ||
CREATE TABLE baz (num2 INTEGER); | ||
INSERT INTO baz (num2) VALUES (456); | ||
SELECT * FROM baz; | ||
SET CATALOG ':memory:'; | ||
SELECT * FROM foo.public.baz; | ||
SELECT * FROM bar.public.baz; | ||
SELECT * FROM foo.public.baz JOIN bar.public.baz ON TRUE; | ||
-- COL1: :memory: | ||
-- COL1: BAR | ||
-- msg: SET CATALOG 1 | ||
-- COL1: FOO | ||
-- msg: SET CATALOG 1 | ||
-- COL1: BAR | ||
-- msg: CREATE TABLE 1 | ||
-- msg: INSERT 1 | ||
-- NUM1: 123 | ||
-- msg: SET CATALOG 1 | ||
-- error 42P01: no such table: FOO.PUBLIC.BAZ | ||
-- msg: CREATE TABLE 1 | ||
-- msg: INSERT 1 | ||
-- NUM2: 456 | ||
-- msg: SET CATALOG 1 | ||
-- NUM2: 456 | ||
-- NUM1: 123 | ||
-- NUM2: 456 NUM1: 123 |
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
Oops, something went wrong.