summaryrefslogtreecommitdiff
path: root/contrib/dblink/sql
AgeCommit message (Collapse)Author
2025-04-29oauth: Disallow OAuth connections via postgres_fdw/dblinkJacob Champion
A subsequent commit will reclassify oauth_client_secret from dispchar="" to dispchar="*", so that UIs will treat it like a secret. For our FDWs, this change will move that option from SERVER to USER MAPPING, which we need to avoid. But upon further discussion, we don't really want our FDWs to use our builtin Device Authorization flow at all, for several reasons: - the URL and code would be printed to the server logs, not sent over the client connection - tokens are not cached/refreshed, so every single connection has to be manually authorized by a user with a browser - oauth_client_secret needs to belong to the foreign server, but options on SERVER are publicly accessible - all non-superusers would need password_required=false, which is dangerous Future OAuth work can use FDWs as a motivating use case. But for now, disallow all oauth_* connection options for these two extensions. Reviewed-by: Noah Misch <noah@leadboat.com> Discussion: https://postgr.es/m/20250415191435.55.nmisch%40google.com
2023-02-01dblink: Fix variable confusion introduced in e4602483e95Andres Freund
Thanks to Robins to find the issue and Nathan for promptly writing a test case to prevent future problems like this. Reported-by: Nathan Bossart <nathandbossart@gmail.com> Reported-by: Robins Tharakan <tharakan@gmail.com> Author: Nathan Bossart <nathandbossart@gmail.com> Discussion: https://postgr.es/m/20230130193008.GA2740781@nathanxps13
2021-12-20Merge dblink's paths test script into its main test.Tom Lane
There's no longer any reason to fire up a separate psql run to create these functions. (Some refactoring in the main regression tests is also called for, but that will take more thought.) Discussion: https://postgr.es/m/1655733.1639871614@sss.pgh.pa.us
2021-12-20Remove dynamic translation of regression test scripts, step 2.Tom Lane
"git mv" all the input/*.source and output/*.source files into the corresponding sql/ and expected/ directories. Then remove the pg_regress and Makefile infrastructure associated with dynamic translation. Discussion: https://postgr.es/m/1655733.1639871614@sss.pgh.pa.us
2021-10-26Improve HINT message that FDW reports when there are no valid options.Fujii Masao
The foreign data wrapper's validator function provides a HINT message with list of valid options for the object specified in CREATE or ALTER command, when the option given in the command is invalid. Previously postgresql_fdw_validator() and the validator functions for postgres_fdw and dblink_fdw worked in that way even there were no valid options in the object, which could lead to the HINT message with empty list (because there were no valid options). For example, ALTER FOREIGN DATA WRAPPER postgres_fdw OPTIONS (format 'csv') reported the following ERROR and HINT messages. This behavior was confusing. ERROR: invalid option "format" HINT: Valid options in this context are: There is no such issue in file_fdw. The validator function for file_fdw reports the HINT message "There are no valid options in this context." instead in that case. This commit improves postgresql_fdw_validator() and the validator functions for postgres_fdw and dblink_fdw so that they do likewise. For example, this change causes the above ALTER FOREIGN DATA WRAPPER command to report the following messages. ERROR: invalid option "nonexistent" HINT: There are no valid options in this context. Author: Kosei Masumura Reviewed-by: Bharath Rupireddy, Fujii Masao Discussion: https://postgr.es/m/557d06cebe19081bfcc83ee2affc98d3@oss.nttdata.com
2018-04-07Indexes with INCLUDE columns and their support in B-treeTeodor Sigaev
This patch introduces INCLUDE clause to index definition. This clause specifies a list of columns which will be included as a non-key part in the index. The INCLUDE columns exist solely to allow more queries to benefit from index-only scans. Also, such columns don't need to have appropriate operator classes. Expressions are not supported as INCLUDE columns since they cannot be used in index-only scans. Index access methods supporting INCLUDE are indicated by amcaninclude flag in IndexAmRoutine. For now, only B-tree indexes support INCLUDE clause. In B-tree indexes INCLUDE columns are truncated from pivot index tuples (tuples located in non-leaf pages and high keys). Therefore, B-tree indexes now might have variable number of attributes. This patch also provides generic facility to support that: pivot tuples contain number of their attributes in t_tid.ip_posid. Free 13th bit of t_info is used for indicating that. This facility will simplify further support of index suffix truncation. The changes of above are backward-compatible, pg_upgrade doesn't need special handling of B-tree indexes for that. Bump catalog version Author: Anastasia Lubennikova with contribition by Alexander Korotkov and me Reviewed by: Peter Geoghegan, Tomas Vondra, Antonin Houska, Jeff Janes, David Rowley, Alexander Korotkov Discussion: https://www.postgresql.org/message-id/flat/56168952.4010101@postgrespro.ru
2017-08-11Remove uses of "slave" in replication contextsPeter Eisentraut
This affects mostly code comments, some documentation, and tests. Official APIs already used "standby".
2016-07-17Establish conventions about global object names used in regression tests.Tom Lane
To ensure that "make installcheck" can be used safely against an existing installation, we need to be careful about what global object names (database, role, and tablespace names) we use; otherwise we might accidentally clobber important objects. There's been a weak consensus that test databases should have names including "regression", and that test role names should start with "regress_", but we didn't have any particular rule about tablespace names; and neither of the other rules was followed with any consistency either. This commit moves us a long way towards having a hard-and-fast rule that regression test databases must have names including "regression", and that test role and tablespace names must start with "regress_". It's not completely there because I did not touch some test cases in rolenames.sql that test creation of special role names like "session_user". That will require some rethinking of exactly what we want to test, whereas the intent of this patch is just to hit all the cases in which the needed renamings are cosmetic. There is no enforcement mechanism in this patch either, but if we don't add one we can expect that the tests will soon be violating the convention again. Again, that's not such a cosmetic change and it will require discussion. (But I did use a quick-hack enforcement patch to find these cases.) Discussion: <16638.1468620817@sss.pgh.pa.us>
2015-09-05Rearrange the handling of error context reports.Tom Lane
Remove the code in plpgsql that suppressed the innermost line of CONTEXT for messages emitted by RAISE commands. That was never more than a quick backwards-compatibility hack, and it's pretty silly in cases where the RAISE is nested in several levels of function. What's more, it violated our design theory that verbosity of error reports should be controlled on the client side not the server side. To alleviate the resulting noise increase, introduce a feature in libpq and psql whereby the CONTEXT field of messages can be suppressed, either always or only for non-error messages. Printing CONTEXT for errors only is now their default behavior. The actual code changes here are pretty small, but the effects on the regression test outputs are widespread. I had to edit some of the alternative expected outputs by hand; hopefully the buildfarm will soon find anything I fat-fingered. In passing, fix up (again) the output line counts in psql's various help displays. Add some commentary about how to verify them. Pavel Stehule, reviewed by Petr JelĂ­nek, Jeevan Chalke, and others
2014-08-26Specify the port in dblink and postgres_fdw tests.Andres Freund
That allows to run those tests against a postmaster listening on a nonstandard port without requiring to export PGPORT in postmaster's environment. This still doesn't support connecting to a nondefault host without configuring it in postmaster's environment. That's harder and less frequently used though. So this is a useful step.
2014-08-26Don't hardcode contrib_regression dbname in postgres_fdw and dblink tests.Andres Freund
That allows parallel installcheck to succeed inside contrib/. The output is not particularly pretty unless make's -O option to synchronize the output is used. There's other tests, outside contrib, that use a hardcoded, non-unique, database name. Those prohibit paralell installcheck to be used across more directories; but that's something for a separate patch.
2014-07-22Diagnose incompatible OpenLDAP versions during build and test.Noah Misch
With OpenLDAP versions 2.4.24 through 2.4.31, inclusive, PostgreSQL backends can crash at exit. Raise a warning during "configure" based on the compile-time OpenLDAP version number, and test the crash scenario in the dblink test suite. Back-patch to 9.0 (all supported versions).
2014-06-20Let installcheck-world pass against a server requiring a password.Noah Misch
Give passwords to each user created in support of an ECPG connection test case. Use SET SESSION AUTHORIZATION, not a fresh connection, to reduce privileges during a dblink test case. To test against such a server, both the "make installcheck-world" environment and the postmaster environment must provide the default user's password; $PGPASSFILE is the principal way to do so. (The postmaster environment needs it for dblink and postgres_fdw tests.)
2013-03-22Fix contrib/dblink to handle inconsistent DateStyle/IntervalStyle safely.Tom Lane
If the remote database's settings of these GUCs are different from ours, ambiguous datetime values may be read incorrectly. To fix, temporarily adopt the remote server's settings while we ingest a query result. This is not a complete fix, since it doesn't do anything about ambiguous values in commands sent to the remote server; but there seems little we can do about that end of it given dblink's entirely textual API for transmitted commands. Back-patch to 9.2. The hazard exists in all versions, but this patch would need more work to apply before 9.2. Given the lack of field complaints about this issue, it doesn't seem worth the effort at present. Daniel Farina and Tom Lane
2012-10-11Remove configure-option-dependent test cases from dblink tests.Tom Lane
The HINTs generated for these error cases vary across builds. We could try to work around that, but the test cases aren't really useful enough to justify taking any trouble. Per buildfarm.
2012-10-10Create an improved FDW option validator function for contrib/dblink.Tom Lane
dblink now has its own validator function dblink_fdw_validator(), which is better than the core function postgresql_fdw_validator() because it gets the list of legal options from libpq instead of having a hard-wired list. Make the dblink extension module provide a standard foreign data wrapper dblink_fdw that encapsulates use of this validator, and recommend use of that wrapper instead of making up wrappers on the fly. Unfortunately, because ad-hoc wrappers *were* recommended practice previously, it's not clear when we can get rid of postgresql_fdw_validator without causing upgrade problems. But this is a step in the right direction. Shigeru Hanada, reviewed by KaiGai Kohei
2011-02-14Convert contrib modules to use the extension facility.Tom Lane
This isn't fully tested as yet, in particular I'm not sure that the "foo--unpackaged--1.0.sql" scripts are OK. But it's time to get some buildfarm cycles on it. sepgsql is not converted to an extension, mainly because it seems to require a very nonstandard installation process. Dimitri Fontaine and Tom Lane
2010-11-23Remove useless whitespace at end of linesPeter Eisentraut
2010-06-15Change the interpretation of the primary_key_attnums parameter ofTom Lane
dblink_build_sql_insert() and related functions. Now the column numbers are treated as logical not physical column numbers. This will provide saner behavior in the presence of dropped columns; furthermore, if we ever get around to allowing rearrangement of logical column ordering, the original definition would become nearly untenable from a usability standpoint. Per recent discussion of dblink's handling of dropped columns. Not back-patched for fear of breaking existing applications.
2010-06-15Fix dblink_build_sql_insert() and related functions to handle droppedTom Lane
columns correctly. In passing, get rid of some dead logic in the underlying get_sql_insert() etc functions --- there is no caller that will pass null value-arrays to them. Per bug report from Robert Voinea.
2010-02-03Check to ensure the number of primary key fields supplied does notJoe Conway
exceed the total number of non-dropped source table fields for dblink_build_sql_*(). Addresses bug report from Rushabh Lathia. Backpatch all the way to the 7.3 branch.
2009-08-05Implement dblink_get_notify().Joe Conway
Adds the ability to retrieve async notifications using dblink, via the addition of the function dblink_get_notify(). Original patch by Marcus Kempe, suggestions by Tom Lane and Alvaro Herrera, patch review and adjustments by Joe Conway.
2009-06-06Add support for using SQL/MED compliant FOREIGN DATA WRAPPER, SERVER,Joe Conway
and USER MAPPING as method to supply dblink connect parameters. Per mailing list and PGCon discussions.
2008-04-06Improve hash_any() to use word-wide fetches when hashing suitably alignedTom Lane
data. This makes for a significant speedup at the cost that the results now vary between little-endian and big-endian machines; which forces us to add explicit ORDER BYs in a couple of regression tests to preserve machine-independent comparison results. Also, force initdb by bumping catversion, since the contents of hash indexes will change (at least on big-endian machines). Kenneth Marshall and Tom Lane, based on work from Bob Jenkins. This commit does not adopt Bob's new faster mix() algorithm, however, since we still need to convince ourselves that that doesn't degrade the quality of the hashing.
2008-04-04Implement current_query(), that shows the currently executing query.Bruce Momjian
At the same time remove dblink/dblink_current_query() as it is no longer necessary *BACKWARD COMPATIBILITY ISSUE* for dblink Tomas Doran
2008-01-03The original patch to disallow non-passworded connections to non-superusersTom Lane
failed to cover all the ways in which a connection can be initiated in dblink. Plug the remaining holes. Also, disallow transient connections in functions for which that feature makes no sense (because they are only sensible as part of a sequence of operations on the same connection). Joe Conway Security: CVE-2007-6601
2007-11-13Fix a few contrib regression test scripts that hadn't gotten the wordTom Lane
about best practice for including the module creation scripts: to wit that you should suppress NOTICE messages. This avoids creating regression failures by adding or removing comment lines in the module scripts.
2006-09-02Added async query capability. Original patch byJoe Conway
Kai Londenberg, modified by Joe Conway
2005-10-18When a cursor is opened using dblink_open, only start a transactionJoe Conway
if there isn't one already open. Upon dblink_close, only commit the open transaction if it was started by dblink_open, and only then when all cursors opened by dblink_open are closed. The transaction accounting is done individually for all named connections, plus the persistent unnamed connection.
2005-10-08Remove unnecessary ABORT commands in dblink regression tests.Bruce Momjian
2005-05-17Add a --dbname option to the pg_regress script, and use pl_regressionTom Lane
for testing PLs and contrib_regression for testing contrib, instead of overwriting the core system's regression database as formerly done. Andrew Dunstan
2004-03-07Added new versions of dblink, dblink_exec, dblink_open, dblink_close,Joe Conway
and, dblink_fetch -- allows ERROR on remote side of connection to throw NOTICE locally instead of ERROR. Also removed documentation for previously deprecated, now removed, functions.
2003-11-28Fix regression in dblink_disconnect() reported by Eduardo Stern:Joe Conway
persistent_conn was left dangling after a disconnect in the unnamed connection case, causing a subsequent disconnect to crash the backend.
2003-07-24Error message editing in contrib (mostly by Joe Conway --- thanks Joe!)Tom Lane
2003-06-25Please apply attached patch to contrib/dblink. It adds named persistentBruce Momjian
connections to dblink. Shridhar Daithanka
2003-05-14Backend support for autocommit removed, per recent discussions. TheTom Lane
only remnant of this failed experiment is that the server will take SET AUTOCOMMIT TO ON. Still TODO: provide some client-side autocommit logic in libpq.
2002-11-23Fix inappropriate quoting in dblink. From Joe Conway.Tom Lane
2002-11-03Fix dblink regression test so that it works when repeated: don'tTom Lane
create a second database, just loop back to 'regression'. Patch from Joe Conway 10/22/02.
2002-10-21SET autocommit no longer needed in /contrib because pg_regress.sh doesBruce Momjian
it automatically now on regression session startup.
2002-10-18Clean up for dblink autocommit OFF handling.Bruce Momjian
2002-10-18Update /contrib for "autocommit TO 'on'".Bruce Momjian
Create objects in public schema. Make spacing/capitalization consistent. Remove transaction block use for object creation. Remove unneeded function GRANTs.
2002-09-14Simplify handling of second database for dblink tests.Tom Lane
2002-09-14The attached adds GRANTs to PUBLIC for dblink functions, removes theTom Lane
non-standard regression test, and adds standard installcheck regression test support. The test creates a second database (regression_slave) and drops it again, in order to avoid the cheesy-ness of connecting back to the same database ;-) Joe Conway