db.pg: fix using postgresql on windows, improve instructions for installing it (#20053)

This commit is contained in:
Dmitriy Mihaylenko 2023-12-01 18:03:28 +02:00 committed by GitHub
parent e30af865f5
commit eec9c7f242
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 4 deletions

View File

@ -7,7 +7,7 @@ Before you can use this module, you must first have PostgreSQL installed on your
To do this, find your OS and perform the actions listed.
> **Note**
> These instructions are meant only as a convenience. If your OS is not listed
> These instructions are meant only as a convenience. If your OS is not listed
> or you need extra help, [go here](https://www.postgresql.org/download/).
### Fedora 31
@ -45,6 +45,34 @@ gem install pg -- --with-pg-config=/opt/local/lib/postgresql[version number]/bin
**ArchLinux**: `pacman -S postgresql-libs`
**Windows**:
```
1. Download PostgreSQL SDK from official site
2. Extract archive to postgres-master folder
3. Copy folder postgres-master/src/interfaces/libpq to v/thirdparty/pg
4. Copy file postgres-master/src/include/postgres_ext.h to v/thirdparty/pg/libpq
If you build PostgreSQL from source pg_config_ext.h and pg_config.h will be created automatically:
5. Copy file postgres-master/src/include/pg_config_ext.h to v/thirdparty/pg/libpq
6. Copy file postgres-master/src/include/pg_config.h to v/thirdparty/pg/libpq
If you do not build PostgreSQL from source code:
5. Copy file postgres-master/src/include/pg_config_ext.h.in to v/thirdparty/pg/libpq
- rename pg_config_ext.h.in to pg_config_ext.h
- in pg_config_ext.h change line **#undef PG_INT64_TYPE** to **#define PG_INT64_TYPE long int**
6. Copy file postgres-master/src/include/pg_config.h.in to v/thirdparty/pg/libpq
- rename pg_config.h.in to pg_config.h
- in pg_config.h change line **#undef PG_VERSION_NUM** to **#define PG_VERSION_NUM X0Y0Z**
where X is major db version, Y is minor version, Z is patch version. So if your version is 17.1.2
PG_VERSION_NUM will be 170102, PG_VERSION_NUM should be number, dot sign is changing to 0,
format *PG_VERSION_NUM 17* without 0 also should work
7. Add libpq.dll to v/thirdparty/pg/win64
To get the libpq.dll file, you can install the PostgreSQL database,
and get this dll from its bin/ folder, or compile DB from source code.
```
## Getting Started with [PostgreSQL](https://www.postgresqltutorial.com/postgresql-getting-started)
Read this section to learn how to install and connect to PostgreSQL
@ -54,7 +82,7 @@ Read this section to learn how to install and connect to PostgreSQL
## Using Parameterized Queries
Parameterized queries (exec_param, etc.) in V require the use of the following syntax: ($n).
Parameterized queries (exec_param, etc.) in V require the use of the following syntax: ($n).
The number following the $ specifies which parameter from the argument array to use.

View File

@ -21,7 +21,7 @@ $if $pkgconfig('libpq') {
#flag darwin -I/opt/homebrew/opt/libpq/include
#flag darwin -L/opt/homebrew/opt/libpq/lib
#flag windows -I @VEXEROOT/thirdparty/pg/include
#flag windows -I @VEXEROOT/thirdparty/pg/libpq
#flag windows -L @VEXEROOT/thirdparty/pg/win64
}
@ -33,7 +33,11 @@ $if $pkgconfig('libpq') {
#include <pg_config.h>
// for orm
#include <arpa/inet.h>
$if windows {
#include <winsock2.h>
} $else {
#include <arpa/inet.h>
}
#include "@VMODROOT/vlib/db/pg/compatibility.h"