execsql2 2.30.0__py3-none-any.whl → 2.31.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- execsql/api.py +1 -0
- execsql/cli/application.py +1 -1
- execsql/cli/commands/lint.py +1 -1
- execsql/cli/dsn.py +35 -1
- execsql/cli/lint.py +10 -1
- execsql/cli/run.py +8 -3
- execsql/config.py +26 -4
- execsql/data/execsql.conf.template +8 -2
- execsql/db/access.py +9 -5
- execsql/db/base.py +18 -0
- execsql/db/dsn.py +3 -0
- execsql/db/factory.py +11 -1
- execsql/db/mysql.py +56 -3
- execsql/db/odbc.py +62 -0
- execsql/db/postgres.py +1 -1
- execsql/db/sqlserver.py +39 -21
- execsql/exporters/ods.py +146 -41
- execsql/exporters/values.py +166 -9
- execsql/importers/base.py +1 -1
- execsql/importers/csv.py +1 -1
- execsql/importers/ods.py +2 -0
- execsql/lsp/diagnostics.py +1 -1
- execsql/lsp/document.py +3 -0
- execsql/metacommands/io_fileops.py +11 -5
- execsql/metacommands/reference.py +1 -1
- execsql/metacommands/upsert.py +10 -1
- execsql/utils/auth.py +21 -14
- execsql/utils/errors.py +1 -1
- execsql/utils/paths.py +31 -0
- {execsql2-2.30.0.data → execsql2-2.31.2.data}/data/execsql2_extras/README.md +9 -8
- {execsql2-2.30.0.data → execsql2-2.31.2.data}/data/execsql2_extras/md_compare.sql +53 -29
- {execsql2-2.30.0.data → execsql2-2.31.2.data}/data/execsql2_extras/md_glossary.sql +20 -20
- {execsql2-2.30.0.data → execsql2-2.31.2.data}/data/execsql2_extras/md_upsert.sql +59 -66
- {execsql2-2.30.0.data → execsql2-2.31.2.data}/data/execsql2_extras/pg_compare.sql +19 -22
- {execsql2-2.30.0.data → execsql2-2.31.2.data}/data/execsql2_extras/pg_glossary.sql +13 -17
- {execsql2-2.30.0.data → execsql2-2.31.2.data}/data/execsql2_extras/script_template.sql +302 -299
- {execsql2-2.30.0.data → execsql2-2.31.2.data}/data/execsql2_extras/ss_compare.sql +39 -29
- {execsql2-2.30.0.data → execsql2-2.31.2.data}/data/execsql2_extras/ss_glossary.sql +13 -17
- {execsql2-2.30.0.data → execsql2-2.31.2.data}/data/execsql2_extras/ss_upsert.sql +56 -66
- {execsql2-2.30.0.dist-info → execsql2-2.31.2.dist-info}/METADATA +17 -41
- {execsql2-2.30.0.dist-info → execsql2-2.31.2.dist-info}/RECORD +48 -47
- execsql2-2.30.0.data/data/execsql2_extras/pg_upsert.sql +0 -2791
- {execsql2-2.30.0.data → execsql2-2.31.2.data}/data/execsql2_extras/config_settings.sqlite +0 -0
- {execsql2-2.30.0.data → execsql2-2.31.2.data}/data/execsql2_extras/example_config_prompt.sql +0 -0
- {execsql2-2.30.0.data → execsql2-2.31.2.data}/data/execsql2_extras/make_config_db.sql +0 -0
- {execsql2-2.30.0.dist-info → execsql2-2.31.2.dist-info}/WHEEL +0 -0
- {execsql2-2.30.0.dist-info → execsql2-2.31.2.dist-info}/entry_points.txt +0 -0
- {execsql2-2.30.0.dist-info → execsql2-2.31.2.dist-info}/licenses/LICENSE.txt +0 -0
- {execsql2-2.30.0.dist-info → execsql2-2.31.2.dist-info}/licenses/NOTICE +0 -0
|
@@ -89,6 +89,7 @@
|
|
|
89
89
|
-- AUTHORS
|
|
90
90
|
-- Dreas Nielsen (RDN)
|
|
91
91
|
-- Elizabeth Shea (ES)
|
|
92
|
+
-- Caleb Grant (CG)
|
|
92
93
|
--
|
|
93
94
|
-- VERSION
|
|
94
95
|
-- 2.0.0
|
|
@@ -145,6 +146,14 @@
|
|
|
145
146
|
-- 2020-04-28 Explicitly rolled back the changes if 'do_commit' = "No". RDN.
|
|
146
147
|
-- 2020-05-09 Moved the assignment of 'upsert_progress_denom' out of the
|
|
147
148
|
-- 'update_console_qa' script. RDN.
|
|
149
|
+
-- 2026-10-15 execsql2: casts are CHAR (MySQL 8 rejects VARCHAR in CAST); the
|
|
150
|
+
-- duplicate primary key check's view has its AS; LOAD_STAGING
|
|
151
|
+
-- halts on do_commit=No, which MySQL/MariaDB cannot roll back
|
|
152
|
+
-- because the load's CREATE and DROP statements commit; each
|
|
153
|
+
-- script's notes are its docstring (SHOW SCRIPTS, the language
|
|
154
|
+
-- server). Comments inside SQL statements have a space after
|
|
155
|
+
-- --, which MySQL and MariaDB require (UPDTPK_ONE failed).
|
|
156
|
+
-- Tested in tests/templates of the execsql2 repository. CG.
|
|
148
157
|
-- ==================================================================
|
|
149
158
|
|
|
150
159
|
|
|
@@ -152,7 +161,7 @@
|
|
|
152
161
|
-- ################################################################
|
|
153
162
|
-- Script VALIDATE_ONE
|
|
154
163
|
-- ===============================================================
|
|
155
|
-
--
|
|
164
|
+
-- !x! BEGIN SCRIPT VALIDATE_ONE with parameters (stage_pfx, table, script, script_line)
|
|
156
165
|
-- Utility script to validate both base and staging versions of one table.
|
|
157
166
|
-- Halts script processing if either of the tables are not present.
|
|
158
167
|
--
|
|
@@ -164,8 +173,6 @@
|
|
|
164
173
|
-- (for error reporting).
|
|
165
174
|
-- script_line : The script line in which they were referenced
|
|
166
175
|
-- (for error reporting).
|
|
167
|
-
-- ===============================================================
|
|
168
|
-
-- !x! BEGIN SCRIPT VALIDATE_ONE with parameters (stage_pfx, table, script, script_line)
|
|
169
176
|
|
|
170
177
|
-- Initialize the strings used to compile error information
|
|
171
178
|
-- !x! sub_empty ~err_info
|
|
@@ -233,7 +240,7 @@ having count(*) > 0
|
|
|
233
240
|
-- ################################################################
|
|
234
241
|
-- Script VALIDATE_CONTROL
|
|
235
242
|
-- ===============================================================
|
|
236
|
-
--
|
|
243
|
+
-- !x! BEGIN SCRIPT VALIDATE_CONTROL with parameters (stage_pfx, control_table, script, script_line)
|
|
237
244
|
-- Utility script to validate contents of control table against about
|
|
238
245
|
-- base and staging schema
|
|
239
246
|
--
|
|
@@ -246,8 +253,6 @@ having count(*) > 0
|
|
|
246
253
|
-- (for error reporting).
|
|
247
254
|
-- script_line : The script line in which they were referenced
|
|
248
255
|
-- (for error reporting).
|
|
249
|
-
-- ===============================================================
|
|
250
|
-
-- !x! BEGIN SCRIPT VALIDATE_CONTROL with parameters (stage_pfx, control_table, script, script_line)
|
|
251
256
|
|
|
252
257
|
-- Initialize the strings used to compile error information
|
|
253
258
|
-- !x! sub_empty ~err_info
|
|
@@ -341,7 +346,7 @@ having count(*) > 0
|
|
|
341
346
|
-- ################################################################
|
|
342
347
|
-- Script STAGED_TO_LOAD
|
|
343
348
|
-- ===============================================================
|
|
344
|
-
--
|
|
349
|
+
-- !x! BEGIN SCRIPT STAGED_TO_LOAD with parameters (control_table, table_list)
|
|
345
350
|
-- Creates a table having the structure that is used to drive other
|
|
346
351
|
-- scripts that perform QA checks and the upsert operation on multiple
|
|
347
352
|
-- staging tables.
|
|
@@ -400,9 +405,6 @@ having count(*) > 0
|
|
|
400
405
|
--
|
|
401
406
|
-- Example:
|
|
402
407
|
-- -- !x! execute script staged_to_load with (control_table=stagingtables, table_list="tbla, tblb, tblc")
|
|
403
|
-
-- ===============================================================
|
|
404
|
-
|
|
405
|
-
-- !x! BEGIN SCRIPT STAGED_TO_LOAD with parameters (control_table, table_list)
|
|
406
408
|
|
|
407
409
|
drop table if exists !!#control_table!! cascade;
|
|
408
410
|
|
|
@@ -447,7 +449,7 @@ from itemtable;
|
|
|
447
449
|
-- ################################################################
|
|
448
450
|
-- Script LOAD_STAGING
|
|
449
451
|
-- ===============================================================
|
|
450
|
-
--
|
|
452
|
+
-- !x! BEGIN SCRIPT LOAD_STAGING with parameters (stage_pfx, control_table, do_commit)
|
|
451
453
|
-- Performs QA checks for nulls in non-null columns, for duplicated
|
|
452
454
|
-- primary key values, and for invalid foreign keys in a set of staging
|
|
453
455
|
-- tables to be loaded into base tables. If there are failures in the
|
|
@@ -473,8 +475,10 @@ from itemtable;
|
|
|
473
475
|
-- (e.g., "stg_").
|
|
474
476
|
-- control_table : The name of a table as created by the
|
|
475
477
|
-- script STAGED_TO_LOAD.
|
|
476
|
-
-- do_commit :
|
|
477
|
-
-- the
|
|
478
|
+
-- do_commit : Must be 'Yes'. MySQL and MariaDB commit at every
|
|
479
|
+
-- CREATE and DROP, which the load runs, so a load
|
|
480
|
+
-- cannot be rolled back; 'No' halts before anything
|
|
481
|
+
-- changes. Run QA_ALL to check without loading.
|
|
478
482
|
-- Global variables:
|
|
479
483
|
-- logfile : The name of a log file to which error
|
|
480
484
|
-- messages will be written. Optional.
|
|
@@ -491,9 +495,16 @@ from itemtable;
|
|
|
491
495
|
--
|
|
492
496
|
-- Tables and views created or modified:
|
|
493
497
|
-- ups_qa_fails : view
|
|
494
|
-
-- ===============================================================
|
|
495
498
|
|
|
496
|
-
--
|
|
499
|
+
-- MySQL and MariaDB commit at every CREATE and DROP, and the load creates and
|
|
500
|
+
-- drops tables and views, so it cannot be rolled back: refuse a dry run rather
|
|
501
|
+
-- than commit one.
|
|
502
|
+
-- !x! if(not is_true(!!#do_commit!!))
|
|
503
|
+
-- !x! sub ~message LOAD_STAGING cannot run with do_commit=!!#do_commit!! on MySQL or MariaDB:
|
|
504
|
+
-- !x! sub_append ~message the load creates tables and views, which commit, so its changes cannot be rolled back.
|
|
505
|
+
-- !x! sub_append ~message Run QA_ALL to check the staging tables without loading them.
|
|
506
|
+
-- !x! halt message "!!~message!!"
|
|
507
|
+
-- !x! endif
|
|
497
508
|
|
|
498
509
|
-- Clear the columns of return values from the control table, in case this control
|
|
499
510
|
-- table has been used previously.
|
|
@@ -555,7 +566,7 @@ drop view if exists ups_qa_fails cascade;
|
|
|
555
566
|
-- ################################################################
|
|
556
567
|
-- Script NULLQA_ONE
|
|
557
568
|
-- ===============================================================
|
|
558
|
-
--
|
|
569
|
+
-- !x! BEGIN SCRIPT NULLQA_ONE with parameters (stage_pfx, table, error_list)
|
|
559
570
|
-- Checks that non-nullable columns are fully populated in a
|
|
560
571
|
-- staging table that is an image of the base table.
|
|
561
572
|
-- Reports any non-conforming columns to the console and optionally
|
|
@@ -584,9 +595,6 @@ drop view if exists ups_qa_fails cascade;
|
|
|
584
595
|
-- ups_next_column : view
|
|
585
596
|
-- ups_null_error_list : view
|
|
586
597
|
-- ups_qa_nonnull_col : view
|
|
587
|
-
-- ===============================================================
|
|
588
|
-
|
|
589
|
-
-- !x! BEGIN SCRIPT NULLQA_ONE with parameters (stage_pfx, table, error_list)
|
|
590
598
|
|
|
591
599
|
-- Write an initial header to the logfile.
|
|
592
600
|
-- !x! if(sub_defined(logfile))
|
|
@@ -643,7 +651,7 @@ limit 1;
|
|
|
643
651
|
-- Create the return value.
|
|
644
652
|
create or replace view ups_null_error_list as
|
|
645
653
|
select
|
|
646
|
-
group_concat(concat(column_name, ' (', cast(null_rows as
|
|
654
|
+
group_concat(concat(column_name, ' (', cast(null_rows as char(100)), ')') separator ', ') as null_errors
|
|
647
655
|
from
|
|
648
656
|
ups_nonnull_columns
|
|
649
657
|
where
|
|
@@ -716,7 +724,8 @@ drop table if exists ups_nonnull_columns cascade;
|
|
|
716
724
|
|
|
717
725
|
-- ################################################################
|
|
718
726
|
-- Script PKQA_ONE
|
|
719
|
-
--
|
|
727
|
+
-- ===============================================================
|
|
728
|
+
-- !x! BEGIN SCRIPT PKQA_ONE with parameters (stage_pfx, table, display_errors, error_list)
|
|
720
729
|
-- Check data in a staging table for violations of the primary key
|
|
721
730
|
-- of the corresponding base table.
|
|
722
731
|
-- Reports any PK violations found to the console and optionally
|
|
@@ -748,9 +757,6 @@ drop table if exists ups_nonnull_columns cascade;
|
|
|
748
757
|
-- ups_primary_key_columns : table
|
|
749
758
|
-- ups_pk_check : table
|
|
750
759
|
-- ups_ercnt : view
|
|
751
|
-
-- ===============================================================
|
|
752
|
-
|
|
753
|
-
-- !x! BEGIN SCRIPT PKQA_ONE with parameters (stage_pfx, table, display_errors, error_list)
|
|
754
760
|
|
|
755
761
|
-- Write an initial header to the logfile.
|
|
756
762
|
-- !x! if(sub_defined(logfile))
|
|
@@ -831,7 +837,7 @@ order by k.ordinal_position
|
|
|
831
837
|
-- !x! if(view_exists(ups_ercnt))
|
|
832
838
|
drop view if exists ups_ercnt cascade;
|
|
833
839
|
-- !x! endif
|
|
834
|
-
create view ups_ercnt
|
|
840
|
+
create view ups_ercnt as
|
|
835
841
|
select count(*) as errcnt, sum(row_count) as total_rows
|
|
836
842
|
from ups_pk_check;
|
|
837
843
|
-- !x! select_sub ups_ercnt
|
|
@@ -866,7 +872,8 @@ drop table if exists ups_pk_check cascade;
|
|
|
866
872
|
|
|
867
873
|
-- ################################################################
|
|
868
874
|
-- Script FKQA_ONE
|
|
869
|
-
--
|
|
875
|
+
-- ===============================================================
|
|
876
|
+
-- !x! BEGIN SCRIPT FKQA_ONE with parameters (stage_pfx, table, display_errors, error_list)
|
|
870
877
|
-- Checks foreign keys from a staging table against a base table
|
|
871
878
|
-- and, if it exists, another staging table that is an image of the
|
|
872
879
|
-- base table.
|
|
@@ -905,9 +912,6 @@ drop table if exists ups_pk_check cascade;
|
|
|
905
912
|
-- ups_fk_joins : view
|
|
906
913
|
-- ups_fk_check : view
|
|
907
914
|
-- ups_ercnt : view
|
|
908
|
-
-- ===============================================================
|
|
909
|
-
|
|
910
|
-
-- !x! BEGIN SCRIPT FKQA_ONE with parameters (stage_pfx, table, display_errors, error_list)
|
|
911
915
|
|
|
912
916
|
-- Write an initial header to the logfile.
|
|
913
917
|
-- !x! if(sub_defined(logfile))
|
|
@@ -1168,7 +1172,8 @@ drop table if exists ups_sel_fks;
|
|
|
1168
1172
|
|
|
1169
1173
|
-- ################################################################
|
|
1170
1174
|
-- Script UPSERT_ONE
|
|
1171
|
-
--
|
|
1175
|
+
-- ===============================================================
|
|
1176
|
+
-- !x! BEGIN SCRIPT UPSERT_ONE with parameters (stage_pfx, table, exclude_cols, display_changes, display_final, updcntvar, inscntvar)
|
|
1172
1177
|
-- Adds data from a staging table to a base table, using UPDATE
|
|
1173
1178
|
-- and INSERT statements. Displays data to be modified to the
|
|
1174
1179
|
-- user before any modifications are done. Reports the changes
|
|
@@ -1219,9 +1224,6 @@ drop table if exists ups_sel_fks;
|
|
|
1219
1224
|
-- ups_stgmatches : temporary view
|
|
1220
1225
|
-- ups_assexpr : temporary view
|
|
1221
1226
|
-- ups_newrows : temporary view
|
|
1222
|
-
-- ===============================================================
|
|
1223
|
-
|
|
1224
|
-
-- !x! BEGIN SCRIPT UPSERT_ONE with parameters (stage_pfx, table, exclude_cols, display_changes, display_final, updcntvar, inscntvar)
|
|
1225
1227
|
|
|
1226
1228
|
-- Remove substitution variables that will contain the generated
|
|
1227
1229
|
-- update and insert statements so that the existence of valid
|
|
@@ -1508,7 +1510,8 @@ drop table if exists ups_cols cascade;
|
|
|
1508
1510
|
|
|
1509
1511
|
-- ################################################################
|
|
1510
1512
|
-- Script UPSERT_ALL
|
|
1511
|
-
--
|
|
1513
|
+
-- ===============================================================
|
|
1514
|
+
-- !x! BEGIN SCRIPT UPSERT_ALL with parameters (stage_pfx, control_table)
|
|
1512
1515
|
-- Updates multiple base tables with new or revised data from
|
|
1513
1516
|
-- staging tables, using the UPSERT_ONE script.
|
|
1514
1517
|
--
|
|
@@ -1549,9 +1552,6 @@ drop table if exists ups_cols cascade;
|
|
|
1549
1552
|
-- ups_proctables : table
|
|
1550
1553
|
-- ups_toprocess : view
|
|
1551
1554
|
-- ups_upsert_rows : view
|
|
1552
|
-
-- ===============================================================
|
|
1553
|
-
|
|
1554
|
-
-- !x! BEGIN SCRIPT UPSERT_ALL with parameters (stage_pfx, control_table)
|
|
1555
1555
|
|
|
1556
1556
|
-- Validate contents of control table
|
|
1557
1557
|
-- !x! execute script validate_control with (stage_pfx=!!#stage_pfx!!, control_table=!!#control_table!!, script=!!$CURRENT_SCRIPT_NAME!!, script_line=!!$SCRIPT_LINE!!)
|
|
@@ -1770,7 +1770,8 @@ drop table if exists ups_dependencies cascade;
|
|
|
1770
1770
|
|
|
1771
1771
|
-- ################################################################
|
|
1772
1772
|
-- Script QA_ALL
|
|
1773
|
-
--
|
|
1773
|
+
-- ===============================================================
|
|
1774
|
+
-- !x! BEGIN SCRIPT QA_ALL with parameters (stage_pfx, control_table)
|
|
1774
1775
|
-- Conducts null, primary key, and foreign key checks on multiple
|
|
1775
1776
|
-- staging tables containing new or revised data for staging tables,
|
|
1776
1777
|
-- using the NULLQA_ONE, PKQA_ONE, and FKQA_ONE scripts.
|
|
@@ -1821,10 +1822,6 @@ drop table if exists ups_dependencies cascade;
|
|
|
1821
1822
|
--
|
|
1822
1823
|
-- Global variables modified:
|
|
1823
1824
|
-- upsert_progress_denom : Created or redefined.
|
|
1824
|
-
--
|
|
1825
|
-
-- ===============================================================
|
|
1826
|
-
|
|
1827
|
-
-- !x! BEGIN SCRIPT QA_ALL with parameters (stage_pfx, control_table)
|
|
1828
1825
|
|
|
1829
1826
|
-- Get denominator for progress bar if console is on.
|
|
1830
1827
|
-- !x! if(console_on)
|
|
@@ -2005,7 +2002,8 @@ drop view if exists ups_toprocess;
|
|
|
2005
2002
|
|
|
2006
2003
|
-- ################################################################
|
|
2007
2004
|
-- Script UPDTPK_ONE
|
|
2008
|
-
--
|
|
2005
|
+
-- ===============================================================
|
|
2006
|
+
-- !x! BEGIN SCRIPT UPDTPK_ONE with parameters (stage_pfx, table, display_errors, display_changes)
|
|
2009
2007
|
-- Updates primary keys in the base table, based on new and existing
|
|
2010
2008
|
-- values of PK columns in a staging table, using UPDATE
|
|
2011
2009
|
-- statements. Displays data to be modified to the
|
|
@@ -2038,9 +2036,6 @@ drop view if exists ups_toprocess;
|
|
|
2038
2036
|
-- ups_pkupdates : temporary table
|
|
2039
2037
|
-- ups_pkupdate_strings : temporary view
|
|
2040
2038
|
-- ups_pkupdates : temporary table
|
|
2041
|
-
-- ===============================================================
|
|
2042
|
-
|
|
2043
|
-
-- !x! BEGIN SCRIPT UPDTPK_ONE with parameters (stage_pfx, table, display_errors, display_changes)
|
|
2044
2039
|
|
|
2045
2040
|
-- !x! if(console_on)
|
|
2046
2041
|
-- !x! console status "Primary key updates"
|
|
@@ -2081,17 +2076,17 @@ select
|
|
|
2081
2076
|
k.table_schema,
|
|
2082
2077
|
k.table_name,
|
|
2083
2078
|
k.column_name,
|
|
2084
|
-
cast(concat('b.', column_name) as
|
|
2085
|
-
cast(concat('s.', column_name) as
|
|
2086
|
-
cast(concat('s.', column_name, ' as staging_', column_name) as
|
|
2087
|
-
cast(concat('b.', column_name, ' = s.', column_name) as
|
|
2088
|
-
cast(concat('new_', column_name) as
|
|
2089
|
-
cast(concat('s.new_', column_name) as
|
|
2090
|
-
cast(concat('new_', column_name, ' is null') as
|
|
2091
|
-
cast(concat('new_', column_name, ' is not null') as
|
|
2092
|
-
cast(concat('b.', column_name, ' = s.new_', column_name) as
|
|
2093
|
-
cast(concat('b.', column_name, ' = s.new_', column_name) as
|
|
2094
|
-
cast(concat('s.new_', column_name, ' = b.new_', column_name) as
|
|
2079
|
+
cast(concat('b.', column_name) as char(2000)) as base_aliased,
|
|
2080
|
+
cast(concat('s.', column_name) as char(2000)) as staging_aliased,
|
|
2081
|
+
cast(concat('s.', column_name, ' as staging_', column_name) as char(2000)) as staging_aliased_prefix,
|
|
2082
|
+
cast(concat('b.', column_name, ' = s.', column_name) as char(2000)) as join_expr,
|
|
2083
|
+
cast(concat('new_', column_name) as char(2000)) as newpk_col,
|
|
2084
|
+
cast(concat('s.new_', column_name) as char(2000)) as newpk_col_aliased,
|
|
2085
|
+
cast(concat('new_', column_name, ' is null') as char(2000)) as newpk_col_empty,
|
|
2086
|
+
cast(concat('new_', column_name, ' is not null') as char(2000)) as newpk_col_not_empty,
|
|
2087
|
+
cast(concat('b.', column_name, ' = s.new_', column_name) as char(2000)) as assmt_expr,
|
|
2088
|
+
cast(concat('b.', column_name, ' = s.new_', column_name) as char(2000)) as join_expr_oldnew,
|
|
2089
|
+
cast(concat('s.new_', column_name, ' = b.new_', column_name) as char(2000)) as join_expr_new,
|
|
2095
2090
|
k.ordinal_position
|
|
2096
2091
|
from information_schema.table_constraints as tc
|
|
2097
2092
|
inner join information_schema.key_column_usage as k
|
|
@@ -2225,7 +2220,8 @@ where
|
|
|
2225
2220
|
|
|
2226
2221
|
-- ################################################################
|
|
2227
2222
|
-- Script UPDTPKQA_ONE
|
|
2228
|
-
--
|
|
2223
|
+
-- ===============================================================
|
|
2224
|
+
-- !x! BEGIN SCRIPT UPDTPKQA_ONE with parameters (stage_pfx, table, pkinfo_table, qaerror_table, display_errors)
|
|
2229
2225
|
-- Performs QA checks on requested primary key updates to a table,
|
|
2230
2226
|
-- based on old and new values of the table's primary key columns
|
|
2231
2227
|
-- in a staging table.
|
|
@@ -2274,9 +2270,6 @@ where
|
|
|
2274
2270
|
-- ups_fkcol_refs : temporary table
|
|
2275
2271
|
-- ups_pkcol_deps : temporary table
|
|
2276
2272
|
-- ups_pkfk_ctrl : temporary table
|
|
2277
|
-
-- ===============================================================
|
|
2278
|
-
|
|
2279
|
-
-- !x! BEGIN SCRIPT UPDTPKQA_ONE with parameters (stage_pfx, table, pkinfo_table, qaerror_table, display_errors)
|
|
2280
2273
|
|
|
2281
2274
|
-- Write an initial header to the logfile.
|
|
2282
2275
|
-- !x! if(sub_defined(logfile))
|
|
@@ -2326,9 +2319,9 @@ where
|
|
|
2326
2319
|
select
|
|
2327
2320
|
group_concat(newpk_col order by ordinal_position separator ', ') as missing_newpk_cols
|
|
2328
2321
|
from
|
|
2329
|
-
--Base table PK columns, with expected name in staging table ("new_" prepended to column name)
|
|
2322
|
+
-- Base table PK columns, with expected name in staging table ("new_" prepended to column name)
|
|
2330
2323
|
!!#pkinfo_table!! as pk
|
|
2331
|
-
--Staging table columns
|
|
2324
|
+
-- Staging table columns
|
|
2332
2325
|
left join
|
|
2333
2326
|
(
|
|
2334
2327
|
select table_name, column_name
|
|
@@ -2748,7 +2741,7 @@ where
|
|
|
2748
2741
|
from
|
|
2749
2742
|
ups_fkcol_refs as refs
|
|
2750
2743
|
inner join
|
|
2751
|
-
--Distinct list of FK constraints on the table that include ANY PK columns
|
|
2744
|
+
-- Distinct list of FK constraints on the table that include ANY PK columns
|
|
2752
2745
|
(
|
|
2753
2746
|
select distinct
|
|
2754
2747
|
fk_constraint, r.table_schema, r.table_name
|
|
@@ -2789,7 +2782,7 @@ where
|
|
|
2789
2782
|
limit 1
|
|
2790
2783
|
;
|
|
2791
2784
|
|
|
2792
|
-
--Process all constraints: check every foreign key
|
|
2785
|
+
-- Process all constraints: check every foreign key
|
|
2793
2786
|
--!x! execute script updtpkqa_one_innerloop with (stage_pfx=!!#stage_pfx!!, qaerror_table=!!#qaerror_table!!, display_errors=!!#display_errors!!)
|
|
2794
2787
|
-- !x! endif
|
|
2795
2788
|
-- !x! endif
|
|
@@ -2970,7 +2963,7 @@ where
|
|
|
2970
2963
|
drop view if exists ups_pk_fk_qa_error cascade;
|
|
2971
2964
|
-- !x! endif
|
|
2972
2965
|
|
|
2973
|
-
--LOOP
|
|
2966
|
+
-- LOOP
|
|
2974
2967
|
-- !x! execute script updtpkqa_one_innerloop with (stage_pfx=!!#stage_pfx!!, qaerror_table=!!#qaerror_table!!, display_errors=!!#display_errors!!)
|
|
2975
2968
|
|
|
2976
2969
|
-- !x! endif
|
|
@@ -29,8 +29,9 @@
|
|
|
29
29
|
-- 3. Temporary tables and views created by these scripts all
|
|
30
30
|
-- begin with "cmp_".
|
|
31
31
|
--
|
|
32
|
-
--
|
|
32
|
+
-- AUTHORS
|
|
33
33
|
-- Dreas Nielsen (RDN)
|
|
34
|
+
-- Caleb Grant (CG)
|
|
34
35
|
--
|
|
35
36
|
-- COPYRIGHT AND LICENSE
|
|
36
37
|
-- Copyright (c) 2020 R.Dreas Nielsen
|
|
@@ -45,7 +46,7 @@
|
|
|
45
46
|
-- The GNU General Public License is available at <http://www.gnu.org/licenses/>
|
|
46
47
|
--
|
|
47
48
|
-- VERSION
|
|
48
|
-
-- 1.
|
|
49
|
+
-- 1.2.0
|
|
49
50
|
--
|
|
50
51
|
-- HISTORY
|
|
51
52
|
-- Date Remarks
|
|
@@ -54,13 +55,17 @@
|
|
|
54
55
|
-- 2020-02-27 Added COMPARE_CHANGES and COMPARE_CHANGED. v. 1.1.0. RDN.
|
|
55
56
|
-- 2020-02-29 Excluded PK columns from output of COMPARE_COMMON_VALS.
|
|
56
57
|
-- v. 1.1.1. RDN.
|
|
58
|
+
-- 2026-10-15 execsql2: each script's notes are its docstring (SHOW SCRIPTS, the
|
|
59
|
+
-- language server); include_cols and exclude_cols are declared
|
|
60
|
+
-- optional parameters. v. 1.2.0. Tested in tests/templates of the
|
|
61
|
+
-- execsql2 repository. CG.
|
|
57
62
|
-- ==================================================================
|
|
58
63
|
|
|
59
64
|
|
|
60
65
|
-- ################################################################
|
|
61
66
|
-- Script COMPARE_COMMON
|
|
62
67
|
-- ===============================================================
|
|
63
|
-
--
|
|
68
|
+
-- !x! BEGIN SCRIPT COMPARE_COMMON with parameters (base_schema, staging, table, sql_var, include_cols="", exclude_cols="")
|
|
64
69
|
-- Generate SQL to compare the attributes of base and staging
|
|
65
70
|
-- tables for only those primary keys in common. This uses an
|
|
66
71
|
-- inner join between the tables, and does not include any rows
|
|
@@ -101,8 +106,6 @@
|
|
|
101
106
|
--
|
|
102
107
|
-- Notes
|
|
103
108
|
-- 1. The generated SQL is not terminated with a semicolon.
|
|
104
|
-
-- ===============================================================
|
|
105
|
-
-- !x! BEGIN SCRIPT COMPARE_COMMON with parameters (base_schema, staging, table, sql_var)
|
|
106
109
|
|
|
107
110
|
-- Create a table of primary key columns for the table
|
|
108
111
|
drop table if exists cmp_primary_key_columns cascade;
|
|
@@ -129,9 +132,9 @@ order by k.ordinal_position
|
|
|
129
132
|
-- that are to be compared.
|
|
130
133
|
-- Include only those columns from the staging table that are also in the base table.
|
|
131
134
|
-- !x! sub_empty ~col_sel
|
|
132
|
-
-- !x! if(
|
|
135
|
+
-- !x! if(not is_null("!!#include_cols!!"))
|
|
133
136
|
-- !x! sub ~col_sel and s.column_name in (!!#include_cols!!)
|
|
134
|
-
-- !x! elseif(
|
|
137
|
+
-- !x! elseif(not is_null("!!#exclude_cols!!"))
|
|
135
138
|
-- !x! sub ~col_sel and s.column_name not in (!!#exclude_cols!!)
|
|
136
139
|
-- !x! endif
|
|
137
140
|
drop table if exists cmp_cols cascade;
|
|
@@ -201,7 +204,7 @@ from
|
|
|
201
204
|
-- ################################################################
|
|
202
205
|
-- Script COMPARE_COMMON_VALS
|
|
203
206
|
-- ===============================================================
|
|
204
|
-
--
|
|
207
|
+
-- !x! BEGIN SCRIPT COMPARE_COMMON_VALS with parameters (base_schema, staging, table, sql_var, include_cols="", exclude_cols="")
|
|
205
208
|
-- Generate SQL to compare the attributes of base and staging
|
|
206
209
|
-- tables for only those primary keys in common. This uses an
|
|
207
210
|
-- inner join between the tables, and does not include any rows
|
|
@@ -238,8 +241,6 @@ from
|
|
|
238
241
|
--
|
|
239
242
|
-- Notes
|
|
240
243
|
-- 1. The generated SQL is not terminated with a semicolon.
|
|
241
|
-
-- ===============================================================
|
|
242
|
-
-- !x! BEGIN SCRIPT COMPARE_COMMON_VALS with parameters (base_schema, staging, table, sql_var)
|
|
243
244
|
|
|
244
245
|
-- Create a table of primary key columns for the table
|
|
245
246
|
drop table if exists cmp_primary_key_columns cascade;
|
|
@@ -266,9 +267,9 @@ order by k.ordinal_position
|
|
|
266
267
|
-- that are to be compared.
|
|
267
268
|
-- Include only those columns from the staging table that are also in the base table.
|
|
268
269
|
-- !x! sub_empty ~col_sel
|
|
269
|
-
-- !x! if(
|
|
270
|
+
-- !x! if(not is_null("!!#include_cols!!"))
|
|
270
271
|
-- !x! sub ~col_sel and s.column_name in (!!#include_cols!!)
|
|
271
|
-
-- !x! elseif(
|
|
272
|
+
-- !x! elseif(not is_null("!!#exclude_cols!!"))
|
|
272
273
|
-- !x! sub ~col_sel and s.column_name not in (!!#exclude_cols!!)
|
|
273
274
|
-- !x! endif
|
|
274
275
|
drop table if exists cmp_cols cascade;
|
|
@@ -340,7 +341,7 @@ from
|
|
|
340
341
|
-- ################################################################
|
|
341
342
|
-- Script COMPARE_CHANGES
|
|
342
343
|
-- ===============================================================
|
|
343
|
-
--
|
|
344
|
+
-- !x! BEGIN SCRIPT COMPARE_CHANGES with parameters (base_schema, staging, table, sql_var, include_cols="", exclude_cols="")
|
|
344
345
|
-- Generate SQL to characterize every row of the staging table
|
|
345
346
|
-- data as either a new row, a row with changed data, or a row
|
|
346
347
|
-- with data that are unchanged relative to the base table.
|
|
@@ -376,8 +377,6 @@ from
|
|
|
376
377
|
--
|
|
377
378
|
-- Notes
|
|
378
379
|
-- 1. The generated SQL is not terminated with a semicolon.
|
|
379
|
-
-- ===============================================================
|
|
380
|
-
-- !x! BEGIN SCRIPT COMPARE_CHANGES with parameters (base_schema, staging, table, sql_var)
|
|
381
380
|
|
|
382
381
|
-- Create a table of primary key columns for the table
|
|
383
382
|
drop table if exists cmp_primary_key_columns cascade;
|
|
@@ -404,9 +403,9 @@ order by k.ordinal_position
|
|
|
404
403
|
-- that are to be compared.
|
|
405
404
|
-- Include only those columns from the staging table that are also in the base table.
|
|
406
405
|
-- !x! sub_empty ~col_sel
|
|
407
|
-
-- !x! if(
|
|
406
|
+
-- !x! if(not is_null("!!#include_cols!!"))
|
|
408
407
|
-- !x! sub ~col_sel and s.column_name in (!!#include_cols!!)
|
|
409
|
-
-- !x! elseif(
|
|
408
|
+
-- !x! elseif(not is_null("!!#exclude_cols!!"))
|
|
410
409
|
-- !x! sub ~col_sel and s.column_name not in (!!#exclude_cols!!)
|
|
411
410
|
-- !x! endif
|
|
412
411
|
drop table if exists cmp_cols cascade;
|
|
@@ -486,7 +485,7 @@ from
|
|
|
486
485
|
-- ################################################################
|
|
487
486
|
-- Script COMPARE_CHANGED
|
|
488
487
|
-- ===============================================================
|
|
489
|
-
--
|
|
488
|
+
-- !x! BEGIN SCRIPT COMPARE_CHANGED with parameters (base_schema, staging, table, sql_var, include_cols="", exclude_cols="")
|
|
490
489
|
-- Generate SQL to characterize every row of the base table
|
|
491
490
|
-- depending on whether there is a matching row in the staging
|
|
492
491
|
-- table, whether a matching row has new data, or whether a
|
|
@@ -523,8 +522,6 @@ from
|
|
|
523
522
|
--
|
|
524
523
|
-- Notes
|
|
525
524
|
-- 1. The generated SQL is not terminated with a semicolon.
|
|
526
|
-
-- ===============================================================
|
|
527
|
-
-- !x! BEGIN SCRIPT COMPARE_CHANGED with parameters (base_schema, staging, table, sql_var)
|
|
528
525
|
|
|
529
526
|
-- Create a table of primary key columns for the table
|
|
530
527
|
drop table if exists cmp_primary_key_columns cascade;
|
|
@@ -551,9 +548,9 @@ order by k.ordinal_position
|
|
|
551
548
|
-- that are to be compared.
|
|
552
549
|
-- Include only those columns from the staging table that are also in the base table.
|
|
553
550
|
-- !x! sub_empty ~col_sel
|
|
554
|
-
-- !x! if(
|
|
551
|
+
-- !x! if(not is_null("!!#include_cols!!"))
|
|
555
552
|
-- !x! sub ~col_sel and s.column_name in (!!#include_cols!!)
|
|
556
|
-
-- !x! elseif(
|
|
553
|
+
-- !x! elseif(not is_null("!!#exclude_cols!!"))
|
|
557
554
|
-- !x! sub ~col_sel and s.column_name not in (!!#exclude_cols!!)
|
|
558
555
|
-- !x! endif
|
|
559
556
|
drop table if exists cmp_cols cascade;
|
|
@@ -36,9 +36,10 @@
|
|
|
36
36
|
--
|
|
37
37
|
-- AUTHORS
|
|
38
38
|
-- Dreas Nielsen (RDN)
|
|
39
|
+
-- Caleb Grant (CG)
|
|
39
40
|
--
|
|
40
41
|
-- VERSION
|
|
41
|
-
-- 1.0
|
|
42
|
+
-- 1.1.0
|
|
42
43
|
--
|
|
43
44
|
-- HISTORY
|
|
44
45
|
-- Date Remarks
|
|
@@ -51,13 +52,17 @@
|
|
|
51
52
|
-- summarization. Modified item addition to do nothing on
|
|
52
53
|
-- conflicts. Modified to use subquery instead of CTE when
|
|
53
54
|
-- appending a new item. Version 1.0.1. RDN.
|
|
55
|
+
-- 2026-10-15 execsql2: each script's notes are its docstring (SHOW SCRIPTS, the
|
|
56
|
+
-- language server); def_url is a declared optional parameter;
|
|
57
|
+
-- ADD_GLOSSARY_ITEM keeps def_url. Version 1.1.0. Tested in
|
|
58
|
+
-- tests/templates of the execsql2 repository. CG.
|
|
54
59
|
-- ============================================================================
|
|
55
60
|
|
|
56
61
|
|
|
57
62
|
-- ################################################################
|
|
58
63
|
-- Script INIT_GLOSSARY
|
|
59
64
|
-- ===============================================================
|
|
60
|
-
--
|
|
65
|
+
-- !x! BEGIN SCRIPT INIT_GLOSSARY with parameters (glossary_db_alias, glossary_table, name_col, def_col, def_url="")
|
|
61
66
|
-- Initialize the custom glossary and describe the master glossary
|
|
62
67
|
-- that will provide descriptions to include in the custom glossary.
|
|
63
68
|
--
|
|
@@ -74,14 +79,12 @@
|
|
|
74
79
|
-- Optional input argument:
|
|
75
80
|
-- def_url : The URL of a page that provides additional
|
|
76
81
|
-- information about the column (or other object).
|
|
77
|
-
-- ===============================================================
|
|
78
|
-
-- !x! BEGIN SCRIPT INIT_GLOSSARY with parameters (glossary_db_alias, glossary_table, name_col, def_col)
|
|
79
82
|
|
|
80
83
|
-- !x! sub gls_alias !!#glossary_db_alias!!
|
|
81
84
|
-- !x! sub gls_table !!#glossary_table!!
|
|
82
85
|
-- !x! sub gls_name !!#name_col!!
|
|
83
86
|
-- !x! sub gls_def !!#def_col!!
|
|
84
|
-
-- !x! if(
|
|
87
|
+
-- !x! if(not is_null("!!#def_url!!"))
|
|
85
88
|
-- !x! sub gls_has_url Yes
|
|
86
89
|
-- !x! sub gls_url !!#def_url!!
|
|
87
90
|
-- !x! sub ~url_colspec !!gls_url!! text,
|
|
@@ -121,13 +124,11 @@ from gls_glossary order by !!gls_name!!;
|
|
|
121
124
|
-- ################################################################
|
|
122
125
|
-- Script ADD_GLOSSARY_LIST
|
|
123
126
|
-- ===============================================================
|
|
124
|
-
--
|
|
127
|
+
-- !x! BEGIN SCRIPT ADD_GLOSSARY_LIST with parameters (column_list)
|
|
125
128
|
-- Add a specific list of columns to the glossary.
|
|
126
129
|
--
|
|
127
130
|
-- Required input arguments:
|
|
128
131
|
-- column_list : A string of comma-separated column names.
|
|
129
|
-
-- ===============================================================
|
|
130
|
-
-- !x! BEGIN SCRIPT ADD_GLOSSARY_LIST with parameters (column_list)
|
|
131
132
|
|
|
132
133
|
-- !x! sub ~entry_alias !!$current_alias!!
|
|
133
134
|
-- !x! use initial
|
|
@@ -196,7 +197,7 @@ drop table gls_newglossary cascade;
|
|
|
196
197
|
-- ################################################################
|
|
197
198
|
-- Script ADD_GLOSSARY_ITEM
|
|
198
199
|
-- ===============================================================
|
|
199
|
-
--
|
|
200
|
+
-- !x! BEGIN SCRIPT ADD_GLOSSARY_ITEM with parameters (item, definition, def_url="")
|
|
200
201
|
-- Add an object name and definition to the custom glossary.
|
|
201
202
|
-- This does not use the master glossary.
|
|
202
203
|
--
|
|
@@ -208,14 +209,12 @@ drop table gls_newglossary cascade;
|
|
|
208
209
|
-- Optional input argument:
|
|
209
210
|
-- def_url : The URL of a page that provides additional
|
|
210
211
|
-- information about the item.
|
|
211
|
-
-- ===============================================================
|
|
212
|
-
-- !x! BEGIN SCRIPT ADD_GLOSSARY_ITEM with parameters (item, definition)
|
|
213
212
|
|
|
214
213
|
-- !x! sub ~entry_alias !!$current_alias!!
|
|
215
214
|
-- !x! use initial
|
|
216
215
|
|
|
217
|
-
-- !x! if(is_true(gls_has_url))
|
|
218
|
-
-- !x! andif(
|
|
216
|
+
-- !x! if(is_true(!!gls_has_url!!))
|
|
217
|
+
-- !x! andif(not is_null("!!#def_url!!"))
|
|
219
218
|
insert into gls_glossary (!!gls_name!!, !!gls_def!!, !!gls_url!!)
|
|
220
219
|
select
|
|
221
220
|
inp.item, inp.definition, inp.url
|
|
@@ -248,16 +247,13 @@ drop table gls_newglossary cascade;
|
|
|
248
247
|
-- ################################################################
|
|
249
248
|
-- Script ADD_GLOSSARY_TABLE
|
|
250
249
|
-- ===============================================================
|
|
251
|
-
--
|
|
250
|
+
-- !x! BEGIN SCRIPT ADD_GLOSSARY_TABLE with parameters (schema, table)
|
|
252
251
|
-- Add definitions of all columns in a specified table to the
|
|
253
252
|
-- custom glossary.
|
|
254
253
|
--
|
|
255
254
|
-- Required input arguments:
|
|
256
255
|
-- schema : The schema of the table.
|
|
257
256
|
-- table : The table name.
|
|
258
|
-
--
|
|
259
|
-
-- ===============================================================
|
|
260
|
-
-- !x! BEGIN SCRIPT ADD_GLOSSARY_TABLE with parameters (schema, table)
|
|
261
257
|
|
|
262
258
|
-- !x! sub ~entry_alias !!$current_alias!!
|
|
263
259
|
|