Changeset: 59e9e61fe4e2 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/59e9e61fe4e2
Branch: clean_parser
Log Message:

merged with recursive cte


diffs (truncated from 576 to 300 lines):

diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -282,7 +282,7 @@ bool GDKexiting(void);
 jmp_buf GDKfataljump;
 bit GDKfataljumpenable;
 str GDKfatalmsg;
-gdk_return GDKfilepath(char *buf, size_t bufsize, int farmid, const char *dir, 
const char *nme, const char *ext) __attribute__((__access__(write_only, 1)));
+gdk_return GDKfilepath(char *buf, size_t bufsize, int farmid, const char *dir, 
const char *nme, const char *ext) __attribute__((__access__(write_only, 1, 2)));
 void GDKfree(void *blk);
 char *GDKgetbuf(void);
 unsigned GDKgetdebug(void);
@@ -301,7 +301,7 @@ MT_Lock *volatile GDKlocklist;
 ATOMIC_FLAG GDKlocklistlock;
 ATOMIC_TYPE GDKlocksleepcnt;
 void GDKlockstatistics(int);
-void *GDKmalloc(size_t size) __attribute__((__malloc__)) 
__attribute__((__alloc_size__(1))) __attribute__((__warn_unused_result__));
+void *GDKmalloc(size_t size) __attribute__((__malloc__)) 
__attribute__((__malloc__(GDKfree, 1))) __attribute__((__alloc_size__(1))) 
__attribute__((__warn_unused_result__));
 size_t GDKmallocated(const void *s);
 size_t GDKmem_cursize(void);
 gdk_return GDKmergeidx(BAT *b, BAT **a, int n_ar);
@@ -324,9 +324,9 @@ stream *GDKstdout;
 ssize_t GDKstrFromStr(unsigned char *restrict dst, const unsigned char 
*restrict src, ssize_t len, char quote);
 int GDKstrcasecmp(const char *s1, const char *s2);
 char *GDKstrcasestr(const char *haystack, const char *needle);
-str GDKstrdup(const char *s) __attribute__((__malloc__)) 
__attribute__((__warn_unused_result__));
+str GDKstrdup(const char *s) __attribute__((__malloc__)) 
__attribute__((__malloc__(GDKfree, 1))) __attribute__((__warn_unused_result__));
 int GDKstrncasecmp(const char *str1, const char *str2, size_t l1, size_t l2);
-str GDKstrndup(const char *s, size_t n) __attribute__((__malloc__)) 
__attribute__((__warn_unused_result__));
+str GDKstrndup(const char *s, size_t n) __attribute__((__malloc__)) 
__attribute__((__malloc__(GDKfree, 1))) __attribute__((__warn_unused_result__));
 gdk_return GDKtolower(char **restrict buf, size_t *restrict buflen, const char 
*restrict s) __attribute__((__access__(read_write, 1))) 
__attribute__((__access__(read_write, 2)));
 gdk_return GDKtoupper(char **restrict buf, size_t *restrict buflen, const char 
*restrict s) __attribute__((__access__(read_write, 1))) 
__attribute__((__access__(read_write, 2)));
 gdk_return GDKtracer_fill_comp_info(BAT *id, BAT *component, BAT *log_level);
@@ -348,7 +348,7 @@ gdk_return GDKupgradevarheap(BAT *b, var
 lng GDKusec(void);
 const char *GDKversion(void) __attribute__((__const__));
 size_t GDKvm_cursize(void);
-void *GDKzalloc(size_t size) __attribute__((__malloc__)) 
__attribute__((__alloc_size__(1))) __attribute__((__warn_unused_result__));
+void *GDKzalloc(size_t size) __attribute__((__malloc__)) 
__attribute__((__malloc__(GDKfree, 1))) __attribute__((__alloc_size__(1))) 
__attribute__((__warn_unused_result__));
 void HASHdestroy(BAT *b);
 BUN HASHlist(Hash *h, BUN i);
 BUN HASHprobe(const Hash *h, const void *v);
@@ -912,8 +912,8 @@ const char corrRef[];
 const char countRef[];
 const char count_no_nilRef[];
 int cpyConstant(MalBlkPtr mb, VarPtr vr);
-str createException(enum malexception, const char *, _In_z_ 
_Printf_format_string_ const char *, ...) __attribute__((__format__(__printf__, 
3, 4))) __attribute__((__returns_nonnull__));
-str createMalException(MalBlkPtr, int, enum malexception, _In_z_ 
_Printf_format_string_ const char *, ...) __attribute__((__format__(__printf__, 
4, 5))) __attribute__((__returns_nonnull__));
+str createException(enum malexception, const char *, _In_z_ 
_Printf_format_string_ const char *, ...) __attribute__((__malloc__)) 
__attribute__((__malloc__(freeException, 1))) 
__attribute__((__format__(__printf__, 3, 4))) 
__attribute__((__returns_nonnull__));
+str createMalException(MalBlkPtr, int, enum malexception, _In_z_ 
_Printf_format_string_ const char *, ...) __attribute__((__malloc__)) 
__attribute__((__malloc__(freeException, 1))) 
__attribute__((__format__(__printf__, 4, 5))) 
__attribute__((__returns_nonnull__));
 const char create_functionRef[];
 const char create_roleRef[];
 const char create_schemaRef[];
@@ -1026,7 +1026,7 @@ int getStrConstant(MalBlkPtr mb, str val
 const char getTraceRef[];
 str getTypeIdentifier(malType tpe);
 str getTypeName(malType tpe);
-char *getVarNameIntoBuffer(MalBlkPtr mb, int idx, char *buf);
+char *getVarNameIntoBuffer(MalBlkPtr mb, int idx, char *buf) 
__attribute__((__access__(write_only, 3)));
 const char getVariableRef[];
 Module globalModule(const char *nme);
 const char grantRef[];
@@ -1069,6 +1069,7 @@ str loadLibrary(const char *modulename, 
 char *locate_file(const char *basename, const char *ext, bit recurse);
 const char lockRef[];
 const char lookupRef[];
+const char mainRef[];
 str mal2str(MalBlkPtr mb, int first, int last);
 int malAtomSize(int size, const char *name);
 str malBootstrap(char *modules[], bool embedded, const char *initpasswd);
diff --git a/common/utils/mstring.h b/common/utils/mstring.h
--- a/common/utils/mstring.h
+++ b/common/utils/mstring.h
@@ -23,9 +23,17 @@
 #define GCC_Pragma(pragma)
 #endif
 
+#if defined(__has_attribute)
+#if ! __has_attribute(access)
+#define __access__(...)
+#endif
+#else
+#define __access__(...)
+#endif
+
 /* copy at most (n-1) bytes from src to dst and add a terminating NULL
  * byte; return length of src (i.e. can be more than what is copied) */
-static inline size_t
+static inline size_t __attribute__((__access__(write_only, 1, 3)))
 strcpy_len(char *restrict dst, const char *restrict src, size_t n)
 {
        if (dst != NULL && n != 0) {
@@ -63,7 +71,7 @@ GCC_Pragma("GCC diagnostic pop")
 
 /* copy the NULL terminated list of src strings with a maximum of n
  * bytes to dst; return the combined length of the src strings */
-static inline size_t
+static inline size_t __attribute__((__access__(write_only, 1, 2)))
 strconcat_len(char *restrict dst, size_t n, const char *restrict src, ...)
 {
        va_list ap;
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -1487,7 +1487,7 @@ gdk_export gdk_return BATsave(BAT *b)
 #define MAXPATH        1024            /* maximum supported file path */
 
 gdk_export gdk_return GDKfilepath(char *buf, size_t bufsize, int farmid, const 
char *dir, const char *nme, const char *ext)
-       __attribute__((__access__(write_only, 1)));
+       __attribute__((__access__(write_only, 1, 2)));
 gdk_export bool GDKinmemory(int farmid);
 gdk_export bool GDKembedded(void);
 gdk_export gdk_return GDKcreatedir(const char *nme);
diff --git a/gdk/gdk_system.h b/gdk/gdk_system.h
--- a/gdk/gdk_system.h
+++ b/gdk/gdk_system.h
@@ -64,8 +64,12 @@
 #if !__has_attribute(__format__)
 #define __format__(...)
 #endif
+/* attribute malloc with argument seems to have been introduced in gcc 13 */
 #if !__has_attribute(__malloc__)
 #define __malloc__
+#define __malloc__(...)
+#elif !defined(__GNUC__) || __GNUC__ < 13
+#define __malloc__(...)
 #endif
 #if !__has_attribute(__nonnull__)
 #define __nonnull__(...)
diff --git a/gdk/gdk_utils.h b/gdk/gdk_utils.h
--- a/gdk/gdk_utils.h
+++ b/gdk/gdk_utils.h
@@ -87,23 +87,27 @@ gdk_export gdk_return GDKmunmap(void *ad
 gdk_export size_t GDKmem_cursize(void);        /* RAM/swapmem that MonetDB has 
claimed from OS */
 gdk_export size_t GDKvm_cursize(void); /* current MonetDB VM address space 
usage */
 
+gdk_export void GDKfree(void *blk);
 gdk_export void *GDKmalloc(size_t size)
        __attribute__((__malloc__))
+       __attribute__((__malloc__(GDKfree, 1)))
        __attribute__((__alloc_size__(1)))
        __attribute__((__warn_unused_result__));
 gdk_export void *GDKzalloc(size_t size)
        __attribute__((__malloc__))
+       __attribute__((__malloc__(GDKfree, 1)))
        __attribute__((__alloc_size__(1)))
        __attribute__((__warn_unused_result__));
 gdk_export void *GDKrealloc(void *pold, size_t size)
        __attribute__((__alloc_size__(2)))
        __attribute__((__warn_unused_result__));
-gdk_export void GDKfree(void *blk);
 gdk_export str GDKstrdup(const char *s)
        __attribute__((__malloc__))
+       __attribute__((__malloc__(GDKfree, 1)))
        __attribute__((__warn_unused_result__));
 gdk_export str GDKstrndup(const char *s, size_t n)
        __attribute__((__malloc__))
+       __attribute__((__malloc__(GDKfree, 1)))
        __attribute__((__warn_unused_result__));
 gdk_export size_t GDKmallocated(const void *s);
 
diff --git a/monetdb5/mal/mal_embedded.c b/monetdb5/mal/mal_embedded.c
--- a/monetdb5/mal/mal_embedded.c
+++ b/monetdb5/mal/mal_embedded.c
@@ -117,7 +117,7 @@ malEmbeddedBoot(int workerlimit, int mem
                MT_thread_set_qry_ctx(qc_old);
                return msg;
        }
-       if ((msg = MSinitClientPrg(c, userRef, "main")) != MAL_SUCCEED) {
+       if ((msg = MSinitClientPrg(c, userRef, mainRef)) != MAL_SUCCEED) {
                MCcloseClient(c);
                MT_thread_set_qry_ctx(qc_old);
                return msg;
diff --git a/monetdb5/mal/mal_exception.h b/monetdb5/mal/mal_exception.h
--- a/monetdb5/mal/mal_exception.h
+++ b/monetdb5/mal/mal_exception.h
@@ -45,26 +45,30 @@ enum malexception {
 #define __returns_nonnull__
 #endif
 
+mal_export void freeException(str);
 mal_export str createException(enum malexception, const char *,
                                                           _In_z_ 
_Printf_format_string_ const char *, ...)
-               __attribute__((__format__(__printf__, 3, 4)))
-               __attribute__((__returns_nonnull__));
+       __attribute__((__malloc__))
+       __attribute__((__malloc__(freeException, 1)))
+       __attribute__((__format__(__printf__, 3, 4)))
+       __attribute__((__returns_nonnull__));
 /*FIXmal_export str createMalException(MalBlkPtr mb, int pc, enum malexception 
type, const char *prev, const char *format, ...);*/
 mal_export str createMalException(MalBlkPtr, int, enum malexception,
                                                                  _In_z_ 
_Printf_format_string_ const char *,
                                                                  ...)
-               __attribute__((__format__(__printf__, 4, 5)))
-               __attribute__((__returns_nonnull__));
+       __attribute__((__malloc__))
+       __attribute__((__malloc__(freeException, 1)))
+       __attribute__((__format__(__printf__, 4, 5)))
+       __attribute__((__returns_nonnull__));
 mal_export char *concatErrors(char *err1, const char *err2)
-               __attribute__((__nonnull__(1, 2)))
-               __attribute__((__returns_nonnull__));
+       __attribute__((__nonnull__(1, 2)))
+       __attribute__((__returns_nonnull__));
 mal_export bool isExceptionVariable(const char *nme);
 
 mal_export enum malexception getExceptionType(const char *);
 mal_export str getExceptionPlace(const char *);
 mal_export str getExceptionMessageAndState(const char *);
 mal_export str getExceptionMessage(const char *);
-mal_export void freeException(str);
 
 #include "mal_errors.h"
 #endif /*  _MAL_EXCEPTION_H */
diff --git a/monetdb5/mal/mal_function.c b/monetdb5/mal/mal_function.c
--- a/monetdb5/mal/mal_function.c
+++ b/monetdb5/mal/mal_function.c
@@ -96,7 +96,7 @@ chkFlow(MalBlkPtr mb)
        int endseen = 0, retseen = 0;
        InstrPtr p, sig;
        str msg = MAL_SUCCEED;
-       char name[IDLENGTH] = { 0 };
+       char name[IDLENGTH];
 
        if (mb->errors != MAL_SUCCEED)
                return mb->errors;
@@ -127,11 +127,13 @@ chkFlow(MalBlkPtr mb)
                        break;
                case EXITsymbol:
                        v = getDestVar(p);
-                       if (btop > 0 && var[btop - 1] != v)
+                       if (btop > 0 && var[btop - 1] != v) {
+                               char name2[IDLENGTH];
                                throw(MAL, "chkFlow",
                                          "%s.%s exit-label '%s' does not match 
'%s'",
                                          getModuleId(sig), getFunctionId(sig), 
getVarNameIntoBuffer(mb, v, name),
-                                         getVarNameIntoBuffer(mb, var[btop - 
1], name));
+                                         getVarNameIntoBuffer(mb, var[btop - 
1], name2));
+                       }
                        if (btop == 0)
                                throw(MAL, "chkFlow",
                                          "%s.%s exit-label '%s' without 
begin-label",
@@ -165,9 +167,9 @@ chkFlow(MalBlkPtr mb)
                                if (var[j] == v)
                                        break;
                        if (j < 0) {
-                               str nme = getVarNameIntoBuffer(mb, v, name);
                                throw(MAL, "chkFlow", "%s.%s label '%s' not in 
guarded block",
-                                         getModuleId(sig), getFunctionId(sig), 
nme);
+                                         getModuleId(sig), getFunctionId(sig),
+                                         getVarNameIntoBuffer(mb, v, name));
                        }
                        break;
                case RETURNsymbol: {
@@ -694,7 +696,7 @@ chkDeclarations(MalBlkPtr mb)
        short blks[MAXDEPTH], top = 0, blkId = 1;
        int dflow = -1;
        str msg = MAL_SUCCEED;
-       char name[IDLENGTH] = { 0 };
+       char name[IDLENGTH];
 
        if (mb->errors)
                return GDKstrdup(mb->errors);
diff --git a/monetdb5/mal/mal_import.c b/monetdb5/mal/mal_import.c
--- a/monetdb5/mal/mal_import.c
+++ b/monetdb5/mal/mal_import.c
@@ -348,7 +348,7 @@ compileString(Symbol *fcn, Client cntxt,
                return msg;
        }
 
-       msg = MSinitClientPrg(c, userRef, "main");      /* create new context */
+       msg = MSinitClientPrg(c, userRef, mainRef);     /* create new context */
        if (msg == MAL_SUCCEED)
                msg = MALparser(c);
        /*
diff --git a/monetdb5/mal/mal_instruction.c b/monetdb5/mal/mal_instruction.c
--- a/monetdb5/mal/mal_instruction.c
+++ b/monetdb5/mal/mal_instruction.c
@@ -587,12 +587,11 @@ char *
 getVarNameIntoBuffer(MalBlkPtr mb, int idx, char *buf)
 {
        char *s = mb->var[idx].name;
-       if (getVarKind(mb, idx) == 0)
-               setVarKind(mb, idx, REFMARKER);
        if (s == NULL) {
-               (void) snprintf(buf, IDLENGTH, "%c_%d", getVarKind(mb, idx), 
idx);
+               char kind = getVarKind(mb, idx);
+               (void) snprintf(buf, IDLENGTH, "%c_%d", kind ? kind : 
REFMARKER, idx);
        } else {
-               (void) snprintf(buf, IDLENGTH, "%s", s);
+               strcpy_len(buf, s, IDLENGTH);
        }
        return buf;
 }
diff --git a/monetdb5/mal/mal_instruction.h b/monetdb5/mal/mal_instruction.h
--- a/monetdb5/mal/mal_instruction.h
+++ b/monetdb5/mal/mal_instruction.h
@@ -58,10 +58,9 @@ setFunctionId(InstrPtr p, const char *s)
 #endif
 #define garbageControl(P)      ((P)->gc)
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to