Andrew Dunstan avatar Andrew Dunstan committed ff9bbd2

Also wrap FROM clause items.

Comments (0)

Files changed (1)

src/backend/utils/adt/ruleutils.c

 			appendContextKeyword(context, prefix,
 								 -PRETTYINDENT_STD, PRETTYINDENT_STD, 2);
 			first = false;
+
+			get_from_clause_item(jtnode, query, context);
 		}
 		else
+		{
+			StringInfoData targetbuf;
+			char          *trailing_nl;
+
 			appendStringInfoString(buf, ", ");
+			
+			initStringInfo(&targetbuf);
+			context->buf = &targetbuf;
+
+			get_from_clause_item(jtnode, query, context);
+
+			context->buf = buf;
+
+			/* Locate the start of the current  line in the buffer */
+
+			trailing_nl = (strrchr(buf->data,'\n'));
+			if (trailing_nl == NULL)
+				trailing_nl = buf->data;
+			else 
+				trailing_nl++;
+			
+			/*
+			 * Add a newline, plus some  indentation, if pretty_wrap is on and the 
+			 * new from-clause item would cause an overflow.
+			 */
+			
+			if (pretty_wrap >= 0 &&
+				(strlen(trailing_nl) + strlen(targetbuf.data) > pretty_wrap))
+			{
+				appendContextKeyword(context, "", -PRETTYINDENT_STD, 
+									 PRETTYINDENT_STD, PRETTYINDENT_VAR);
+			}
+
+			/* Add the new item */
+
+			appendStringInfoString(buf, targetbuf.data);
+			
+			/* cleanup */
+
+			pfree (targetbuf.data);
+		}
 
-		get_from_clause_item(jtnode, query, context);
 	}
 }
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.