Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: brianc/node-postgres
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 3ac356a812f473ad1f0a748b662524f9b7913583
Choose a base ref
...
head repository: brianc/node-postgres
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 29877530c6f7b5ebc0bf814e3a711b4b66e4d51a
Choose a head ref
Loading
Showing with 13,605 additions and 482 deletions.
  1. +73 −0 .devcontainer/Dockerfile
  2. +31 −0 .devcontainer/devcontainer.json
  3. +44 −0 .devcontainer/docker-compose.yml
  4. +30 −2 .eslintrc
  5. +3 −0 .github/FUNDING.yml
  6. +4 −0 .gitignore
  7. +0 −8 .npmignore
  8. +42 −25 .travis.yml
  9. +113 −24 CHANGELOG.md
  10. +1 −1 LICENSE
  11. +28 −12 README.md
  12. +19 −1 SPONSORS.md
  13. +12 −0 lerna.json
  14. +14 −43 package.json
  15. +37 −0 packages/pg-cursor/README.md
  16. +218 −0 packages/pg-cursor/index.js
  17. +33 −0 packages/pg-cursor/package.json
  18. +54 −0 packages/pg-cursor/test/close.js
  19. +86 −0 packages/pg-cursor/test/error-handling.js
  20. +181 −0 packages/pg-cursor/test/index.js
  21. +3 −0 packages/pg-cursor/test/mocha.opts
  22. +34 −0 packages/pg-cursor/test/no-data-handling.js
  23. +107 −0 packages/pg-cursor/test/pool.js
  24. +35 −0 packages/pg-cursor/test/query-config.js
  25. +43 −0 packages/pg-cursor/test/transactions.js
  26. +22 −0 packages/pg-packet-stream/package.json
  27. +44 −0 packages/pg-packet-stream/src/BufferReader.ts
  28. +510 −0 packages/pg-packet-stream/src/inbound-parser.test.ts
  29. +328 −0 packages/pg-packet-stream/src/index.ts
  30. +169 −0 packages/pg-packet-stream/src/messages.ts
  31. +79 −0 packages/pg-packet-stream/src/testing/buffer-list.ts
  32. +183 −0 packages/pg-packet-stream/src/testing/test-buffers.ts
  33. +1 −0 packages/pg-packet-stream/src/types/chunky.d.ts
  34. +24 −0 packages/pg-packet-stream/tsconfig.json
  35. +21 −0 packages/pg-pool/LICENSE
  36. +350 −0 packages/pg-pool/README.md
  37. +385 −0 packages/pg-pool/index.js
  38. +39 −0 packages/pg-pool/package.json
  39. +36 −0 packages/pg-pool/test/bring-your-own-promise.js
  40. +30 −0 packages/pg-pool/test/connection-strings.js
  41. +224 −0 packages/pg-pool/test/connection-timeout.js
  42. +34 −0 packages/pg-pool/test/ending.js
  43. +244 −0 packages/pg-pool/test/error-handling.js
  44. +86 −0 packages/pg-pool/test/events.js
  45. +79 −0 packages/pg-pool/test/idle-timeout.js
  46. +229 −0 packages/pg-pool/test/index.js
  47. +20 −0 packages/pg-pool/test/logging.js
  48. +3 −0 packages/pg-pool/test/mocha.opts
  49. +54 −0 packages/pg-pool/test/releasing-clients.js
  50. +10 −0 packages/pg-pool/test/setup.js
  51. +50 −0 packages/pg-pool/test/sizing.js
  52. +19 −0 packages/pg-pool/test/submittable.js
  53. 0 packages/pg-pool/test/timeout.js
  54. +25 −0 packages/pg-pool/test/verify.js
  55. +9 −0 packages/pg-query-stream/LICENSE
  56. +68 −0 packages/pg-query-stream/README.md
  57. +45 −0 packages/pg-query-stream/index.js
  58. +38 −0 packages/pg-query-stream/package.json
  59. +112 −0 packages/pg-query-stream/test/async-iterator.es6
  60. +4 −0 packages/pg-query-stream/test/async-iterator.js
  61. +88 −0 packages/pg-query-stream/test/close.js
  62. +22 −0 packages/pg-query-stream/test/concat.js
  63. +26 −0 packages/pg-query-stream/test/config.js
  64. +20 −0 packages/pg-query-stream/test/empty-query.js
  65. +22 −0 packages/pg-query-stream/test/error.js
  66. +35 −0 packages/pg-query-stream/test/fast-reader.js
  67. +17 −0 packages/pg-query-stream/test/helper.js
  68. +15 −0 packages/pg-query-stream/test/instant.js
  69. +32 −0 packages/pg-query-stream/test/issue-3.js
  70. +1 −0 packages/pg-query-stream/test/mocha.opts
  71. +38 −0 packages/pg-query-stream/test/passing-options.js
  72. +18 −0 packages/pg-query-stream/test/pauses.js
  73. +26 −0 packages/pg-query-stream/test/slow-reader.js
  74. +26 −0 packages/pg-query-stream/test/stream-tester-timestamp.js
  75. +15 −0 packages/pg-query-stream/test/stream-tester.js
  76. +3 −1 { → packages/pg}/Makefile
  77. +101 −0 packages/pg/README.md
  78. +68 −0 packages/pg/bench.js
  79. +208 −59 { → packages/pg}/lib/client.js
  80. +22 −0 packages/pg/lib/compat/check-constructor.js
  81. +19 −0 packages/pg/lib/compat/warn-deprecation.js
  82. +378 −0 packages/pg/lib/connection-fast.js
  83. +23 −4 { → packages/pg}/lib/connection-parameters.js
  84. +102 −47 { → packages/pg}/lib/connection.js
  85. +17 −2 { → packages/pg}/lib/defaults.js
  86. +6 −0 { → packages/pg}/lib/index.js
  87. +126 −54 { → packages/pg}/lib/native/client.js
  88. 0 { → packages/pg}/lib/native/index.js
  89. +9 −2 { → packages/pg}/lib/native/query.js
  90. +20 −20 { → packages/pg}/lib/query.js
  91. +13 −12 { → packages/pg}/lib/result.js
  92. +147 −0 packages/pg/lib/sasl.js
  93. 0 { → packages/pg}/lib/type-overrides.js
  94. +17 −4 { → packages/pg}/lib/utils.js
  95. +56 −0 packages/pg/package.json
  96. +31 −11 { → packages/pg}/script/create-test-tables.js
  97. 0 { → packages/pg}/script/dump-db-types.js
  98. 0 { → packages/pg}/script/list-db-types.js
  99. +7 −0 { → packages/pg}/test/buffer-list.js
  100. 0 { → packages/pg}/test/cli.js
  101. +86 −44 { → packages/pg}/test/integration/client/api-tests.js
  102. 0 { → packages/pg}/test/integration/client/appname-tests.js
  103. 0 { → packages/pg}/test/integration/client/array-tests.js
  104. 0 { → packages/pg}/test/integration/client/big-simple-query-tests.js
  105. 0 { → packages/pg}/test/integration/client/configuration-tests.js
  106. +85 −0 packages/pg/test/integration/client/connection-timeout-tests.js
  107. +38 −0 packages/pg/test/integration/client/custom-types-tests.js
  108. 0 { → packages/pg}/test/integration/client/empty-query-tests.js
  109. +18 −0 { → packages/pg}/test/integration/client/error-handling-tests.js
  110. 0 { → packages/pg}/test/integration/client/field-name-escape-tests.js
  111. 0 { → packages/pg}/test/integration/client/huge-numeric-tests.js
  112. +79 −0 packages/pg/test/integration/client/idle_in_transaction_session_timeout-tests.js
  113. 0 { → packages/pg}/test/integration/client/json-type-parsing-tests.js
  114. 0 { → packages/pg}/test/integration/client/multiple-results-tests.js
  115. +6 −4 { → packages/pg}/test/integration/client/network-partition-tests.js
  116. 0 { → packages/pg}/test/integration/client/no-data-tests.js
  117. 0 { → packages/pg}/test/integration/client/no-row-result-tests.js
  118. 0 { → packages/pg}/test/integration/client/notice-tests.js
  119. 0 { → packages/pg}/test/integration/client/parse-int-8-tests.js
  120. +11 −0 { → packages/pg}/test/integration/client/prepared-statement-tests.js
  121. 0 { → packages/pg}/test/integration/client/promise-api-tests.js
  122. +23 −1 { → packages/pg}/test/integration/client/query-as-promise-tests.js
  123. 0 { → packages/pg}/test/integration/client/query-column-names-tests.js
  124. 0 { → packages/pg}/test/integration/client/query-error-handling-prepared-statement-tests.js
  125. 0 { → packages/pg}/test/integration/client/query-error-handling-tests.js
  126. 0 { → packages/pg}/test/integration/client/quick-disconnect-tests.js
  127. 0 { → packages/pg}/test/integration/client/result-metadata-tests.js
  128. 0 { → packages/pg}/test/integration/client/results-as-array-tests.js
  129. 0 { → packages/pg}/test/integration/client/row-description-on-results-tests.js
  130. +41 −0 packages/pg/test/integration/client/sasl-scram-tests.js
  131. 0 { → packages/pg}/test/integration/client/simple-query-tests.js
  132. 0 { → packages/pg}/test/integration/client/ssl-tests.js
  133. 0 { → packages/pg}/test/integration/client/statement_timeout-tests.js
  134. 0 { → packages/pg}/test/integration/client/test-helper.js
  135. 0 { → packages/pg}/test/integration/client/timezone-tests.js
  136. 0 { → packages/pg}/test/integration/client/transaction-tests.js
  137. +1 −1 { → packages/pg}/test/integration/client/type-coercion-tests.js
  138. 0 { → packages/pg}/test/integration/client/type-parser-override-tests.js
  139. 0 { → packages/pg}/test/integration/connection-pool/connection-pool-size-tests.js
  140. +130 −0 packages/pg/test/integration/connection-pool/error-tests.js
  141. 0 { → packages/pg}/test/integration/connection-pool/idle-timeout-tests.js
  142. 0 { → packages/pg}/test/integration/connection-pool/native-instance-tests.js
  143. 0 { → packages/pg}/test/integration/connection-pool/test-helper.js
  144. 0 { → packages/pg}/test/integration/connection-pool/yield-support-tests.js
  145. 0 { → packages/pg}/test/integration/connection/bound-command-tests.js
  146. 0 { → packages/pg}/test/integration/connection/copy-tests.js
  147. +118 −0 packages/pg/test/integration/connection/dynamic-password-tests.js
  148. 0 { → packages/pg}/test/integration/connection/notification-tests.js
  149. 0 { → packages/pg}/test/integration/connection/query-tests.js
  150. 0 { → packages/pg}/test/integration/connection/test-helper.js
  151. 0 { → packages/pg}/test/integration/domain-tests.js
  152. +8 −6 { → packages/pg}/test/integration/gh-issues/130-tests.js
  153. 0 { → packages/pg}/test/integration/gh-issues/131-tests.js
  154. 0 { → packages/pg}/test/integration/gh-issues/1382-tests.js
  155. +33 −0 packages/pg/test/integration/gh-issues/1854-tests.js
  156. 0 { → packages/pg}/test/integration/gh-issues/199-tests.js
  157. +23 −0 packages/pg/test/integration/gh-issues/2056-tests.js
  158. +56 −0 packages/pg/test/integration/gh-issues/2079-tests.js
  159. +15 −0 packages/pg/test/integration/gh-issues/2085-tests.js
  160. 0 { → packages/pg}/test/integration/gh-issues/507-tests.js
  161. 0 { → packages/pg}/test/integration/gh-issues/600-tests.js
  162. 0 { → packages/pg}/test/integration/gh-issues/675-tests.js
  163. 0 { → packages/pg}/test/integration/gh-issues/699-tests.js
  164. 0 { → packages/pg}/test/integration/gh-issues/787-tests.js
  165. 0 { → packages/pg}/test/integration/gh-issues/882-tests.js
  166. 0 { → packages/pg}/test/integration/gh-issues/981-tests.js
  167. 0 { → packages/pg}/test/integration/test-helper.js
  168. 0 { → packages/pg}/test/native/callback-api-tests.js
  169. 0 { → packages/pg}/test/native/evented-api-tests.js
  170. 0 { → packages/pg}/test/native/missing-native.js
  171. 0 { → packages/pg}/test/native/native-vs-js-error-tests.js
  172. 0 { → packages/pg}/test/native/stress-tests.js
  173. +15 −1 { → packages/pg}/test/suite.js
  174. +22 −0 { → packages/pg}/test/test-buffers.js
  175. +1 −1 { → packages/pg}/test/test-helper.js
  176. 0 { → packages/pg}/test/unit/client/cleartext-password-tests.js
  177. 0 { → packages/pg}/test/unit/client/configuration-tests.js
  178. 0 { → packages/pg}/test/unit/client/early-disconnect-tests.js
  179. 0 { → packages/pg}/test/unit/client/escape-tests.js
  180. 0 { → packages/pg}/test/unit/client/md5-password-tests.js
  181. 0 { → packages/pg}/test/unit/client/notification-tests.js
  182. 0 { → packages/pg}/test/unit/client/prepared-statement-tests.js
  183. 0 { → packages/pg}/test/unit/client/query-queue-tests.js
  184. 0 { → packages/pg}/test/unit/client/result-metadata-tests.js
  185. +135 −0 packages/pg/test/unit/client/sasl-scram-tests.js
  186. +32 −0 packages/pg/test/unit/client/set-keepalives-tests.js
  187. +20 −0 { → packages/pg}/test/unit/client/simple-query-tests.js
  188. 0 { → packages/pg}/test/unit/client/stream-and-query-error-interaction-tests.js
  189. 0 { → packages/pg}/test/unit/client/test-helper.js
  190. 0 { → packages/pg}/test/unit/client/throw-in-type-parser-tests.js
  191. +7 −3 { → packages/pg}/test/unit/connection-parameters/creation-tests.js
  192. 0 { → packages/pg}/test/unit/connection-parameters/environment-variable-tests.js
  193. 0 { → packages/pg}/test/unit/connection/error-tests.js
  194. +27 −2 { → packages/pg}/test/unit/connection/inbound-parser-tests.js
  195. +10 −0 { → packages/pg}/test/unit/connection/outbound-sending-tests.js
  196. 0 { → packages/pg}/test/unit/connection/startup-tests.js
  197. 0 { → packages/pg}/test/unit/connection/test-helper.js
  198. 0 { → packages/pg}/test/unit/test-helper.js
  199. +39 −17 { → packages/pg}/test/unit/utils-tests.js
  200. +0 −20 test/integration/client/custom-types-tests.js
  201. +0 −50 test/integration/connection-pool/error-tests.js
  202. +5,933 −0 yarn.lock
73 changes: 73 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#-------------------------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
#-------------------------------------------------------------------------------------------------------------

FROM node:12

# Avoid warnings by switching to noninteractive
ENV DEBIAN_FRONTEND=noninteractive

# The node image includes a non-root user with sudo access. Use the
# "remoteUser" property in devcontainer.json to use it. On Linux, update
# these values to ensure the container user's UID/GID matches your local values.
# See https://aka.ms/vscode-remote/containers/non-root-user for details.
ARG USERNAME=node
ARG USER_UID=1000
ARG USER_GID=$USER_UID

# Configure apt and install packages
RUN apt-get update \
&& apt-get -y install --no-install-recommends apt-utils dialog 2>&1 \
#
# Verify git and needed tools are installed
&& apt-get -y install git iproute2 procps \
#
# Remove outdated yarn from /opt and install via package
# so it can be easily updated via apt-get upgrade yarn
&& rm -rf /opt/yarn-* \
&& rm -f /usr/local/bin/yarn \
&& rm -f /usr/local/bin/yarnpkg \
&& apt-get install -y curl apt-transport-https lsb-release \
&& curl -sS https://dl.yarnpkg.com/$(lsb_release -is | tr '[:upper:]' '[:lower:]')/pubkey.gpg | apt-key add - 2>/dev/null \
&& echo "deb https://dl.yarnpkg.com/$(lsb_release -is | tr '[:upper:]' '[:lower:]')/ stable main" | tee /etc/apt/sources.list.d/yarn.list \
&& apt-get update \
&& apt-get -y install --no-install-recommends yarn tmux locales postgresql \
#
# Install eslint globally
&& npm install -g eslint \
#
# [Optional] Update a non-root user to UID/GID if needed.
&& if [ "$USER_GID" != "1000" ] || [ "$USER_UID" != "1000" ]; then \
groupmod --gid $USER_GID $USERNAME \
&& usermod --uid $USER_UID --gid $USER_GID $USERNAME \
&& chown -R $USER_UID:$USER_GID /home/$USERNAME; \
fi \
# [Optional] Add add sudo support for non-root user
&& apt-get install -y sudo \
&& echo node ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME \
#
# Clean up
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*

RUN curl https://raw.githubusercontent.com/brianc/dotfiles/master/.tmux.conf > ~/.tmux.conf

# install nvm
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash

# set up a nicer prompt
RUN git clone https://github.com/magicmonty/bash-git-prompt.git ~/.bash-git-prompt --depth=1

RUN echo "source $HOME/.bash-git-prompt/gitprompt.sh" >> ~/.bashrc

# Set the locale
RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && locale-gen
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8

# Switch back to dialog for any ad-hoc use of apt-get
ENV DEBIAN_FRONTEND=dialog
31 changes: 31 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// If you want to run as a non-root user in the container, see .devcontainer/docker-compose.yml.
{
"name": "Node.js 12 & Postgres",
"dockerComposeFile": "docker-compose.yml",
"service": "web",
"workspaceFolder": "/workspace",

// Use 'settings' to set *default* container specific settings.json values on container create.
// You can edit these settings after create using File > Preferences > Settings > Remote.
"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
},

// Uncomment the next line if you want start specific services in your Docker Compose config.
// "runServices": [],

// Uncomment the line below if you want to keep your containers running after VS Code shuts down.
// "shutdownAction": "none",

// Uncomment the next line to run commands after the container is created.
// "postCreateCommand": "npm install",

// Uncomment the next line to have VS Code connect as an existing non-root user in the container. See
// https://aka.ms/vscode-remote/containers/non-root for details on adding a non-root user if none exist.
// "remoteUser": "node",

// Add the IDs of extensions you want installed when the container is created in the array below.
"extensions": [
"dbaeumer.vscode-eslint"
]
}
44 changes: 44 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#-------------------------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
#-------------------------------------------------------------------------------------------------------------

version: '3'
services:
web:
# Uncomment the next line to use a non-root user for all processes. You can also
# simply use the "remoteUser" property in devcontainer.json if you just want VS Code
# and its sub-processes (terminals, tasks, debugging) to execute as the user. On Linux,
# you may need to update USER_UID and USER_GID in .devcontainer/Dockerfile to match your
# user if not 1000. See https://aka.ms/vscode-remote/containers/non-root for details.
# user: node

build:
context: .
dockerfile: Dockerfile

volumes:
- ..:/workspace:cached

environment:
PGPASSWORD: pass
PGUSER: user
PGDATABASE: data
PGHOST: db

# Overrides default command so things don't shut down after the process ends.
command: sleep infinity

links:
- db

db:
image: postgres
restart: unless-stopped
ports:
- 5432:5432
environment:
POSTGRES_PASSWORD: pass
POSTGRES_USER: user
POSTGRES_DB: data

32 changes: 30 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,34 @@
{
"extends": "standard",
"plugins": [
"node"
],
"extends": [
"standard",
"eslint:recommended",
"plugin:node/recommended"
],
"ignorePatterns": [
"**/*.ts"
],
"parserOptions": {
"ecmaVersion": 2017,
"sourceType": "module"
},
"env": {
"node": true,
"es6": true,
"mocha": true
},
"rules": {
"no-new-func": "off"
"space-before-function-paren": "off",
"node/no-unsupported-features/es-syntax": "off",
"node/no-unpublished-require": [
"error",
{
"allowModules": [
"pg"
]
}
]
}
}
3 changes: 3 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# These are supported funding model platforms

github: [brianc]
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -5,3 +5,7 @@ build/
node_modules/
package-lock.json
*.swp
dist
.DS_Store
.vscode/
manually-test-on-heroku.js
8 changes: 0 additions & 8 deletions .npmignore

This file was deleted.

67 changes: 42 additions & 25 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,58 @@
language: node_js
sudo: false
dist: trusty
before_script:
- node script/create-test-tables.js pg://postgres@127.0.0.1:5432/postgres
dist: bionic

before_script: |
node packages/pg/script/create-test-tables.js postgresql:///
env:
- CC=clang CXX=clang++ npm_config_clang=1 PGUSER=postgres PGDATABASE=postgres

node_js:
- lts/dubnium
- lts/erbium
# node 13.7 seems to have changed behavior of async iterators exiting early on streams
# if 13.8 still has this problem when it comes down I'll talk to the node team about the change
# in the mean time...peg to 13.6
- 13.6

addons:
postgresql: "10"

matrix:
include:
- node_js: "lts/boron"
addons:
postgresql: "9.6"
- node_js: "lts/argon"
addons:
postgresql: "9.6"
- node_js: "9"
addons:
postgresql: "9.6"
- node_js: "10"
addons:
postgresql: "9.6"
- node_js: "lts/carbon"
# Run tests/paths that require password authentication
- node_js: lts/erbium
env:
- CC=clang CXX=clang++ npm_config_clang=1 PGUSER=postgres PGDATABASE=postgres PGPASSWORD=test-password
before_script: |
sudo -u postgres sed -i \
-e '/^local/ s/trust$/peer/' \
-e '/^host/ s/trust$/md5/' \
/etc/postgresql/10/main/pg_hba.conf
sudo -u postgres psql -c "ALTER ROLE postgres PASSWORD 'test-password'; SELECT pg_reload_conf()"
node packages/pg/script/create-test-tables.js postgresql:///
- node_js: lts/carbon
addons:
postgresql: "9.1"
postgresql: "9.5"
dist: precise
- node_js: "lts/carbon"
addons:
postgresql: "9.2"
- node_js: "lts/carbon"

# different PostgreSQL versions on Node LTS
- node_js: lts/erbium
addons:
postgresql: "9.3"
- node_js: "lts/carbon"
- node_js: lts/erbium
addons:
postgresql: "9.4"
- node_js: "lts/carbon"
- node_js: lts/erbium
addons:
postgresql: "9.5"
- node_js: "lts/carbon"
- node_js: lts/erbium
addons:
postgresql: "9.6"

# PostgreSQL 9.2 only works on precise
- node_js: lts/carbon
addons:
postgresql: "9.2"
dist: precise
Loading