Changeset: 382b875db9ee for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/382b875db9ee
Modified Files:
        sql/server/sql_scan.c
Branch: default
Log Message:

preserve inline query comments


diffs (37 lines):

diff --git a/sql/server/sql_scan.c b/sql/server/sql_scan.c
--- a/sql/server/sql_scan.c
+++ b/sql/server/sql_scan.c
@@ -32,6 +32,8 @@ query_cleaned(sql_allocator *sa, const c
        bool bs = false;                /* seen a backslash in a quoted string 
*/
        bool incomment1 = false;        /* inside traditional C style comment */
        bool incomment2 = false;        /* inside comment starting with --  */
+       bool inline_comment = false;
+
        r = SA_NEW_ARRAY(sa, char, strlen(query) + 1);
        if(!r)
                return NULL;
@@ -44,10 +46,13 @@ query_cleaned(sql_allocator *sa, const c
                } else if (incomment2) {
                        if (*query == '\n') {
                                incomment2 = false;
+                               inline_comment = false;
                                /* add newline only if comment doesn't
                                 * occupy whole line */
                                if (q > r && q[-1] != '\n')
                                        *q++ = '\n';
+                       } else if (inline_comment){
+                               *q++ = *query; // preserve in line query 
comments
                        }
                } else if (quote) {
                        if (bs) {
@@ -65,6 +70,10 @@ query_cleaned(sql_allocator *sa, const c
                        quote = '}';
                        *q++ = *query;
                } else if (*query == '-' && query[1] == '-') {
+                       if (q > r && q[-1] != '\n') {
+                               inline_comment = true;
+                               *q++ = *query; // preserve in line query 
comments
+                       }
                        incomment2 = true;
                } else if (*query == '/' && query[1] == '*') {
                        incomment1 = true;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to