Skip to content

Commit d32f84e

Browse files
committed
Annoyingly handhold the snippet ordering.
Once the typemapper is able to recognize uses of a UDT that is being defined, it should also certainly be able to enter a provides-requires relationship between the type and any SQL snippet that uses it. Until then, these need to be added explicitly, to make sure things are written to the DDR in a workable order.
1 parent 73b662b commit d32f84e

File tree

2 files changed

+56
-5
lines changed

2 files changed

+56
-5
lines changed

‎java/src/main/java/com/invariantproperties/udt/sql/ComplexUDT.java‎

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
*
4747
4848
*/
49-
@BaseUDT(
49+
@BaseUDT(provides="complexudt",
5050
schema="invariantproperties", name="complex",
5151
internalLength=16,
5252
alignment=BaseUDT.Alignment.INT4 // can this be right? components are 8 wide
@@ -224,6 +224,7 @@ public String toString() {
224224
* @throws SQLException
225225
*/
226226
@Function(schema="invariantproperties", name="complex_string_as_complex",
227+
requires="complexudt",
227228
effects=IMMUTABLE, onNullInput=RETURNS_NULL)
228229
public static ComplexUDT newInstance(String input) throws SQLException {
229230
if (input == null) {
@@ -240,6 +241,7 @@ public static ComplexUDT newInstance(String input) throws SQLException {
240241
* @throws SQLException
241242
*/
242243
@Function(schema="invariantproperties", name="complex_double_as_complex",
244+
requires="complexudt",
243245
effects=IMMUTABLE, onNullInput=RETURNS_NULL)
244246
public static ComplexUDT newInstance(double value) throws SQLException {
245247
return new ComplexUDT(value);
@@ -255,6 +257,7 @@ public static ComplexUDT newInstance(double value) throws SQLException {
255257
*/
256258
@Function(schema="invariantproperties",
257259
name="complex_bigdecimal_as_complex",
260+
requires="complexudt",
258261
effects=IMMUTABLE, onNullInput=RETURNS_NULL)
259262
public static ComplexUDT newInstance(BigDecimal value) throws SQLException {
260263
return new ComplexUDT(value.doubleValue());
@@ -268,6 +271,7 @@ public static ComplexUDT newInstance(BigDecimal value) throws SQLException {
268271
* @throws SQLException
269272
*/
270273
@Function(schema="invariantproperties", name="complex_int_as_complex",
274+
requires="complexudt",
271275
effects=IMMUTABLE, onNullInput=RETURNS_NULL)
272276
public static ComplexUDT newInstance(int value) throws SQLException {
273277
return new ComplexUDT(value);
@@ -281,6 +285,7 @@ public static ComplexUDT newInstance(int value) throws SQLException {
281285
* @throws SQLException
282286
*/
283287
@Function(schema="invariantproperties", name="complex_long_as_complex",
288+
requires="complexudt",
284289
effects=IMMUTABLE, onNullInput=RETURNS_NULL)
285290
public static ComplexUDT newInstance(long value) throws SQLException {
286291
return new ComplexUDT(value);
@@ -294,6 +299,7 @@ public static ComplexUDT newInstance(long value) throws SQLException {
294299
* @throws SQLException
295300
*/
296301
@Function(schema="invariantproperties", name="complex_negate",
302+
requires="complexudt",
297303
effects=IMMUTABLE, onNullInput=RETURNS_NULL)
298304
public static ComplexUDT negate(ComplexUDT p) throws SQLException {
299305
if ((p == null) || (p.value == null)) {
@@ -311,6 +317,7 @@ public static ComplexUDT negate(ComplexUDT p) throws SQLException {
311317
* @throws SQLException
312318
*/
313319
@Function(schema="invariantproperties", name="complex_add",
320+
requires="complexudt",
314321
effects=IMMUTABLE, onNullInput=RETURNS_NULL)
315322
public static ComplexUDT add(ComplexUDT p, ComplexUDT q)
316323
throws SQLException {
@@ -330,6 +337,7 @@ public static ComplexUDT add(ComplexUDT p, ComplexUDT q)
330337
* @throws SQLException
331338
*/
332339
@Function(schema="invariantproperties", name="complex_add",
340+
requires="complexudt",
333341
effects=IMMUTABLE, onNullInput=RETURNS_NULL)
334342
public static ComplexUDT add(ComplexUDT p, int q) throws SQLException {
335343
return add(p, (double) q);
@@ -344,6 +352,7 @@ public static ComplexUDT add(ComplexUDT p, int q) throws SQLException {
344352
* @throws SQLException
345353
*/
346354
@Function(schema="invariantproperties", name="complex_add",
355+
requires="complexudt",
347356
effects=IMMUTABLE, onNullInput=RETURNS_NULL)
348357
public static ComplexUDT add(ComplexUDT p, long q) throws SQLException {
349358
return add(p, (double) q);
@@ -358,6 +367,7 @@ public static ComplexUDT add(ComplexUDT p, long q) throws SQLException {
358367
* @throws SQLException
359368
*/
360369
@Function(schema="invariantproperties", name="complex_add",
370+
requires="complexudt",
361371
effects=IMMUTABLE, onNullInput=RETURNS_NULL)
362372
public static ComplexUDT add(ComplexUDT p, float q) throws SQLException {
363373
return add(p, (double) q);
@@ -372,6 +382,7 @@ public static ComplexUDT add(ComplexUDT p, float q) throws SQLException {
372382
* @throws SQLException
373383
*/
374384
@Function(schema="invariantproperties", name="complex_add",
385+
requires="complexudt",
375386
effects=IMMUTABLE, onNullInput=RETURNS_NULL)
376387
public static ComplexUDT add(ComplexUDT p, double q) throws SQLException {
377388
if ((p == null) || (p.value == null)) {
@@ -389,6 +400,7 @@ public static ComplexUDT add(ComplexUDT p, double q) throws SQLException {
389400
* @throws SQLException
390401
*/
391402
@Function(schema="invariantproperties", name="complex_add",
403+
requires="complexudt",
392404
effects=IMMUTABLE, onNullInput=RETURNS_NULL)
393405
public static ComplexUDT add(ComplexUDT p, BigDecimal q)
394406
throws SQLException {
@@ -404,6 +416,7 @@ public static ComplexUDT add(ComplexUDT p, BigDecimal q)
404416
* @throws SQLException
405417
*/
406418
@Function(schema="invariantproperties", name="complex_add",
419+
requires="complexudt",
407420
effects=IMMUTABLE, onNullInput=RETURNS_NULL)
408421
public static ComplexUDT add(int q, ComplexUDT p) throws SQLException {
409422
return add(p, (double) q);
@@ -418,6 +431,7 @@ public static ComplexUDT add(int q, ComplexUDT p) throws SQLException {
418431
* @throws SQLException
419432
*/
420433
@Function(schema="invariantproperties", name="complex_add",
434+
requires="complexudt",
421435
effects=IMMUTABLE, onNullInput=RETURNS_NULL)
422436
public static ComplexUDT add(long q, ComplexUDT p) throws SQLException {
423437
return add(p, (double) q);
@@ -432,6 +446,7 @@ public static ComplexUDT add(long q, ComplexUDT p) throws SQLException {
432446
* @throws SQLException
433447
*/
434448
@Function(schema="invariantproperties", name="complex_add",
449+
requires="complexudt",
435450
effects=IMMUTABLE, onNullInput=RETURNS_NULL)
436451
public static ComplexUDT add(float q, ComplexUDT p) throws SQLException {
437452
return add(p, (double) q);
@@ -446,6 +461,7 @@ public static ComplexUDT add(float q, ComplexUDT p) throws SQLException {
446461
* @throws SQLException
447462
*/
448463
@Function(schema="invariantproperties", name="complex_add",
464+
requires="complexudt",
449465
effects=IMMUTABLE, onNullInput=RETURNS_NULL)
450466
public static ComplexUDT add(double q, ComplexUDT p) throws SQLException {
451467
return add(p, q);
@@ -460,6 +476,7 @@ public static ComplexUDT add(double q, ComplexUDT p) throws SQLException {
460476
* @throws SQLException
461477
*/
462478
@Function(schema="invariantproperties", name="complex_add",
479+
requires="complexudt",
463480
effects=IMMUTABLE, onNullInput=RETURNS_NULL)
464481
public static ComplexUDT add(BigDecimal q, ComplexUDT p)
465482
throws SQLException {
@@ -475,6 +492,7 @@ public static ComplexUDT add(BigDecimal q, ComplexUDT p)
475492
* @throws SQLException
476493
*/
477494
@Function(schema="invariantproperties", name="complex_subtract",
495+
requires="complexudt",
478496
effects=IMMUTABLE, onNullInput=RETURNS_NULL)
479497
public static ComplexUDT subtract(ComplexUDT p, ComplexUDT q)
480498
throws SQLException {
@@ -494,6 +512,7 @@ public static ComplexUDT subtract(ComplexUDT p, ComplexUDT q)
494512
* @throws SQLException
495513
*/
496514
@Function(schema="invariantproperties", name="complex_multiply",
515+
requires="complexudt",
497516
effects=IMMUTABLE, onNullInput=RETURNS_NULL)
498517
public static ComplexUDT multiply(ComplexUDT p, ComplexUDT q)
499518
throws SQLException {
@@ -513,6 +532,7 @@ public static ComplexUDT multiply(ComplexUDT p, ComplexUDT q)
513532
* @throws SQLException
514533
*/
515534
@Function(schema="invariantproperties", name="complex_multiply",
535+
requires="complexudt",
516536
effects=IMMUTABLE, onNullInput=RETURNS_NULL)
517537
public static ComplexUDT multiply(ComplexUDT p, int q) throws SQLException {
518538
return multiply(p, (double) q);
@@ -527,6 +547,7 @@ public static ComplexUDT multiply(ComplexUDT p, int q) throws SQLException {
527547
* @throws SQLException
528548
*/
529549
@Function(schema="invariantproperties", name="complex_multiply",
550+
requires="complexudt",
530551
effects=IMMUTABLE, onNullInput=RETURNS_NULL)
531552
public static ComplexUDT multiply(ComplexUDT p, long q) throws SQLException {
532553
return multiply(p, (double) q);
@@ -541,6 +562,7 @@ public static ComplexUDT multiply(ComplexUDT p, long q) throws SQLException {
541562
* @throws SQLException
542563
*/
543564
@Function(schema="invariantproperties", name="complex_multiply",
565+
requires="complexudt",
544566
effects=IMMUTABLE, onNullInput=RETURNS_NULL)
545567
public static ComplexUDT multiply(ComplexUDT p, float q)
546568
throws SQLException {
@@ -556,6 +578,7 @@ public static ComplexUDT multiply(ComplexUDT p, float q)
556578
* @throws SQLException
557579
*/
558580
@Function(schema="invariantproperties", name="complex_multiply",
581+
requires="complexudt",
559582
effects=IMMUTABLE, onNullInput=RETURNS_NULL)
560583
public static ComplexUDT multiply(ComplexUDT p, double q)
561584
throws SQLException {
@@ -574,6 +597,7 @@ public static ComplexUDT multiply(ComplexUDT p, double q)
574597
* @throws SQLException
575598
*/
576599
@Function(schema="invariantproperties", name="complex_multiply",
600+
requires="complexudt",
577601
effects=IMMUTABLE, onNullInput=RETURNS_NULL)
578602
public static ComplexUDT multiply(ComplexUDT p, BigDecimal q)
579603
throws SQLException {
@@ -589,6 +613,7 @@ public static ComplexUDT multiply(ComplexUDT p, BigDecimal q)
589613
* @throws SQLException
590614
*/
591615
@Function(schema="invariantproperties", name="complex_multiply",
616+
requires="complexudt",
592617
effects=IMMUTABLE, onNullInput=RETURNS_NULL)
593618
public static ComplexUDT multiply(int q, ComplexUDT p) throws SQLException {
594619
return multiply(p, (double) q);
@@ -603,6 +628,7 @@ public static ComplexUDT multiply(int q, ComplexUDT p) throws SQLException {
603628
* @throws SQLException
604629
*/
605630
@Function(schema="invariantproperties", name="complex_multiply",
631+
requires="complexudt",
606632
effects=IMMUTABLE, onNullInput=RETURNS_NULL)
607633
public static ComplexUDT multiply(long q, ComplexUDT p) throws SQLException {
608634
return multiply(p, (double) q);
@@ -617,6 +643,7 @@ public static ComplexUDT multiply(long q, ComplexUDT p) throws SQLException {
617643
* @throws SQLException
618644
*/
619645
@Function(schema="invariantproperties", name="complex_multiply",
646+
requires="complexudt",
620647
effects=IMMUTABLE, onNullInput=RETURNS_NULL)
621648
public static ComplexUDT multiply(float q, ComplexUDT p)
622649
throws SQLException {
@@ -632,6 +659,7 @@ public static ComplexUDT multiply(float q, ComplexUDT p)
632659
* @throws SQLException
633660
*/
634661
@Function(schema="invariantproperties", name="complex_multiply",
662+
requires="complexudt",
635663
effects=IMMUTABLE, onNullInput=RETURNS_NULL)
636664
public static ComplexUDT multiply(double q, ComplexUDT p)
637665
throws SQLException {
@@ -647,6 +675,7 @@ public static ComplexUDT multiply(double q, ComplexUDT p)
647675
* @throws SQLException
648676
*/
649677
@Function(schema="invariantproperties", name="complex_multiply",
678+
requires="complexudt",
650679
effects=IMMUTABLE, onNullInput=RETURNS_NULL)
651680
public static ComplexUDT multiply(BigDecimal q, ComplexUDT p)
652681
throws SQLException {
@@ -660,7 +689,7 @@ public static ComplexUDT multiply(BigDecimal q, ComplexUDT p)
660689
* @return
661690
* @throws SQLException
662691
*/
663-
@Function(schema="invariantproperties",
692+
@Function(schema="invariantproperties", requires="complexudt",
664693
effects=IMMUTABLE, onNullInput=RETURNS_NULL)
665694
public static ComplexUDT abs(ComplexUDT p) throws SQLException {
666695
if ((p == null) || (p.value == null)) {
@@ -676,7 +705,7 @@ public static ComplexUDT abs(ComplexUDT p) throws SQLException {
676705
* @return
677706
* @throws SQLException
678707
*/
679-
@Function(schema="invariantproperties",
708+
@Function(schema="invariantproperties", requires="complexudt",
680709
effects=IMMUTABLE, onNullInput=RETURNS_NULL)
681710
public static ComplexUDT conjugate(ComplexUDT p) throws SQLException {
682711
if ((p == null) || (p.value == null)) {
@@ -692,7 +721,7 @@ public static ComplexUDT conjugate(ComplexUDT p) throws SQLException {
692721
* @return
693722
* @throws SQLException
694723
*/
695-
@Function(schema="invariantproperties",
724+
@Function(schema="invariantproperties", requires="complexudt",
696725
effects=IMMUTABLE, onNullInput=RETURNS_NULL)
697726
public static Double magnitude(ComplexUDT p) throws SQLException {
698727
if ((p == null) || (p.value == null)) {

0 commit comments

Comments
 (0)