### Start Doltgres server Source: https://github.com/dolthub/doltgresql/blob/main/README.md Run the `doltgres` command to start the server. It creates a `postgres` user and database in the current directory with default password `password`. You can customize the data directory via `config.yaml` or `DOLTGRES_DATA_DIR`, and the super-user credentials via `DOLTGRES_USER` and `DOLTGRES_PASSWORD`. ```bash $ doltgres INFO[0000] Server ready. Accepting connections. ``` -------------------------------- ### Install npm dependencies Source: https://github.com/dolthub/doltgresql/blob/main/testing/postgres-client-tests/node/README.md Run this command to install the required npm packages for the Node client integration tests. ```shell $ npm install ``` -------------------------------- ### Add psql to PATH Source: https://github.com/dolthub/doltgresql/blob/main/README.md Add the Postgres bin directory to your PATH to use `psql`. This example uses Homebrew's Postgres 15 installation path; adjust if your installation differs. ```bash export PATH="/opt/homebrew/opt/postgresql@15/bin:$PATH" ``` -------------------------------- ### Install Doltgres via curl script Source: https://github.com/dolthub/doltgresql/blob/main/README.md Downloads and runs the latest Doltgres installer, placing the binary in /usr/local/bin/. ```bash sudo bash -c 'curl -L https://github.com/dolthub/doltgresql/releases/latest/download/install.sh | bash' ``` -------------------------------- ### Stage and commit tables Source: https://github.com/dolthub/doltgresql/blob/main/README.md Use Dolt commands to stage and commit the new tables. The example shows `dolt.status`, `dolt_add`, and `dolt_commit` commands with their outputs, including the commit hash. ```sql getting_started=> select * from dolt.status; table_name | staged | status ------------------------+--------+----------- public.employees | f | new table public.employees_teams | f | new table public.teams | f | new table (3 rows) getting_started=> select dolt_add('teams', 'employees', 'employees_teams'); dolt_add ---------- 0 (1 row) getting_started=> select * from dolt.status; table_name | staged | status -----------------------+--------+----------- public.employees | t | new table public.employees_teams | t | new table public.teams | t | new table (3 rows) getting_started=> select dolt_commit('-m', 'Created initial schema'); dolt_commit ---------------------------------- peqq98e2dl5gscvfvic71e7j6ne34533 (1 row) ``` -------------------------------- ### Build and run PostgreSQL client tests with Docker Source: https://github.com/dolthub/doltgresql/blob/main/testing/postgres-client-tests/README.md Builds the Docker image for the client tests and runs the container. The build may take a few minutes to install dependencies. ```bash $ docker build -t postgres-client-tests -f testing/postgres-client-tests/Dockerfile . $ docker run postgres-client-tests:latest ``` -------------------------------- ### Run Doltgres container with port mapping Source: https://github.com/dolthub/doltgresql/blob/main/dockerREADME.md Starts the Doltgres server in a container, mapping host port 5432 to the container's port 5432. Note that port 5432 may be in use if Postgres is installed locally. ```bash $ docker run -p 5432:5432 dolthub/doltgresql:latest ``` -------------------------------- ### Run Doltgres Docker container Source: https://github.com/dolthub/doltgresql/blob/main/README.md Starts the official Doltgres Docker image, setting the password and exposing port 5432. ```bash $ docker run -e DOLTGRES_PASSWORD=myPassword -p 5432:5432 dolthub/doltgresql:latest ``` -------------------------------- ### Create database and tables Source: https://github.com/dolthub/doltgresql/blob/main/README.md Create the `getting_started` database and the `employees`, `teams`, and `employees_teams` tables. The `employees_teams` table includes foreign keys referencing the other two tables. The output shows the expected psql responses. ```sql postgres=> create database getting_started; -- (0 rows) postgres=> \c getting_started; psql (15.4 (Homebrew), server 15.0) You are now connected to database "getting_started" as user "postgres". getting_started=> create table employees ( id int8, last_name text, first_name text, primary key(id)); -- (0 rows) getting_started=> create table teams ( id int8, team_name text, primary key(id)); -- (0 rows) getting_started=> create table employees_teams( team_id int8, employee_id int8, primary key(team_id, employee_id), foreign key (team_id) references teams(id), foreign key (employee_id) references employees(id)); -- (0 rows) getting_started=> \d List of relations Schema | Name | Type | Owner --------+-----------------+-------+---------- public | employees | table | postgres public | employees_teams | table | postgres public | teams | table | postgres (3 rows) ``` -------------------------------- ### Mount initialization scripts directory Source: https://github.com/dolthub/doltgresql/blob/main/dockerREADME.md Mounts a local directory containing .sql (or compressed) initialization scripts to /docker-entrypoint-initdb.d/. Scripts are executed during container startup. ```shell $ docker run -v ./init_scripts:/docker-entrypoint-initdb.d/ -p 5432:5432 dolthub/doltgresql:latest ``` -------------------------------- ### Run Doltgres image with --help flag Source: https://github.com/dolthub/doltgresql/blob/main/dockerREADME.md Displays all supported options for the doltgres command inside the container. ```shell $ docker run dolthub/doltgresql:latest --help ``` -------------------------------- ### Build Doltgres from source Source: https://github.com/dolthub/doltgresql/blob/main/README.md Runs the build script to produce a binary from source code. ```bash ./scripts/build.sh ``` -------------------------------- ### Run workbench.js tests Source: https://github.com/dolthub/doltgresql/blob/main/testing/postgres-client-tests/node/README.md Run this command to execute the workbench.js test file against the running server. The run-tests.sh script sets up the database, runs the SQL server, runs the provided .js test file, and then tears down the database. ```shell sh run-tests.sh workbench.js ``` -------------------------------- ### Run tests with DOLTGRES_BIN_PATH Source: https://github.com/dolthub/doltgresql/blob/main/integration-tests/go-sql-server-driver/tests/README.md Sets the DOLTGRES_BIN_PATH environment variable to point to the doltgres binary, falling back to doltgres on the PATH, then runs all tests with go test. ```bash DOLTGRES_BIN_PATH=/path/to/doltgres go test ./... ``` -------------------------------- ### Simple statement rule with HELPTOKEN Source: https://github.com/dolthub/doltgresql/blob/main/postgres/parser/parser/README.md Shows the initial simple statement rule and two alternative extensions to handle HELPTOKEN after a valid statement. The first alternative adds a separate rule with HELPTOKEN, the second uses an error token. Both are presented as possible approaches. ```yacc somesimplestmt: SIMPLE DO SOMETHING { $$ = reduce(...) } | SIMPLE error { help ... } ``` ```yacc somesimplestmt: SIMPLE DO SOMETHING { $$ = reduce(...) } | SIMPLE DO SOMETHING HELPTOKEN { help ... } | SIMPLE error { help ... } ``` ```yacc somesimplestmt: SIMPLE DO SOMETHING { $$ = reduce(...) } | SIMPLE DO SOMETHING error { help ... } | SIMPLE error { help ... } ``` -------------------------------- ### Connect to Doltgres with psql Source: https://github.com/dolthub/doltgresql/blob/main/dockerREADME.md Connects to the Doltgres server using psql with the default super-user 'postgres' and password 'password'. ```bash $ PGPASSWORD=password psql --host 127.0.0.1 -U postgres ``` -------------------------------- ### Expected output from running postgres-client-tests container Source: https://github.com/dolthub/doltgresql/blob/main/testing/postgres-client-tests/README.md Shows the output when running the built container, indicating successful execution of the client tests. ```bash $ docker run postgres-client-tests:latest Running postgres-client-tests: 1..2 ok 1 postgres-connector-java client ok 2 node postgres client ``` -------------------------------- ### Build Doltgres image with Dockerfile Source: https://github.com/dolthub/doltgresql/blob/main/dockerREADME.md Builds the Doltgres image using the Dockerfile in the repository root. Supports building the latest release, a specific version, or from local source via the DOLTGRES_VERSION build argument. ```shell # Build the latest Doltgres version (automatically fetches the latest release) $ docker build -t doltgres:latest . # Build the latest Doltgres version (fetches the latest release) $ docker build --build-arg DOLTGRES_VERSION=latest -t doltgres:latest . # Build with a specific Doltgres version $ docker build --build-arg DOLTGRES_VERSION=0.55.1 -t doltgres:0.55.1 . # Build from local source code $ docker build --build-arg DOLTGRES_VERSION=source -t doltgres:source . ``` -------------------------------- ### Mount configuration directory for Doltgres Source: https://github.com/dolthub/doltgresql/blob/main/dockerREADME.md Mounts a local directory containing config.yaml to /etc/doltgres/servercfg.d and maps port 5432. The server reads configuration from the mounted directory. ```shell $ docker run -v ./doltgres_cfg:/etc/doltgres/servercfg.d -p 5432:5432 dolthub/doltgresql:latest ``` -------------------------------- ### Shorthand syntax for help rule Source: https://github.com/dolthub/doltgresql/blob/main/postgres/parser/parser/README.md Shows the shorthand comment syntax that is substituted by replace_help_rules.awk into the full error recovery form. The comment 'SHOW HELP: BACKUP' is replaced with the equivalent error rule. ```yacc backup_stmt: ... | BACKUP error // SHOW HELP: BACKUP ``` -------------------------------- ### Bison rule with precedence and help action Source: https://github.com/dolthub/doltgresql/blob/main/postgres/parser/parser/README.md Shows a Bison rule pattern where a rule can be extended with a help token and action, using %prec to set precedence. This pattern is common and is automated by a special syntax. ```bison rule: somerule %prec VALUES | somerule HELPTOKEN %prec UMINUS { help ...}` ``` -------------------------------- ### Set DOLTGRES_USER and DOLTGRES_PASSWORD Source: https://github.com/dolthub/doltgresql/blob/main/dockerREADME.md Sets the super-user name and password via environment variables. POSTGRES_USER and POSTGRES_PASSWORD are aliases. ```shell $ docker run -e DOLTGRES_USER=myuser -e DOLTGRES_PASSWORD=mypass -p 5432:5432 dolthub/doltgresql:latest ``` -------------------------------- ### Bison rule with EXTEND WITH HELP comment Source: https://github.com/dolthub/doltgresql/blob/main/postgres/parser/parser/README.md Shows the special syntax that automates the pattern above. The comment // EXTEND WITH HELP: XXX is replaced by the awk script to expand to the full rule with help action. ```bison rule: somerule // EXTEND WITH HELP: XXX ``` -------------------------------- ### View Dolt log Source: https://github.com/dolthub/doltgresql/blob/main/README.md Query the `dolt.log` table to see the commit history. The output shows the commit hash, committer, email, date, and message for each commit. ```sql getting_started=> select * from dolt.log; commit_hash | committer | email | date | message ----------------------------------+-----------+--------------------+---------------------+---------------------------- peqq98e2dl5gscvfvic71e7j6ne34533 | postgres | postgres@127.0.0.1 | 2023-11-01 22:08:04 | Created initial schema in7bk735qa6p6rv6i3s797jjem2pg4ru | timsehn | tim@dolthub.com | 2023-11-01 22:04:03 | Initialize data repository (2 rows) ``` -------------------------------- ### Grammar rule with error recovery for BACKUP Source: https://github.com/dolthub/doltgresql/blob/main/postgres/parser/parser/README.md Shows a grammar rule that uses the 'error' token to recover from parsing errors and return contextual help. When the BACKUP keyword is followed by invalid tokens, the parser reduces to this rule and executes the action that returns help. ```yacc backup_stmt: BACKUP targets TO string_or_placeholder opt_as_of_clause opt_incremental opt_with_options { $$.val = &Backup{Targets: $2.targetList(), To: $4.expr(), IncrementalFrom: $6.exprs(), AsOf: $5.asOfClause(), Options: $7.kvOptions()} } | BACKUP error { return helpWith(sqllex, `BACKUP`) } ``` -------------------------------- ### Yacc comment markers for help text Source: https://github.com/dolthub/doltgresql/blob/main/postgres/parser/parser/README.md Defines the format for embedding help text in yacc comments. The HELPKEY becomes the map key in the generated Go map. The markers include %Help, %Category, %Text, %SeeAlso, and optional %End. ```yacc // %Help: HELPKEY - shortdescription // %Category: SomeCat // %Text: whatever until next %marker at start of line, or non-comment. // %SeeAlso: whatever until next %marker at start of line, or non-comment. // %End (optional) ``` -------------------------------- ### Factored rule using %prec to resolve conflict Source: https://github.com/dolthub/doltgresql/blob/main/postgres/parser/parser/README.md Shows the recommended solution: factoring the statement into a real_alter_rename_table_stmt rule and adding a separate rule with HELPTOKEN, using %prec with LOWTOKEN and HIGHTOKEN to resolve the shift/reduce conflict. ```yacc alter_rename_table_stmt: real_alter_rename_table_stmt %prec LOWTOKEN { $$ = $1 } | real_alter_rename_table_stmt HELPTOKEN %prec HIGHTOKEN { help ... } real_alter_rename_table_stmt: ALTER TABLE relation_expr RENAME TO qualified_name { ... } | ALTER TABLE IF EXISTS relation_expr RENAME TO qualified_name { ... } | ALTER TABLE relation_expr RENAME opt_column name TO name { ... } | ALTER TABLE IF EXISTS relation_expr RENAME opt_column name TO name { ... } ``` -------------------------------- ### Duplicated rules for alter_rename_table_stmt Source: https://github.com/dolthub/doltgresql/blob/main/postgres/parser/parser/README.md Shows the original alter_rename_table_stmt rule with multiple alternatives, and the undesirable duplication required to add HELPTOKEN handling to each alternative. ```yacc alter_rename_table_stmt: ALTER TABLE relation_expr RENAME TO qualified_name { ... } | ALTER TABLE IF EXISTS relation_expr RENAME TO qualified_name { ... } | ALTER TABLE relation_expr RENAME opt_column name TO name { ... } | ALTER TABLE IF EXISTS relation_expr RENAME opt_column name TO name { ... } ``` ```yacc alter_rename_table_stmt: ALTER TABLE relation_expr RENAME TO qualified_name { ... } | ALTER TABLE relation_expr RENAME TO qualified_name HELPTOKEN { help ... } | ALTER TABLE IF EXISTS relation_expr RENAME TO qualified_name { ... } | ALTER TABLE IF EXISTS relation_expr RENAME TO qualified_name HELPTOKEN { help ... } | ALTER TABLE relation_expr RENAME opt_column name TO name { ... } | ALTER TABLE relation_expr RENAME opt_column name TO name HELPTOKEN { help ... } | ALTER TABLE IF EXISTS relation_expr RENAME opt_column name TO name { ... } | ALTER TABLE IF EXISTS relation_expr RENAME opt_column name TO name HELPTOKEN { help ... } ``` -------------------------------- ### Update Doltgres config Source: https://github.com/dolthub/doltgresql/blob/main/testing/postgres-client-tests/node/README.md Run this shell script to update the Doltgres configuration before running the tests. ```shell sh ../postgres-client-tests-entrypoint.sh ``` -------------------------------- ### Set PGDATA environment variable for Doltgres Source: https://github.com/dolthub/doltgresql/blob/main/dockerREADME.md Overrides the default data directory (/var/lib/doltgresql/) by setting the PGDATA environment variable. The directory can be a mounted volume. ```shell $ docker run -e PGDATA=/path/to/doltgres/data -p 5432:5432 dolthub/doltgresql:latest ``` -------------------------------- ### Top-level grammar rule with error token Source: https://github.com/dolthub/doltgresql/blob/main/postgres/parser/parser/README.md Illustrates a top-level grammar rule that attempts to use the 'error' token for recovery. This approach does not work because the error action cannot observe the tokens seen so far, so it cannot determine which statement type caused the error. ```yacc stmt: alter_stmt | backup_stmt | ... | delete_stmt | ... | error { ??? } ``` -------------------------------- ### Bats test structure Source: https://github.com/dolthub/doltgresql/blob/main/CONTRIBUTING.md All Bats tests must follow this general structure. The file-name is the name of the file without the .bats extension, and test name is the unique name of the test within that file. The name portion can be surrounded by single or double quotes, though double quotes may cause issues if the test name includes a backslash. ```bash @test "file-name: test name" { # Test Contents } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.