Changeset: b2c166f7bd87 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/b2c166f7bd87
Modified Files:
        clients/mapiclient/dump.c
        gdk/gdk_bat.c
        sql/test/testdb/Tests/dump-nogeom.stable.out
        sql/test/testdb/Tests/dump.stable.out
Branch: default
Log Message:

Merge with Dec2023 branch.


diffs (truncated from 755 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
@@ -3203,6 +3203,123 @@ dump_database(Mapi mid, stream *sqlf, co
        mapi_close_handle(hdl);
        hdl = NULL;
 
+       /* dump views, functions and triggers */
+       if ((hdl = mapi_query(mid, views_functions_triggers)) == NULL ||
+               mapi_error(mid))
+               goto bailout;
+
+       while (rc == 0 &&
+              mnstr_errnr(sqlf) == MNSTR_NO__ERROR &&
+              mapi_fetch_row(hdl) != 0) {
+               char *id = strdup(mapi_fetch_field(hdl, 0));
+               char *schema = strdup(mapi_fetch_field(hdl, 1));
+               char *name = strdup(mapi_fetch_field(hdl, 2));
+               const char *query = mapi_fetch_field(hdl, 3);
+               const char *remark = mapi_fetch_field(hdl, 4);
+
+               if (mapi_error(mid) || id == NULL || schema == NULL || name == 
NULL) {
+                       free(id);
+                       free(schema);
+                       free(name);
+                       goto bailout;
+               }
+               if (sname != NULL && strcmp(schema, sname) != 0) {
+                       free(id);
+                       free(schema);
+                       free(name);
+                       continue;
+               }
+               if (curschema == NULL || strcmp(schema, curschema) != 0) {
+                       if (curschema)
+                               free(curschema);
+                       curschema = strdup(schema);
+                       if (curschema == NULL) {
+                               free(id);
+                               free(schema);
+                               free(name);
+                               goto bailout;
+                       }
+                       mnstr_printf(sqlf, "SET SCHEMA ");
+                       dquoted_print(sqlf, curschema, ";\n");
+               }
+               if (query) {
+                       /* view or trigger */
+                       mnstr_printf(sqlf, "%s\n", query);
+                       /* only views have comments due to query */
+                       comment_on(sqlf, "VIEW", schema, name, NULL, remark);
+               } else {
+                       /* procedure */
+                       dump_functions(mid, sqlf, 0, schema, name, id);
+               }
+               free(id);
+               free(schema);
+               free(name);
+       }
+       mapi_close_handle(hdl);
+       hdl = NULL;
+
+       /* dump DEFAULT clauses for tables */
+       if (dump_table_defaults(mid, NULL, NULL, sqlf))
+               goto bailout2;
+
+       if (!describe) {
+               if (dump_foreign_keys(mid, NULL, NULL, NULL, sqlf))
+                       goto bailout2;
+
+               /* dump sequences, part 2 */
+               if ((hdl = mapi_query(mid, sequences2)) == NULL ||
+                   mapi_error(mid))
+                       goto bailout;
+
+               while (mapi_fetch_row(hdl) != 0) {
+                       const char *schema = mapi_fetch_field(hdl, 0);          
/* sch */
+                       const char *name = mapi_fetch_field(hdl, 1);            
/* seq */
+                       const char *restart = mapi_fetch_field(hdl, 3);         
/* rs */
+                       const char *minvalue;
+                       const char *maxvalue;
+                       const char *increment = mapi_fetch_field(hdl, 6);       
/* inc */
+                       const char *cycle = mapi_fetch_field(hdl, 8);           
/* cycle */
+
+                       if (mapi_get_field_count(hdl) > 9) {
+                               /* new version (Jan2022) of 
sys.describe_sequences */
+                               minvalue = mapi_fetch_field(hdl, 11);           
        /* rmi */
+                               maxvalue = mapi_fetch_field(hdl, 12);           
        /* rma */
+                       } else {
+                               /* old version (pre Jan2022) of 
sys.describe_sequences */
+                               minvalue = mapi_fetch_field(hdl, 4);            
        /* minvalue */
+                               maxvalue = mapi_fetch_field(hdl, 5);            
        /* maxvalue */
+                               if (strcmp(minvalue, "0") == 0)
+                                       minvalue = NULL;
+                               if (strcmp(maxvalue, "0") == 0)
+                                       maxvalue = NULL;
+                       }
+
+                       if (sname != NULL && strcmp(schema, sname) != 0)
+                               continue;
+
+                       mnstr_printf(sqlf,
+                                    "ALTER SEQUENCE ");
+                       dquoted_print(sqlf, schema, ".");
+                       dquoted_print(sqlf, name, NULL);
+                       mnstr_printf(sqlf, " RESTART WITH %s", restart);
+                       if (strcmp(increment, "1") != 0)
+                               mnstr_printf(sqlf, " INCREMENT BY %s", 
increment);
+                       if (minvalue)
+                               mnstr_printf(sqlf, " MINVALUE %s", minvalue);
+                       if (maxvalue)
+                               mnstr_printf(sqlf, " MAXVALUE %s", maxvalue);
+                       mnstr_printf(sqlf, " %sCYCLE;\n", strcmp(cycle, "true") 
== 0 ? "" : "NO ");
+                       if (mnstr_errnr(sqlf) != MNSTR_NO__ERROR) {
+                               mapi_close_handle(hdl);
+                               hdl = NULL;
+                               goto bailout2;
+                       }
+               }
+               if (mapi_error(mid))
+                       goto bailout;
+               mapi_close_handle(hdl);
+       }
+
        /* add tables to MERGE tables */
        if ((hdl = mapi_query(mid, mergetables)) == NULL || mapi_error(mid))
                goto bailout;
@@ -3334,123 +3451,6 @@ dump_database(Mapi mid, stream *sqlf, co
        mapi_close_handle(hdl);
        hdl = NULL;
 
-       /* dump views, functions and triggers */
-       if ((hdl = mapi_query(mid, views_functions_triggers)) == NULL ||
-               mapi_error(mid))
-               goto bailout;
-
-       while (rc == 0 &&
-              mnstr_errnr(sqlf) == MNSTR_NO__ERROR &&
-              mapi_fetch_row(hdl) != 0) {
-               char *id = strdup(mapi_fetch_field(hdl, 0));
-               char *schema = strdup(mapi_fetch_field(hdl, 1));
-               char *name = strdup(mapi_fetch_field(hdl, 2));
-               const char *query = mapi_fetch_field(hdl, 3);
-               const char *remark = mapi_fetch_field(hdl, 4);
-
-               if (mapi_error(mid) || id == NULL || schema == NULL || name == 
NULL) {
-                       free(id);
-                       free(schema);
-                       free(name);
-                       goto bailout;
-               }
-               if (sname != NULL && strcmp(schema, sname) != 0) {
-                       free(id);
-                       free(schema);
-                       free(name);
-                       continue;
-               }
-               if (curschema == NULL || strcmp(schema, curschema) != 0) {
-                       if (curschema)
-                               free(curschema);
-                       curschema = strdup(schema);
-                       if (curschema == NULL) {
-                               free(id);
-                               free(schema);
-                               free(name);
-                               goto bailout;
-                       }
-                       mnstr_printf(sqlf, "SET SCHEMA ");
-                       dquoted_print(sqlf, curschema, ";\n");
-               }
-               if (query) {
-                       /* view or trigger */
-                       mnstr_printf(sqlf, "%s\n", query);
-                       /* only views have comments due to query */
-                       comment_on(sqlf, "VIEW", schema, name, NULL, remark);
-               } else {
-                       /* procedure */
-                       dump_functions(mid, sqlf, 0, schema, name, id);
-               }
-               free(id);
-               free(schema);
-               free(name);
-       }
-       mapi_close_handle(hdl);
-       hdl = NULL;
-
-       /* dump DEFAULT clauses for tables */
-       if (dump_table_defaults(mid, NULL, NULL, sqlf))
-               goto bailout2;
-
-       if (!describe) {
-               if (dump_foreign_keys(mid, NULL, NULL, NULL, sqlf))
-                       goto bailout2;
-
-               /* dump sequences, part 2 */
-               if ((hdl = mapi_query(mid, sequences2)) == NULL ||
-                   mapi_error(mid))
-                       goto bailout;
-
-               while (mapi_fetch_row(hdl) != 0) {
-                       const char *schema = mapi_fetch_field(hdl, 0);          
/* sch */
-                       const char *name = mapi_fetch_field(hdl, 1);            
/* seq */
-                       const char *restart = mapi_fetch_field(hdl, 3);         
/* rs */
-                       const char *minvalue;
-                       const char *maxvalue;
-                       const char *increment = mapi_fetch_field(hdl, 6);       
/* inc */
-                       const char *cycle = mapi_fetch_field(hdl, 8);           
/* cycle */
-
-                       if (mapi_get_field_count(hdl) > 9) {
-                               /* new version (Jan2022) of 
sys.describe_sequences */
-                               minvalue = mapi_fetch_field(hdl, 11);           
        /* rmi */
-                               maxvalue = mapi_fetch_field(hdl, 12);           
        /* rma */
-                       } else {
-                               /* old version (pre Jan2022) of 
sys.describe_sequences */
-                               minvalue = mapi_fetch_field(hdl, 4);            
        /* minvalue */
-                               maxvalue = mapi_fetch_field(hdl, 5);            
        /* maxvalue */
-                               if (strcmp(minvalue, "0") == 0)
-                                       minvalue = NULL;
-                               if (strcmp(maxvalue, "0") == 0)
-                                       maxvalue = NULL;
-                       }
-
-                       if (sname != NULL && strcmp(schema, sname) != 0)
-                               continue;
-
-                       mnstr_printf(sqlf,
-                                    "ALTER SEQUENCE ");
-                       dquoted_print(sqlf, schema, ".");
-                       dquoted_print(sqlf, name, NULL);
-                       mnstr_printf(sqlf, " RESTART WITH %s", restart);
-                       if (strcmp(increment, "1") != 0)
-                               mnstr_printf(sqlf, " INCREMENT BY %s", 
increment);
-                       if (minvalue)
-                               mnstr_printf(sqlf, " MINVALUE %s", minvalue);
-                       if (maxvalue)
-                               mnstr_printf(sqlf, " MAXVALUE %s", maxvalue);
-                       mnstr_printf(sqlf, " %sCYCLE;\n", strcmp(cycle, "true") 
== 0 ? "" : "NO ");
-                       if (mnstr_errnr(sqlf) != MNSTR_NO__ERROR) {
-                               mapi_close_handle(hdl);
-                               hdl = NULL;
-                               goto bailout2;
-                       }
-               }
-               if (mapi_error(mid))
-                       goto bailout;
-               mapi_close_handle(hdl);
-       }
-
        if ((hdl = mapi_query(mid, table_grants)) == NULL || mapi_error(mid))
                goto bailout;
 
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -1702,10 +1702,13 @@ BUNinplacemulti(BAT *b, const oid *posit
                        default:
                                MT_UNREACHABLE();
                        }
+                       MT_lock_set(&b->theaplock);
                        if (ATOMreplaceVAR(b, &_d, t) != GDK_SUCCEED) {
+                               MT_lock_unset(&b->theaplock);
                                MT_rwlock_wrunlock(&b->thashlock);
                                goto bailout;
                        }
+                       MT_lock_unset(&b->theaplock);
                        if (b->twidth < SIZEOF_VAR_T &&
                            (b->twidth <= 2 ? _d - GDK_VAROFFSET : _d) >= 
((size_t) 1 << (8 << b->tshift))) {
                                /* doesn't fit in current heap, upgrade it */
diff --git a/sql/test/testdb-previous-upgrade-hge/Tests/dump.stable.out 
b/sql/test/testdb-previous-upgrade-hge/Tests/dump.stable.out
--- a/sql/test/testdb-previous-upgrade-hge/Tests/dump.stable.out
+++ b/sql/test/testdb-previous-upgrade-hge/Tests/dump.stable.out
@@ -101349,21 +101349,6 @@ CREATE TABLE "testschema"."geomtest" (
 COPY 2 RECORDS INTO "testschema"."geomtest" FROM stdin USING DELIMITERS 
E'\t',E'\n','"';
 POINT (10.5 12.3)      LINESTRING (10 10, 20 20, 30 40)        LINESTRING (10 
10, 20 20, 30 40)        POLYGON ((10 10, 10 20, 20 20, 20 15, 10 10))   
POLYGON ((10 10, 10 20, 20 20, 20 15, 10 10))   MULTIPOINT ((20 80), (110 160), 
(20 160))       MULTILINESTRING ((0 0, 0 80, 60 80, 60 0, 0 0)) MULTILINESTRING 
((0 0, 0 80, 60 80, 60 0, 0 0)) MULTIPOLYGON (((140 110, 260 110, 170 20, 50 
20, 140 110)), ((300 270, 420 270, 340 190, 220 190, 300 270)))    MULTIPOLYGON 
(((140 110, 260 110, 170 20, 50 20, 140 110)), ((300 270, 420 270, 340 190, 220 
190, 300 270)))    POLYGON ((10 10, 10 20, 20 20, 20 15, 10 10))   
GEOMETRYCOLLECTION (POLYGON ((0 0, 0 100, 100 100, 100 0, 0 0)), LINESTRING (10 
10, 20 20, 30 40))      BOX (10.000000 10.000000, 20.000000 20.000000)
 NULL   NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    
NULL    NULL    NULL
-ALTER TABLE "testschema"."testme" ADD TABLE "testschema"."subtable1" AS 
PARTITION FROM RANGE MINVALUE TO '11' WITH NULL VALUES;
-ALTER TABLE "testschema"."testme" ADD TABLE "testschema"."subtable2" AS 
PARTITION FROM '11' TO '20';
-ALTER TABLE "testschema"."testme" ADD TABLE "testschema"."subtable3" AS 
PARTITION FROM '21' TO RANGE MAXVALUE;
-ALTER TABLE "testschema"."testme2" ADD TABLE "testschema"."subtable4" AS 
PARTITION FROM RANGE MINVALUE TO RANGE MAXVALUE;
-ALTER TABLE "testschema"."testme2" ADD TABLE "testschema"."subtable5" AS 
PARTITION FOR NULL VALUES;
-ALTER TABLE "testschema"."testme3" ADD TABLE "testschema"."subtable6" AS 
PARTITION FROM RANGE MINVALUE TO RANGE MAXVALUE WITH NULL VALUES;
-ALTER TABLE "testschema"."testvaluespartitions" ADD TABLE 
"testschema"."sublimits1" AS PARTITION IN ('1', '2', '3');
-ALTER TABLE "testschema"."testvaluespartitions" ADD TABLE 
"testschema"."sublimits2" AS PARTITION IN ('4', '5', '6') WITH NULL VALUES;
-ALTER TABLE "testschema"."testvaluespartitions" ADD TABLE 
"testschema"."sublimits3" AS PARTITION IN ('7', '8', '9');
-ALTER TABLE "testschema"."mt3" ADD TABLE "testschema"."mt1";
-ALTER TABLE "testschema"."mt3" ADD TABLE "testschema"."t4";
-ALTER TABLE "testschema"."mt2" ADD TABLE "testschema"."t1";
-ALTER TABLE "testschema"."mt2" ADD TABLE "testschema"."t3";
-ALTER TABLE "testschema"."mt1" ADD TABLE "testschema"."t1";
-ALTER TABLE "testschema"."mt1" ADD TABLE "testschema"."t2";
 create view keytest3 as select t2.key1, t2.key2, t1.key3 from keytest1 t1, 
keytest2 t2 where t1.key1 = t2.key1 and t1.key2 = t2.key2
 ;
 COMMENT ON VIEW "testschema"."keytest3" IS 'a view used for testing';
@@ -101445,6 +101430,21 @@ ALTER TABLE "testschema"."keytest2" ADD 
 ALTER TABLE "testschema"."selfref" ADD CONSTRAINT "selfref_parentid_fkey" 
FOREIGN KEY ("parentid") REFERENCES "testschema"."selfref" ("id");
 ALTER SEQUENCE "testschema"."selfref_seq" RESTART WITH 7 NO CYCLE;
 ALTER SEQUENCE "testschema"."test_seq" RESTART WITH 8 INCREMENT BY 3 MINVALUE 
5 MAXVALUE 10 CYCLE;
+ALTER TABLE "testschema"."testme" ADD TABLE "testschema"."subtable1" AS 
PARTITION FROM RANGE MINVALUE TO '11' WITH NULL VALUES;
+ALTER TABLE "testschema"."testme" ADD TABLE "testschema"."subtable2" AS 
PARTITION FROM '11' TO '20';
+ALTER TABLE "testschema"."testme" ADD TABLE "testschema"."subtable3" AS 
PARTITION FROM '21' TO RANGE MAXVALUE;
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to