Changeset: 82bbe62ddfc8 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/82bbe62ddfc8
Modified Files:
clients/mapiclient/dump.c
clients/mapiclient/mclient.c
clients/mapilib/mapi.c
common/stream/stdio_stream.c
gdk/gdk_heap.c
geom/monetdb5/geom.c
monetdb5/modules/atoms/str.c
monetdb5/modules/kernel/batstr.c
sql/backends/monet5/UDF/capi/capi.c
sql/backends/monet5/sql.c
sql/backends/monet5/sql_bincopy.c
sql/backends/monet5/sql_bincopyconvert.c
sql/backends/monet5/sql_scenario.c
sql/backends/monet5/sql_upgrades.c
sql/backends/monet5/vaults/csv/csv.c
sql/backends/monet5/vaults/odbc/odbc_loader.c
sql/server/sql_semantic.c
sql/server/sqlparse.c
sql/storage/store.c
tools/merovingian/client/monetdb.c
tools/merovingian/daemon/handlers.c
tools/monetdbe/monetdbe.c
tools/mserver/mserver5.c
Branch: Mar2025
Log Message:
Constant, arrays initialized with fixed values don't have to be on the stack.
diffs (truncated from 944 to 300 lines):
diff --git a/clients/mapiclient/dump.c b/clients/mapiclient/dump.c
--- a/clients/mapiclient/dump.c
+++ b/clients/mapiclient/dump.c
@@ -2637,9 +2637,9 @@ bailout:
int
dump_database(Mapi mid, stream *sqlf, const char *ddir, const char *ext, bool
describe, bool useInserts, bool noescape)
{
- const char start_trx[] = "START TRANSACTION";
- const char end[] = "ROLLBACK";
- const char types[] =
+ static const char start_trx[] = "START TRANSACTION";
+ static const char end[] = "ROLLBACK";
+ static const char types[] =
"SELECT s.name, "
"t.systemname, "
"t.sqlname "
@@ -2678,13 +2678,13 @@ dump_database(Mapi mid, stream *sqlf, co
"AND ui.name <> 'monetdb' "
"AND ui.name <> '.snapshot' "
"ORDER BY ui.name";
- const char roles[] =
+ static const char roles[] =
"SELECT name "
"FROM sys.auths "
"WHERE name NOT IN (SELECT name FROM sys.db_user_info) "
"AND grantor <> 0 "
"ORDER BY name";
- const char grants[] =
+ static const char grants[] =
/* all grants granting roles to users excepting the default
role */
"SELECT a1.name, "
"a2.name "
@@ -2697,7 +2697,7 @@ dump_database(Mapi mid, stream *sqlf, co
"AND a1.name = ui.name "
"AND a2.id <> ui.default_role "
"ORDER BY a1.name, a2.name";
- const char table_grants[] =
+ static const char table_grants[] =
"SELECT s.name, t.name, "
"a.name, "
"sum(p.privileges), "
@@ -2714,7 +2714,7 @@ dump_database(Mapi mid, stream *sqlf, co
"AND p.grantable = go.id "
"GROUP BY s.name, t.name, a.name, g.name, go.opt "
"ORDER BY s.name, t.name, a.name, g.name, go.opt";
- const char column_grants[] =
+ static const char column_grants[] =
"SELECT s.name, t.name, "
"c.name, a.name, "
"pc.privilege_code_name, "
@@ -2736,7 +2736,7 @@ dump_database(Mapi mid, stream *sqlf, co
"AND p.privileges = pc.privilege_code_id "
"AND p.grantable = go.id "
"ORDER BY s.name, t.name, c.name, a.name, g.name, p.grantable";
- const char function_grants[] =
+ static const char function_grants[] =
"SELECT f.id, "
"s.name, "
"f.name, "
@@ -2773,7 +2773,7 @@ dump_database(Mapi mid, stream *sqlf, co
"f.id, "
"a.inout DESC, "
"a.number";
- const char global_grants[] =
+ static const char global_grants[] =
"SELECT a.name, pc.grnt, g.name, go.opt "
"FROM sys.privileges p, "
"sys.auths a, "
@@ -2786,22 +2786,22 @@ dump_database(Mapi mid, stream *sqlf, co
"AND p.privileges = pc.id "
"AND p.grantable = go.id "
"ORDER BY a.name, g.name, go.opt";
- const char schemas[] =
+ static const char schemas[] =
"SELECT s.name, a.name, rem.remark "
"FROM sys.schemas s LEFT OUTER JOIN sys.comments rem ON s.id =
rem.id, "
"sys.auths a "
"WHERE s.\"authorization\" = a.id "
"AND s.system = FALSE "
"ORDER BY s.name";
- const char sequences1[] =
+ static const char sequences1[] =
"SELECT sch.name, seq.name, rem.remark "
"FROM sys.schemas sch, "
"sys.sequences seq LEFT OUTER JOIN sys.comments rem ON
seq.id = rem.id "
"WHERE sch.id = seq.schema_id "
"ORDER BY sch.name, seq.name";
- const char sequences2[] =
+ static const char sequences2[] =
"SELECT * FROM sys.describe_sequences ORDER BY sch, seq";
- const char tables[] =
+ static const char tables[] =
"SELECT t.id AS id, "
"s.name AS sname, "
"t.name AS name, "
@@ -2812,7 +2812,7 @@ dump_database(Mapi mid, stream *sqlf, co
"AND t.system = FALSE "
"AND s.id = t.schema_id "
"ORDER BY id";
- const char mergetables[] =
+ static const char mergetables[] =
"SELECT subq.s1name, "
"subq.t1name, "
"subq.s2name, "
@@ -2841,7 +2841,7 @@ dump_database(Mapi mid, stream *sqlf, co
"ON subq.id = table_partitions.table_id";
/* we must dump views, functions/procedures and triggers in order
* of creation since they can refer to each other */
- const char views_functions_triggers[] =
+ static const char views_functions_triggers[] =
"with vft (sname, name, id, query, remark) AS ("
"SELECT s.name AS sname, " /* views */
"t.name AS name, "
diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -2533,7 +2533,7 @@ doFile(Mapi mid, stream *fp, bool useins
}
if (x & MD_MERGE) {
- const char mquery[] = "select
s1.name as s1name,"
+ static const char mquery[] =
"select s1.name as s1name,"
" t1.name as t1name,"
" c1.name as c1name,"
" s2.name as s2name,"
@@ -2706,7 +2706,7 @@ doFile(Mapi mid, stream *fp, bool useins
}
if (x &
(MD_TABLE|MD_VIEW|MD_SEQ|MD_FUNC|MD_SCHEMA)) {
/* get all object names in
current schema */
- const char with_clause[] =
+ static const char with_clause[]
=
"with
describe_all_objects AS (\n"
" SELECT s.name AS
sname,\n"
" t.name,\n"
diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c
--- a/clients/mapilib/mapi.c
+++ b/clients/mapilib/mapi.c
@@ -1271,7 +1271,7 @@ mapi_impl_log_record(Mapi mid, const cha
void
mapi_impl_log_data(Mapi mid, const char *filename, long line, const char
*mark, const char *start, size_t len)
{
- const char hexdigits[] = "0123456789abcdef";
+ static const char hexdigits[] = "0123456789abcdef";
if (mid->tracelog == NULL)
return;
diff --git a/common/stream/stdio_stream.c b/common/stream/stdio_stream.c
--- a/common/stream/stdio_stream.c
+++ b/common/stream/stdio_stream.c
@@ -289,7 +289,7 @@ file_wstream(FILE *restrict fp, bool bin
stream *
stdin_rastream(void)
{
- const char name[] = "<stdin>";
+ static const char name[] = "<stdin>";
// Make an attempt to skip a BOM marker.
// It would be nice to integrate this with with the BOM removal code
// in text_stream.c but that is complicated. In text_stream,
@@ -320,7 +320,7 @@ stdin_rastream(void)
stream *
stdout_wastream(void)
{
- const char name[] = "<stdout>";
+ static const char name[] = "<stdout>";
#ifdef _MSC_VER
if (isatty(fileno(stdout)))
return win_console_out_stream(name);
@@ -331,7 +331,7 @@ stdout_wastream(void)
stream *
stderr_wastream(void)
{
- const char name[] = "<stderr>";
+ static const char name[] = "<stderr>";
#ifdef _MSC_VER
if (isatty(fileno(stderr)))
return win_console_out_stream(name);
diff --git a/gdk/gdk_heap.c b/gdk/gdk_heap.c
--- a/gdk/gdk_heap.c
+++ b/gdk/gdk_heap.c
@@ -720,7 +720,7 @@ HEAPload(Heap *h, const char *nme, const
int ret = 0;
char srcpath[MAXPATH], dstpath[MAXPATH];
lng t0;
- const char suffix[] = ".new";
+ static const char suffix[] = ".new";
if (h->storage == STORE_INVALID || h->newstorage == STORE_INVALID) {
size_t allocated;
@@ -841,7 +841,7 @@ HEAPsave(Heap *h, const char *nme, const
storage_t store = h->newstorage;
long_str extension;
gdk_return rc;
- const char suffix[] = ".new";
+ static const char suffix[] = ".new";
if (h->base == NULL) {
GDKerror("no heap to save\n");
diff --git a/geom/monetdb5/geom.c b/geom/monetdb5/geom.c
--- a/geom/monetdb5/geom.c
+++ b/geom/monetdb5/geom.c
@@ -2078,7 +2078,7 @@ dumpPointsPolygon(BAT *idBAT, BAT *geomB
const int lvlDigitsNum = 10; //MAX_UNIT = 4,294,967,295
size_t pathLength = strlen(path);
char *newPath;
- const char extraStr[] = ",";
+ static const char extraStr[] = ",";
int extraLength = 1;
//get the exterior ring of the polygon
@@ -2133,7 +2133,7 @@ dumpPointsMultiGeometry(BAT *idBAT, BAT
unsigned int lvl = 0;
size_t pathLength = strlen(path);
char *newPath = NULL;
- const char extraStr[] = ",";
+ static const char extraStr[] = ",";
int extraLength = 1;
geometriesNum = GEOSGetNumGeometries_r(geoshandle, geosGeometry);
@@ -2648,7 +2648,7 @@ wkbAsText(char **txt, wkb **geomWKB, int
{
size_t len = 0;
char *wkt = NULL;
- const char sridTxt[] = "SRID:";
+ static const char sridTxt[] = "SRID:";
if (is_wkb_nil(*geomWKB) || (withSRID && is_int_nil(*withSRID))) {
if ((*txt = GDKstrdup(str_nil)) == NULL)
diff --git a/monetdb5/modules/atoms/str.c b/monetdb5/modules/atoms/str.c
--- a/monetdb5/modules/atoms/str.c
+++ b/monetdb5/modules/atoms/str.c
@@ -1790,7 +1790,8 @@ STRspace(str *res, const int *ll)
if (is_int_nil(l) || l < 0) {
*res = GDKstrdup(str_nil);
} else {
- const char space[] = " ", *s = space;
+ static const char space[] = " ";
+ const char *s = space;
size_t buflen = INITIAL_STR_BUFFER_LENGTH;
*res = NULL;
diff --git a/monetdb5/modules/kernel/batstr.c b/monetdb5/modules/kernel/batstr.c
--- a/monetdb5/modules/kernel/batstr.c
+++ b/monetdb5/modules/kernel/batstr.c
@@ -332,7 +332,8 @@ STRbatSpace(Client cntxt, MalBlkPtr mb,
int *restrict vals, x;
str buf = GDKmalloc(buflen), msg = MAL_SUCCEED;
bool nils = false;
- const char space[] = " ", *s = space;
+ static const char space[] = " ";
+ const char *s = space;
struct canditer ci1 = { 0 };
oid off1;
bat *res = getArgReference_bat(stk, pci, 0),
diff --git a/sql/backends/monet5/UDF/capi/capi.c
b/sql/backends/monet5/UDF/capi/capi.c
--- a/sql/backends/monet5/UDF/capi/capi.c
+++ b/sql/backends/monet5/UDF/capi/capi.c
@@ -481,7 +481,7 @@ static str CUDFeval(Client cntxt, MalBlk
:
JIT_CPP_COMPILER_NAME)
: (GDKgetenv(cc_flag) ? GDKgetenv(cc_flag) :
JIT_COMPILER_NAME);
- const char struct_prefix[] = "struct cudf_data_struct_";
+ static const char struct_prefix[] = "struct cudf_data_struct_";
const char *funcname;
BUN expression_hash = 0, funcname_hash = 0;
@@ -674,7 +674,7 @@ static str CUDFeval(Client cntxt, MalBlk
// we place the temporary files in the TEMPDIR directory
// because this will be removed again upon server startup
const int RANDOM_NAME_SIZE = 32;
- const char prefix[] = TEMPDIR_NAME DIR_SEP_STR;
+ static const char prefix[] = TEMPDIR_NAME DIR_SEP_STR;
size_t prefix_size = strlen(prefix);
char tempdirpath[MAXPATH];
diff --git a/sql/backends/monet5/sql.c b/sql/backends/monet5/sql.c
--- a/sql/backends/monet5/sql.c
+++ b/sql/backends/monet5/sql.c
@@ -350,7 +350,7 @@ create_table_or_view(mvc *sql, char *sna
if (c->def) {
/* TODO please don't place an auto incremented sequence
in the default value */
- const char next_value_for[] = "next value for
\"sys\".\"seq_";
+ static const char next_value_for[] = "next value for
\"sys\".\"seq_";
sql_rel *r = NULL;
sa_reset(nsa);
@@ -1987,7 +1987,7 @@ mvc_clear_table_wrap(Client cntxt, MalBl
throw(SQL, "sql.clear_table", SQLSTATE(42000) "Table clear
failed%s", clear_res == (BUN_NONE - 1) ? " due to conflict with another
transaction" : "");
if (restart_sequences) { /* restart the sequences if it's the case */
sql_trans *tr = m->session->tr;
- const char next_value_for[] = "next value for ";
+ static const char next_value_for[] = "next value for ";
for (node *n = ol_first_node(t->columns); n; n = n->next) {
sql_column *col = n->data;
diff --git a/sql/backends/monet5/sql_bincopy.c
b/sql/backends/monet5/sql_bincopy.c
--- a/sql/backends/monet5/sql_bincopy.c
+++ b/sql/backends/monet5/sql_bincopy.c
@@ -34,7 +34,7 @@
static str
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]