You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<
10000
script type="application/json" data-target="react-app.embeddedData">{"payload":{"commit":{"oid":"57d11ef028d126f95595c08c62ffb4c5147d0f86","url":"/postgres/postgres/commit/57d11ef028d126f95595c08c62ffb4c5147d0f86","authoredDate":"2023-01-07T14:22:09.000+01:00","committedDate":"2023-01-07T14:39:33.000+01:00","shortMessage":null,"shortMessageMarkdown":"\u003cdiv\u003eCheck relkind before using TABLESAMPLE in postgres_fdw\u003c/div\u003e","shortMessageMarkdownLink":null,"bodyMessageHtml":"Check the remote relkind before trying to use TABLESAMPLE to acquire\nsample from the remote relation. Even if the remote server version has\nTABLESAMPLE support, the foreign table may point to incompatible relkind\n(e.g. a view or a sequence).\n\nIf the relkind does not support TABLESAMPLE, error out if TABLESAMPLE\nwas requested specifically (as system/bernoulli), or fallback to random\njust like we do for old server versions.\n\nWe currently end up disabling sampling for such relkind values anyway,\ndue to reltuples being -1 or 1, but that seems rather accidental, and\nmight get broken by improving reltuples estimates, etc. So better to\nmake the check explicit.\n\nReported-by: Tom Lane\nDiscussion: \u003ca href=\"https://postgr.es/m/951485.1672461744%40sss.pgh.pa.us\" rel=\"nofollow\"\u003ehttps://postgr.es/m/951485.1672461744%40sss.pgh.pa.us\u003c/a\u003e","authors":[{"login":"tvondra","displayName":"Tomas Vondra","avatarUrl":"https://avatars.githubusercontent.com/u/539575?v=4","path":"/tvondra","isGitHub":false}],"committerAttribution":false,"committer":{"login":"tvondra","displayName":"Tomas Vondra","avatarUrl":"https://avatars.githubusercontent.com/u/539575?v=4","path":"/tvondra","isGitHub":false},"parents":["d913928c9c5e905d0062d1e7237b7fb5fbde61ed"],"globalRelayId":"C_kwDOAA4m0toAKDU3ZDExZWYwMjhkMTI2Zjk1NTk1YzA4YzYyZmZiNGM1MTQ3ZDBmODY","sha1":"d913928c9c5e905d0062d1e7237b7fb5fbde61ed","sha2":"57d11ef028d126f95595c08c62ffb4c5147d0f86"},"currentUser":null,"repo":{"id":927442,"defaultBranch":"master","name":"postgres","ownerLogin":"postgres","currentUserCanPush":false,"isFork":false,"isEmpty":false,"createdAt":"2010-09-21T11:35:45.000Z","ownerAvatar":"https://avatars.githubusercontent.com/u/177543?v=4","public":true,"private":false,"isOrgOwned":true},"diffEntryData":[{"diffLines":[{"stylingDirective":null,"type":"HUNK","blobLineNumber":2367,"text":"@@ -2368,22 +2368,23 @@ deparseAnalyzeSizeSql(StringInfo buf, Relation rel)","html":"@@ -2368,22 +2368,23 @@ deparseAnalyzeSizeSql(StringInfo buf, Relation rel)","displayNoNewLineWarning":false,"position":0,"left":2367,"right":2367},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":2368,"text":" }","html":" }","displayNoNewLineWarning":false,"position":1,"left":2368,"right":2368},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":2369,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":2,"left":2369,"right":2369},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":2370,"text":" /*","html":" \u003cspan class=pl-c\u003e/*\u003c/span\u003e","displayNoNewLineWarning":false,"position":3,"left":2370,"right":2370},{"stylingDirective":null,"type":"DELETION","blobLineNumber":2371,"text":"- * Construct SELECT statement to acquire the number of rows of a relation.","html":"-\u003cspan class=pl-c\u003e * Construct SELECT statement to acquire the number of rows of a relation.\u003c/span\u003e","displayNoNewLineWarning":false,"position":4,"left":2371,"right":2370},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":2371,"text":"+ * Construct SELECT statement to acquire the number of rows and the relkind of","html":"+\u003cspan class=pl-c\u003e * Construct SELECT statement to acquire the number of rows and the relkind of\u003c/span\u003e","displayNoNewLineWarning":false,"position":5,"left":2371,"right":2371},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":2372,"text":"+ * a relation.","html":"+\u003cspan class=pl-c\u003e * a relation.\u003c/span\u003e","displayNoNewLineWarning":false,"position":6,"left":2371,"right":2372},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":2373,"text":" *","html":" \u003cspan class=pl-c\u003e *\u003c/span\u003e","displayNoNewLineWarning":false,"position":7,"left":2372,"right":2373},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":2374,"text":" * Note: we just return the remote server's reltuples value, which might","html":" \u003cspan class=pl-c\u003e * Note: we just return the remote server\u0026#39;s reltuples value, which might\u003c/span\u003e","displayNoNewLineWarning":false,"position":8,"left":2373,"right":2374},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":2375,"text":" * be off a good deal, but it doesn't seem worth working harder. See","html":" \u003cspan class=pl-c\u003e * be off a good deal, but it doesn\u0026#39;t seem worth working harder. See\u003c/span\u003e","displayNoNewLineWarning":false,"position":9,"left":2374,"right":2375},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":2376,"text":" * comments in postgresAcquireSampleRowsFunc.","html":" \u003cspan class=pl-c\u003e * comments in postgresAcquireSampleRowsFunc.\u003c/span\u003e","displayNoNewLineWarning":false,"position":10,"left":2375,"right":2376},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":2377,"text":" */","html":" \u003cspan class=pl-c\u003e */\u003c/span\u003e","displayNoNewLineWarning":false,"position":11,"left":2376,"right":2377},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":2378,"text":" void","html":" \u003cspan class=pl-smi\u003evoid\u003c/span\u003e","displayNoNewLineWarning":false,"position":12,"left":2377,"right":2378},{"stylingDirective":null,"type":"DELETION","blobLineNumber":2378,"text":"-deparseAnalyzeTuplesSql(StringInfo buf, Relation rel)","html":"-\u003cspan class=\"pl-en x x-first x-last\"\u003edeparseAnalyzeTuplesSql\u003c/span\u003e(\u003cspan class=\"pl-smi\"\u003eStringInfo\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003ebuf\u003c/span\u003e, \u003cspan class=\"pl-smi\"\u003eRelation\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003erel\u003c/span\u003e)","displayNoNewLineWarning":false,"position":13,"left":2378,"right":2378},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":2379,"text":"+deparseAnalyzeInfoSql(StringInfo buf, Relation rel)","html":"+\u003cspan class=\"pl-en x x-first x-last\"\u003edeparseAnalyzeInfoSql\u003c/span\u003e(\u003cspan class=\"pl-smi\"\u003eStringInfo\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003ebuf\u003c/span\u003e, \u003cspan class=\"pl-smi\"\u003eRelation\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003erel\u003c/span\u003e)","displayNoNewLineWarning":false,"position":14,"left":2378,"right":2379},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":2380,"text":" {","html":" {","displayNoNewLineWarning":false,"position":15,"left":2379,"right":2380},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":2381,"text":" \tStringInfoData relname;","html":" \t\u003cspan class=pl-smi\u003eStringInfoData\u003c/span\u003e \u003cspan class=pl-s1\u003erelname\u003c/span\u003e;","displayNoNewLineWarning":false,"position":16,"left":2380,"right":2381},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":2382,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":17,"left":2381,"right":2382},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":2383,"text":" \t/* We'll need the remote relation name as a literal. */","html":" \t\u003cspan class=pl-c\u003e/* We\u0026#39;ll need the remote relation name as a literal. */\u003c/span\u003e","displayNoNewLineWarning":false,"position":18,"left":2382,"right":2383},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":2384,"text":" \tinitStringInfo(\u0026relname);","html":" \t\u003cspan class=pl-en\u003einitStringInfo\u003c/span\u003e(\u003cspan class=pl-c1\u003e\u0026amp;\u003c/span\u003e\u003cspan class=pl-s1\u003erelname\u003c/span\u003e);","displayNoNewLineWarning":false,"position":19,"left":2383,"right":2384},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":2385,"text":" \tdeparseRelation(\u0026relname, rel);","html":" \t\u003cspan class=pl-en\u003edeparseRelation\u003c/span\u003e(\u003cspan class=pl-c1\u003e\u0026amp;\u003c/span\u003e\u003cspan class=pl-s1\u003erelname\u003c/span\u003e, \u003cspan class=pl-s1\u003erel\u003c/span\u003e);","displayNoNewLineWarning":false,"position":20,"left":2384,"right":2385},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":2386,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":21,"left":2385,"right":2386},{"stylingDirective":null,"type":"DELETION","blobLineNumber":2386,"text":"-\tappendStringInfoString(buf, \"SELECT reltuples FROM pg_catalog.pg_class WHERE oid = \");","html":"-\t\u003cspan class=\"pl-en\"\u003eappendStringInfoString\u003c/span\u003e(\u003cspan class=\"pl-s1\"\u003ebuf\u003c/span\u003e, \u003cspan class=\"pl-s\"\u003e\"SELECT reltuples FROM pg_catalog.pg_class WHERE oid = \"\u003c/span\u003e);","displayNoNewLineWarning":false,"position":22,"left":2386,"right":2386},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":2387,"text":"+\tappendStringInfoString(buf, \"SELECT reltuples, relkind FROM pg_catalog.pg_class WHERE oid = \");","html":"+\t\u003cspan class=\"pl-en\"\u003eappendStringInfoString\u003c/span\u003e(\u003cspan class=\"pl-s1\"\u003ebuf\u003c/span\u003e, \u003cspan class=\"pl-s\"\u003e\"SELECT reltuples\u003cspan class=\"x x-first x-last\"\u003e, relkind\u003c/span\u003e FROM pg_catalog.pg_class WHERE oid = \"\u003c/span\u003e);","displayNoNewLineWarning":false,"position":23,"left":2386,"right":2387},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":2388,"text":" \tdeparseStringLiteral(buf, relname.data);","html":" \t\u003cspan class=pl-en\u003edeparseStringLiteral\u003c/span\u003e(\u003cspan class=pl-s1\u003ebuf\u003c/span\u003e, \u003cspan class=pl-s1\u003erelname\u003c/span\u003e.\u003cspan class=pl-c1\u003edata\u003c/span\u003e);","displayNoNewLineWarning":false,"position":24,"left":2387,"right":2388},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":2389,"text":" \tappendStringInfoString(buf, \"::pg_catalog.regclass\");","html":" \t\u003cspan class=pl-en\u003eappendStringInfoString\u003c/span\u003e(\u003cspan class=pl-s1\u003ebuf\u003c/span\u003e, \u003cspan class=pl-s\u003e\u0026quot;::pg_catalog.regclass\u0026quot;\u003c/span\u003e);","displayNoNewLineWarning":false,"position":25,"left":2388,"right":2389},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":2390,"text":" }","html":" }","displayNoNewLineWarning":false,"position":26,"left":2389,"right":2390}],"diffNumber":0,"diffSize":"0 Bytes","isBinary":false,"isTooBig":false,"collapsed":false,"isSubmodule":false,"lineCount":4032,"linesChanged":7,"newTreeEntry":{"lineCount":4032,"path":"contrib/postgres_fdw/deparse.c","mode":100644,"isGenerated":false},"oldTreeEntry":{"lineCount":0,"path":"contrib/postgres_fdw/deparse.c","mode":100644},"linesAdded":4,"linesDeleted":3,"path":"contrib/postgres_fdw/deparse.c","pathDigest":"9ed7bda5944d72f1491da1c7311ee42afabee85028b71a3cfd978039877a2c2d","status":"MODIFIED","truncatedReason":null,"oldOid":"d913928c9c5e905d0062d1e7237b7fb5fbde61ed","newOid":"57d11ef028d126f95595c08c62ffb4c5147d0f86","copilotChatReference":null,"deletedSha":"d913928c9c5e905d0062d1e7237b7fb5fbde61ed","canToggleRichDiff":false,"defaultToRichDiff":false,"proseDifffHtml":null,"renderInfo":null,"dependencyDiffPath":null,"submodule":null},{"diffLines":[{"stylingDirective":null,"type":"HUNK","blobLineNumber":4973,"text":"@@ -4974,18 +4974,25 @@ postgresAnalyzeForeignTable(Relation relation,","html":"@@ -4974,18 +4974,25 @@ postgresAnalyzeForeignTable(Relation relation,","displayNoNewLineWarning":false,"position":0,"left":4973,"right":4973},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":4974,"text":" }","html":" }","displayNoNewLineWarning":false,"position":1,"left":4974,"right":4974},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":4975,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":2,"left":4975,"right":4975},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":4976,"text":" /*","html":" \u003cspan class=pl-c\u003e/*\u003c/span\u003e","displayNoNewLineWarning":false,"position":3,"left":4976,"right":4976},{"stylingDirective":null,"type":"DELETION","blobLineNumber":4977,"text":"- * postgresCountTuplesForForeignTable","html":"-\u003cspan class=\"pl-c\"\u003e * \u003cspan class=\"x x-first x-last\"\u003epostgresCountTuplesForForeignTable\u003c/span\u003e\u003c/span\u003e","displayNoNewLineWarning":false,"position":4,"left":4977,"right":4976},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":4977,"text":"+ * postgresGetAnalyzeInfoForForeignTable","html":"+\u003cspan class=\"pl-c\"\u003e * \u003cspan class=\"x x-first x-last\"\u003epostgresGetAnalyzeInfoForForeignTable\u003c/span\u003e\u003c/span\u003e","displayNoNewLineWarning":false,"position":5,"left":4977,"right":4977},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":4978,"text":" *\t\tCount tuples in foreign table (just get pg_class.reltuples).","html":" \u003cspan class=pl-c\u003e *\t\tCount tuples in foreign table (just get pg_class.reltuples).\u003c/span\u003e","displayNoNewLineWarning":false,"position":6,"left":4978,"right":4978},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":4979,"text":"+ *","html":"+\u003cspan class=pl-c\u003e *\u003c/span\u003e","displayNoNewLineWarning":false,"position":7,"left":4978,"right":4979},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":4980,"text":"+ * can_tablesample determines if the remote relation supports acquiring the","html":"+\u003cspan class=pl-c\u003e * can_tablesample determines if the remote relation supports acquiring the\u003c/span\u003e","displayNoNewLineWarning":false,"position":8,"left":4978,"right":4980},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":4981,"text":"+ * sample using TABLESAMPLE.","html":"+\u003cspan class=pl-c\u003e * sample using TABLESAMPLE.\u003c/span\u003e","displayNoNewLineWarning":false,"position":9,"left":4978,"right":4981},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":4982,"text":" */","html":" \u003cspan class=pl-c\u003e */\u003c/span\u003e","displayNoNewLineWarning":false,"position":10,"left":4979,"right":4982},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":4983,"text":" static double","html":" \u003cspan class=pl-k\u003estatic\u003c/span\u003e \u003cspan class=pl-smi\u003edouble\u003c/span\u003e","displayNoNewLineWarning":false,"position":11,"left":4980,"right":4983},{"stylingDirective":null,"type":"DELETION","blobLineNumber":4981,"text":"-postgresCountTuplesForForeignTable(Relation relation)","html":"-\u003cspan class=\"pl-en x x-first x-last\"\u003epostgresCountTuplesForForeignTable\u003c/span\u003e(\u003cspan class=\"pl-smi\"\u003eRelation\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003erelation\u003c/span\u003e)","displayNoNewLineWarning":false,"position":12,"left":4981,"right":4983},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":4984,"text":"+postgresGetAnalyzeInfoForForeignTable(Relation relation, bool *can_tablesample)","html":"+\u003cspan class=\"pl-en x x-first x-last\"\u003epostgresGetAnalyzeInfoForForeignTable\u003c/span\u003e(\u003cspan class=\"pl-smi\"\u003eRelation\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003erelation\u003c/span\u003e\u003cspan class=\"x x-first\"\u003e, \u003c/span\u003e\u003cspan class=\"pl-smi x\"\u003ebool\u003c/span\u003e\u003cspan class=\"x\"\u003e \u003c/span\u003e\u003cspan class=\"pl-c1 x\"\u003e*\u003c/span\u003e\u003cspan class=\"pl-s1 x x-last\"\u003ecan_tablesample\u003c/span\u003e)","displayNoNewLineWarning":false,"position":13,"left":4981,"right":4984},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":4985,"text":" {","html":" {","displayNoNewLineWarning":false,"position":14,"left":4982,"right":4985},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":4986,"text":" \tForeignTable *table;","html":" \t\u003cspan class=pl-smi\u003eForeignTable\u003c/span\u003e \u003cspan class=pl-c1\u003e*\u003c/span\u003e\u003cspan class=pl-s1\u003etable\u003c/span\u003e;","displayNoNewLineWarning":false,"position":15,"left":4983,"right":4986},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":4987,"text":" \tUserMapping *user;","html":" \t\u003cspan class=pl-smi\u003eUserMapping\u003c/span\u003e \u003cspan class=pl-c1\u003e*\u003c/span\u003e\u003cspan class=pl-s1\u003euser\u003c/span\u003e;","displayNoNewLineWarning":false,"position":16,"left":4984,"right":4987},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":4988,"text":" \tPGconn\t *conn;","html":" \t\u003cspan class=pl-smi\u003ePGconn\u003c/span\u003e\t \u003cspan class=pl-c1\u003e*\u003c/span\u003e\u003cspan class=pl-s1\u003econn\u003c/span\u003e;","displayNoNewLineWarning":false,"position":17,"left":4985,"right":4988},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":4989,"text":" \tStringInfoData sql;","html":" \t\u003cspan class=pl-smi\u003eStringInfoData\u003c/span\u003e \u003cspan class=pl-s1\u003esql\u003c/span\u003e;","displayNoNewLineWarning":false,"position":18,"left":4986,"right":4989},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":4990,"text":" \tPGresult *volatile res = NULL;","html":" \t\u003cspan class=pl-smi\u003ePGresult\u003c/span\u003e \u003cspan class=pl-c1\u003e*\u003c/span\u003e\u003cspan class=pl-k\u003evolatile\u003c/span\u003e \u003cspan class=pl-s1\u003eres\u003c/span\u003e \u003cspan class=pl-c1\u003e=\u003c/span\u003e \u003cspan class=pl-c1\u003eNULL\u003c/span\u003e;","displayNoNewLineWarning":false,"position":19,"left":4987,"right":4990},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":4991,"text":" \tvolatile double reltuples = -1;","html":" \t\u003cspan class=pl-k\u003evolatile\u003c/span\u003e \u003cspan class=pl-smi\u003edouble\u003c/span\u003e \u003cspan class=pl-s1\u003ereltuples\u003c/span\u003e \u003cspan class=pl-c1\u003e=\u003c/span\u003e \u003cspan class=pl-c1\u003e-1\u003c/span\u003e;","displayNoNewLineWarning":false,"position":20,"left":4988,"right":4991},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":4992,"text":"+\tvolatile char relkind = 0;","html":"+\t\u003cspan class=pl-k\u003evolatile\u003c/span\u003e \u003cspan class=pl-smi\u003echar\u003c/span\u003e \u003cspan class=pl-s1\u003erelkind\u003c/span\u003e \u003cspan class=pl-c1\u003e=\u003c/span\u003e \u003cspan class=pl-c1\u003e0\u003c/span\u003e;","displayNoNewLineWarning":false,"position":21,"left":4988,"right":4992},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":4993,"text":"+","html":"+","displayNoNewLineWarning":false,"position":22,"left":4988,"right":4993},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":4994,"text":"+\t/* assume the remote relation does not support TABLESAMPLE */","html":"+\t\u003cspan class=pl-c\u003e/* assume the remote relation does not support TABLESAMPLE */\u003c/span\u003e","displayNoNewLineWarning":false,"position":23,"left":4988,"right":4994},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":4995,"text":"+\t*can_tablesample = false;","html":"+\t\u003cspan class=pl-c1\u003e*\u003c/span\u003e\u003cspan class=pl-s1\u003ecan_tablesample\u003c/span\u003e \u003cspan class=pl-c1\u003e=\u003c/span\u003e false;","displayNoNewLineWarning":false,"position":24,"left":4988,"right":4995},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":4996,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":25,"left":4989,"right":4996},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":4997,"text":" \t/*","html":" \t\u003cspan class=pl-c\u003e/*\u003c/span\u003e","displayNoNewLineWarning":false,"position":26,"left":4990,"right":4997},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":4998,"text":" \t * Get the connection to use. We do the remote access as the table's","html":" \u003cspan class=pl-c\u003e\t * Get the connection to use. We do the remote access as the table\u0026#39;s\u003c/span\u003e","displayNoNewLineWarning":false,"position":27,"left":4991,"right":4998},{"stylingDirective":null,"type":"HUNK","blobLineNumber":5005,"text":"@@ -4999,7 +5006,7 @@ postgresCountTuplesForForeignTable(Relation relation)","html":"@@ -4999,7 +5006,7 @@ postgresCountTuplesForForeignTable(Relation relation)","displayNoNewLineWarning":false,"position":28,"left":4998,"right":5005},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":5006,"text":" \t * Construct command to get page count for relation.","html":" \u003cspan class=pl-c\u003e\t * Construct command to get page count for relation.\u003c/span\u003e","displayNoNewLineWarning":false,"position":29,"left":4999,"right":5006},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":5007,"text":" \t */","html":" \u003cspan class=pl-c\u003e\t */\u003c/span\u003e","displayNoNewLineWarning":false,"position":30,"left":5000,"right":5007},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":5008,"text":" \tinitStringInfo(\u0026sql);","html":" \t\u003cspan class=pl-en\u003einitStringInfo\u003c/span\u003e(\u003cspan class=pl-c1\u003e\u0026amp;\u003c/span\u003e\u003cspan class=pl-s1\u003esql\u003c/span\u003e);","displayNoNewLineWarning":false,"position":31,"left":5001,"right":5008},{"stylingDirective":null,"type":"DELETION","blobLineNumber":5002,"text":"-\tdeparseAnalyzeTuplesSql(\u0026sql, relation);","html":"-\t\u003cspan class=\"pl-en x x-first x-last\"\u003edeparseAnalyzeTuplesSql\u003c/span\u003e(\u003cspan class=\"pl-c1\"\u003e\u0026amp;\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003esql\u003c/span\u003e, \u003cspan class=\"pl-s1\"\u003erelation\u003c/span\u003e);","displayNoNewLineWarning":false,"position":32,"left":5002,"right":5008},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":5009,"text":"+\tdeparseAnalyzeInfoSql(\u0026sql, relation);","html":"+\t\u003cspan class=\"pl-en x x-first x-last\"\u003edeparseAnalyzeInfoSql\u003c/span\u003e(\u003cspan class=\"pl-c1\"\u003e\u0026amp;\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003esql\u003c/span\u003e, \u003cspan class=\"pl-s1\"\u003erelation\u003c/span\u003e);","displayNoNewLineWarning":false,"position":33,"left":5002,"right":5009},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":5010,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":34,"left":5003,"right":5010},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":5011,"text":" \t/* In what follows, do not risk leaking any PGresults. */","html":" \t\u003cspan class=pl-c\u003e/* In what follows, do not risk leaking any PGresults. */\u003c/span\u003e","displayNoNewLineWarning":false,"position":35,"left":5004,"right":5011},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":5012,"text":" \tPG_TRY();","html":" \t\u003cspan class=pl-en\u003ePG_TRY\u003c/span\u003e();","displayNoNewLineWarning":false,"position":36,"left":5005,"right":5012},{"stylingDirective":null,"type":"HUNK","blobLineNumber":5014,"text":"@@ -5008,9 +5015,10 @@ postgresCountTuplesForForeignTable(Relation relation)","html":"@@ -5008,9 +5015,10 @@ postgresCountTuplesForForeignTable(Relation relation)","displayNoNewLineWarning":false,"position":37,"left":5007,"right":5014},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":5015,"text":" \t\tif (PQresultStatus(res) != PGRES_TUPLES_OK)","html":" \t\t\u003cspan class=pl-k\u003eif\u003c/span\u003e (\u003cspan class=pl-en\u003ePQresultStatus\u003c/span\u003e(\u003cspan class=pl-s1\u003eres\u003c/span\u003e) \u003cspan class=pl-c1\u003e!=\u003c/span\u003e \u003cspan class=pl-c1\u003ePGRES_TUPLES_OK\u003c/span\u003e)","displayNoNewLineWarning":false,"position":38,"left":5008,"right":5015},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":5016,"text":" \t\t\tpgfdw_report_error(ERROR, res, conn, false, sql.data);","html":" \t\t\t\u003cspan class=pl-en\u003epgfdw_report_error\u003c/span\u003e(\u003cspan class=pl-c1\u003eERROR\u003c/span\u003e, \u003cspan class=pl-s1\u003eres\u003c/span\u003e, \u003cspan class=pl-s1\u003econn\u003c/span\u003e, false, \u003cspan class=pl-s1\u003esql\u003c/span\u003e.\u003cspan class=pl-c1\u003edata\u003c/span\u003e);","displayNoNewLineWarning":false,"position":39,"left":5009,"right":5016},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":5017,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":40,"left":5010,"right":5017},{"stylingDirective":null,"type":"DELETION","blobLineNumber":5011,"text":"-\t\tif (PQntuples(res) != 1 || PQnfields(res) != 1)","html":"-\t\t\u003cspan class=\"pl-k\"\u003eif\u003c/span\u003e (\u003cspan class=\"pl-en\"\u003ePQntuples\u003c/span\u003e(\u003cspan class=\"pl-s1\"\u003eres\u003c/span\u003e) \u003cspan class=\"pl-c1\"\u003e!=\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e1\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e||\u003c/span\u003e \u003cspan class=\"pl-en\"\u003ePQnfields\u003c/span\u003e(\u003cspan class=\"pl-s1\"\u003eres\u003c/span\u003e) \u003cspan class=\"pl-c1\"\u003e!=\u003c/span\u003e \u003cspan class=\"pl-c1 x x-first x-last\"\u003e1\u003c/span\u003e)","displayNoNewLineWarning":false,"position":41,"left":5011,"right":5017},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":5018,"text":"+\t\tif (PQntuples(res) != 1 || PQnfields(res) != 2)","html":"+\t\t\u003cspan class=\"pl-k\"\u003eif\u003c/span\u003e (\u003cspan class=\"pl-en\"\u003ePQntuples\u003c/span\u003e(\u003cspan class=\"pl-s1\"\u003eres\u003c/span\u003e) \u003cspan class=\"pl-c1\"\u003e!=\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e1\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e||\u003c/span\u003e \u003cspan class=\"pl-en\"\u003ePQnfields\u003c/span\u003e(\u003cspan class=\"pl-s1\"\u003eres\u003c/span\u003e) \u003cspan class=\"pl-c1\"\u003e!=\u003c/span\u003e \u003cspan class=\"pl-c1 x x-first x-last\"\u003e2\u003c/span\u003e)","displayNoNewLineWarning":false,"position":42,"left":5011,"right":5018},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":5019,"text":" \t\t\telog(ERROR, \"unexpected result from deparseAnalyzeTuplesSql query\");","html":" \t\t\t\u003cspan class=pl-en\u003eelog\u003c/span\u003e(\u003cspan class=pl-c1\u003eERROR\u003c/span\u003e, \u003cspan class=pl-s\u003e\u0026quot;unexpected result from deparseAnalyzeTuplesSql query\u0026quot;\u003c/span\u003e);","displayNoNewLineWarning":false,"position":43,"left":5012,"right":5019},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":5020,"text":" \t\treltuples = strtod(PQgetvalue(res, 0, 0), NULL);","html":" \t\t\u003cspan class=pl-s1\u003ereltuples\u003c/span\u003e \u003cspan class=pl-c1\u003e=\u003c/span\u003e \u003cspan class=pl-en\u003estrtod\u003c/span\u003e(\u003cspan class=pl-en\u003ePQgetvalue\u003c/span\u003e(\u003cspan class=pl-s1\u003eres\u003c/span\u003e, \u003cspan class=pl-c1\u003e0\u003c/span\u003e, \u003cspan class=pl-c1\u003e0\u003c/span\u003e), \u003cspan class=pl-c1\u003eNULL\u003c/span\u003e);","displayNoNewLineWarning":false,"position":44,"left":5013,"right":5020},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":5021,"text":"+\t\trelkind = *(PQgetvalue(res, 0, 1));","html":"+\t\t\u003cspan class=pl-s1\u003erelkind\u003c/span\u003e \u003cspan class=pl-c1\u003e=\u003c/span\u003e \u003cspan class=pl-c1\u003e*\u003c/span\u003e(\u003cspan class=pl-en\u003ePQgetvalue\u003c/span\u003e(\u003cspan class=pl-s1\u003eres\u003c/span\u003e, \u003cspan class=pl-c1\u003e0\u003c/span\u003e, \u003cspan class=pl-c1\u003e1\u003c/span\u003e));","displayNoNewLineWarning":false,"position":45,"left":5013,"right":5021},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":5022,"text":" \t}","html":" \t}","displayNoNewLineWarning":false,"position":46,"left":5014,"right":5022},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":5023,"text":" \tPG_FINALLY();","html":" \t\u003cspan class=pl-en\u003ePG_FINALLY\u003c/span\u003e();","displayNoNewLineWarning":false,"position":47,"left":5015,"right":5023},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":5024,"text":" \t{","html":" \t{","displayNoNewLineWarning":false,"position":48,"left":5016,"right":5024},{"stylingDirective":null,"type":"HUNK","blobLineNumber":5028,"text":"@@ -5021,6 +5029,11 @@ postgresCountTuplesForForeignTable(Relation relation)","html":"@@ -5021,6 +5029,11 @@ postgresCountTuplesForForeignTable(Relation relation)","displayNoNewLineWarning":false,"position":49,"left":5020,"right":5028},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":5029,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":50,"left":5021,"right":5029},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":5030,"text":" \tReleaseConnection(conn);","html":" \t\u003cspan class=pl-en\u003eReleaseConnection\u003c/span\u003e(\u003cspan class=pl-s1\u003econn\u003c/span\u003e);","displayNoNewLineWarning":false,"position":51,"left":5022,"right":5030},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":5031,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":52,"left":5023,"right":5031},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":5032,"text":"+\t/* TABLESAMPLE is supported only for regular tables and matviews */","html":"+\t\u003cspan class=pl-c\u003e/* TABLESAMPLE is supported only for regular tables and matviews */\u003c/span\u003e","displayNoNewLineWarning":false,"position":53,"left":5023,"right":5032},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":5033,"text":"+\t*can_tablesample = (relkind == RELKIND_RELATION ||","html":"+\t\u003cspan class=pl-c1\u003e*\u003c/span\u003e\u003cspan class=pl-s1\u003ecan_tablesample\u003c/span\u003e \u003cspan class=pl-c1\u003e=\u003c/span\u003e (\u003cspan class=pl-s1\u003erelkind\u003c/span\u003e \u003cspan class=pl-c1\u003e==\u003c/span\u003e \u003cspan class=pl-c1\u003eRELKIND_RELATION\u003c/span\u003e \u003cspan class=pl-c1\u003e||\u003c/span\u003e","displayNoNewLineWarning":false,"position":54,"left":5023,"right":5033},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":5034,"text":"+\t\t\t\t\t\trelkind == RELKIND_MATVIEW ||","html":"+\t\t\t\t\t\t\u003cspan class=pl-s1\u003erelkind\u003c/span\u003e \u003cspan class=pl-c1\u003e==\u003c/span\u003e \u003cspan class=pl-c1\u003eRELKIND_MATVIEW\u003c/span\u003e \u003cspan class=pl-c1\u003e||\u003c/span\u003e","displayNoNewLineWarning":false,"position":55,"left":5023,"right":5034},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":5035,"text":"+\t\t\t\t\t\trelkind == RELKIND_PARTITIONED_TABLE);","html":"+\t\t\t\t\t\t\u003cspan class=pl-s1\u003erelkind\u003c/span\u003e \u003cspan class=pl-c1\u003e==\u003c/span\u003e \u003cspan class=pl-c1\u003eRELKIND_PARTITIONED_TABLE\u003c/span\u003e);","displayNoNewLineWarning":false,"position":56,"left":5023,"right":5035},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":5036,"text":"+","html":"+","displayNoNewLineWarning":false,"position":57,"left":5023,"right":5036},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":5037,"text":" \treturn reltuples;","html":" \t\u003cspan class=pl-k\u003ereturn\u003c/span\u003e \u003cspan class=pl-s1\u003ereltuples\u003c/span\u003e;","displayNoNewLineWarning":false,"position":58,"left":5024,"right":5037},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":5038,"text":" }","html":" }","displayNoNewLineWarning":false,"position":59,"left":5025,"right":5038},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":5039,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":60,"left":5026,"right":5039},{"stylingDirective":null,"type":"HUNK","blobLineNumber":5159,"text":"@@ -5147,27 +5160,25 @@ postgresAcquireSampleRowsFunc(Relation relation, int elevel,","html":"@@ -5147,27 +5160,25 @@ postgresAcquireSampleRowsFunc(Relation relation, int elevel,","displayNoNewLineWarning":false,"position":61,"left":5146,"right":5159},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":5160,"text":" \t\t\t\t(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),","html":" \t\t\t\t(\u003cspan class=pl-en\u003eerrcode\u003c/span\u003e(\u003cspan class=pl-c1\u003eERRCODE_FEATURE_NOT_SUPPORTED\u003c/span\u003e),","displayNoNewLineWarning":false,"position":62,"left":5147,"right":5160},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":5161,"text":" \t\t\t\t errmsg(\"remote server does not support TABLESAMPLE feature\")));","html":" \t\t\t\t \u003cspan class=pl-en\u003eerrmsg\u003c/span\u003e(\u003cspan class=pl-s\u003e\u0026quot;remote server does not support TABLESAMPLE feature\u0026quot;\u003c/span\u003e)));","displayNoNewLineWarning":false,"position":63,"left":5148,"right":5161},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":5162,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":64,"left":5149,"right":5162},{"stylingDirective":null,"type":"DELETION","blobLineNumber":5150,"text":"-\t/*","html":"-\t\u003cspan class=pl-c\u003e/*\u003c/span\u003e","displayNoNewLineWarning":false,"position":65,"left":5150,"right":5162},{"stylingDirective":null,"type":"DELETION","blobLineNumber":5151,"text":"-\t * For \"auto\" method, pick the one we believe is best. For servers with","html":"-\u003cspan class=pl-c\u003e\t * For \u0026quot;auto\u0026quot; method, pick the one we believe is best. For servers with\u003c/span\u003e","displayNoNewLineWarning":false,"position":66,"left":5151,"right":5162},{"stylingDirective":null,"type":"DELETION","blobLineNumber":5152,"text":"-\t * TABLESAMPLE support we pick BERNOULLI, for old servers we fall-back to","html":"-\u003cspan class=pl-c\u003e\t * TABLESAMPLE support we pick BERNOULLI, for old servers we fall-back to\u003c/span\u003e","displayNoNewLineWarning":false,"position":67,"left":5152,"right":5162},{"stylingDirective":null,"type":"DELETION","blobLineNumber":5153,"text":"-\t * random() to at least reduce network transfer.","html":"-\u003cspan class=pl-c\u003e\t * random() to at least reduce network transfer.\u003c/span\u003e","displayNoNewLineWarning":false,"position":68,"left":5153,"right":5162},{"stylingDirective":null,"type":"DELETION","blobLineNumber":5154,"text":"-\t */","html":"-\u003cspan class=pl-c\u003e\t */\u003c/span\u003e","displayNoNewLineWarning":false,"position":69,"left":5154,"right":5162},{"stylingDirective":null,"type":"DELETION","blobLineNumber":5155,"text":"-\tif (method == ANALYZE_SAMPLE_AUTO)","html":"-\t\u003cspan class=pl-k\u003eif\u003c/span\u003e (\u003cspan class=pl-s1\u003emethod\u003c/span\u003e \u003cspan class=pl-c1\u003e==\u003c/span\u003e \u003cspan class=pl-c1\u003eANALYZE_SAMPLE_AUTO\u003c/span\u003e)","displayNoNewLineWarning":false,"position":70,"left":5155,"right":5162},{"stylingDirective":null,"type":"DELETION","blobLineNumber":5156,"text":"-\t{","html":"-\t{","displayNoNewLineWarning":false,"position":71,"left":5156,"right":5162},{"stylingDirective":null,"type":"DELETION","blobLineNumber":5157,"text":"-\t\tif (server_version_num \u003c 95000)","html":"-\t\t\u003cspan class=pl-k\u003eif\u003c/span\u003e (\u003cspan class=pl-s1\u003eserver_version_num\u003c/span\u003e \u003cspan class=pl-c1\u003e\u0026lt;\u003c/span\u003e \u003cspan class=pl-c1\u003e95000\u003c/span\u003e)","displayNoNewLineWarning":false,"position":72,"left":5157,"right":5162},{"stylingDirective":null,"type":"DELETION","blobLineNumber":5158,"text":"-\t\t\tmethod = ANALYZE_SAMPLE_RANDOM;","html":"-\t\t\t\u003cspan class=pl-s1\u003emethod\u003c/span\u003e \u003cspan class=pl-c1\u003e=\u003c/span\u003e \u003cspan class=pl-c1\u003eANALYZE_SAMPLE_RANDOM\u003c/span\u003e;","displayNoNewLineWarning":false,"position":73,"left":5158,"right":5162},{"stylingDirective":null,"type":"DELETION","blobLineNumber":5159,"text":"-\t\telse","html":"-\t\t\u003cspan class=pl-k\u003eelse\u003c/span\u003e","displayNoNewLineWarning":false,"position":74,"left":5159,"right":5162},{"stylingDirective":null,"type":"DELETION","blobLineNumber":5160,"text":"-\t\t\tmethod = ANALYZE_SAMPLE_BERNOULLI;","html":"-\t\t\t\u003cspan class=pl-s1\u003emethod\u003c/span\u003e \u003cspan class=pl-c1\u003e=\u003c/span\u003e \u003cspan class=pl-c1\u003eANALYZE_SAMPLE_BERNOULLI\u003c/span\u003e;","displayNoNewLineWarning":false,"position":75,"left":5160,"right":5162},{"stylingDirective":null,"type":"DELETION","blobLineNumber":5161,"text":"-\t}","html":"-\t}","displayNoNewLineWarning":false,"position":76,"left":5161,"right":5162},{"stylingDirective":null,"type":"DELETION","blobLineNumber":5162,"text":"-","html":"-","displayNoNewLineWarning":false,"position":77,"left":5162,"right":5162},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":5163,"text":" \t/*","html":" \t\u003cspan class=pl-c\u003e/*\u003c/span\u003e","displayNoNewLineWarning":false,"position":78,"left":5163,"right":5163},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":5164,"text":" \t * If we've decided to do remote sampling, calculate the sampling rate. We","html":" \u003cspan class=pl-c\u003e\t * If we\u0026#39;ve decided to do remote sampling, calculate the sampling rate. We\u003c/span\u003e","displayNoNewLineWarning":false,"position":79,"left":5164,"right":5164},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":5165,"text":" \t * need to get the number of tuples from the remote server, but skip that","html":" \u003cspan class=pl-c\u003e\t * need to get the number of tuples from the remote server, but skip that\u003c/span\u003e","displayNoNewLineWarning":false,"position":80,"left":5165,"right":5165},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":5166,"text":" \t * network round-trip if not needed.","html":" \u003cspan class=pl-c\u003e\t * network round-trip if not needed.\u003c/span\u003e","displayNoNewLineWarning":false,"position":81,"left":5166,"right":5166},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":5167,"text":" \t */","html":" \u003cspan class=pl-c\u003e\t */\u003c/span\u003e","displayNoNewLineWarning":false,"position":82,"left":5167,"right":5167},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":5168,"text":" \tif (method != ANALYZE_SAMPLE_OFF)","html":" \t\u003cspan class=pl-k\u003eif\u003c/span\u003e (\u003cspan class=pl-s1\u003emethod\u003c/span\u003e \u003cspan class=pl-c1\u003e!=\u003c/span\u003e \u003cspan class=pl-c1\u003eANALYZE_SAMPLE_OFF\u003c/span\u003e)","displayNoNewLineWarning":false,"position":83,"left":5168,"right":5168},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":5169,"text":" \t{","html":" \t{","displayNoNewLineWarning":false,"position":84,"left":5169,"right":5169},{"stylingDirective":null,"type":"DELETION","blobLineNumber":5170,"text":"-\t\treltuples = postgresCountTuplesForForeignTable(relation);","html":"-\t\t\u003cspan class=pl-s1\u003ereltuples\u003c/span\u003e \u003cspan class=pl-c1\u003e=\u003c/span\u003e \u003cspan class=pl-en\u003epostgresCountTuplesForForeignTable\u003c/span\u003e(\u003cspan class=pl-s1\u003erelation\u003c/span\u003e);","displayNoNewLineWarning":false,"position":85,"left":5170,"right":5169},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":5170,"text":"+\t\tbool\tcan_tablesample;","html":"+\t\t\u003cspan class=pl-smi\u003ebool\u003c/span\u003e\t\u003cspan class=pl-s1\u003ecan_tablesample\u003c/span\u003e;","displayNoNewLineWarning":false,"position":86,"left":5170,"right":5170},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":5171,"text":"+","html":"+","displayNoNewLineWarning":false,"position":87,"left":5170,"right":5171},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":5172,"text":"+\t\treltuples = postgresGetAnalyzeInfoForForeignTable(relation,","html":"+\t\t\u003cspan class=pl-s1\u003ereltuples\u003c/span\u003e \u003cspan class=pl-c1\u003e=\u003c/span\u003e \u003cspan class=pl-en\u003epostgresGetAnalyzeInfoForForeignTable\u003c/span\u003e(\u003cspan class=pl-s1\u003erelation\u003c/span\u003e,","displayNoNewLineWarning":false,"position":88,"left":5170,"right":5172},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":5173,"text":"+\t\t\t\t\t\t\t\t\t\t\t\t\t\t \u0026can_tablesample);","html":"+\t\t\t\t\t\t\t\t\t\t\t\t\t\t \u003cspan class=pl-c1\u003e\u0026amp;\u003c/span\u003e\u003cspan class=pl-s1\u003ecan_tablesample\u003c/span\u003e);","displayNoNewLineWarning":false,"position":89,"left":5170,"right":5173},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":5174,"text":"+","html":"+","displayNoNewLineWarning":false,"position":90,"left":5170,"right":5174},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":5175,"text":"+\t\t/*","html":"+\t\t\u003cspan class=pl-c\u003e/*\u003c/span\u003e","displayNoNewLineWarning":false,"position":91,"left":5170,"right":5175},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":5176,"text":"+\t\t * Make sure we're not choosing TABLESAMPLE when the remote relation does","html":"+\u003cspan class=pl-c\u003e\t\t * Make sure we\u0026#39;re not choosing TABLESAMPLE when the remote relation does\u003c/span\u003e","displayNoNewLineWarning":false,"position":92,"left":5170,"right":5176},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":5177,"text":"+\t\t * not support that. But only do this for \"auto\" - if the user explicitly","html":"+\u003cspan class=pl-c\u003e\t\t * not support that. But only do this for \u0026quot;auto\u0026quot; - if the user explicitly\u003c/span\u003e","displayNoNewLineWarning":false,"position":93,"left":5170,"right":5177},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":5178,"text":"+\t\t * requested BERNOULLI/SYSTEM, it's better to fail.","html":"+\u003cspan class=pl-c\u003e\t\t * requested BERNOULLI/SYSTEM, it\u0026#39;s better to fail.\u003c/span\u003e","displayNoNewLineWarning":false,"position":94,"left":5170,"right":5178},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":5179,"text":"+\t\t */","html":"+\u003cspan class=pl-c\u003e\t\t */\u003c/span\u003e","displayNoNewLineWarning":false,"position":95,"left":5170,"right":5179},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":5180,"text":"+\t\tif (!can_tablesample \u0026\u0026 (method == ANALYZE_SAMPLE_AUTO))","html":"+\t\t\u003cspan class=pl-k\u003eif\u003c/span\u003e (!\u003cspan class=pl-s1\u003ecan_tablesample\u003c/span\u003e \u003cspan class=pl-c1\u003e\u0026amp;\u0026amp;\u003c/span\u003e (\u003cspan class=pl-s1\u003emethod\u003c/span\u003e \u003cspan class=pl-c1\u003e==\u003c/span\u003e \u003cspan class=pl-c1\u003eANALYZE_SAMPLE_AUTO\u003c/span\u003e))","displayNoNewLineWarning":false,"position":96,"left":5170,"right":5180},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":5181,"text":"+\t\t\tmethod = ANALYZE_SAMPLE_RANDOM;","html":"+\t\t\t\u003cspan class=pl-s1\u003emethod\u003c/span\u003e \u003cspan class=pl-c1\u003e=\u003c/span\u003e \u003cspan class=pl-c1\u003eANALYZE_SAMPLE_RANDOM\u003c/span\u003e;","displayNoNewLineWarning":false,"position":97,"left":5170,"right":5181},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":5182,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":98,"left":5171,"right":5182},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":5183,"text":" \t\t/*","html":" \t\t\u003cspan class=pl-c\u003e/*\u003c/span\u003e","displayNoNewLineWarning":false,"position":99,"left":5172,"right":5183},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":5184,"text":" \t\t * Remote's reltuples could be 0 or -1 if the table has never been","html":" \u003cspan class=pl-c\u003e\t\t * Remote\u0026#39;s reltuples could be 0 or -1 if the table has never been\u003c/span\u003e","displayNoNewLineWarning":false,"position":100,"left":5173,"right":5184},{"stylingDirective":null,"type":"HUNK","blobLineNumber":5222,"text":"@@ -5212,6 +5223,19 @@ postgresAcquireSampleRowsFunc(Relation relation, int elevel,","html":"@@ -5212,6 +5223,19 @@ postgresAcquireSampleRowsFunc(Relation relation, int elevel,","displayNoNewLineWarning":false,"position":101,"left":5211,"right":5222},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":5223,"text":" \t\t}","html":" \t\t}","displayNoNewLineWarning":false,"position":102,"left":5212,"right":5223},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":5224,"text":" \t}","html":" \t}","displayNoNewLineWarning":false,"position":103,"left":5213,"right":5224},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":5225,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":104,"left":5214,"right":5225},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":5226,"text":"+\t/*","html":"+\t\u003cspan class=pl-c\u003e/*\u003c/span\u003e","displayNoNewLineWarning":false,"position":105,"left":5214,"right":5226},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":5227,"text":"+\t * For \"auto\" method, pick the one we believe is best. For servers with","html":"+\u003cspan class=pl-c\u003e\t * For \u0026quot;auto\u0026quot; method, pick the one we believe is best. For servers with\u003c/span\u003e","displayNoNewLineWarning":false,"position":106,"left":5214,"right":5227},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":5228,"text":"+\t * TABLESAMPLE support we pick BERNOULLI, for old servers we fall-back to","html":"+\u003cspan class=pl-c\u003e\t * TABLESAMPLE support we pick BERNOULLI, for old servers we fall-back to\u003c/span\u003e","displayNoNewLineWarning":false,"position":107,"left":5214,"right":5228},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":5229,"text":"+\t * random() to at least reduce network transfer.","html":"+\u003cspan class=pl-c\u003e\t * random() to at least reduce network transfer.\u003c/span\u003e","displayNoNewLineWarning":false,"position":108,"left":5214,"right":5229},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":5230,"text":"+\t */","html":"+\u003cspan class=pl-c\u003e\t */\u003c/span\u003e","displayNoNewLineWarning":false,"position":109,"left":5214,"right":5230},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":5231,"text":"+\tif (method == ANALYZE_SAMPLE_AUTO)","html":"+\t\u003cspan class=pl-k\u003eif\u003c/span\u003e (\u003cspan class=pl-s1\u003emethod\u003c/span\u003e \u003cspan class=pl-c1\u003e==\u003c/span\u003e \u003cspan class=pl-c1\u003eANALYZE_SAMPLE_AUTO\u003c/span\u003e)","displayNoNewLineWarning":false,"position":110,"left":5214,"right":5231},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":5232,"text":"+\t{","html":"+\t{","displayNoNewLineWarning":false,"position":111,"left":5214,"right":5232},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":5233,"text":"+\t\tif (server_version_num \u003c 95000)","html":"+\t\t\u003cspan class=pl-k\u003eif\u003c/span\u003e (\u003cspan class=pl-s1\u003eserver_version_num\u003c/span\u003e \u003cspan class=pl-c1\u003e\u0026lt;\u003c/span\u003e \u003cspan class=pl-c1\u003e95000\u003c/span\u003e)","displayNoNewLineWarning":false,"position":112,"left":5214,"right":5233},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":5234,"text":"+\t\t\tmethod = ANALYZE_SAMPLE_RANDOM;","html":"+\t\t\t\u003cspan class=pl-s1\u003emethod\u003c/span\u003e \u003cspan class=pl-c1\u003e=\u003c/span\u003e \u003cspan class=pl-c1\u003eANALYZE_SAMPLE_RANDOM\u003c/span\u003e;","displayNoNewLineWarning":false,"position":113,"left":5214,"right":5234},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":5235,"text":"+\t\telse","html":"+\t\t\u003cspan class=pl-k\u003eelse\u003c/span\u003e","displayNoNewLineWarning":false,"position":114,"left":5214,"right":5235},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":5236,"text":"+\t\t\tmethod = ANALYZE_SAMPLE_BERNOULLI;","html":"+\t\t\t\u003cspan class=pl-s1\u003emethod\u003c/span\u003e \u003cspan class=pl-c1\u003e=\u003c/span\u003e \u003cspan class=pl-c1\u003eANALYZE_SAMPLE_BERNOULLI\u003c/span\u003e;","displayNoNewLineWarning":false,"position":115,"left":5214,"right":5236},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":5237,"text":"+\t}","html":"+\t}","displayNoNewLineWarning":false,"position":116,"left":5214,"right":5237},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":5238,"text":"+","html":"+","displayNoNewLineWarning":false,"position":117,"left":5214,"right":5238},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":5239,"text":" \t/*","html":" \t\u003cspan class=pl-c\u003e/*\u003c/span\u003e","displayNoNewLineWarning":false,"position":118,"left":5215,"right":5239},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":5240,"text":" \t * Construct cursor that retrieves whole rows from remote.","html":" \u003cspan class=pl-c\u003e\t * Construct cursor that retrieves whole rows from remote.\u003c/span\u003e","displayNoNewLineWarning":false,"position":119,"left":5216,"right":5240},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":5241,"text":" \t */","html":" \u003cspan class=pl-c\u003e\t */\u003c/span\u003e","displayNoNewLineWarning":false,"position":120,"left":5217,"right":5241}],"diffNumber":1,"diffSize":"0 Bytes","isBinary":false,"isTooBig":false,"collapsed":false,"isSubmodule":false,"lineCount":7807,"linesChanged":60,"newTreeEntry":{"lineCount":7807,"path":"contrib/postgres_fdw/postgres_fdw.c","mode":100644,"isGenerated":false},"oldTreeEntry":{"lineCount":0,"path":"contrib/postgres_fdw/postgres_fdw.c","mode":100644},"linesAdded":42,"linesDeleted":18,"path":"contrib/postgres_fdw/postgres_fdw.c","pathDigest":"e399f5c029192320f310a79f18c20fb18c8e916fee993237f6f82f05dad851c5","status":"MODIFIED","truncatedReason":null,"oldOid":"d913928c9c5e905d0062d1e7237b7fb5fbde61ed","newOid":"57d11ef028d126f95595c08c62ffb4c5147d0f86","copilotChatReference":null,"deletedSha":"d913928c9c5e905d0062d1e7237b7fb5fbde61ed","canToggleRichDiff":false,"defaultToRichDiff":false,"proseDifffHtml":null,"renderInfo":null,"dependencyDiffPath":null,"submodule":null},{"diffLines":[{"stylingDirective":null,"type":"HUNK","blobLineNumber":222,"text":"@@ -223,7 +223,7 @@ extern void deparseDirectDeleteSql(StringInfo buf, PlannerInfo *root,","html":"@@ -223,7 +223,7 @@ extern void deparseDirectDeleteSql(StringInfo buf, PlannerInfo *root,","displayNoNewLineWarning":false,"position":0,"left":222,"right":222},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":223,"text":" \t\t\t\t\t\t\t\t List *returningList,","html":" \t\t\t\t\t\t\t\t \u003cspan class=pl-smi\u003eList\u003c/span\u003e \u003cspan class=pl-c1\u003e*\u003c/span\u003e\u003cspan class=pl-s1\u003ereturningList\u003c/span\u003e,","displayNoNewLineWarning":false,"position":1,"left":223,"right":223},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":224,"text":" \t\t\t\t\t\t\t\t List **retrieved_attrs);","html":" \t\t\t\t\t\t\t\t \u003cspan class=pl-smi\u003eList\u003c/span\u003e \u003cspan class=pl-c1\u003e*\u003c/span\u003e\u003cspan class=pl-c1\u003e*\u003c/span\u003e\u003cspan class=pl-s1\u003eretrieved_attrs\u003c/span\u003e);","displayNoNewLineWarning":false,"position":2,"left":224,"right":224},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":225,"text":" extern void deparseAnalyzeSizeSql(StringInfo buf, Relation rel);","html":" \u003cspan class=pl-k\u003eextern\u003c/span\u003e \u003cspan class=pl-smi\u003evoid\u003c/span\u003e \u003cspan class=pl-en\u003edeparseAnalyzeSizeSql\u003c/span\u003e(\u003cspan class=pl-smi\u003eStringInfo\u003c/span\u003e \u003cspan class=pl-s1\u003ebuf\u003c/span\u003e, \u003cspan class=pl-smi\u003eRelation\u003c/span\u003e \u003cspan class=pl-s1\u003erel\u003c/span\u003e);","displayNoNewLineWarning":false,"position":3,"left":225,"right":225},{"stylingDirective":null,"type":"DELETION","blobLineNumber":226,"text":"-extern void deparseAnalyzeTuplesSql(StringInfo buf, Relation rel);","html":"-\u003cspan class=\"pl-k\"\u003eextern\u003c/span\u003e \u003cspan class=\"pl-smi\"\u003evoid\u003c/span\u003e \u003cspan class=\"pl-en x x-first x-last\"\u003edeparseAnalyzeTuplesSql\u003c/span\u003e(\u003cspan class=\"pl-smi\"\u003eStringInfo\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003ebuf\u003c/span\u003e, \u003cspan class=\"pl-smi\"\u003eRelation\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003erel\u003c/span\u003e);","displayNoNewLineWarning":false,"position":4,"left":226,"right":225},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":226,"text":"+extern void deparseAnalyzeInfoSql(StringInfo buf, Relation rel);","html":"+\u003cspan class=\"pl-k\"\u003eextern\u003c/span\u003e \u003cspan class=\"pl-smi\"\u003evoid\u003c/span\u003e \u003cspan class=\"pl-en x x-first x-last\"\u003edeparseAnalyzeInfoSql\u003c/span\u003e(\u003cspan class=\"pl-smi\"\u003eStringInfo\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003ebuf\u003c/span\u003e, \u003cspan class=\"pl-smi\"\u003eRelation\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003erel\u003c/span\u003e);","displayNoNewLineWarning":false,"position":5,"left":226,"right":226},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":227,"text":" extern void deparseAnalyzeSql(StringInfo buf, Relation rel,","html":" \u003cspan class=pl-k\u003eextern\u003c/span\u003e \u003cspan class=pl-smi\u003evoid\u003c/span\u003e \u003cspan class=pl-en\u003edeparseAnalyzeSql\u003c/span\u003e(\u003cspan class=pl-smi\u003eStringInfo\u003c/span\u003e \u003cspan class=pl-s1\u003ebuf\u003c/span\u003e, \u003cspan class=pl-smi\u003eRelation\u003c/span\u003e \u003cspan class=pl-s1\u003erel\u003c/span\u003e,","displayNoNewLineWarning":false,"position":6,"left":227,"right":227},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":228,"text":" \t\t\t\t\t\t\t PgFdwSamplingMethod sample_method,","html":" \t\t\t\t\t\t\t \u003cspan class=pl-smi\u003ePgFdwSamplingMethod\u003c/span\u003e \u003cspan class=pl-s1\u003esample_method\u003c/span\u003e,","displayNoNewLineWarning":false,"position":7,"left":228,"right":228},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":229,"text":" \t\t\t\t\t\t\t double sample_frac,","html":" \t\t\t\t\t\t\t \u003cspan class=pl-smi\u003edouble\u003c/span\u003e \u003cspan class=pl-s1\u003esample_frac\u003c/span\u003e,","displayNoNewLineWarning":false,"position":8,"left":229,"right":229}],"diffNumber":2,"diffSize":"0 Bytes","isBinary":false,"isTooBig":false,"collapsed":false,"isSubmodule":false,"lineCount":255,"linesChanged":2,"newTreeEntry":{"lineCount":255,"path":"contrib/postgres_fdw/postgres_fdw.h","mode":100644,"isGenerated":false},"oldTreeEntry":{"lineCount":0,"path":"contrib/postgres_fdw/postgres_fdw.h","mode":100644},"linesAdded":1,"linesDeleted":1,"path":"contrib/postgres_fdw/postgres_fdw.h","pathDigest":"93883f788f0398929a3c6187329d529e909dd197895afede1a9cfb4365d5e8b7","status":"MODIFIED","truncatedReason":null,"oldOid":"d913928c9c5e905d0062d1e7237b7fb5fbde61ed","newOid":"57d11ef028d126f95595c08c62ffb4c5147d0f86","copilotChatReference":null,"deletedSha":"d913928c9c5e905d0062d1e7237b7fb5fbde61ed","canToggleRichDiff":false,"defaultToRichDiff":false,"proseDifffHtml":null,"renderInfo":null,"dependencyDiffPath":null,"submodule":null}],"splitViewPreference":"unified","ignoreWhitespace":false,"repoOwnerGlobalRelayId":"MDEyOk9yZ2FuaXphdGlvbjE3NzU0Mw==","commentsPreference":"visible","diffLineSpacingPreference":"relaxed","useMonospaceFont":false,"pasteUrlLinkAsPlainText":false,"userNotices":[],"path":"/postgres/postgres/commit/57d11ef028d126f95595c08c62ffb4c5147d0f86","fileTreeExpanded":true,"headerInfo":{"additions":47,"deletions":22,"filesChanged":3,"filesChangedString":"3"},"moreDiffsToLoad":false,"asyncDiffLoadInfo":{"startIndex":3,"truncated":false,"byteCount":5447,"lineShownCount":157},"commentInfo":{"canComment":false,"locked":false,"canLock":false,"repoArchived":false},"csrf_tokens":{"/users/diffview?diff=split":{"post":"cafMWHXErOIFNxEo38QdPGuQmhRg1ouQHZOGdHhJhxu62XT9iD3RlRViig9ZEF-2EFhEN6btY43TjDAa-oCMOA"},"/users/diffview?diff=unified":{"post":"-23dnKF2LWsAMaZ8b_l14p_swn_5du-mRQlixOHW7dowE2U5XI9QHBBkPVvpLTdo5CQcXD9NB7uLFtSqYx_m-Q"},"/notifications/thread":{"post":"ucKoC9-XMw44EgtuZu1avu4VHfWKvRwkh-Ip1dlNIYjzHKkfyZTd5TxbiJamIGv5o-t9JHLzH_qnJhUgxNrP2Q"}}},"title":"Check relkind before using TABLESAMPLE in postgres_fdw · postgres/postgres@57d11ef","appPayload":{"helpUrl":"https://docs.github.com","findInDiffWorkerPath":"/assets-cdn/worker/find-in-diff-worker-2bfe39677d14.js","enabled_features":{"diff_ux_refresh_beta":false,"diff_inline_comments":true,"diff_ux_refresh_ssr_five":false,"diff_ux_refresh_ssr_ten":false,"react_diff_line_type_character_correction":true}}}
Check relkind before using TABLESAMPLE in postgres_fdw
Check the remote relkind before trying to use TABLESAMPLE to acquire
sample from the remote relation. Even if the remote server version has
TABLESAMPLE support, the foreign table may point to incompatible relkind
(e.g. a view or a sequence).
If the relkind does not support TABLESAMPLE, error out if TABLESAMPLE
was requested specifically (as system/bernoulli), or fallback to random
just like we do for old server versions.
We currently end up disabling sampling for such relkind values anyway,
due to reltuples being -1 or 1, but that seems rather accidental, and
might get broken by improving reltuples estimates, etc. So better to
make the check explicit.
Reported-by: Tom Lane
Discussion: https://postgr.es/m/951485.1672461744%40sss.pgh.pa.us
0 commit comments